import { ApiResponse , RequestOptions } from '../core' ; import { CreateCardRequest , createCardRequestSchema , } from '../models/createCardRequest' ; import { CreateCardResponse , createCardResponseSchema , } from '../models/createCardResponse' ; import { DisableCardResponse , disableCardResponseSchema , } from '../models/disableCardResponse' ; import { ListCardsResponse , listCardsResponseSchema , } from '../models/listCardsResponse' ; import { RetrieveCardResponse , retrieveCardResponseSchema , } from '../models/retrieveCardResponse' ; import { boolean , optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class CardsApi extends BaseApi { param cursor param customerId param includeDisabled param referenceId param sortOrder return async listCards ( cursor ? , customerId ? , includeDisabled ? , referenceId ? , sortOrder ? , requestOptions ? ) { const req = this . createRequest ( 'GET' , '/v2/cards' ) ; const mapped = req . prepareArgs ( { cursor : [ cursor , optional ( string ( ) ) ] , customerId : [ customerId , optional ( string ( ) ) ] , includeDisabled : [ includeDisabled , optional ( boolean ( ) ) ] , referenceId : [ referenceId , optional ( string ( ) ) ] , sortOrder : [ sortOrder , optional ( string ( ) ) ] , } ) ; req . query ( 'cursor' , mapped . cursor ) ; req . query ( 'customer_id' , mapped . customerId ) ; req . query ( 'include_disabled' , mapped . includeDisabled ) ; req . query ( 'reference_id' , mapped . referenceId ) ; req . query ( 'sort_order' , mapped . sortOrder ) ; return req . callAsJson ( listCardsResponseSchema , requestOptions ) ; } param body return async createCard ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/cards' ) ; const mapped = req . prepareArgs ( { body : [ body , createCardRequestSchema ] } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( createCardResponseSchema , requestOptions ) ; } param cardId return async retrieveCard ( cardId , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { cardId : [ cardId , string ( ) ] } ) ; req . appendTemplatePath `/v2/cards/${ mapped . cardId }` ; return req . callAsJson ( retrieveCardResponseSchema , requestOptions ) ; } param cardId return async disableCard ( cardId , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { cardId : [ cardId , string ( ) ] } ) ; req . appendTemplatePath `/v2/cards/${ mapped . cardId }/disable` ; return req . callAsJson ( disableCardResponseSchema , requestOptions ) ; } }