package Ġcom . example . new sc ast . network Ċ Ċ import Ġcom . squareup . mos hi . M oshi Ċ import Ġcom . squareup . mos hi . kotlin . reflect . Kotlin Json Adapter Factory Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . logging . Http Logging Interceptor Ċ import Ġorg . k oin . core . qual ifier . named Ċ import Ġorg . k oin . dsl . module Ċ import Ġretrofit 2 . Converter Ċ import Ġretrofit 2 . Ret rofit Ċ import Ġretrofit 2 . converter . mos hi . M oshi Converter Factory Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ val Ġnetwork Module Ġ= Ġmodule Ġ{ ĊĠĠĠ Ġfactory Ġ{ Ġprovide Logging Interceptor () Ġ} ĊĠĠĠ Ġfactory Ġ{ Ġprovide Ok HttpClient ( get ()) Ġ} ĊĠĠĠ Ġfactory Ġ{ Ġprovide Converter Factory () Ġ} ĊĠĠĠ Ġsingle ( named (" event _ registry ")) Ġ{ Ġprovide Ret rofit ( get (), Ġget (), ĠBASE _ URL ) Ġ} ĊĠĠĠ Ġfactory Ġ{ ĠNetwork Response Helper () Ġ} ĊĠĠĠ Ġfactory Ġ{ Ġprovide News Api ( Ġget ( named (" event _ registry ")) Ġ) Ġ} Ċ } Ċ Ċ private Ġconst Ġval ĠBASE _ URL Ġ= Ġ" http :// event registry . org / api / v 1 / article /" Ċ Ċ fun Ġprovide Ok HttpClient ( logging Interceptor : ĠHttp Logging Interceptor ): ĠOk HttpClient Ġ{ ĊĠĠĠ Ġreturn ĠOk HttpClient (). newBuilder () ĊĠĠĠĠĠĠĠ Ġ. add Interceptor ( logging Interceptor ) ĊĠĠĠĠĠĠĠ Ġ. connect Timeout ( 1 5 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠ Ġ. read Timeout ( 1 5 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠ Ġ. write Timeout ( 1 5 , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠ Ġ. build () Ċ } Ċ Ċ fun Ġprovide Converter Factory (): ĠConverter . Factory Ġ{ ĊĠĠĠ Ġreturn ĠM oshi Converter Factory . create ( ĊĠĠĠĠĠĠĠ ĠM oshi . Builder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. add ( Kotlin Json Adapter Factory ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. build () ĊĠĠĠ Ġ) Ċ } Ċ Ċ fun Ġprovide Logging Interceptor (): ĠHttp Logging Interceptor Ġ{ ĊĠĠĠ Ġval Ġlogger Ġ= ĠHttp Logging Interceptor () ĊĠĠĠ Ġlogger . level Ġ= ĠHttp Logging Interceptor . Level . BASIC ĊĠĠĠ Ġreturn Ġlogger Ċ } Ċ Ċ fun Ġprovide Ret rofit ( ok HttpClient : ĠOk HttpClient , Ġconverter Factory : ĠConverter . Factory , Ġurl : ĠString ): ĠRet rofit Ġ{ ĊĠĠĠ Ġreturn ĠRet rofit . Builder () ĊĠĠĠĠĠĠĠ Ġ. baseUrl ( url ) ĊĠĠĠĠĠĠĠ Ġ. add Converter Factory ( converter Factory ) ĊĠĠĠĠĠĠĠ Ġ. client ( ok HttpClient ) ĊĠĠĠĠĠĠĠ Ġ. build () Ċ } Ċ Ċ fun Ġprovide News Api ( ret rofit : ĠRet rofit ): ĠNews Service Ġ= Ġretrofit . create ( News Service :: class . java )