package Ġcom . shal atan . ent ert ain ment app . network Ċ Ċ import Ġcom . jak ew h art on . ret rofit 2 . adapter . kotlin . coroutines . Coroutine Call Adapter Factory Ċ import Ġcom . shal atan . ent ert ain ment app . model . Complete Movie Detail Ċ import Ġcom . shal atan . ent ert ain ment app . model . Movie Ċ import Ġcom . shal atan . ent ert ain ment app . model . Movie Response Ċ import Ġcom . shal atan . ent ert ain ment app . utils . Constants Ċ import Ġcom . squareup . mos hi . M oshi Ċ import Ġcom . squareup . mos hi . kotlin . reflect . Kotlin Json Adapter Factory Ċ import Ġkotlinx . coroutines . Deferred Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . logging . Http Logging Interceptor Ċ import Ġretrofit 2 . Ret rofit Ċ import Ġretrofit 2 . converter . mos hi . M oshi Converter Factory Ċ import Ġretrofit 2 . http . GET Ċ import Ġretrofit 2 . http . Path Ċ import Ġretrofit 2 . http . Query Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ // movies Ġlist Ġ- Ġhttps :// api . the mov ied b . org / 3 / movie / popular ? api _ key ={ api _ key } Ċ // complete Ġmovie Ġdetails Ġ- Ġhttps :// api . the mov ied b . org / 3 / movie / 2 1 6 0 1 5 ? api _ key ={ api _ key }& append _ to _ response = videos , images , reviews Ċ // search Ġ- Ġhttps :// api . the mov ied b . org / 3 / search / movie ? api _ key ={ api _ key }& query = Jack + Re acher Ċ Ċ private Ġval Ġm oshi Ġ= ĠM oshi . Builder () ĊĠĠĠ Ġ. add ( Kotlin Json Adapter Factory ()) ĊĠĠĠ Ġ. build () Ċ Ċ private Ġval Ġhttp Logging Interceptor Ġ= ĊĠĠĠ ĠHttp Logging Interceptor (). setLevel ( Http Logging Interceptor . Level . BASIC ) Ċ Ċ private Ġval Ġok HttpClient Ġ= ĠOk HttpClient . Builder () ĊĠĠĠ Ġ. add Interceptor ( http Logging Interceptor ) ĊĠĠĠ Ġ. connect Timeout ( 1 , ĠTimeUnit . MIN UTES ) Ġ// Ġconnect Ġtimeout ĊĠĠĠ Ġ. write Timeout ( 1 , ĠTimeUnit . MIN UTES ) Ġ// Ġwrite Ġtimeout ĊĠĠĠ Ġ. read Timeout ( 1 , ĠTimeUnit . MIN UTES ) Ġ// Ġread Ġtimeout ĊĠĠĠ Ġ. build () Ċ Ċ private Ġval Ġretrofit Ġ= ĠRet rofit . Builder () ĊĠĠĠ Ġ. add Converter Factory ( M oshi Converter Factory . create ( mos hi )) ĊĠĠĠ Ġ. add Call Adapter Factory ( Coroutine Call Adapter Factory ()) ĊĠĠĠ Ġ. baseUrl ( Constants . BASE _ URL ) ĊĠĠĠ Ġ. client ( ok HttpClient ) ĊĠĠĠ Ġ. build () ĊĊ Ċ interface ĠT mdb ApiService Ġ{ ĊĊĠĠĠ Ġ// add Ġregion ĊĠĠĠ Ġ@ GET (" 3 / movie / now _ playing ? api _ key = ea 9 a 4 9 ebf 2 b 7 4 7 2 1 a 7 5 aae 2 7 1 ebd 3 0 3 6 ") ĊĠĠĠ Ġfun Ġget Now Playing Movies Async ( ĊĠĠĠĠĠĠĠ Ġ@ Query (" page ") Ġpage : ĠInt Ġ= Ġ 1 ĊĠĠĠ Ġ): ĠDeferred < Movie Response > ĊĊĠĠĠ Ġ@ GET (" 3 / movie / popular ? api _ key = ea 9 a 4 9 ebf 2 b 7 4 7 2 1 a 7 5 aae 2 7 1 ebd 3 0 3 6 ") ĊĠĠĠ Ġfun Ġget Pop ular Movies Async ( Ċ // ĠĠĠĠĠĠĠ Ġ@ Query (" region ") Ġlang : ĠString Ġ= ĠConstants . REGION _ IN DI A , ĊĠĠĠĠĠĠĠ Ġ@ Query (" page ") Ġpage : ĠInt Ġ= Ġ 1 ĊĠĠĠ Ġ): ĠDeferred < Movie Response > ĊĊĠĠĠ Ġ@ GET (" 3 / movie / top _ r ated ? api _ key = ea 9 a 4 9 ebf 2 b 7 4 7 2 1 a 7 5 aae 2 7 1 ebd 3 0 3 6 ") ĊĠĠĠ Ġfun Ġget Top R ated Movies Async ( Ċ // ĠĠĠĠĠĠĠ Ġ@ Query (" region ") Ġlang : ĠString Ġ= ĠConstants . REGION _ IN DI A , ĊĠĠĠĠĠĠĠ Ġ@ Query (" page ") Ġpage : ĠInt Ġ= Ġ 1 ĊĠĠĠ Ġ): ĠDeferred < Movie Response > ĊĊĠĠĠ Ġ// add Ġregion ĊĠĠĠ Ġ@ GET (" 3 / movie / up coming ? api _ key = ea 9 a 4 9 ebf 2 b 7 4 7 2 1 a 7 5 aae 2 7 1 ebd 3 0 3 6 ") ĊĠĠĠ Ġfun Ġget Up coming Movies Async ( Ċ // ĠĠĠĠĠĠĠ Ġ@ Query (" region ") Ġlang : ĠString Ġ= ĠConstants . REGION _ IN DI A , ĊĠĠĠĠĠĠĠ Ġ@ Query (" page ") Ġpage : ĠInt Ġ= Ġ 1 ĊĠĠĠ Ġ): ĠDeferred < Movie Response > ĊĊĠĠĠ Ġ@ GET (" 3 / movie /{ movie Id }") ĊĠĠĠ Ġfun Ġget Complete Movie Detail Async ( ĊĠĠĠĠĠĠĠ Ġ@ Path (" movie Id ") Ġmovie ID : ĠInt , ĊĠĠĠĠĠĠĠ Ġ@ Query (" api _ key ") ĠapiKey : ĠString Ġ= ĠConstants . API _ KEY , ĊĠĠĠĠĠĠĠ Ġ@ Query (" append _ to _ response ") Ġat r : ĠString Ġ= ĠConstants . V IR ĊĠĠĠ Ġ): ĠDeferred < Complete Movie Detail > ĊĊĠĠĠ Ġ@ GET (" 3 / search / movie ") ĊĠĠĠ Ġfun Ġget Se ar ched Movie ( ĊĠĠĠĠĠĠĠ Ġ@ Query (" api _ key ") ĠapiKey : ĠString Ġ= ĠConstants . API _ KEY , ĊĠĠĠĠĠĠĠ Ġ@ Query (" query ") Ġsearch : ĠString ĊĠĠĠ Ġ): ĠDeferred < Movie Response > Ċ } Ċ Ċ object ĠT mdb Api Ġ{ ĊĠĠĠ Ġval ĠRET RO FIT _ SERVICE : ĠT mdb ApiService Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ Ġretrofit . create ( T mdb ApiService :: class . java ) ĊĠĠĠ Ġ} Ċ }