import { ApiResponse , RequestOptions } from '../core' ; import { GetPaymentRefundResponse , getPaymentRefundResponseSchema , } from '../models/getPaymentRefundResponse' ; import { ListPaymentRefundsResponse , listPaymentRefundsResponseSchema , } from '../models/listPaymentRefundsResponse' ; import { RefundPaymentRequest , refundPaymentRequestSchema , } from '../models/refundPaymentRequest' ; import { RefundPaymentResponse , refundPaymentResponseSchema , } from '../models/refundPaymentResponse' ; import { number , optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class RefundsApi extends BaseApi { param beginTime param endTime param sortOrder param cursor param locationId param status param sourceType param limit return async listPaymentRefunds ( beginTime ? , endTime ? , sortOrder ? , cursor ? , locationId ? , status ? , sourceType ? , limit ? , requestOptions ? ) { const req = this . createRequest ( 'GET' , '/v2/refunds' ) ; const mapped = req . prepareArgs ( { beginTime : [ beginTime , optional ( string ( ) ) ] , endTime : [ endTime , optional ( string ( ) ) ] , sortOrder : [ sortOrder , optional ( string ( ) ) ] , cursor : [ cursor , optional ( string ( ) ) ] , locationId : [ locationId , optional ( string ( ) ) ] , status : [ status , optional ( string ( ) ) ] , sourceType : [ sourceType , 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 ( 'status' , mapped . status ) ; req . query ( 'source_type' , mapped . sourceType ) ; req . query ( 'limit' , mapped . limit ) ; return req . callAsJson ( listPaymentRefundsResponseSchema , requestOptions ) ; } param body return async refundPayment ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/refunds' ) ; const mapped = req . prepareArgs ( { body : [ body , refundPaymentRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( refundPaymentResponseSchema , requestOptions ) ; } param refundId return async getPaymentRefund ( refundId , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { refundId : [ refundId , string ( ) ] } ) ; req . appendTemplatePath `/v2/refunds/${ mapped . refundId }` ; return req . callAsJson ( getPaymentRefundResponseSchema , requestOptions ) ; } }