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.Int 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.POST import retrofit2.http.PUT import retrofit2.http.Path import retrofit2.http.Query /** * This code was generated by [models.generator.kotlin.KotlinGenerator] */ interface PaymentsClient { /** * Used to create a payment. */ @POST(value="payments/create") fun postPaymentsCreate( @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="currency") currency: String, @Query(value="phone") phone: Long, @Query(value="pin") pin: Int, @Query(value="payment_context") paymentContext: String ): Single> /** * Used to update a payment. */ @PUT(value="payments/update/{payid}") fun putPaymentsUpdatePayid( @Path(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: Int, @Query(value="currency") currency: String, @Query(value="payment_context") paymentContext: String ): Single> /** * Delete some payment. */ @DELETE(value="payments/delete/{payid}") fun deletePaymentsDeletePayid(@Path(value="payid") payid: Long): Single> /** * Find payment by its id. */ @GET(value="payments/{payid}") fun getPaymentsPayid( @Path(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> /** * Find payment by id accountid */ @GET(value="payments/{ref_accountid}") fun getPaymentsRefAccountid( @Path(value="ref_accountid") refAccountid: Long, @Query(value="payid") payid: Long, @Query(value="payment_method") paymentMethod: String, @Query(value="actorid") actorid: String, @Query(value="operatorid") operatorid: String, @Query(value="amount") amount: Double, @Query(value="phone") phone: Long, @Query(value="pin") pin: Int, @Query(value="currency") currency: String, @Query(value="payment_context") paymentContext: String ): Single> /** * List all the payments */ @GET(value="payments/list") fun getPaymentsList( @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 PostPaymentsCreateCall { val toError: (Throwable) -> EitherCallOrCommonNetworkError = { t -> when (t) { is HttpException -> { val body: String? = t.response().errorBody()?.string() when (t.code()) { 409 -> CallError (ErrorResponses.Error409) else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } fun getCallAndErrorLambda( client: PaymentsClient, payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, currency: String, phone: Long, pin: Int, paymentContext: String ) = ApiNetworkCallResponse( client.postPaymentsCreate(payid,paymentMethod,actorid,refAccountid,operatorid,amount,currency,phone,pin,paymentContext) .map{ response -> if(response.isSuccessful) response.body()?.let { body -> Pair(body, response.code())} else throw HttpException(response)} .map{it} , toError) /** * Error Responses for postPaymentsCreate - Used to create a payment. */ sealed class ErrorResponses { object Error409 : ErrorResponses() } } object PutPaymentsUpdatePayidCall { val toError: (Throwable) -> EitherCallOrCommonNetworkError = { t -> when (t) { is HttpException -> { val body: String? = t.response().errorBody()?.string() when (t.code()) { 409 -> CallError (ErrorResponses.Error409) else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } else -> CommonNetworkError(CommonNetworkErrors.processCommonNetworkError(t)) } } fun getCallAndErrorLambda( client: PaymentsClient, payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Int, currency: String, paymentContext: String ) = ApiNetworkCallResponse( client.putPaymentsUpdatePayid(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 putPaymentsUpdatePayid - Used to update a payment. */ sealed class ErrorResponses { object Error409 : ErrorResponses() } } object DeletePaymentsDeletePayidCall { 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: PaymentsClient, payid: Long) = ApiNetworkCallResponse( client.deletePaymentsDeletePayid(payid) .map{ response -> if(response.isSuccessful) Pair(Unit, response.code()) else throw HttpException(response)} .map{it} , toError) /** * Error Responses for deletePaymentsDeletePayid - Delete some payment. */ sealed class ErrorResponses { object Error401 : ErrorResponses() object Error404 : ErrorResponses() } } object GetPaymentsPayidCall { 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: PaymentsClient, payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ) = ApiNetworkCallResponse( client.getPaymentsPayid(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 getPaymentsPayid - Find payment by its id. */ sealed class ErrorResponses { object Error404 : ErrorResponses() } } object GetPaymentsRefAccountidCall { 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: PaymentsClient, refAccountid: Long, payid: Long, paymentMethod: String, actorid: String, operatorid: String, amount: Double, phone: Long, pin: Int, currency: String, paymentContext: String ) = ApiNetworkCallResponse( client.getPaymentsRefAccountid(refAccountid,payid,paymentMethod,actorid,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 getPaymentsRefAccountid - Find payment by id accountid */ sealed class ErrorResponses { object Error404 : ErrorResponses() } } object GetPaymentsListCall { 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: PaymentsClient, payid: Long, paymentMethod: String, actorid: String, refAccountid: Long, operatorid: String, amount: Double, phone: Long, pin: Long, currency: String, paymentContext: String ) = ApiNetworkCallResponse( client.getPaymentsList(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 getPaymentsList - List all the payments */ sealed class ErrorResponses { object Error404 : ErrorResponses() } } }