Skip to main content
Skip to main content

CustomerGroupService

internal.internal.CustomerGroupService

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
customerGroupRepository_Repository<CustomerGroup> & { addCustomers: Method addCustomers ; findWithRelationsAndCount: Method findWithRelationsAndCount ; removeCustomers: Method removeCustomers }Required
customerService_CustomerServiceRequired
handleCreationFailanyRequired
manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited from

TransactionBaseService.activeManager_

Methods

addCustomers

addCustomers(id, customerIds): Promise<CustomerGroup>

Add a batch of customers to a customer group at once

Parameters

idstringRequired
id of the customer group to add customers to
customerIdsstring | string[]Required
customer id's to add to the group

Returns

Promise<CustomerGroup>

PromisePromise<CustomerGroup>Required
the customer group after insertion

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.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_


create

create(group): Promise<CustomerGroup>

Creates a customer group with the provided data.

Parameters

groupDeepPartial<CustomerGroup>Required
the customer group to create

Returns

Promise<CustomerGroup>

PromisePromise<CustomerGroup>Required
the result of the create operation

delete

delete(groupId): Promise<void>

Remove customer group

Parameters

groupIdstringRequired
id of the customer group to delete

Returns

Promise<void>

PromisePromise<void>Required
a promise

list

list(selector, config): Promise<CustomerGroup[]>

List customer groups.

Parameters

selectorundefined | Selector<CustomerGroup> & { discount_condition_id?: string ; q?: string }Required
the query object for find
configFindConfig<CustomerGroup>Required
the config to be used for find

Returns

Promise<CustomerGroup[]>

PromisePromise<CustomerGroup[]>Required
the result of the find operation

listAndCount

listAndCount(selector, config): Promise<[CustomerGroup[], number]>

Retrieve a list of customer groups and total count of records that match the query.

Parameters

selectorundefined | Selector<CustomerGroup> & { discount_condition_id?: string ; q?: string }Required
the query object for find
configFindConfig<CustomerGroup>Required
the config to be used for find

Returns

Promise<[CustomerGroup[], number]>

PromisePromise<[CustomerGroup[], number]>Required
the result of the find operation

removeCustomer

removeCustomer(id, customerIds): Promise<CustomerGroup>

Remove list of customers from a customergroup

Parameters

idstringRequired
id of the customer group from which the customers are removed
customerIdsstring | string[]Required
id's of the customer to remove from group

Returns

Promise<CustomerGroup>

PromisePromise<CustomerGroup>Required
the customergroup with the provided id

retrieve

retrieve(customerGroupId, config?): Promise<CustomerGroup>

Parameters

customerGroupIdstringRequired
configobject

Returns

Promise<CustomerGroup>

PromisePromise<CustomerGroup>Required

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

errRecord<string, unknown> | { code: string }Required

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


update

update(customerGroupId, update): Promise<CustomerGroup>

Update a customer group.

Parameters

customerGroupIdstringRequired
id of the customer group
updateCustomerGroupUpdateRequired
customer group partial data

Returns

Promise<CustomerGroup>

PromisePromise<CustomerGroup>Required
resulting customer group

withTransaction

withTransaction(transactionManager?): CustomerGroupService

Parameters

transactionManagerEntityManager

Returns

CustomerGroupService

CustomerGroupServiceCustomerGroupServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?