CustomerService
Provides layer to manipulate customers.
constructor
Parameters
__namedParametersInjectedDependenciesRequiredProperties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>manager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequiredEventsobjectRequiredEvents.CREATEDstringRequiredDefault: "customer.created"
Events.PASSWORD_RESETstringRequiredDefault: "customer.password_reset"
Events.UPDATEDstringRequiredDefault: "customer.updated"
Accessors
activeManager_
Returns
EntityManagerEntityManagerRequiredMethods
addAddress
Parameters
customerIdstringRequiredReturns
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
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
PromisePromise<TResult>Requiredcount
Return the total number of documents in database
Returns
PromisePromise<number>Requiredcreate
Creates a customer from an email - customers can have accounts associated, e.g. to login and view order history, etc. If a password is provided the customer will automatically get an account, otherwise the customer is just used to hold details of customers.
Parameters
customerCreateCustomerInputRequiredReturns
delete
Deletes a customer from a given customer id.
Parameters
customerIdstringRequiredReturns
generateResetPasswordToken
Generate a JSON Web token, that will be sent to a customer, that wishes to reset password. The token will be signed with the customer's current password hash as a secret a long side a payload with userId and the expiry time for the token, which is always 15 minutes.
Parameters
customerIdstringRequiredReturns
PromisePromise<string>RequiredhashPassword_
Hashes a password
Parameters
passwordstringRequiredReturns
PromisePromise<string>Requiredlist
Parameters
Default: {}
Returns
listAndCount
Parameters
Returns
listByEmail
Parameters
emailstringRequiredReturns
removeAddress
Parameters
customerIdstringRequiredaddressIdstringRequiredReturns
PromisePromise<void>Requiredretrieve
Gets a customer by id.
Parameters
customerIdstringRequiredDefault: {}
Returns
retrieveByEmail
Gets a registered customer by email.
Parameters
emailstringRequiredDefault: {}
Returns
Deprecated
retrieveByPhone
Gets a customer by phone.
Parameters
phonestringRequiredDefault: {}
Returns
retrieveRegisteredByEmail
Parameters
emailstringRequiredDefault: {}
Returns
retrieveUnregisteredByEmail
Parameters
emailstringRequiredDefault: {}
Returns
retrieve_
Parameters
Default: {}
Returns
shouldRetryTransaction_
Parameters
errRecord<string, unknown> | objectRequiredReturns
booleanbooleanupdate
Updates a customer.
Parameters
customerIdstringRequiredupdateUpdateCustomerInputRequiredReturns
updateAddress
Parameters
customerIdstringRequiredaddressIdstringRequiredReturns
updateBillingAddress_
Updates the customers' billing address.
Parameters
Returns
PromisePromise<void>RequiredwithTransaction
Parameters
transactionManagerEntityManagerReturns
CustomerServiceobjectRequired