176 lines
10 KiB
Plaintext
176 lines
10 KiB
Plaintext
---
|
|
displayed_sidebar: servicesSidebar
|
|
---
|
|
|
|
import ParameterTypes from "@site/src/components/ParameterTypes"
|
|
|
|
# CustomerGroupService
|
|
|
|
## constructor
|
|
|
|
### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"__namedParameters","type":"`CustomerGroupConstructorProps`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
___
|
|
|
|
## Properties
|
|
|
|
<ParameterTypes parameters={[{"name":"__container__","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerGroupRepository_","type":"Repository<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)> & `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerService_","type":"[CustomerService](services.CustomerService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"manager_","type":"`EntityManager`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"transactionManager_","type":"`undefined` \\| `EntityManager`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"__configModule__","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
___
|
|
|
|
## Accessors
|
|
|
|
### activeManager\_
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"EntityManager","type":"`EntityManager`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} />
|
|
|
|
___
|
|
|
|
## Methods
|
|
|
|
### addCustomers
|
|
|
|
Add a batch of customers to a customer group at once
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"id of the customer group to add customers to","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerIds","type":"`string` \\| `string`[]","description":"customer id's to add to the group","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)>","optional":false,"defaultValue":"","description":"the customer group after insertion","expandable":false,"children":[]}]} />
|
|
|
|
### atomicPhase\_
|
|
|
|
Wraps some work within a transactional block. If the service already has
|
|
a transaction manager attached this will be reused, otherwise a new
|
|
transaction manager is created.
|
|
|
|
#### Type Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"TResult","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TError","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"work","type":"(`transactionManager`: `EntityManager`) => Promise<TResult>","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise<void \\| TResult>","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise<void \\| TResult>","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<TResult>","optional":false,"defaultValue":"","description":"the result of the transactional work","expandable":false,"children":[]}]} />
|
|
|
|
### create
|
|
|
|
Creates a customer group with the provided data.
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"group","type":"DeepPartial<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)>","description":"the customer group to create","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)>","optional":false,"defaultValue":"","description":"the result of the create operation","expandable":false,"children":[]}]} />
|
|
|
|
### delete
|
|
|
|
Remove customer group
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"groupId","type":"`string`","description":"id of the customer group to delete","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<void>","optional":false,"defaultValue":"","description":"a promise","expandable":false,"children":[]}]} />
|
|
|
|
### handleCreationFail
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"ids","type":"`string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"error","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<never>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} />
|
|
|
|
### list
|
|
|
|
List customer groups.
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"selector","type":"[Selector](../../medusa/types/medusa.Selector.mdx)<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)> & `object`","description":"the query object for find","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)>","description":"the config to be used for find","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)[]>","optional":false,"defaultValue":"","description":"the result of the find operation","expandable":false,"children":[]}]} />
|
|
|
|
### listAndCount
|
|
|
|
Retrieve a list of customer groups and total count of records that match the query.
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"selector","type":"[Selector](../../medusa/types/medusa.Selector.mdx)<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)> & `object`","description":"the query object for find","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)>","description":"the config to be used for find","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<[[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)[], number]>","optional":false,"defaultValue":"","description":"the result of the find operation","expandable":false,"children":[]}]} />
|
|
|
|
### removeCustomer
|
|
|
|
Remove list of customers from a customergroup
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"id","type":"`string`","description":"id of the customer group from which the customers are removed","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerIds","type":"`string` \\| `string`[]","description":"id's of the customer to remove from group","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)>","optional":false,"defaultValue":"","description":"the customergroup with the provided id","expandable":false,"children":[]}]} />
|
|
|
|
### retrieve
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"customerGroupId","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"`object`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)>","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} />
|
|
|
|
### shouldRetryTransaction\_
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"err","type":"`Record<string, unknown>` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"boolean","type":"`boolean`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} />
|
|
|
|
### update
|
|
|
|
Update a customer group.
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"customerGroupId","type":"`string`","description":"id of the customer group","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"update","type":"`CustomerGroupUpdate`","description":"customer group partial data","optional":false,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"Promise","type":"Promise<[CustomerGroup](../../entities/classes/entities.CustomerGroup.mdx)>","optional":false,"defaultValue":"","description":"resulting customer group","expandable":false,"children":[]}]} />
|
|
|
|
### withTransaction
|
|
|
|
#### Parameters
|
|
|
|
<ParameterTypes parameters={[{"name":"transactionManager","type":"`EntityManager`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} />
|
|
|
|
#### Returns
|
|
|
|
<ParameterTypes parameters={[{"name":"this","type":"`this`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} />
|