Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
add: Networks method function
Browse files Browse the repository at this point in the history
  • Loading branch information
amirisback committed Mar 29, 2020
1 parent c7413c8 commit 4738c18
Show file tree
Hide file tree
Showing 12 changed files with 406 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,28 @@ https://developers.themoviedb.org/3/getting-started/introduction

## LIST
## NETWORKS

// NETWORKS
// Get Details
fun getNetworkDetail(
network_id: Int,
callback: MovieResultCallback<NetworkDetail>
)

// NETWORKS
// Get Alternative Names
fun getNetworkAlternativeName(
network_id: Int,
callback: MovieResultCallback<NetworkAlternativeName>
)

// NETWORKS
// Get Images
fun getNetworkImage(
network_id: Int,
callback: MovieResultCallback<NetworkImage>
)

## PEOPLE
## SEARCH
## TV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,4 +1042,76 @@ class ConsumeMovieApi(private val apiKey: String) : ConsumeMovieApiView {
}
})
}

override fun getNetworkDetail(network_id: Int, callback: MovieResultCallback<NetworkDetail>) {
movieRepository.getNetworkDetail(
network_id,
apiKey,
object : MovieDataSource.GetRemoteCallback<NetworkDetail> {
override fun onSuccess(data: NetworkDetail) {
callback.getResultData(data)
}

override fun onFailed(statusCode: Int, errorMessage: String?) {
callback.failedResult(statusCode, errorMessage)
}

override fun onShowProgress() {
callback.onShowProgress()
}

override fun onHideProgress() {
callback.onHideProgress()
}
})
}

override fun getNetworkAlternativeName(
network_id: Int,
callback: MovieResultCallback<NetworkAlternativeName>
) {
movieRepository.getNetworkAlternativeName(
network_id,
apiKey,
object : MovieDataSource.GetRemoteCallback<NetworkAlternativeName> {
override fun onSuccess(data: NetworkAlternativeName) {
callback.getResultData(data)
}

override fun onFailed(statusCode: Int, errorMessage: String?) {
callback.failedResult(statusCode, errorMessage)
}

override fun onShowProgress() {
callback.onShowProgress()
}

override fun onHideProgress() {
callback.onHideProgress()
}
})
}

