---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# CustomerService
Provides layer to manipulate customers.
## constructor
### Parameters
___
## Properties
`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__container__",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__moduleDeclaration__",
"type": "`Record`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "addressRepository_",
"type": "Repository<[Address](../../entities/classes/entities.Address.mdx)>",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerRepository_",
"type": "Repository<[Customer](../../entities/classes/entities.Customer.mdx)> & `object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "eventBusService_",
"type": "[EventBusService](services.EventBusService.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": []
},
{
"name": "Events",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "Events.CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"customer.created\"",
"expandable": false,
"children": []
},
{
"name": "Events.PASSWORD_RESET",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"customer.password_reset\"",
"expandable": false,
"children": []
},
{
"name": "Events.UPDATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"customer.updated\"",
"expandable": false,
"children": []
}
]} />
___
## Accessors
### activeManager\_
#### Returns
___
## Methods
### addAddress
#### Parameters
#### Returns
___
### 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
#### Parameters
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
___
### count
Return the total number of documents in database
#### Returns
___
### create
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
#### Returns
___
### 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
#### Returns
___
### hashPassword\_
Hashes a password
#### Parameters
#### Returns
___
### list
#### Parameters
#### Returns
___
### listAndCount
#### Parameters
#### Returns
___
### listByEmail
#### Parameters
#### Returns
___
### removeAddress
#### Parameters
#### Returns
___
### retrieve
Gets a customer by id.
#### Parameters
#### Returns
___
### retrieveByEmail
Gets a registered customer by email.
#### Parameters
#### Returns
#### Deprecated
___
### retrieveByPhone
Gets a customer by phone.
#### Parameters
#### Returns
___
### retrieveRegisteredByEmail
#### Parameters
#### Returns
___
### retrieveUnregisteredByEmail
#### Parameters
#### Returns
___
### retrieve\_
#### Parameters
#### Returns
___
### shouldRetryTransaction\_
#### Parameters
` \\| `object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
___
### update
Updates a customer.
#### Parameters
#### Returns
___
### updateAddress
#### Parameters
#### Returns
___
### updateBillingAddress\_
Updates the customers' billing address.
#### Parameters
#### Returns
___
### withTransaction
#### Parameters
#### Returns