Skip to main content

Using the SDK

Accessing the library

Once the package is installed, you can import the library using import or require approach:

import DimeSchedulerClient from 'dimescheduler';

API key

Create an API key in Dime.Scheduler and store it somewhere safely. Once you have a key, you can instantiate the DimeSchedulerClient class:

const client = new DimeSchedulerClient("My API KEY");

Optional: choose environment

By default, the production environment is used. To use the SDK for the sandbox, you can import the Environment enum:

import DimeSchedulerClient, { Environment } from 'dimescheduler';
const client = new DimeSchedulerClient("My API KEY", Environment.Sandbox);

Models

The models are available in the dimescheduler/models submodule:

Import:

import { Category } from "dimescheduler/models";
const category = new Category();

Require:

const models = require('dimescheduler/models');
const category = new models.Category();

For the complete list of supported models, check out the API docs.

Using the API

For most operations, the import method in the DimeSchedulerClient will suffice. All models in the dimescheduler/models submodule are supported.

To add or update an entry, simply make a call like this:

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

const response = await dimeSchedulerClient.import(category);

To remove an entry, specify the append argument, which is true by default:

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

const response = await dimeSchedulerClient.import(category, false);