override fun getNetworkImage(network_id: Int, callback: MovieResultCallback<NetworkImage>) {
movieRepository.getNetworkImage(
network_id,
apiKey,
object : MovieDataSource.GetRemoteCallback<NetworkImage> {
override fun onSuccess(data: NetworkImage) {
callback.getResultData(data)
}

override fun onFailed(statusCode: Int, errorMessage: String?) {
callback.failedResult(statusCode, errorMessage)
}

override fun onShowProgress() {
callback.onShowProgress()
}

override fun onHideProgress() {
callback.onHideProgress()
}
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,25 @@ interface ConsumeMovieApiView {
callback: MovieResultCallback<Reviews>
)

// NETWORKS
// Get Details
fun getNetworkDetail(
network_id: Int,
callback: MovieResultCallback<NetworkDetail>
)

// NETWORKS
// Get Alternative Names
fun getNetworkAlternativeName(
network_id: Int,
callback: MovieResultCallback<NetworkAlternativeName>
)

// NETWORKS
// Get Images
fun getNetworkImage(
network_id: Int,
callback: MovieResultCallback<NetworkImage>
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.frogobox.frogothemoviedbapi.data.model

import com.google.gson.annotations.SerializedName

data class NetworkLogo(

@SerializedName("aspect_ratio")
var aspect_ratio: Int? = null,

@SerializedName("file_path")
var file_path: String? = null,

@SerializedName("height")
var height: Int? = null,

@SerializedName("id")
var id: String? = null,

@SerializedName("file_type")
var file_type: String? = null,

@SerializedName("vote_average")
var vote_average: Int? = null,

@SerializedName("vote_count")
var vote_count: Int? = null,

@SerializedName("width")
var width: Int? = null

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.frogobox.frogothemoviedbapi.data.model

import com.google.gson.annotations.SerializedName

data class NetworkName(

@SerializedName("name")
var name: String? = null,

@SerializedName("type")
var type: String? = null

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.frogobox.frogothemoviedbapi.data.response

import com.frogobox.frogothemoviedbapi.data.model.NetworkName
import com.google.gson.annotations.SerializedName

/**
* Created by Faisal Amir
* FrogoBox Inc License
* =========================================
* consumable-code-movie-tmdb-api
* Copyright (C) 29/03/2020.
* All rights reserved
* -----------------------------------------
* Name : Muhammad Faisal Amir
* E-mail : faisalamircs@gmail.com
* Github : github.com/amirisback
* LinkedIn : linkedin.com/in/faisalamircs
* -----------------------------------------
* FrogoBox Software Industries
* com.frogobox.frogothemoviedbapi.data.response
*
*/
data class NetworkAlternativeName(

@SerializedName("id")
var id: Int? = null,

@SerializedName("results")
var results: List<NetworkName>? = null

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.frogobox.frogothemoviedbapi.data.response

import com.google.gson.annotations.SerializedName

/**
* Created by Faisal Amir
* FrogoBox Inc License
* =========================================
* consumable-code-movie-tmdb-api
* Copyright (C) 29/03/2020.
* All rights reserved
* -----------------------------------------
* Name : Muhammad Faisal Amir
* E-mail : faisalamircs@gmail.com
* Github : github.com/amirisback
* LinkedIn : linkedin.com/in/faisalamircs
* -----------------------------------------
* FrogoBox Software Industries
* com.frogobox.frogothemoviedbapi.data.response
*
*/
data class NetworkDetail(

@SerializedName("headquarters")
var headquarters: String? = null,

@SerializedName("homepage")
var homepage: String? = null,

@SerializedName("id")
var id: Int? = null,

@SerializedName("name")
var name: String? = null,

@SerializedName("origin_country")
var origin_country: String? = null

)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.frogobox.frogothemoviedbapi.data.response

import com.frogobox.frogothemoviedbapi.data.model.NetworkLogo
import com.frogobox.frogothemoviedbapi.data.model.NetworkName
import com.google.gson.annotations.SerializedName

/**
* Created by Faisal Amir
* FrogoBox Inc License
* =========================================
* consumable-code-movie-tmdb-api
* Copyright (C) 29/03/2020.
* All rights reserved
* -----------------------------------------
* Name : Muhammad Faisal Amir
* E-mail : faisalamircs@gmail.com
* Github : github.com/amirisback
* LinkedIn : linkedin.com/in/faisalamircs
* -----------------------------------------
* FrogoBox Software Industries
* com.frogobox.frogothemoviedbapi.data.response
*
*/
data class NetworkImage(

@SerializedName("id")
var id: Int? = null,

@SerializedName("results")
var results: List<NetworkLogo>? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,30 @@ interface MovieApiService {
@Query(MovieConstant.QUERY_API_KEY) apiKey: String
): Observable<Reviews>

// NETWORKS
// Get Details
@GET(MovieUrl.NETWORKS_GET_DETAILS)
fun getNetworkDetail(
@Path(MovieConstant.PATH_NETWORK_ID) network_id: Int,
@Query(MovieConstant.QUERY_API_KEY) apiKey: String
): Observable<NetworkDetail>

// NETWORKS
// Get Alternative Names
@GET(MovieUrl.NETWORKS_GET_ALTERNATIVE_NAMES)
fun getNetworkAlternativeName(
@Path(MovieConstant.PATH_NETWORK_ID) network_id: Int,
@Query(MovieConstant.QUERY_API_KEY) apiKey: String
): Observable<NetworkAlternativeName>

// NETWORKS
// Get Images
@GET(MovieUrl.NETWORKS_GET_IMAGES)
fun getNetworkImage(
@Path(MovieConstant.PATH_NETWORK_ID) network_id: Int,
@Query(MovieConstant.QUERY_API_KEY) apiKey: String
): Observable<NetworkImage>

companion object Factory {

private var isUsingChuckInterceptor = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,30 @@ interface MovieDataSource {
callback: GetRemoteCallback<Reviews>
)

// NETWORKS
// Get Details
fun getNetworkDetail(
network_id: Int,
apiKey: String,
callback: GetRemoteCallback<NetworkDetail>
)

// NETWORKS
// Get Alternative Names
fun getNetworkAlternativeName(
network_id: Int,
apiKey: String,
callback: GetRemoteCallback<NetworkAlternativeName>
)

// NETWORKS
// Get Images
fun getNetworkImage(
network_id: Int,
apiKey: String,
callback: GetRemoteCallback<NetworkImage>
)

// Response Callback
interface GetRemoteCallback<T> : BaseMovieDataSource.ResponseCallback<T>

Expand Down
Loading

0 comments on commit 4738c18

Please sign in to comment.