import { ApiResponse , RequestOptions } from '../core' ; import { AddGroupToCustomerResponse , addGroupToCustomerResponseSchema , } from '../models/addGroupToCustomerResponse' ; import { CreateCustomerCardRequest , createCustomerCardRequestSchema , } from '../models/createCustomerCardRequest' ; import { CreateCustomerCardResponse , createCustomerCardResponseSchema , } from '../models/createCustomerCardResponse' ; import { CreateCustomerRequest , createCustomerRequestSchema , } from '../models/createCustomerRequest' ; import { CreateCustomerResponse , createCustomerResponseSchema , } from '../models/createCustomerResponse' ; import { DeleteCustomerCardResponse , deleteCustomerCardResponseSchema , } from '../models/deleteCustomerCardResponse' ; import { DeleteCustomerResponse , deleteCustomerResponseSchema , } from '../models/deleteCustomerResponse' ; import { ListCustomersResponse , listCustomersResponseSchema , } from '../models/listCustomersResponse' ; import { RemoveGroupFromCustomerResponse , removeGroupFromCustomerResponseSchema , } from '../models/removeGroupFromCustomerResponse' ; import { RetrieveCustomerResponse , retrieveCustomerResponseSchema , } from '../models/retrieveCustomerResponse' ; import { SearchCustomersRequest , searchCustomersRequestSchema , } from '../models/searchCustomersRequest' ; import { SearchCustomersResponse , searchCustomersResponseSchema , } from '../models/searchCustomersResponse' ; import { UpdateCustomerRequest , updateCustomerRequestSchema , } from '../models/updateCustomerRequest' ; import { UpdateCustomerResponse , updateCustomerResponseSchema , } from '../models/updateCustomerResponse' ; import { bigint , number , optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class CustomersApi extends BaseApi { param cursor param limit param sortField param sortOrder return async listCustomers ( cursor ? , limit ? , sortField ? , sortOrder ? , requestOptions ? ) { const req = this . createRequest ( 'GET' , '/v2/customers' ) ; const mapped = req . prepareArgs ( { cursor : [ cursor , optional ( string ( ) ) ] , limit : [ limit , optional ( number ( ) ) ] , sortField : [ sortField , optional ( string ( ) ) ] , sortOrder : [ sortOrder , optional ( string ( ) ) ] , } ) ; req . query ( 'cursor' , mapped . cursor ) ; req . query ( 'limit' , mapped . limit ) ; req . query ( 'sort_field' , mapped . sortField ) ; req . query ( 'sort_order' , mapped . sortOrder ) ; return req . callAsJson ( listCustomersResponseSchema , requestOptions ) ; } param body return async createCustomer ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/customers' ) ; const mapped = req . prepareArgs ( { body : [ body , createCustomerRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( createCustomerResponseSchema , requestOptions ) ; } param body return async searchCustomers ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/customers/search' ) ; const mapped = req . prepareArgs ( { body : [ body , searchCustomersRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( searchCustomersResponseSchema , requestOptions ) ; } param customerId param version return async deleteCustomer ( customerId , version ? , requestOptions ? ) { const req = this . createRequest ( 'DELETE' ) ; const mapped = req . prepareArgs ( { customerId : [ customerId , string ( ) ] , version : [ version , optional ( bigint ( ) ) ] , } ) ; req . query ( 'version' , mapped . version ) ; req . appendTemplatePath `/v2/customers/${ mapped . customerId }` ; return req . callAsJson ( deleteCustomerResponseSchema , requestOptions ) ; } param customerId return async retrieveCustomer ( customerId , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { customerId : [ customerId , string ( ) ] } ) ; req . appendTemplatePath `/v2/customers/${ mapped . customerId }` ; return req . callAsJson ( retrieveCustomerResponseSchema , requestOptions ) ; } param customerId param body return async updateCustomer ( customerId , body , requestOptions ? ) { const req = this . createRequest ( 'PUT' ) ; const mapped = req . prepareArgs ( { customerId : [ customerId , string ( ) ] , body : [ body , updateCustomerRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/customers/${ mapped . customerId }` ; return req . callAsJson ( updateCustomerResponseSchema , requestOptions ) ; } param customerId param body return deprecated async createCustomerCard ( customerId , body , requestOptions ? ) { const req = this . createRequest ( 'POST' ) ; const mapped = req . prepareArgs ( { customerId : [ customerId , string ( ) ] , body : [ body , createCustomerCardRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/customers/${ mapped . customerId }/cards` ; req . deprecated ( 'CustomersApi.createCustomerCard' ) ; return req . callAsJson ( createCustomerCardResponseSchema , requestOptions ) ; } param customerId param cardId return deprecated async deleteCustomerCard ( customerId , cardId , requestOptions ? ) { const req = this . createRequest ( 'DELETE' ) ; const mapped = req . prepareArgs ( { customerId : [ customerId , string ( ) ] , cardId : [ cardId , string ( ) ] , } ) ; req . appendTemplatePath `/v2/customers/${ mapped . customerId }/cards/${ mapped . cardId }` ; req . deprecated ( 'CustomersApi.deleteCustomerCard' ) ; return req . callAsJson ( deleteCustomerCardResponseSchema , requestOptions ) ; } param customerId param groupId return async removeGroupFromCustomer ( customerId , groupId , requestOptions ? ) { const req = this . createRequest ( 'DELETE' ) ; const mapped = req . prepareArgs ( { customerId : [ customerId , string ( ) ] , groupId : [ groupId , string ( ) ] , } ) ; req . appendTemplatePath `/v2/customers/${ mapped . customerId }/groups/${ mapped . groupId }` ; return req . callAsJson ( removeGroupFromCustomerResponseSchema , requestOptions ) ; } param customerId param groupId return async addGroupToCustomer ( customerId , groupId , requestOptions ? ) { const req = this . createRequest ( 'PUT' ) ; const mapped = req . prepareArgs ( { customerId : [ customerId , string ( ) ] , groupId : [ groupId , string ( ) ] , } ) ; req . appendTemplatePath `/v2/customers/${ mapped . customerId }/groups/${ mapped . groupId }` ; return req . callAsJson ( addGroupToCustomerResponseSchema , requestOptions ) ; } }