CustomerService
Provides layer to manipulate customers.
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredretrieve_
anyRequiredtransactionManager_
undefined | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredEvents.PASSWORD_RESET
stringRequiredEvents.UPDATED
stringRequiredAccessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
addAddress
Parameters
customerId
stringRequiredReturns
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.
Parameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>Requiredcount
Return the total number of documents in database
Returns
Promise
Promise<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
Returns
delete
Deletes a customer from a given customer id.
Parameters
customerId
stringRequiredReturns
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
customerId
stringRequiredReturns
Promise
Promise<string>RequiredhashPassword_
Hashes a password
Parameters
password
stringRequiredReturns
Promise
Promise<string>Requiredlist
Parameters
config
FindConfig<Customer>Returns
listAndCount
Parameters
config
FindConfig<Customer>Returns
listByEmail
Parameters
email
stringRequiredconfig
FindConfig<Customer>Returns
removeAddress
Parameters
customerId
stringRequiredaddressId
stringRequiredReturns
Promise
Promise<void>Requiredretrieve
Gets a customer by id.
Parameters
customerId
stringRequiredconfig
FindConfig<Customer>Returns
retrieveByEmail
Gets a registered customer by email.
Parameters
email
stringRequiredconfig
FindConfig<Customer>Returns
Deprecated
retrieveByPhone
Gets a customer by phone.
Parameters
phone
stringRequiredconfig
FindConfig<Customer>Returns
retrieveRegisteredByEmail
Parameters
email
stringRequiredconfig
FindConfig<Customer>Returns
retrieveUnregisteredByEmail
Parameters
email
stringRequiredconfig
FindConfig<Customer>Returns
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
booleanupdate
Updates a customer.
Parameters
customerId
stringRequiredReturns
updateAddress
Parameters
customerId
stringRequiredaddressId
stringRequiredReturns
updateBillingAddress_
Updates the customers' billing address.
Parameters
Returns
Promise
Promise<void>Required