@smokeballdev/smokeball-client-sdk


Interface: Api

Entry point for staff to Smokeball.

Methods

all()

all(): Promise<Staff[]>

Gets all staff members.

Returns

Promise<Staff[]>

all staff members.

Example

// Returns all staff members.
const allStaff = await sdk.staff.all();

get()

get(staffId): Promise<Staff>

Gets the staff member associated to the specified staff id.

Parameters

staffId

string

the staff member to retrieve.

Returns

Promise<Staff>

the specified staff member.

Example

// Returns the staff member with the specified staff id.
const staff = await sdk.staff.get('e9b9084b-c9b4-4f3c-9f5a-4c83ed3ac265');

observe()

observe(callback): void

Creates a subscription for all staff. Check against the staff member you are interested in within your registered callback.

To prevent doubling up of changes, notifications triggered by the staff update call will not be notified here.

Only one subscription will be made per session. Regardless of how many times this function is called, the last registered callback will be used.

Parameters

callback

(staff) => void

the function to execute when a change is made to staff in Smokeball.

Returns

void

Example

sdk.staff.observe(staff => {
  for (let i = 0; i < staff.length; i++) {
    let staffMember = staff[i];
    // Check the staff id here.
    if (staffMember.id = 'e9b9084b-c9b4-4f3c-9f5a-4c83ed3ac265') {
      // Perform syncing code here.
    }
  }
});