Skip to main content

Calendar Client

Calendar Client allows you to interact with the Onlive calendars API.

Installation

ES6 Module

Using module imports, you need to create the .npmrc file at the root of the project with the following content:

@onlive.site:registry=https://gitlab.com/api/v4/projects/66230274/packages/npm/

Then, you can install the package with the following command:

npm install @onlive.site/calendar
import { CalendarClient } from "@onlive.site/calendar";

const client = new CalendarClient({
baseUrl: "https://example.com/api/v1",
organizationId: "<organizationId>",
});

UMD (Universal Module Definition)

<script src="https://cdn.onlive.site/@onlive.site/calendar@latest/index.iife.js"></script>

<script>
const { CalendarClient } = window.OnliveCalendar;

const client = new CalendarClient({
baseUrl: "https://example.com/api/v1",
organizationId: "<organizationId>",
});
</script>

Usage

Constructor

Signature:

constructor(_options: ClientOptions)
  • Initializes a new instance of CalendarClient.
  • Parameters:
    • options (ClientOptions): Configuration object for the client, validated according to ClientOptionsSchema.

Methods

1. getAvailability

Description:

Fetches the availability of a service.

Signature:
public async getAvailability(options: GetAvailabilityOptions): Promise<AvailabilityResponse>
  • Parameters:

    • options: The options must adhere to the GetAvailabilityOptions.
      • serviceId (string - UUID): A required ID for the service.
      • startDate (string - ISO datetime, optional): Start date for availability lookup.
      • endDate (string - non-empty, optional): End date for availability lookup.
      • calendarFilters (object, optional): Filter criteria for the calendar.
  • Response:

    • Returns a promise that resolves to an AvailabilityResponse, which is an array of objects. Each object has:
      • availabilityTime (string - ISO datetime): Time of availability.
      • owners (string[]): Array of owner UUIDs.
      • assets (string[]): Array of asset UUIDs.
Example:
import { CalendarClient } from "@onlive.site/calendar";

const client = new CalendarClient({
baseUrl: "https://example.com/api/v1",
organizationId: "<organizationId>",
});

calendarClient
.getAvailability({
serviceId: "SERVICE-UUID",
startDate: "2024-01-01T00:00:00Z",
endDate: "2024-01-02T00:00:00Z",
calendarFilters: {
model: "tavascan",
}
})
.then((response) => {
console.log("Availability Response:", response);
})
.catch((error) => {
console.error("Error fetching availability:", error);
});