ICustomerModuleService
The main service interface for the Customer Module.
Methods
retrieve
This method retrieves a customer by its ID.
Example
A simple example that retrieves a customer by its ID:
To specify relations that should be retrieved:
Parameters
customerId
stringRequiredconfig
FindConfig<CustomerDTO>The configurations determining how the customer is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a customer.
config
FindConfig<CustomerDTO>select
or relations
, accept the
attributes or relations associated with a customer.Returns
The retrieved customer.
create
**create**(data, sharedContext?): Promise<[CustomerDTO](types.CustomerTypes.CustomerDTO.mdx)[]>
This method creates customers.
Example
Parameters
The customers to be created.
Returns
The created customers.
**create**(data, sharedContext?): Promise<[CustomerDTO](types.CustomerTypes.CustomerDTO.mdx)>
This method creates a customer.
Example
Parameters
The customer to be created.
Returns
The created customer.
update
**update**(customerId, data, sharedContext?): Promise<[CustomerDTO](types.CustomerTypes.CustomerDTO.mdx)>
This method updates an existing customer.
Example
Parameters
customerId
stringRequiredThe updatable fields of a customer.
Returns
The updated customer.
**update**(customerIds, data, sharedContext?): Promise<[CustomerDTO](types.CustomerTypes.CustomerDTO.mdx)[]>
This method updates existing customers.
Example
Parameters
customerIds
string[]RequiredThe attributes to update in the customers.
Returns
The updated customers.
**update**(selector, data, sharedContext?): Promise<[CustomerDTO](types.CustomerTypes.CustomerDTO.mdx)[]>
This method updates existing customers.
Example
Parameters
The filters that specify which API keys should be updated.
The attributes to update in the customers.
Returns
The updated customers.
delete
**delete**(customerId, sharedContext?): Promise<void>
This method deletes a customer by its ID.
Example
Parameters
customerId
stringRequiredReturns
Promise
Promise<void>Required**delete**(customerIds, sharedContext?): Promise<void>
This method deletes customers by their IDs.
Example
Parameters
customerIds
string[]RequiredReturns
Promise
Promise<void>Required**delete**(selector, sharedContext?): Promise<void>
This method deletes a customer matching the specified filters.
Example
Parameters
The filters that specify which customers should be deleted.
Returns
Promise
Promise<void>RequiredcreateCustomerGroup
**createCustomerGroup**(data, sharedContext?): Promise<[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)[]>
This method creates customer groups.
Example
Parameters
The customer groups to be created.
Returns
The created customer groups.
**createCustomerGroup**(data, sharedContext?): Promise<[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)>
This method creates a customer group.
Example
Parameters
The customer group to be created.
Returns
The created customer group.
retrieveCustomerGroup
This method retrieves a customer group by its ID.
Example
Parameters
groupId
stringRequiredconfig
FindConfig<CustomerGroupDTO>The configurations determining how the customer group is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a customer group.
config
FindConfig<CustomerGroupDTO>select
or relations
, accept the
attributes or relations associated with a customer group.Returns
The retrieved customer group.
updateCustomerGroups
**updateCustomerGroups**(groupId, data, sharedContext?): Promise<[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)>
This method updates an existing customer group.
Example
Parameters
groupId
stringRequiredThe attributes to update in the customer group.
Returns
The updated customer group.
**updateCustomerGroups**(groupIds, data, sharedContext?): Promise<[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)[]>
This method updates existing customer groups.
Example
Parameters
groupIds
string[]RequiredThe attributes to update in the customer groups.
Returns
The updated customer groups.
**updateCustomerGroups**(selector, data, sharedContext?): Promise<[CustomerGroupDTO](types.CustomerTypes.CustomerGroupDTO.mdx)[]>
This method updates existing customer groups.
Example
Parameters
The filters that specify which customer groups should be updates.
The attributes to update in the customer groups.
Returns
The updated customer groups.
deleteCustomerGroups
**deleteCustomerGroups**(groupId, sharedContext?): Promise<void>
This method deletes a customer group by its ID.
Example
Parameters
groupId
stringRequiredReturns
Promise
Promise<void>Required**deleteCustomerGroups**(groupIds, sharedContext?): Promise<void>
This method deletes customer groups by their IDs.
Example
Parameters
groupIds
string[]RequiredReturns
Promise
Promise<void>Required**deleteCustomerGroups**(selector, sharedContext?): Promise<void>
This method deletes customer groups matching the specified filters.
Example
Parameters
The filters that specify which customer group to delete.
Returns
Promise
Promise<void>RequiredaddCustomerToGroup
**addCustomerToGroup**(groupCustomerPair, sharedContext?): Promise<{ id: string }>
This method adds a customer to a group.
Example
Parameters
The details of the customer and the group it should be added to.
Returns
Promise
Promise<object>RequiredThe ID of the relation between the customer and the group.
Promise
Promise<object>Required**addCustomerToGroup**(groupCustomerPairs, sharedContext?): Promise<{ id: string }[]>
This method adds customers to groups.
Example
Parameters
A list of items, each being the details of a customer and the group it should be added to.
Returns
Promise
Promise<object[]>RequiredThe IDs of the relations between each of the customer and group pairs.
Promise
Promise<object[]>RequiredremoveCustomerFromGroup
**removeCustomerFromGroup**(groupCustomerPair, sharedContext?): Promise<void>
This method removes a customer from a group.
Example
Parameters
The details of the customer and the group it should be removed from.
Returns
Promise
Promise<void>Required**removeCustomerFromGroup**(groupCustomerPairs, sharedContext?): Promise<void>
This method removes customers from groups.
Example
Parameters
A list of items, each being the details of a customer and the group it should be removed from.
Returns
Promise
Promise<void>RequiredaddAddresses
**addAddresses**(addresses, sharedContext?): Promise<[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)[]>
This method adds addresses to customers.
Example
Parameters
A list of items, each being the details of the address to add to a customer.
Returns
The list of created addresses.
**addAddresses**(address, sharedContext?): Promise<[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)>
This method adds an address to a customer.
Example
Parameters
The details of the address to add to a customer.
Returns
The created address.
updateAddresses
**updateAddresses**(addressId, data, sharedContext?): Promise<[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)>
This method updates an address.
Example
Parameters
addressId
stringRequiredThe attributes to update in the address.
Returns
The updated address.
**updateAddresses**(addressIds, data, sharedContext?): Promise<[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)[]>
This method updates existing addresses.
Example
Parameters
addressIds
string[]RequiredThe attributes to update in the addresses.
Returns
The updated addresses.
**updateAddresses**(selector, data, sharedContext?): Promise<[CustomerAddressDTO](types.CustomerTypes.CustomerAddressDTO.mdx)[]>
This method updates existing addresses matching the specified filters.
Example
Parameters
The filters that specify which address should be updated.
The attributes to update in the addresses.
Returns
The updated addresses.
deleteAddresses
**deleteAddresses**(addressId, sharedContext?): Promise<void>
This method deletes an address by its ID.
Example
Parameters
addressId
stringRequiredReturns
Promise
Promise<void>Required**deleteAddresses**(addressIds, sharedContext?): Promise<void>
This method deletes addresses by their IDs.
Example
Parameters
addressIds
string[]RequiredReturns
Promise
Promise<void>Required**deleteAddresses**(selector, sharedContext?): Promise<void>
This method deletes addresses matching the specified filters.
Example
Parameters
The filters that specify which addresses should be deleted.
Returns
Promise
Promise<void>RequiredlistAddresses
This method retrieves a paginated list of addresses based on optional filters and configuration.
Example
To retrieve a list of addresses using their IDs:
To specify relations that should be retrieved within the addresses:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
The filters to apply on the retrieved addresss.
config
FindConfig<CustomerAddressDTO>The configurations determining how the address is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a address.
config
FindConfig<CustomerAddressDTO>select
or relations
, accept the
attributes or relations associated with a address.Returns
The list of addresses.
listAndCountAddresses
This method retrieves a paginated list of addresses along with the total count of available addresses satisfying the provided filters.
Example
To retrieve a list of addresses using their IDs:
To specify relations that should be retrieved within the addresses:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
The filters to apply on the retrieved addresss.
config
FindConfig<CustomerAddressDTO>The configurations determining how the address is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a address.
config
FindConfig<CustomerAddressDTO>select
or relations
, accept the
attributes or relations associated with a address.Returns
The list of addresses along with their total count.
listCustomerGroupCustomers
This method retrieves a paginated list of relations between customer and groups based on optional filters and configuration.
Example
To retrieve a list of customer-group relations using their IDs:
To specify relations that should be retrieved within the customer-group relations:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
The filters to apply on the retrieved customer-group relations.
The configurations determining how the customer-group relations is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a customer-group relations.
select
or relations
, accept the
attributes or relations associated with a customer-group relations.Returns
The list of customer-group relations.
list
This method retrieves a paginated list of customers based on optional filters and configuration.
Example
To retrieve a list of customers using their IDs:
To specify relations that should be retrieved within the customers:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableCustomerPropsThe filters to apply on the retrieved customers.
filters
FilterableCustomerPropsconfig
FindConfig<CustomerDTO>The configurations determining how the customer is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a customer.
config
FindConfig<CustomerDTO>select
or relations
, accept the
attributes or relations associated with a customer.Returns
The list of customers.
listAndCount
This method retrieves a paginated list of customers along with the total count of available customers satisfying the provided filters.
Example
To retrieve a list of customers using their IDs:
To specify relations that should be retrieved within the customers:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableCustomerPropsThe filters to apply on the retrieved customers.
filters
FilterableCustomerPropsconfig
FindConfig<CustomerDTO>The configurations determining how the customer is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a customer.
config
FindConfig<CustomerDTO>select
or relations
, accept the
attributes or relations associated with a customer.Returns
The list of customers along with their total count.
listCustomerGroups
This method retrieves a paginated list of customer groups based on optional filters and configuration.
Example
To retrieve a list of customer groups using their IDs:
To specify relations that should be retrieved within the customer groups:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableCustomerGroupPropsThe filters to apply on the retrieved customer groups.
filters
FilterableCustomerGroupPropsconfig
FindConfig<CustomerGroupDTO>The configurations determining how the customer group is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a customer group.
config
FindConfig<CustomerGroupDTO>select
or relations
, accept the
attributes or relations associated with a customer group.Returns
The list of customer groups.
listAndCountCustomerGroups
This method retrieves a paginated list of customer groups along with the total count of available customer groups satisfying the provided filters.
Example
To retrieve a list of customer groups using their IDs:
To specify relations that should be retrieved within the customer groups:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableCustomerGroupPropsThe filters to apply on the retrieved customer groups.
filters
FilterableCustomerGroupPropsconfig
FindConfig<CustomerGroupDTO>The configurations determining how the customer group is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a customer group.
config
FindConfig<CustomerGroupDTO>select
or relations
, accept the
attributes or relations associated with a customer group.Returns
The list of customer groups along with their total count.
softDelete
This method soft deletes customers by their IDs.
Example
Type Parameters
TReturnableLinkableKeys
stringRequiredParameters
customerIds
string[]Requiredconfig
SoftDeleteReturn<TReturnableLinkableKeys>An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted.
config
SoftDeleteReturn<TReturnableLinkableKeys>Returns
Promise
Promise<void | Record<TReturnableLinkableKeys, string[]>>RequiredAn object that includes the IDs of related records that were also soft deleted, such as the ID of the associated address.
The object's keys are the ID attribute names of the customer entity's relations, such as address_id
, and its value is an array of strings, each being the ID of a record associated
with the customer through this relation, such as the IDs of associated address.
If there are no related records, the promise resolves to void
.
Promise
Promise<void | Record<TReturnableLinkableKeys, string[]>>Requiredaddress_id
, and its value is an array of strings, each being the ID of a record associated
with the customer through this relation, such as the IDs of associated address.
If there are no related records, the promise resolves to void
.restore
This method restores soft deleted customer by their IDs.
Example
Type Parameters
TReturnableLinkableKeys
stringRequiredParameters
customerIds
string[]Requiredconfig
RestoreReturn<TReturnableLinkableKeys>Configurations determining which relations to restore along with each of the customer. You can pass to its returnLinkableKeys
property any of the customer's relation attribute names, such as groups
.
config
RestoreReturn<TReturnableLinkableKeys>returnLinkableKeys
property any of the customer's relation attribute names, such as groups
.Returns
Promise
Promise<void | Record<TReturnableLinkableKeys, string[]>>RequiredAn object that includes the IDs of related records that were restored.
If there are no related records restored, the promise resolves to void
.
Promise
Promise<void | Record<TReturnableLinkableKeys, string[]>>Requiredvoid
.softDeleteCustomerGroups
This method soft deletes customer groups by their IDs.
Example
Type Parameters
TReturnableLinkableKeys
stringRequiredParameters
groupIds
string[]Requiredconfig
SoftDeleteReturn<TReturnableLinkableKeys>An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted.
config
SoftDeleteReturn<TReturnableLinkableKeys>Returns
Promise
Promise<void | Record<TReturnableLinkableKeys, string[]>>RequiredAn object that includes the IDs of related records that were also soft deleted.
If there are no related records, the promise resolves to void
.
Promise
Promise<void | Record<TReturnableLinkableKeys, string[]>>Requiredvoid
.restoreCustomerGroups
This method restores a soft deleted customer group by its IDs.
Example
Type Parameters
TReturnableLinkableKeys
stringRequiredParameters
groupIds
string[]Requiredconfig
RestoreReturn<TReturnableLinkableKeys>Configurations determining which relations to restore along with each of the customer groups. You can pass to its returnLinkableKeys
property any of the customer group's relation attribute names, such as customers
.
config
RestoreReturn<TReturnableLinkableKeys>returnLinkableKeys
property any of the customer group's relation attribute names, such as customers
.Returns
Promise
Promise<void | Record<TReturnableLinkableKeys, string[]>>RequiredAn object that includes the IDs of related records that were restored.
If there are no related records restored, the promise resolves to void
.
Promise
Promise<void | Record<TReturnableLinkableKeys, string[]>>Requiredvoid
.