@brickwork-software/bw-customer-data

0.0.2 • Public • Published

bw-customer-data

Post customer data into a Brickwork by B8ta appointment page iframe. Currently supports customer's email, firstName, lastName, and id. Appointment page listens for data from whitelisted origins. Contact support to edit the whitelist for your organization.

Retries until either success or limits reached. Default limits: 10 retries, with 500ms between tries. Both are optionally configurable by options parameter (see Usage).

Installation

npm install 'bw-customer-data'

or by CDN:
<script async src="https://unpkg.com/bw-customer-data/dist/bw-customer-data.min.js"></script>

Configuration

Customer data can be sent to a Brickwork by B8ta iframe with an id of bw-iframe that has loaded an appointmentpage path.

<iframe id="bw-iframe" src="https://example.com/appointmentpage" />

Usage

const data = {
  email: "geoffrey@example.com"
  firstName: "Geoffrey",
  id: "123",
  lastName: "Jefferies",
}
const targetOrigin = "https://example.com/appointmentpage"
const options = {
  maxRetries: 20,
  retryDelay: 100,
}

bwCustomerData.post(data, targetOrigin, options)
  .then(result => {
    console.log(result)
  })
  .catch(result => {
    console.log(result)
  })

data: object
data.email: string
data.firstName: string
data.id: string
data.lastName: string

targetOrigin: string

options: object
options.maxRetries: number
options.retryDelay: number

Examples

With valid arguments.

bwCustomerData.post(
  { firstName: "Geoffrey" },
  "https://example.com/appointmentpage"
)
  .then(result => {
    console.log(result) // { status: "success" }
  })
  .catch(result => {
    console.log(result)
  })

With invalid arguments or misconfiguration.

bwCustomerData.post(
  "Geoffrey",
  "https://example.com/appointmentpage",
  { maxRetries: 20 }
)
  .then(result => {
    console.log(result)
  })
  .catch(result => {
    console.log(result) // { Error: First argument must be an object, received 'string'.}
  })

Data not received, such as when the iframe is not yet loaded.

bwCustomerData.post(
  { firstName: "Geoffrey" },
  "https://example.com/appointmentpage",
  { maxRetries: 20 }
)
  .then(result => {
    console.log(result)
  })
  .catch(result => {
    console.log(result) // { status: "error" }
  })

Bugs

Include version number bwCustomerData.version() with your issue.

Readme

Keywords

none

Package Sidebar

Install

npm i @brickwork-software/bw-customer-data

Weekly Downloads

0

Version

0.0.2

License

ISC

Unpacked Size

23.1 kB

Total Files

9

Last publish

Collaborators

  • wjbergin
  • systemdisc
  • bw-ops
  • thunderousswami
  • bw-pjconroy