Files
medusa-store/www/apps/docs/content/references/services/classes/CustomerGroupService.mdx
github-actions[bot] 39649b3552 chore(docs): Generated References (#5602)
Generated the following references:
- `pricing`
- `product`

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2023-11-10 17:31:02 +00:00

679 lines
14 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# CustomerGroupService
## Constructors
### constructor
**new CustomerGroupService**(`«destructured»`)
#### Parameters
<ParameterTypes parameters={[
{
"name": "__namedParameters",
"type": "[`CustomerGroupConstructorProps`](../types/CustomerGroupConstructorProps.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
## Properties
<ParameterTypes parameters={[
{
"name": "__configModule__",
"type": "Record<`string`, `unknown`\\>",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__container__",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__moduleDeclaration__",
"type": "Record<`string`, `unknown`\\>",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerGroupRepository_",
"type": "`Repository`<[`CustomerGroup`](CustomerGroup.mdx)\\> & { `addCustomers`: Method addCustomers ; `findWithRelationsAndCount`: Method findWithRelationsAndCount ; `removeCustomers`: Method removeCustomers }",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerService_",
"type": "[`CustomerService`](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": []
}
]} />
## Accessors
### activeManager\_
`Protected` `get` **activeManager_**(): `EntityManager`
#### Returns
`EntityManager`
<ParameterTypes parameters={[
{
"name": "EntityManager",
"type": "`EntityManager`",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
## Methods
### addCustomers
**addCustomers**(`id`, `customerIds`): `Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
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
`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\\>",
"optional": false,
"defaultValue": "",
"description": "the customer group after insertion",
"expandable": false,
"children": []
}
]} />
___
### atomicPhase\_
`Protected` **atomicPhase_**<`TResult`, `TError`\>(`work`, `isolationOrErrorHandler?`, `maybeErrorHandlerOrDontFail?`): `Promise`<`TResult`\>
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.
<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
`Promise`<`TResult`\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<`TResult`\\>",
"optional": false,
"defaultValue": "",
"description": "the result of the transactional work",
"expandable": false,
"children": []
}
]} />
___
### create
**create**(`group`): `Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
Creates a customer group with the provided data.
#### Parameters
<ParameterTypes parameters={[
{
"name": "group",
"type": "`DeepPartial`<[`CustomerGroup`](CustomerGroup.mdx)\\>",
"description": "the customer group to create",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\\>",
"optional": false,
"defaultValue": "",
"description": "the result of the create operation",
"expandable": false,
"children": []
}
]} />
___
### delete
**delete**(`groupId`): `Promise`<`void`\>
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
`Promise`<`void`\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<`void`\\>",
"optional": false,
"defaultValue": "",
"description": "a promise",
"expandable": false,
"children": []
}
]} />
___
### handleCreationFail
`Private` **handleCreationFail**(`id`, `ids`, `error`): `Promise`<`never`\>
#### 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
`Promise`<`never`\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<`never`\\>",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### list
**list**(`selector?`, `config`): `Promise`<[`CustomerGroup`](CustomerGroup.mdx)[]\>
List customer groups.
#### Parameters
<ParameterTypes parameters={[
{
"name": "selector",
"type": "[`Selector`](../types/Selector.mdx)<[`CustomerGroup`](CustomerGroup.mdx)\\> & { `discount_condition_id?`: `string` ; `q?`: `string` }",
"description": "the query object for find",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[`FindConfig`](../interfaces/FindConfig.mdx)<[`CustomerGroup`](CustomerGroup.mdx)\\>",
"description": "the config to be used for find",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<[`CustomerGroup`](CustomerGroup.mdx)[]\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<[`CustomerGroup`](CustomerGroup.mdx)[]\\>",
"optional": false,
"defaultValue": "",
"description": "the result of the find operation",
"expandable": false,
"children": []
}
]} />
___
### listAndCount
**listAndCount**(`selector?`, `config`): `Promise`<[[`CustomerGroup`](CustomerGroup.mdx)[], `number`]\>
Retrieve a list of customer groups and total count of records that match the query.
#### Parameters
<ParameterTypes parameters={[
{
"name": "selector",
"type": "[`Selector`](../types/Selector.mdx)<[`CustomerGroup`](CustomerGroup.mdx)\\> & { `discount_condition_id?`: `string` ; `q?`: `string` }",
"description": "the query object for find",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[`FindConfig`](../interfaces/FindConfig.mdx)<[`CustomerGroup`](CustomerGroup.mdx)\\>",
"description": "the config to be used for find",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<[[`CustomerGroup`](CustomerGroup.mdx)[], `number`]\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<[[`CustomerGroup`](CustomerGroup.mdx)[], `number`]\\>",
"optional": false,
"defaultValue": "",
"description": "the result of the find operation",
"expandable": false,
"children": []
}
]} />
___
### removeCustomer
**removeCustomer**(`id`, `customerIds`): `Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
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
`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\\>",
"optional": false,
"defaultValue": "",
"description": "the customergroup with the provided id",
"expandable": false,
"children": []
}
]} />
___
### retrieve
**retrieve**(`customerGroupId`, `config?`): `Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
#### 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
`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\\>",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### shouldRetryTransaction\_
`Protected` **shouldRetryTransaction_**(`err`): `boolean`
#### Parameters
<ParameterTypes parameters={[
{
"name": "err",
"type": "Record<`string`, `unknown`\\> \\| { `code`: `string` }",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`boolean`
<ParameterTypes parameters={[
{
"name": "boolean",
"type": "`boolean`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### update
**update**(`customerGroupId`, `update`): `Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
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`](CustomerGroupUpdate.mdx)",
"description": "customer group partial data",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\>
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "`Promise`<[`CustomerGroup`](CustomerGroup.mdx)\\>",
"optional": false,
"defaultValue": "",
"description": "resulting customer group",
"expandable": false,
"children": []
}
]} />
___
### withTransaction
**withTransaction**(`transactionManager?`): [`CustomerGroupService`](CustomerGroupService.mdx)
#### Parameters
<ParameterTypes parameters={[
{
"name": "transactionManager",
"type": "`EntityManager`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
[`CustomerGroupService`](CustomerGroupService.mdx)
<ParameterTypes parameters={[
{
"name": "CustomerGroupService",
"type": "[`CustomerGroupService`](CustomerGroupService.mdx)",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />