JSPM

  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q36641F
  • License MIT

Mockable wrapper around the Brightpearl API

Package Exports

  • brightpearl-client

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (brightpearl-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Brightpearl Client

NPM

  • Still in beta

Usage

  • Setup
const clientParams: BrightpearlClientParams = {
     dataCenter: "use",
     account: "OrgAccount",
     appRef: "privateAppRef",
     appToken: "privateAppToken"
}
const brightPearlClient = new BrightpearlClient(Axios, clientParams);
/*
Set whether to cache customFieldMetaData lookup to reduce # of calls to Brightpearl
for lifetime of the class
 */
const customField = new CustomField(brightPearlClient, true);
  • Get Sales Order
const order: SalesOrderInformation[] = await brightPearlClient.getSalesOrder(100743);
  • Update multiple freeform custom fields
// Find custom fields Accepted and Date Of Acceptance field codes
const [acceptedField, dateOfAcceptanceField] = await Promise.all<CustomFieldMetadataInformation>([
    customField.find("Accepted", OrderType.PURCHASE_ORDER),
    customField.find("Date Of Acceptance", OrderType.PURCHASE_ORDER)
])

// Build Requests
const acceptedFieldRequest: CustomFieldUpdate = customField.buildFreeformRequest<boolean>(acceptedField.code, true, CustomFieldOperation.ADD);
const dateOfAcceptanceRequest: CustomFieldUpdate = customField.buildFreeformRequest<string>(dateOfAcceptanceField.code, new DateTime().toISOString(), CustomFieldOperation.ADD);

// Update custom fields
await customField.update<boolean | string>(100743, [acceptedFieldRequest, dateOfAcceptanceRequest]);