package Ġme . ty ler bw ong . re bel base . data . providers . api Ċ Ċ import Ġcom . google . gson . Gson Ċ import Ġcom . google . gson . Gson Builder Ċ import Ġio . reactivex . schedul ers . Schedulers Ċ import Ġme . ty ler bw ong . re bel base . Build Config Ċ import Ġme . ty ler bw ong . re bel base . data . api . Re bel Api Ċ import Ġme . ty ler bw ong . re bel base . data . converters . People Response Converter Ċ import Ġme . ty ler bw ong . re bel base . data . converters . Person Converter Ċ import Ġme . ty ler bw ong . re bel base . data . models . People Response Ċ import Ġme . ty ler bw ong . re bel base . data . models . Person Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . logging . Http Logging Interceptor Ċ import Ġretrofit 2 . Ret rofit Ċ import Ġretrofit 2 . adapter . rx java 2 . Rx Java 2 Call Adapter Factory Ċ import Ġretrofit 2 . converter . gson . Gson Converter Factory Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ /** Ċ Ġ* ĠThe ĠGame ĠAPI ĠProvider Ġprovides Ġan Ġinstance Ġof Ċ Ġ* Ġthe ĠAPI Ġservice Ġbuilt Ġby ĠRet rofit . ĊĊ Ġ* Ġ@ author ĠTy ler ĠW ong Ċ Ġ* Ġ* Ċ Ġ* Ġ@ version Ġ 1 . 0 Ċ Ġ*/ Ċ object ĠRe bel Api Impl Ġ{ ĊĠĠĠ Ġvar Ġapi Service : ĠRe bel Api Ġ= ĠRet rofit . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. baseUrl ( Build Config . SERVER _ ENDPOINT ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. client ( make Ok HttpClient ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Call Adapter Factory ( Rx Java 2 Call Adapter Factory . create With Scheduler ( Schedulers . io ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Converter Factory ( Gson Converter Factory . create ( setup Gson ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. create ( Re bel Api :: class . java ) Ċ Ċ } Ċ Ċ val Ġapi Service : ĠRe bel Api Ġ= ĠRe bel Api Impl . api Service Ċ private Ġconst Ġval ĠCONNECTION _ TIMEOUT : ĠLong Ġ= Ġ 1 0 Ċ Ċ /** Ċ Ġ* ĠThis Ġmethod Ġprovides Ġand Ġhandles Ġthe Ġcreation Ġof Ġan ĠOk HttpClient . Ċ Ġ* ĠIf Ġwe Ġare Ġan Ġa Ġdebug Ġbuild , Ġadd Ġa Ġlogging Ġinterceptor , Ċ Ġ* Ġotherwise Ġprovide Ġno Ġlogging Ġinterceptor . ĊĊ Ġ* Ġ@ return ĠThe Ġdevelopment Ġor Ġproduction ĠOk HttpClient Ċ Ġ*/ Ċ private Ġfun Ġmake Ok HttpClient (): ĠOk HttpClient Ġ{ ĊĠĠĠ Ġval Ġok HttpClient Builder Ġ= ĠOk HttpClient . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. read Timeout ( CONNECTION _ TIMEOUT , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. connect Timeout ( CONNECTION _ TIMEOUT , ĠTimeUnit . SECONDS ) ĊĊĠĠĠ Ġif Ġ( Build Config . DEBUG ) Ġ{ ĊĠĠĠĠĠĠĠ Ġok HttpClient Builder . add Interceptor ( Http Logging Interceptor ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġok HttpClient Builder . build () Ċ } Ċ Ċ /** Ċ Ġ* ĠThis Ġmethod Ġprovides Ġand Ġhandles Ġthe Ġcreation Ġof Ġa ĠGson Ġparser . Ċ Ġ* ĠIt Ġwill Ġadd Ġall Ġof Ġthe Ġnecessary ĠType ĠAdapter s Ġto Ġserialize Ġand Ċ Ġ* Ġdeserialize Ġobjects Ġpassed Ġto Ġand Ġfrom Ġthe Ġserver . ĊĊ Ġ* Ġ@ return ĠThe ĠGson Ġparser Ġto Ġbe Ġused Ġwith Ġa ĠRet rofit Ġinstance Ċ Ġ*/ Ċ private Ġfun Ġsetup Gson (): ĠGson Ġ{ ĊĠĠĠ Ġval Ġbuilder Ġ= ĠGson Builder () ĊĠĠĠ Ġbuilder . register Type Adapter ( Person :: class . java , ĠPerson Converter ()) ĊĠĠĠ Ġbuilder . register Type Adapter ( People Response :: class . java , ĠPeople Response Converter ()) ĊĠĠĠ Ġbuilder . exclude Fields Without Expose Annotation () ĊĠĠĠ Ġreturn Ġbuilder . create () Ċ }