Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 782 Bytes

Retrofit.md

File metadata and controls

28 lines (24 loc) · 782 Bytes

You can create Retrofit instance via createRetrofitService function. This function creates retrofit service with EitherCallAdapterFactory, so we recommend you using ResponseEither in your WebApi pattern.

Ex:

interface WebApi {
    @FormUrlEncoded
    @POST("v1/login")
    suspend fun login(
        @FieldMap fields: Fields
    ): ResponseE<ErrorResponse, LoginData>
}

val apiService = createRetrofitService(
    service = WebApi::class.java,
    httpClient = createHttpClient(),
    baseUrl = "http:https://..."
)

// Or via delegation
val apiService by retrofitService(
    service = WebApi::class.java,
    httpClient = createHttpClient(),
    baseUrl = "http:https://..."
)

See : Retrofit Util