import { ApiResponse , RequestOptions } from '../core' ; import { CreateGiftCardRequest , createGiftCardRequestSchema , } from '../models/createGiftCardRequest' ; import { CreateGiftCardResponse , createGiftCardResponseSchema , } from '../models/createGiftCardResponse' ; import { LinkCustomerToGiftCardRequest , linkCustomerToGiftCardRequestSchema , } from '../models/linkCustomerToGiftCardRequest' ; import { LinkCustomerToGiftCardResponse , linkCustomerToGiftCardResponseSchema , } from '../models/linkCustomerToGiftCardResponse' ; import { ListGiftCardsResponse , listGiftCardsResponseSchema , } from '../models/listGiftCardsResponse' ; import { RetrieveGiftCardFromGANRequest , retrieveGiftCardFromGANRequestSchema , } from '../models/retrieveGiftCardFromGANRequest' ; import { RetrieveGiftCardFromGANResponse , retrieveGiftCardFromGANResponseSchema , } from '../models/retrieveGiftCardFromGANResponse' ; import { RetrieveGiftCardFromNonceRequest , retrieveGiftCardFromNonceRequestSchema , } from '../models/retrieveGiftCardFromNonceRequest' ; import { RetrieveGiftCardFromNonceResponse , retrieveGiftCardFromNonceResponseSchema , } from '../models/retrieveGiftCardFromNonceResponse' ; import { RetrieveGiftCardResponse , retrieveGiftCardResponseSchema , } from '../models/retrieveGiftCardResponse' ; import { UnlinkCustomerFromGiftCardRequest , unlinkCustomerFromGiftCardRequestSchema , } from '../models/unlinkCustomerFromGiftCardRequest' ; import { UnlinkCustomerFromGiftCardResponse , unlinkCustomerFromGiftCardResponseSchema , } from '../models/unlinkCustomerFromGiftCardResponse' ; import { number , optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class GiftCardsApi extends BaseApi { param type param state param limit param cursor param customerId return async listGiftCards ( type ? , state ? , limit ? , cursor ? , customerId ? , requestOptions ? ) { const req = this . createRequest ( 'GET' , '/v2/gift-cards' ) ; const mapped = req . prepareArgs ( { type : [ type , optional ( string ( ) ) ] , state : [ state , optional ( string ( ) ) ] , limit : [ limit , optional ( number ( ) ) ] , cursor : [ cursor , optional ( string ( ) ) ] , customerId : [ customerId , optional ( string ( ) ) ] , } ) ; req . query ( 'type' , mapped . type ) ; req . query ( 'state' , mapped . state ) ; req . query ( 'limit' , mapped . limit ) ; req . query ( 'cursor' , mapped . cursor ) ; req . query ( 'customer_id' , mapped . customerId ) ; return req . callAsJson ( listGiftCardsResponseSchema , requestOptions ) ; } param body return async createGiftCard ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/gift-cards' ) ; const mapped = req . prepareArgs ( { body : [ body , createGiftCardRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( createGiftCardResponseSchema , requestOptions ) ; } param body return async retrieveGiftCardFromGAN ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/gift-cards/from-gan' ) ; const mapped = req . prepareArgs ( { body : [ body , retrieveGiftCardFromGANRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( retrieveGiftCardFromGANResponseSchema , requestOptions ) ; } param body return async retrieveGiftCardFromNonce ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/gift-cards/from-nonce' ) ; const mapped = req . prepareArgs ( { body : [ body , retrieveGiftCardFromNonceRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( retrieveGiftCardFromNonceResponseSchema , requestOptions ) ; } param giftCardId param body return async linkCustomerToGiftCard ( giftCardId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { giftCardId : [ giftCardId , string ( ) ] , body : [ body , linkCustomerToGiftCardRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/gift-cards/${ mapped . giftCardId }/link-customer` ; return req . callAsJson ( linkCustomerToGiftCardResponseSchema , requestOptions ) ; } param giftCardId param body return async unlinkCustomerFromGiftCard ( giftCardId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { giftCardId : [ giftCardId , string ( ) ] , body : [ body , unlinkCustomerFromGiftCardRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/gift-cards/${ mapped . giftCardId }/unlink-customer` ; return req . callAsJson ( unlinkCustomerFromGiftCardResponseSchema , requestOptions ) ; } param id return async retrieveGiftCard ( id , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { id : [ id , string ( ) ] } ) ; req . appendTemplatePath `/v2/gift-cards/${ mapped . id }` ; return req . callAsJson ( retrieveGiftCardResponseSchema , requestOptions ) ; } }