CustomerService
Provides layer to manipulate customers.
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredEvents
objectRequiredEvents.PASSWORD_RESET
stringRequiredDefault: "customer.password_reset"
Events.CREATED
stringRequiredDefault: "customer.created"
Events.UPDATED
stringRequiredDefault: "customer.updated"
__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
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
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>RequiredgenerateResetPasswordToken
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>Requiredlist
Parameters
Default: {}
Returns
listAndCount
Parameters
Returns
count
Return the total number of documents in database
Returns
Promise
Promise<number>Requiredretrieve_
Parameters
Default: {}
Returns
retrieveByEmail
Gets a registered customer by email.
Parameters
email
stringRequiredDefault: {}
Returns
Deprecated
retrieveUnregisteredByEmail
Parameters
email
stringRequiredDefault: {}
Returns
retrieveRegisteredByEmail
Parameters
email
stringRequiredDefault: {}
Returns
listByEmail
Parameters
email
stringRequiredReturns
retrieveByPhone
Gets a customer by phone.
Parameters
phone
stringRequiredDefault: {}
Returns
retrieve
Gets a customer by id.
Parameters
customerId
stringRequiredDefault: {}
Returns
hashPassword_
Hashes a password
Parameters
password
stringRequiredReturns
Promise
Promise<string>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
customer
CreateCustomerInputRequiredReturns
update
Updates a customer.
Parameters
customerId
stringRequiredupdate
UpdateCustomerInputRequiredReturns
updateBillingAddress_
Updates the customers' billing address.
Parameters
Returns
Promise
Promise<void>RequiredupdateAddress
Parameters
customerId
stringRequiredaddressId
stringRequiredReturns
removeAddress
Parameters
customerId
stringRequiredaddressId
stringRequiredReturns
Promise
Promise<void>RequiredaddAddress
Parameters
customerId
stringRequiredReturns
delete
Deletes a customer from a given customer id.
Parameters
customerId
stringRequired