Broadleaf Microservices
  • v1.0.0-latest-prod

Customers

Customers represent registered users of your storefront. The following operations allow you to retrieve and manage the current customer’s data.

Note

To operate on a customer, the user must be authenticated and their access token must be provided to the function call.

Get Customer

Operation

CustomerClient#getCustomer(customerId, options);

Parameters

Parameter Type Required? Description

customerId

string

✅

Provide a customer id to fetch

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Customer.

Example

Example of retrieving a customer by its id and access token
const customer = await customerClient.getCustomer('CUSTOMER_ID', { accessToken });

console.log(customer);

Update Customer

Operation

CustomerClient#updateCustomer(customerId, customer, options);

Parameters

Parameter Type Required? Description

customerId

string

✅

Provide a customer id to update

customer

Customer

✅

The new customer data

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Customer.

Example

Example of updating a customer by its id and access token
const data: Customer {
  id: 'CUSTOMER_ID',
  username: 'test@customer.com',
  email: 'test@customer.com',
  fullName: 'Test Customer'
};

const customer = await customerClient.updateCustomer('CUSTOMER_ID', data, { accessToken });

console.log(customer);

List Customer Addresses

Retrieves a page of customer addresses.

Operation

CustomerClient#listCustomerAddresses(customerId, options);

Parameters

Parameter Type Required? Description

customerId

string

✅

The customer’s ID

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

A page of Customer Addresses.

Example

Example request
const addresses = await customerClient.listCustomerAddresses(customerId);

console.log(addresses);

Get Customer Address

Retrieves a single customer address by customer Id and customer address Id.

Operation

CustomerClient#getCustomerAddress(customerId, addressId, options);

Parameters

Parameter Type Required? Description

customerId

string

✅

The customer’s ID

customerAddressId

string

✅

The address' ID

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

Example

Example request
const address = await customerClient.getCustomerAddress(customerId, addressId);

console.log(address);

Add Customer Address

Adds a new customer address to an existing customer.

Operation

CustomerClient#addCustomerAddress(customerId, address, options);

Parameters

Parameter Type Required? Description

customerId

string

✅

The customer’s ID

customerAddress

Customer Address

✅

The new address

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

Example

Example request
const address = await customerClient.addCustomerAddress(customerId, address);

console.log(address);

Update Customer Address

Updates an existing customer address.

Operation

CustomerClient#updateCustomerAddress(customerId, addressId, address, options);

Parameters

Parameter Type Required? Description

customerId

string

✅

The customer’s ID

customerAddressId

string

✅

The address' ID

customerAddress

Customer Address

✅

The new address

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

Example

Example request
const address = await customerClient.updateCustomerAddress(customerId, addressId, address);

console.log(address);

Delete Customer Address

Deletes a Customer address.

Operation

CustomerClient#deleteCustomerAddress(customerId, addressId, options);

Parameters

Parameter Type Required? Description

customerId

string

✅

The customer’s ID

customerAddressId

string

✅

The address' ID

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

None.

Example

Example request
await customerClient.deleteCustomerAddress(customerId, addressId);

List Customer Order History

Retrieves the order history for a customer.

Operation

CustomerClient#listCustomerOrderHistory(options);

Parameters

Parameter Type Required? Description

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

A page of Orders.

Example

Example request
const orders = await customerClient.listCustomerOrderHistory();

console.log(orders);

Get Customer Order

Operation

CustomerClient#getCustomerOrder(orderRef, options);

Parameters

Parameter Type Required? Description

orderRef

string

✅

The order’s ID or number

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

An Order.

Example

Example request
const order = await customerClient.getCustomerOrder(orderNumber);

console.log(order);