Skip to main content

Customer Details

While managing a bundle, you may want to request certain details from a customer. You can also expose the ability for a customer to give grant other users access to their bundle.

This feature requires access to the Conversion Accelerator addon. This system is still in active development and you will need to reach out to us to enable this functionality.

Adding or Updating Customer Details

To assign customer details to a bundle, you'll need to call addStakeholder on the bundle object. This function has an optional parameter, which specifies the access level of the stakeholder. The default is 'Owner'.

If the customer already exists, their details will be updated.

await bundle.addStakeholder(
{
emailAddress: "johndoe@example.com",
firstName: "John", // Optional
lastName: "Doe", // Optional
phoneNumber: "1234567890", // Optional
},
"Owner" // Optional. Defaults to 'Owner'
);

Retrieving Stakeholders

You can retrieve a list of stakeholders from the bundle object by calling getAllStakeholders. This will return an array of BundleStakeholder objects.

const stakeholders = await bundle.getAllStakeholders();

Managing Stakeholders

Updating the current collection of stakeholders is achieved by calling updateStakeholders on the bundle object. This function takes an array of BundleStakeholderInput objects.

Any entries that are not currently in the bundle will be added, and any entries that are in the bundle but not in the array will be removed.

const stakeholderInput = [
{
customerDetails: {
emailAddress: "johndoe@example.com",
firstName: "John", // Optional
lastName: "Doe", // Optional
phoneNumber: "1234567890", // Optional
},
type: "Owner",
},
];
await bundle.updateStakeholders(stakeholderInput);

Fetching Bundles for a Customer

If a customer is currently logged in (see Authenticating a customer), you can retrieve a list of bundles that they have access to by calling getBundleStakeholders on the client. This will return an array of BundleStakeholder objects.

note

For performance reasons, only certain data fields are retrieved in this call:

  • The id, type, and bundle of the stakeholder.
  • The id, name, createdAt, and metadata of the bundle.
const stakeholders = await client.getBundleStakeholders();

// Example of mapping the data to a table format.
const tableRows = stakeholders.map((stakeholder) => {
// Metadata is completely user defined. This is just an example of how you might use it.
const tagsEntry = stakeholder.bundle.metadata.find((entry) => entry.key === "tags");
const tags = tagsEntry?.value?.split(",") ?? [];
return {
name: stakeholder.bundle.name, // The name of the bundle. This is user defined.
type: stakeholder.type, // Owner, Editor, Viewer, etc.
createdAt: stakeholder.bundle.createdAt, // ISO 8601 date string
tags: tags,
};
});