package Ġcom . su cho . kode in example . mock Ċ Ċ import Ġcom . su cho . kode in example . Build Config Ċ import Ġcom . su cho . kode in example . data . services . ApiService Ċ import Ġcom . su cho . kode in example . data . services . Github ApiService Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . logging . Http Logging Interceptor Ċ import Ġorg . kode in . di . K ode in . Module Ċ import Ġorg . kode in . di . generic . bind Ċ import Ġorg . kode in . di . generic . instance Ċ import Ġorg . kode in . di . generic . singleton Ċ 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 Ċ Ċ private Ġconst Ġval ĠMODULE _ NAME Ġ= Ġ" Network ĠModule " Ċ Ċ val Ġmock Network Module Ġ= ĠModule ( MODULE _ NAME , Ġfalse ) Ġ{ ĊĠ Ġbind < Ok HttpClient >() Ġwith Ġsingleton Ġ{ Ġget Ok HttpClient () Ġ} ĊĠ Ġbind < Ret rofit >() Ġwith Ġsingleton Ġ{ Ġget Ret rofit ( instance ()) Ġ} ĊĠ Ġbind < ApiService >() Ġwith Ġsingleton Ġ{ Ġget ApiService ( instance ()) Ġ} ĊĠ Ġbind < Github ApiService >() Ġwith Ġsingleton Ġ{ Ġget Github ApiService ( instance ()) Ġ} Ċ } ĊĊ Ċ private Ġfun Ġget Ok HttpClient (): ĠOk HttpClient Ġ{ ĊĠ Ġval Ġhttp Builder Ġ= ĠOk HttpClient . Builder () ĊĠ Ġif Ġ( Build Config . ENABLE _ LOG GING ) Ġ{ ĊĠĠĠ Ġval Ġhttp Logging Interceptor Ġ= ĠHttp Logging Interceptor () ĊĠĠĠ Ġhttp Logging Interceptor . level Ġ= ĠHttp Logging Interceptor . Level . BODY ĊĠĠĠ Ġhttp Builder . intercept ors () ĊĠĠĠĠĠĠĠ Ġ. add ( http Logging Interceptor ) ĊĠ Ġ} ĊĠ Ġreturn Ġhttp Builder . build () Ċ } Ċ Ċ private Ġfun Ġget Ret rofit ( ok HttpClient : ĠOk HttpClient ): ĠRet rofit Ġ= ĠRet rofit . Builder () ĊĠĠĠ Ġ. baseUrl ( Build Config . BASE _ URL ) ĊĠĠĠ Ġ. add Converter Factory ( Gson Converter Factory . create ()) ĊĠĠĠ Ġ. add Call Adapter Factory ( Rx Java 2 Call Adapter Factory . create ()) ĊĠĠĠ Ġ. client ( ok HttpClient ) ĊĠĠĠ Ġ. build () Ċ Ċ private Ġfun Ġget ApiService ( ret rofit : ĠRet rofit ): ĠApi Service Ġ= Ġretrofit . create ( ApiService :: class . java ) Ċ Ċ private Ġfun Ġget Github ApiService ( ret rofit : ĠRet rofit ): ĠGithub ApiService Ġ= Ġretrofit . newBuilder () ĊĠĠĠĠĠĠĠ Ġ. baseUrl (" https :// api . github . com "). build (). create ( Github ApiService :: class . java )