Class Calendar

Representation of a calendar, which can be:

  • private (linked to a user) or shared (linked to a team).
  • linked to an external service (Microsoft, Google, etc.) or not.

Table: idea_calendars.

Indexes:

  • userId-name-index (GSI, all)
  • teamId-name-index (GSI, all)

Hierarchy

Constructors

  • Object initialization, setting all the default values.

    Parameters

    • Optional newData: any

      the data to load, optional

    • Optional options: any

      custom options to apply; they will depend on the child resource

      Usually, there is no need to implement the constructor; implicitly, it will call the load of the child resource and therefore loading all the resources with default values. If needed, this is the suggested implementation:

      super();
      this.load(x);
      // ...

    Returns Calendar

Properties

calendarId: string

The id (IUID) of the calendar.

color: string

An identifying color for the calendar; e.g. #0010AA.

createdByUserId?: string

In case of shared calendar, the id of the user who created it.

description: string

The description of the calendar. Max 300 characters.

Extra info about the calendar, if linked to an external service.

name: string

The name of the calendar. Max 100 characters.

teamId?: string

The id of the teamId owning the calendar, in case of team calendar (this cannot be changed).

timezone: string

A default timezone for the calendar.

userId?: string

The id of the user owning the calendar, in case of private calendar (this cannot be changed). If teamId is set, this attribute is ignored.

usersCanManageAppointments?: string[]

In case of shared calendar, the IDs of the users that can manage the calendar's appointments. If null, everyone can manage the calendar's appointments; if empty ([]), no one can (read-only).

Methods

  • Check whether the chosen user can edit the appointments of this calendar.

    Parameters

    • userId: string

    Returns boolean

  • Return an attribute in a cleaned standard that force-cast the element.

    Parameters

    • origin: any

      the origin attribute, to cast

    • castFunction: ((x) => any)

      the cast function, e.g. Boolean, Number, String, x => new CustomClass(x), etc.

        • (x): any
        • Parameters

          • x: any

          Returns any

    • Optional defaultVal: any

      if set, the fallback value instead of null

    Returns any

    cleaned attribute

  • Return an array in a cleaned standard that force-cast each element, keeping only the valid ones.

    Parameters

    • origin: any[]

      the origin array, to cast and check

    • castFunction: ((x) => any)

      the cast function, e.g. x => String(x) or x => new CustomClass(x)

        • (x): any
        • Parameters

          • x: any

          Returns any

    • Optional defaultVal: any

      if set, the fallback value instead of null

    Returns any[]

    cleaned array

  • The id to use to represent the calendar, based on the fact the calendar is linked to external sources or not.

    Returns string

  • Whether the calendar is shared (linked to a team) or not.

    Returns boolean

  • Load the attributes from an already existing resource and then force some attributes to assume safeData values. The function is usually used in the back-end to mix together db data with new data, without the risk of changing ids and other attributes which are managed in appositely curated scenario.

    Parameters

    • newData: any

      the data to load

    • safeData: any

      the attributes to force to specific values

    Returns void

  • Valide the object's attributes, performing all the checkings.

    Returns string[]

    errors if empty, the checkings are successfully passed.

    Typical implementation:

    const e = super.validate();
    if(this.iE(this.attr)) e.push(`attr`);
    // ...
    return e;

Generated using TypeDoc