package Ġcom . ish ub h ams ing h . jenkins . di . module čĊč Ċ import Ġandroid . content . Context č Ċ import Ġcom . ish ub h ams ing h . jenkins . Build Config č Ċ import Ġcom . ish ub h ams ing h . jenkins . Constants č Ċ import Ġcom . ish ub h ams ing h . jenkins . J enkins Application č Ċ import Ġcom . ish ub h ams ing h . jenkins . core . ret rofit . Auth Request Interceptor č Ċ import Ġcom . ish ub h ams ing h . jenkins . core . ret rofit . Connectivity Interceptor č Ċ import Ġcom . ish ub h ams ing h . jenkins . core . ret rofit . Network Handler č Ċ import Ġcom . ish ub h ams ing h . jenkins . data . Preferences č Ċ import Ġcom . ish ub h ams ing h . jenkins . inter actor . api . J enkins Api č Ċ import Ġcom . ish ub h ams ing h . jenkins . inter actor . api . J enkins Auth Api č Ċ import Ġdagger . Module č Ċ import Ġdagger . Provides č Ċ import Ġokhttp 3 . Ok HttpClient č Ċ import Ġokhttp 3 . logging . Http Logging Interceptor č Ċ import Ġretrofit 2 . Ret rofit č Ċ import Ġretrofit 2 . converter . gson . Gson Converter Factory č Ċ import Ġjava . util . concurrent . TimeUnit č Ċ import Ġjavax . inject . Singleton čĊč Ċ /** čĊ Ġ* ĠCreated Ġby ĠSh ub ham ĠSing h Ġon Ġ 1 4 - 0 7 - 2 0 1 9 . čĊ Ġ*/ čĊč Ċ @ Module č Ċ class ĠApplication Module Ġ{ čĊčĊĠĠĠ Ġ@ Provides čĊĠĠĠ Ġ@ Singleton čĊĠĠĠ Ġfun Ġprovide ApplicationContext ( application : ĠJenkins Application ): ĠContext Ġ= Ġapplication čĊčĊĠĠĠ Ġ@ Provides čĊĠĠĠ Ġ@ Singleton čĊĠĠĠ Ġfun Ġprovides Preferences ( application : ĠJenkins Application ): ĠPreferences Ġ{ čĊĠĠĠĠĠĠĠ Ġreturn ĠPreferences ( application ) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Provides čĊĠĠĠ Ġ@ Singleton čĊĠĠĠ Ġfun Ġprovides Http Logging Interceptor (): ĠHttp Logging Interceptor Ġ{ čĊĠĠĠĠĠĠĠ Ġval Ġhttp Logging Interceptor Ġ= ĠHttp Logging Interceptor () čĊĠĠĠĠĠĠĠ Ġhttp Logging Interceptor . level Ġ= Ġif Ġ( Build Config . BUILD _ TYPE . equals (" debug ", Ġignore Case Ġ= Ġtrue )) čĊĠĠĠĠĠĠĠĠĠĠĠ ĠHttp Logging Interceptor . Level . BODY čĊĠĠĠĠĠĠĠ Ġelse čĊĠĠĠĠĠĠĠĠĠĠĠ ĠHttp Logging Interceptor . Level . NONE čĊčĊĠĠĠĠĠĠĠ Ġreturn Ġhttp Logging Interceptor čĊčĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Provides čĊĠĠĠ Ġ@ Singleton čĊĠĠĠ Ġfun Ġprovides J enkins Auth Api ( auth Request Interceptor : ĠAuth Request Interceptor , Ġconnectivity Interceptor : ĠConnect ivity Interceptor , čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhttp Logging Interceptor : ĠHttp Logging Interceptor , Ġpreferences : ĠPreferences ): ĠJenkins Auth Api Ġ{ čĊčĊčĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠOk HttpClient . Builder () čĊĠĠĠĠĠĠĠ Ġbuilder . intercept ors (). add ( auth Request Interceptor ) čĊĠĠĠĠĠĠĠ Ġbuilder . intercept ors (). add ( connectivity Interceptor ) čĊĠĠĠĠĠĠĠ Ġbuilder . intercept ors (). add ( http Logging Interceptor ) čĊčĊĠĠĠĠĠĠĠ Ġbuilder . read Timeout ( Constants . NETWORK _ CALL _ TIMEOUT _ SECONDS . to Long (), ĠTimeUnit . SECONDS ) čĊĠĠĠĠĠĠĠ Ġbuilder . write Timeout ( Constants . NETWORK _ CALL _ TIMEOUT _ SECONDS . to Long (), ĠTimeUnit . SECONDS ) čĊĠĠĠĠĠĠĠ Ġbuilder . connect Timeout ( Constants . NETWORK _ CALL _ TIMEOUT _ SECONDS . to Long (), ĠTimeUnit . SECONDS ) čĊĠĠĠĠĠĠĠ Ġval Ġclient Ġ= Ġbuilder . build () čĊĠĠĠĠĠĠĠ Ġval Ġretrofit Ġ= ĠRet rofit . Builder () čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. baseUrl (" http :// localhost ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Converter Factory ( Gson Converter Factory . create ()) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. client ( client ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () čĊĠĠĠĠĠĠĠ Ġreturn Ġretrofit . create ( J enkins Auth Api :: class . java ) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Provides čĊĠĠĠ Ġ@ Singleton čĊĠĠĠ Ġfun Ġprovides J enkins Api ( connectivity Interceptor : ĠConnect ivity Interceptor , čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhttp Logging Interceptor : ĠHttp Logging Interceptor , Ġpreferences : ĠPreferences ): ĠJenkins Api Ġ{ čĊčĊčĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠOk HttpClient . Builder () čĊĠĠĠĠĠĠĠ Ġbuilder . intercept ors (). add ( connectivity Interceptor ) čĊĠĠĠĠĠĠĠ Ġbuilder . intercept ors (). add ( http Logging Interceptor ) čĊčĊĠĠĠĠĠĠĠ Ġbuilder . read Timeout ( Constants . NETWORK _ CALL _ TIMEOUT _ SECONDS . to Long (), ĠTimeUnit . SECONDS ) čĊĠĠĠĠĠĠĠ Ġbuilder . write Timeout ( Constants . NETWORK _ CALL _ TIMEOUT _ SECONDS . to Long (), ĠTimeUnit . SECONDS ) čĊĠĠĠĠĠĠĠ Ġbuilder . connect Timeout ( Constants . NETWORK _ CALL _ TIMEOUT _ SECONDS . to Long (), ĠTimeUnit . SECONDS ) čĊĠĠĠĠĠĠĠ Ġval Ġclient Ġ= Ġbuilder . build () čĊĠĠĠĠĠĠĠ Ġval Ġretrofit Ġ= ĠRet rofit . Builder () čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. baseUrl (" http :// localhost ") čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Converter Factory ( Gson Converter Factory . create ()) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. client ( client ) čĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () čĊĠĠĠĠĠĠĠ Ġreturn Ġretrofit . create ( J enkins Api :: class . java ) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Provides čĊĠĠĠ Ġ@ Singleton čĊĠĠĠ Ġfun Ġprovides Auth Request Interceptor ( preferences : ĠPreferences ): ĠAuth Request Interceptor Ġ{ čĊĠĠĠĠĠĠĠ Ġreturn ĠAuth Request Interceptor ( preferences ) čĊĠĠĠ Ġ} čĊĠĠĠ Ġ@ Provides čĊĠĠĠ Ġ@ Singleton čĊĠĠĠ Ġfun Ġprovides Connectivity Interceptor ( context : ĠContext ): ĠConnect ivity Interceptor Ġ{ čĊĠĠĠĠĠĠĠ Ġreturn ĠConnect ivity Interceptor ( context ) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Provides čĊĠĠĠ Ġ@ Singleton čĊĠĠĠ Ġfun Ġprovides Network Handler ( application : ĠJenkins Application ): ĠNetwork Handler Ġ{ čĊĠĠĠĠĠĠĠ Ġreturn ĠNetwork Handler ( application ) čĊčĊĠĠĠ Ġ} č Ċ }