import { ApiResponse , RequestOptions } from '../core' ; import { CreateCustomerGroupRequest , createCustomerGroupRequestSchema , } from '../models/createCustomerGroupRequest' ; import { CreateCustomerGroupResponse , createCustomerGroupResponseSchema , } from '../models/createCustomerGroupResponse' ; import { DeleteCustomerGroupResponse , deleteCustomerGroupResponseSchema , } from '../models/deleteCustomerGroupResponse' ; import { ListCustomerGroupsResponse , listCustomerGroupsResponseSchema , } from '../models/listCustomerGroupsResponse' ; import { RetrieveCustomerGroupResponse , retrieveCustomerGroupResponseSchema , } from '../models/retrieveCustomerGroupResponse' ; import { UpdateCustomerGroupRequest , updateCustomerGroupRequestSchema , } from '../models/updateCustomerGroupRequest' ; import { UpdateCustomerGroupResponse , updateCustomerGroupResponseSchema , } from '../models/updateCustomerGroupResponse' ; import { number , optional , string } from '../schema' ; import { BaseApi } from './baseApi' ; export class CustomerGroupsApi extends BaseApi { param cursor param limit return async listCustomerGroups ( cursor ? , limit ? , requestOptions ? ) { const req = this . createRequest ( 'GET' , '/v2/customers/groups' ) ; const mapped = req . prepareArgs ( { cursor : [ cursor , optional ( string ( ) ) ] , limit : [ limit , optional ( number ( ) ) ] , } ) ; req . query ( 'cursor' , mapped . cursor ) ; req . query ( 'limit' , mapped . limit ) ; return req . callAsJson ( listCustomerGroupsResponseSchema , requestOptions ) ; } param body return async createCustomerGroup ( body , requestOptions ? ) { const req = this . createRequest ( 'POST' , '/v2/customers/groups' ) ; const mapped = req . prepareArgs ( { body : [ body , createCustomerGroupRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; return req . callAsJson ( createCustomerGroupResponseSchema , requestOptions ) ; } param groupId return async deleteCustomerGroup ( groupId , requestOptions ? ) { const req = this . createRequest ( 'DELETE' ) ; const mapped = req . prepareArgs ( { groupId : [ groupId , string ( ) ] } ) ; req . appendTemplatePath `/v2/customers/groups/${ mapped . groupId }` ; return req . callAsJson ( deleteCustomerGroupResponseSchema , requestOptions ) ; } param groupId return async retrieveCustomerGroup ( groupId , requestOptions ? ) { const req = this . createRequest ( 'GET' ) ; const mapped = req . prepareArgs ( { groupId : [ groupId , string ( ) ] } ) ; req . appendTemplatePath `/v2/customers/groups/${ mapped . groupId }` ; return req . callAsJson ( retrieveCustomerGroupResponseSchema , requestOptions ) ; } param groupId param body return async updateCustomerGroup ( groupId , body , requestOptions ? ) { const req = this . createRequest ( 'PUT' ) ; const mapped = req . prepareArgs ( { groupId : [ groupId , string ( ) ] , body : [ body , updateCustomerGroupRequestSchema ] , } ) ; req . header ( 'Content-Type' , 'application/json' ) ; req . json ( mapped . body ) ; req . appendTemplatePath `/v2/customers/groups/${ mapped . groupId }` ; return req . callAsJson ( updateCustomerGroupResponseSchema , requestOptions ) ; } }