package payp.mard2p.api.v0.models import com.jakewharton.retrofit2.adapter.rxjava2.HttpException import io.apibuilder.app.ApiNetworkCallResponse import io.apibuilder.app.CommonNetworkErrors import io.apibuilder.app.EitherCallOrCommonNetworkError import io.apibuilder.app.EitherCallOrCommonNetworkError.CallError import io.apibuilder.app.EitherCallOrCommonNetworkError.CommonNetworkError import io.reactivex.Single import kotlin.Double import kotlin.Long import kotlin.String import kotlin.Throwable import kotlin.Unit import kotlin.collections.List import retrofit2.Response import retrofit2.http.DELETE import retrofit2.http.GET import retrofit2.http.Path import retrofit2.http.Query /** * This code was generated by [models.generator.kotlin.KotlinGenerator] */ interface WithdrawsClient { /** * Delete some withdraw. */ @DELETE(value="withdraws/delete/{wdwid}") fun deleteWithdrawsDeleteWdwid(@Path(value="wdwid") wdwid: Long): Single> /** * Find withdraw by its id. */ @GET(value="withdraws/{wdwid}") fun getWithdrawsWdwid( @Path(value="wdwid") wdwid: Long, @Query(value="depid") depid: Long, @Query(value="payment_method") paymentMethod: String, @Query(value="actorid") actorid: String, @Query(value="ref_accountid") refAccountid: Long, @Query(value="operatorid") operatorid: String, @Query(value="amount") amount: Double, @Query(value="phone") phone: Long, @Query(value="pin") pin: Long, @Query(value="currency") currency: String, @Query(value="payment_context") paymentContext: String ): Single> /** * List all the withdraws */ @GET(value="withdraws/list") fun getWithdrawsList( @Query(value="payid") payid: Long, @Query(value="payment_method") paymentMethod: String, @Query(value="actorid") actorid: String, @Query(value="ref_accountid") refAccountid: Long, @Query(value="operatorid") operatorid: String, @Query(value="amount") amount: Double, @Query(value="phone") phone: Long, @Query(value="pin") pin: Long, @Query(value="currency") currency: String, @Query(value="payment_context") paymentContext: String ): Single>> object DeleteWithdrawsDeleteWdwidCall { val toError: (Throwable) -> EitherCallOrCommonNetworkError = { t -> when (t) { is HttpException -> { val body: String? = t.response().errorBody()?.string() when (t.code()) { 401 -> CallError (ErrorResponses.Error401) 404 -> CallError (ErrorResponses.Error404) else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } fun getCallAndErrorLambda(client: WithdrawsClient, wdwid: Long) = ApiNetworkCallResponse( client.deleteWithdrawsDeleteWdwid(wdwid) .map{ response -> if(response.isSuccessful) Pair(Unit, response.code()) else throw HttpException(response)} .map{it} , toError) /** * Error Responses for deleteWithdrawsDeleteWdwid - Delete some withdraw. */ sealed class ErrorResponses { object Error401 : ErrorResponses() object Error404 : ErrorResponses() } } object GetWithdrawsWdwidCall { val toError: (Throwable) -> EitherCallOrCommonNetworkError = { t -> when (t) { is HttpException -> { val body: String? = t.response().errorBody()?.string() when (t.code()) { 404 -> CallError (ErrorResponses.Error404) else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } fun getCallAndErrorLambda( client: WithdrawsClient, wdwid: Long, depid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ) = ApiNetworkCallResponse( client.getWithdrawsWdwid(wdwid,depid,paymentMethod,actorid,refAccountid,operatorid,amount,phone,pin,currency,paymentContext) .map{ response -> if(response.isSuccessful) response.body()?.let { body -> Pair(body, response.code())} else throw HttpException(response)} .map{it} , toError) /** * Error Responses for getWithdrawsWdwid - Find withdraw by its id. */ sealed class ErrorResponses { object Error404 : ErrorResponses() } } object GetWithdrawsListCall { val toError: (Throwable) -> EitherCallOrCommonNetworkError = { t -> when (t) { is HttpException -> { val body: String? = t.response().errorBody()?.string() when (t.code()) { 404 -> CallError (ErrorResponses.Error404) else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } fun getCallAndErrorLambda( client: WithdrawsClient, payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ) = ApiNetworkCallResponse( client.getWithdrawsList(payid,paymentMethod,actorid,refAccountid,operatorid,amount,phone,pin,currency,paymentContext) .map{ response -> if(response.isSuccessful) response.body()?.let { body -> Pair(body, response.code())} else throw HttpException(response)} .map{it} , toError) /** * Error Responses for getWithdrawsList - List all the withdraws */ sealed class ErrorResponses { object Error404 : ErrorResponses() } } }