Files
medusa-store/docs/content/references/services/classes/CustomerService.md
Shahed Nasser e134f6d237 chore: fixed commit branch on generate reference action (#1857)
* fixed commit branch

* fixes after yarn upgrade
2022-07-15 18:08:07 +03:00

13 KiB

Class: CustomerService

Hierarchy

Constructors

constructor

new CustomerService(__namedParameters)

Parameters

Name Type
__namedParameters InjectedDependencies

Overrides

TransactionBaseService<CustomerService&gt;.constructor

Defined in

services/customer.ts:40

Properties

addressRepository_

Protected Readonly addressRepository_: typeof AddressRepository

Defined in

services/customer.ts:28


configModule

Protected Optional Readonly configModule: Record<string, unknown>

Inherited from

TransactionBaseService.configModule


container

Protected Readonly container: unknown

Inherited from

TransactionBaseService.container


customerRepository_

Protected Readonly customerRepository_: typeof CustomerRepository

Defined in

services/customer.ts:27


eventBusService_

Protected Readonly eventBusService_: EventBusService

Defined in

services/customer.ts:29


manager_

Protected Readonly manager_: EntityManager

Overrides

TransactionBaseService.manager_

Defined in

services/customer.ts:31


transactionManager_

Protected Readonly transactionManager_: undefined | EntityManager

Overrides

TransactionBaseService.transactionManager_

Defined in

services/customer.ts:32


Events

Static Events: Object

Type declaration

Name Type
CREATED string
PASSWORD_RESET string
UPDATED string

Defined in

services/customer.ts:34

Methods

addAddress

addAddress(customerId, address): Promise<Address | Customer>

Parameters

Name Type
customerId string
address AddressCreatePayload

Returns

Promise<Address | Customer>

Defined in

services/customer.ts:471


atomicPhase_

Protected atomicPhase_<TResult, TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>

Type parameters

Name
TResult
TError

Parameters

Name Type Description
work (transactionManager: EntityManager) => Promise<TResult>
isolationOrErrorHandler? IsolationLevel | (error: TError) => Promise<void | TResult>
maybeErrorHandlerOrDontFail? (error: TError) => Promise<void | TResult>

Returns

Promise<TResult>

Inherited from

TransactionBaseService.atomicPhase_

Defined in

interfaces/transaction-base-service.ts:53


count

count(): Promise<number>

Returns

Promise<number>

Defined in

services/customer.ts:161


create

create(customer): Promise<Customer>

Parameters

Name Type Description
customer CreateCustomerInput

Returns

Promise<Customer>

Defined in

services/customer.ts:255


delete

delete(customerId): Promise<void | Customer>

Parameters

Name Type Description
customerId string

Returns

Promise<void | Customer>

Defined in

services/customer.ts:519


generateResetPasswordToken

generateResetPasswordToken(customerId): Promise<string>

Parameters

Name Type Description
customerId string

Returns

Promise<string>

Defined in

services/customer.ts:65


hashPassword_

hashPassword_(password): Promise<string>

Parameters

Name Type Description
password string

Returns

Promise<string>

Defined in

services/customer.ts:242


list

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

Parameters

Name Type Description
selector Selector<Customer> & { q?: string }
config FindConfig<Customer>

Returns

Promise<Customer[]>

Defined in

services/customer.ts:108


listAndCount

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

Parameters

Name Type Description
selector Selector<Customer> & { q?: string }
config FindConfig<Customer>

Returns

Promise<[Customer[], number]>

Defined in

services/customer.ts:133


removeAddress

removeAddress(customerId, addressId): Promise<void>

Parameters

Name Type
customerId string
addressId string

Returns

Promise<void>

Defined in

services/customer.ts:454


retrieve

retrieve(customerId, config?): Promise<Customer>

Parameters

Name Type Description
customerId string
config FindConfig<Customer>

Returns

Promise<Customer>

Defined in

services/customer.ts:228


retrieveByEmail

retrieveByEmail(email, config?): Promise<Customer>

Parameters

Name Type Description
email string
config FindConfig<Customer>

Returns

Promise<Customer>

Defined in

services/customer.ts:198


retrieveByPhone

retrieveByPhone(phone, config?): Promise<Customer>

Parameters

Name Type Description
phone string
config FindConfig<Customer>

Returns

Promise<Customer>

Defined in

services/customer.ts:213


retrieve_

Private retrieve_(selector, config?): Promise<Customer>

Parameters

Name Type
selector Selector<Customer>
config FindConfig<Customer>

Returns

Promise<Customer>

Defined in

services/customer.ts:168


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

Name Type
err Record<string, unknown> | { code: string }

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

interfaces/transaction-base-service.ts:34


update

update(customerId, update): Promise<Customer>

Parameters

Name Type Description
customerId string
update UpdateCustomerInput

Returns

Promise<Customer>

Defined in

services/customer.ts:310


updateAddress

updateAddress(customerId, addressId, address): Promise<Address>

Parameters

Name Type
customerId string
addressId string
address StorePostCustomersCustomerAddressesAddressReq

Returns

Promise<Address>

Defined in

services/customer.ts:426


updateBillingAddress_

updateBillingAddress_(customer, addressOrId): Promise<void>

Parameters

Name Type Description
customer Customer
addressOrId undefined | string | { address_1?: null | string ; address_2?: null | string ; city?: null | string ; company?: null | string ; country?: null | { id?: number | undefined; iso_2?: string | undefined; iso_3?: string | undefined; num_code?: number | undefined; name?: string | undefined; display_name?: string | undefined; region_id?: string | ... 1 more ... | undefined; region?: { ...; } | undefined; } ; country_code?: null | string ; created_at?: { toString?: {} | undefined; toDateString?: {} | undefined; toTimeString?: {} | undefined; toLocaleString?: {} | undefined; toLocaleDateString?: {} | undefined; toLocaleTimeString?: {} | undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} | undefined; } ; customer?: null | { email?: string | undefined; first_name?: string | undefined; last_name?: string | undefined; billing_address_id?: string | null | undefined; billing_address?: { customer_id?: string | null | undefined; ... 16 more ...; updated_at?: { ...; } | undefined; } | undefined; ... 10 more ...; updated_at?: { ...; } | undef... ; customer_id?: null | string ; deleted_at?: null | { toString?: {} | undefined; toDateString?: {} | undefined; toTimeString?: {} | undefined; toLocaleString?: {} | undefined; toLocaleDateString?: {} | undefined; toLocaleTimeString?: {} | undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} | undefined; } ; first_name?: null | string ; id?: string ; last_name?: null | string ; metadata?: { [x: string]: unknown; } ; phone?: null | string ; postal_code?: null | string ; province?: null | string ; updated_at?: { toString?: {} | undefined; toDateString?: {} | undefined; toTimeString?: {} | undefined; toLocaleString?: {} | undefined; toLocaleDateString?: {} | undefined; toLocaleTimeString?: {} | undefined; ... 37 more ...; [Symbol.toPrimitive]?: {} | undefined; } }

Returns

Promise<void>

Defined in

services/customer.ts:374


withTransaction

withTransaction(transactionManager?): CustomerService

Parameters

Name Type
transactionManager? EntityManager

Returns

CustomerService

Inherited from

TransactionBaseService.withTransaction

Defined in

interfaces/transaction-base-service.ts:16