package Ġcom . ample mind . network Ċ Ċ import Ġcom . google . gson . Gson Builder Ċ import Ġokhttp 3 . Interceptor Ċ 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 ĊĊ Ċ fun Ġcreate Network Client ( baseUrl : ĠString , Ġdebug : ĠBoolean Ġ= Ġfalse ) Ġ= ĊĠĠĠ Ġretrofit Client ( baseUrl , ĠhttpClient ( debug )) Ċ Ċ private Ġfun ĠhttpClient ( debug : ĠBoolean ): ĠOk HttpClient Ġ{ ĊĠĠĠ Ġval Ġhttp Logging Interceptor Ġ= ĠHttp Logging Interceptor ( Http Logging Interceptor . Logger . DEFAULT ) ĊĠĠĠ Ġval Ġclient Builder Ġ= ĠOk HttpClient . Builder () ĊĠĠĠ Ġif Ġ( debug ) Ġ{ ĊĠĠĠĠĠĠĠ Ġhttp Logging Interceptor . level Ġ= ĠHttp Logging Interceptor . Level . BODY ĊĠĠĠĠĠĠĠ Ġclient Builder . add Interceptor ( http Logging Interceptor ) ĊĠĠĠĠĠĠĠ Ġclient Builder . network Intercept ors (). add ( net Work Interceptor ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġclient Builder . build () Ċ } Ċ Ċ val Ġnet Work Interceptor Ġ= ĠInter ceptor Ġ{ Ġchain Ġ-> ĊĠĠĠ Ġval Ġrequest Ġ= Ġchain . request (). newBuilder (). build () ĊĠĠĠ Ġval Ġresponse Ġ= Ġchain . proceed ( request ) ĊĠĠĠ Ġresponse Ċ } Ċ Ċ private Ġfun Ġgson () Ġ= ĠGson Builder (). set Len ient (). create () Ċ Ċ private Ġfun Ġretrofit Client ( baseUrl : ĠString , ĠhttpClient : ĠOk HttpClient ): ĠRet rofit Ġ= ĊĠĠĠ ĠRet rofit . Builder () ĊĠĠĠĠĠĠĠ Ġ. baseUrl ( baseUrl ) ĊĠĠĠĠĠĠĠ Ġ. client ( httpClient ) ĊĠĠĠĠĠĠĠ Ġ. add Converter Factory ( Gson Converter Factory . create ( gson ())) ĊĠĠĠĠĠĠĠ Ġ. add Call Adapter Factory ( Rx Java 2 Call Adapter Factory . create ()) ĊĠĠĠĠĠĠĠ Ġ. build () ĊĊ