import { ApiResponse , RequestOptions } from '../core' ; import { CancelPaymentByIdempotencyKeyRequest , cancelPaymentByIdempotencyKeyRequestSchema , } from '../models/cancelPaymentByIdempotencyKeyRequest' ; import { CancelPaymentByIdempotencyKeyResponse , cancelPaymentByIdempotencyKeyResponseSchema , } from '../models/cancelPaymentByIdempotencyKeyResponse' ; import { CancelPaymentResponse , cancelPaymentResponseSchema , } from '../models/cancelPaymentResponse' ; import { CompletePaymentRequest , completePaymentRequestSchema , } from '../models/completePaymentRequest' ; import { CompletePaymentResponse , completePaymentResponseSchema , } from '../models/completePaymentResponse' ; import { CreatePaymentRequest , createPaymentRequestSchema , } from '../models/createPaymentRequest' ; import { CreatePaymentResponse , createPaymentResponseSchema , } from '../models/createPaymentResponse' ; import { GetPaymentResponse , getPaymentResponseSchema , } from '../models/getPaymentResponse' ; import { ListPaymentsResponse , listPaymentsResponseSchema , } from '../models/listPaymentsResponse' ; import { UpdatePaymentRequest , updatePaymentRequestSchema , } from '../models/updatePaymentRequest' ; import { UpdatePaymentResponse , updatePaymentResponseSchema , } from '../models/updatePaymentResponse' ; import { bigint , number , optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class PaymentsApi extends BaseApi { param beginTime param endTime param sortOrder param cursor param locationId param total param last4 param cardBrand param limit return async listPayments ( beginTime ? , endTime ? , sortOrder ? , cursor ? , locationId ? , total ? , last4 ? , cardBrand ? , limit ? , requestOptions ? ) { const req = this . createRequest ( 'GET' , '/v2/payments' ) ; const mapped = req . prepareArgs ( { beginTime : [ beginTime , optional ( string ( ) ) ] , endTime : [ endTime , optional ( string ( ) ) ] , sortOrder : [ sortOrder , optional ( string ( ) ) ] , cursor : [ cursor , optional ( string ( ) ) ] , locationId : [ locationId , optional ( string ( ) ) ] , total : [ total , optional ( bigint ( ) ) ] , last4 : [ last4 , optional ( string ( ) ) ] , cardBrand : [ cardBrand , optional ( string ( ) ) ] , limit : [ limit , optional ( number ( ) ) ] , } ) ; req . query ( 'begin_time' , mapped . beginTime ) ; req . query ( 'end_time' , mapped . endTime ) ; req . query ( 'sort_order' , mapped . sortOrder ) ; req . query ( 'cursor' , mapped . cursor ) ; req . query ( 'location_id' , mapped . locationId ) ; req . query ( 'total' , mapped . total ) ; req . query ( 'last_4' , mapped . last4 ) ; req . query ( 'card_brand' , mapped . cardBrand ) ; req . query ( 'limit' , mapped . limit ) ; return req . callAsJson ( listPaymentsResponseSchema , requestOptions ) ; } param body return async createPayment ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/payments' ) ; const mapped = req . prepareArgs ( { body : [ body , createPaymentRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( createPaymentResponseSchema , requestOptions ) ; } param body return async cancelPaymentByIdempotencyKey ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/payments/cancel' ) ; const mapped = req . prepareArgs ( { body : [ body , cancelPaymentByIdempotencyKeyRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( cancelPaymentByIdempotencyKeyResponseSchema , requestOptions ) ; } param paymentId return async getPayment ( paymentId , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { paymentId : [ paymentId , string ( ) ] } ) ; req . appendTemplatePath `/v2/payments/${ mapped . paymentId }` ; return req . callAsJson ( getPaymentResponseSchema , requestOptions ) ; } param paymentId param body return async updatePayment ( paymentId , body , requestOptions ? ) { const req = this . createRequest ( 'PUT' ) ; const mapped = req . prepareArgs ( { paymentId : [ paymentId , string ( ) ] , body : [ body , updatePaymentRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/payments/${ mapped . paymentId }` ; return req . callAsJson ( updatePaymentResponseSchema , requestOptions ) ; } param paymentId return async cancelPayment ( paymentId , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { paymentId : [ paymentId , string ( ) ] } ) ; req . appendTemplatePath `/v2/payments/${ mapped . paymentId }/cancel` ; return req . callAsJson ( cancelPaymentResponseSchema , requestOptions ) ; } param paymentId param body return async completePayment ( paymentId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { paymentId : [ paymentId , string ( ) ] , body : [ body , completePaymentRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/payments/${ mapped . paymentId }/complete` ; return req . callAsJson ( completePaymentResponseSchema , requestOptions ) ; } }