Skip to main content

Examples

The general flow to use the package is the following:

  • Import the Dime.Scheduler client class.
  • Import and instantiate the model classes.
  • Instantiate the client class with the API key, and optionally, the environment.
  • Invoke the import method to enter this object into Dime.Scheduler.

Create a category

The sample below shows how to insert or update a category, which is a visual indicator that is used to render the background colors of appointments on the planning board.

// Step 1: import the necessary classes
import DimeSchedulerClient from 'dimescheduler';
import { Category } from "dimescheduler/models";

// Instantiate and populate the model
const category = new Category();
category.color = '#' + (Math.random() * 0xFFFFFF << 0).toString(16);
category.name = "My category";

// Instantiate the client
const dimeSchedulerClient = new DimeSchedulerClient(apiKey);

// Call the import API
const response = await dimeSchedulerClient.import(category);

Set the location of a resource

The sample below shows how to set the actual location of a resource.

// Step 1: import the necessary classes
import DimeSchedulerClient from 'dimescheduler';
import { ResourceGpsTracking } from "dimescheduler/models";

// Instantiate and populate the model
const location = new ResourceGpsTracking();
location.resourceNo = "YOURRESOURCENOGOESHERE";
location.latitude = YOURLATITUDEGOESHERE;
location.longitude = YOURLONGITUDEGOESHERE;

// Instantiate the client
const dimeSchedulerClient = new DimeSchedulerClient(apiKey);

// Call the import API
const response = await dimeSchedulerClient.import(location);

Create a job and task

The sample below shows how to create or update a job and task.

// Step 1: import the necessary classes
import DimeSchedulerClient from 'dimescheduler';
import { Job, Task } from "dimescheduler/models";

// Instantiate and populate the models
const sourceApp = "CRM";
const sourceType = "SERVICECASE";
const jobNo = "CASE_123";

const job = new Job();
job.sourceApp = sourceApp;
job.sourceType = sourceType;
job.jobNo = jobNo;
job.shortDescription = "Do a good job.";
job.description = "Do a good job, but in more words!";

const task = new Task();
task.sourceApp = sourceApp;
task.sourceType = sourceType;
task.jobNo = jobNo;
task.taskNo = "CASE_123_ACTIVITY001";
task.shortDescription = "Do a good job.";
task.description = "Do a good job, but in more words!";

// Instantiate the client
const dimeSchedulerClient = new DimeSchedulerClient(apiKey);

// Call the import API
// Order is important here as it will insert a job before the task
const response = await dimeSchedulerClient.import([job,task]);

Create a resource

The sample below shows how to create or update a resource.

// Step 1: import the necessary classes
import DimeSchedulerClient from 'dimescheduler';
import { Resource } from "dimescheduler/models";

// Instantiate and populate the model
const resource = new Resource();
resource.resourceNo = "RESOURCENO_001";
resource.name = "Johnny B. Goode";
resource.displayName = "Johnny B. Goode";

// Instantiate the client
const dimeSchedulerClient = new DimeSchedulerClient(apiKey);

// Call the import API
const response = await dimeSchedulerClient.import(resource);

Send a fly-in message

Add a transient message to active users.

// Step 1: import the necessary classes
import DimeSchedulerClient from 'dimescheduler';
import { Message } from "dimescheduler/models";

// Instantiate the client
const dimeSchedulerClient = new DimeSchedulerClient(apiKey);

// Call the messages API
client.sendMessage("Hi there, esteemed colleagues! I hope y'all having a jolly good day.", Severity.Warning);

More examples can be found on Github.