@555platform/555-calendar-sdk 中文文档教程

发布于 3年前 浏览 24 项目主页 更新于 3年前

Calendar

Overview

日历库提供 API 来创建日历、事件和提醒。 日历是事件的容器。 这些事件可以是单一事件或重复事件。 重复的事件会有结束时间。 可以为每个域创建多个日历,例如工作日历和个人日历。 事件与日历类型相关联。 事件可以设置提醒。

Installation

npm install @555platform/555-calendar-sdk

Calendar API's

日历库提供 API 来为用户创建、读取、更新和删除日历。

Init :

init API 用于初始化服务器 URL。 init 接受一个配置参数。 config 是对象类型,它应该有一个属性 config.URL

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.init("config")

`

Create Calendar :

createCalendar API 用于为用户创建日历。 我们需要将用户名和日历名称作为参数传递。

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.createCalendar("username", "calendarname")

`

Handling Response

createCalendar API 返回一个承诺。 如果调用成功,响应将有日历 deatils 否则错误 JSON 代码和错误原因。

Calendar.createCalendar("Rahul","home").then(response => {
      console.log(" Calendarlist Data ::",response)
    }).catch(error => {
      console.log("get calendarlist failed ::", error);
    });
}

## 获取日历:

getCalendar API 用于获取用户的日历详细信息。 我们需要将用户名作为参数传递。

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.getCalendar("username")

`

Handling Response

getCalendar API 返回承诺。 如果调用成功,响应将有日历 deatils 否则错误 JSON 代码和错误原因。

Calendar.getCalendar("Rahul").then(response => {
      console.log(" Calendarlist Data ::",response)
    }).catch(error => {
      console.log("get calendarlist failed ::", error);
    });
}

Update Calendar :

updateCalendar API 用于更新用户的日历详细信息。 我们需要将 calendarId 和 calendarName 作为参数传递。

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.updateCalendar("calendarid","calendarname")

`

Handling Response

updateCalendar API 返回一个承诺。 如果调用成功,响应将有日历 deatils 否则错误 JSON 代码和错误原因。

Calendar.updateCalendar("1ea1f9d3b4a927b264c83c07", "home").then(response => {
      console.log(" Calendarlist updateds ::",response)
    }).catch(error => {
      console.log("get calendarlist failed ::", error);
    });
}

Delete Calendar :

deleteCalendar API 用于删除用户的日历。 我们需要将 calendarId 作为参数传递。

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.deleteCalendar("calendarid")

`

Handling Response

deleteCalendar API 返回承诺。 如果调用成功,响应将有日历 deatils 否则错误 JSON 代码和错误原因。

Calendar.deleteCalendar("1ea1f9d3b4a927b264c83c07").then(response => {
      console.log(" Calendarlist updateds ::",response)
    }).catch(error => {
      console.log("get calendarlist failed ::", error);
    });
}

Event API's

日历库提供 API 来为用户创建、更新、取消和删除日历中的事件。

Create Event :

createEvent API 用于在日历中为用户创建事件。 我们需要将 eventData 作为参数传递。

以下是需要作为参数传递给 createEvent API 的事件数据。

PropertyTypeDescription
calendar_idstringUnique calendar id
subjectstringtitle of event
bodyjson
  • contentType - type of content
  • content - description of event
startjsonstart date and time of event
  • date_time - date and time
endjsonend date and time of event
  • date_time - date and time
participantsarray[Objects]
  • Event Organizer
  • Required participants
  • Optional participants
locationstringlocation of event or meeting link
recurrenceObjectDefines the type of event
allownewtime_proposalsboolallow time to change
show_asstringstate of user
import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.createEvent({eventData})

`

Handling Response

createCalendar API 返回一个承诺。 如果调用成功,响应将有事件 deatils 否则错误 JSON 代码和错误原因。

  let eventData = {
      "calendar_id": "8fa1f9d3b4a927b264c83c00",
      "subject": "Let's chat about chat",
      "body": {
          "contentType": "HTML",
          "content": "Talk about all things chat..."
      },
      "start": {
          "date_time": "2020-04-28T17:30:00Z"
      },
      "end": {
          "date_time": "2020-04-28T18:00:00Z"
      },
      "location": {
          "display_name": "Rob's desk"
      },
      "participants": [
          {
              "user_id": "7E163156-7762-4BEB-A1C6-729EA81755A7",
              "type": "organizer"
          },
          {
              "user_id": "7E163156-7762-4BEB-A1C6-729EA81755B8",
              "type": "required"
          }
      ],
      "recurrence": {
          "pattern": {
              "type": "weekly",
              "interval": 1,
              "days_of_week": [
                  "Tuesday"
              ]
          },
          "range": {
              "type": "endDate",
              "start_date": "2020-04-28T00:00:00Z",
              "end_date": "2020-06-28T00:00:00Z"
          }
      },
      "allow_new_time_proposals": true,
      "show_as": "busy"
  }

  Calendar.createEvent(eventData).then((response) => {
      console.log("create event response ::",response)

  })
  .catch(error => {
      console.log(error);
  })

## 更新事件:

updateEvent API 用于为用户更新事件。 我们需要将 userid、eventid 和更新事件信息作为参数传递。

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.updateEvent(userid,eventid,updatedEventInfo)

`

Handling Response

updateEvent API 返回一个承诺。 如果调用成功,响应将有事件 deatils 否则错误 JSON 代码和错误原因。

  Calendar.updateEvent(userid,eventid,updatedEventInfo).then((response) => {
      console.log("create event response ::",response)

  })
  .catch(error => {
      console.log(error);
  })

## 取消事件:

cancelEvent API 用于为用户取消事件。 我们需要传递 userid,eventid 作为参数。

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.cancelEvent(userid,eventid)

`

Handling Response

cancelEvent API 返回承诺。 如果调用成功,响应将有事件 deatils 否则错误 JSON 代码和错误原因。

  Calendar.cancelEvent(userid,eventid).then((response) => {
      console.log("create event response ::",response)

  })
  .catch(error => {
      console.log(error);
  })

## 删除事件:

deleteEvent API 用于为用户删除事件。 我们需要传递 userid,eventid 作为参数。

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.deleteEvent(userid,eventid)

`

Handling Response

deleteEvent API 返回承诺。 如果调用成功,响应将有事件 deatils 否则错误 JSON 代码和错误原因。

  Calendar.deleteEvent(userid,eventid).then((response) => {
      console.log("create event response ::",response)

  })
  .catch(error => {
      console.log(error);
  })

## 列表事件:

listEvents API 用于为用户列出事件。 我们需要将 userId、calendarId、startDate 和 endDate 作为参数传递。 startDate 和 endDate 是用户想要获取事件的日期。

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.listEvents(userId, calendarId, startDate, endDate)

`

Handling Response

listEvents API 返回一个承诺。 如果调用成功,响应将包含事件详细信息,否则会出现带有代码和错误原因的错误 JSON。

  const userId = '7E163156-7762-4BEB-A1C6-729EA81755A7';
  const calendarId = '8fa1f9d3b4a927b264c83c00';
  const startDate = '2021-06-18T00:00:00Z';
  const endDate = '2021-06-22T00:00:00Z';

  Calendar.listEvents('userId','calendarId','startDate','endDate')
  .then((response) => {
      console.log("list event response ::",response)
  })
  .catch(error => {
      console.log(" error"+error.message);
  })

Calendar

Overview

Calendar Library provides API'S to create calendar,events and reminders. A calendar is a container for events. These events can be single instance or repeating events. Repeating events will have ending time. Multiple calendars can be created per domain, for example, work and personal calendars. Events are associated with calendar type. Events can have reminders set on them.

Installation

npm install @555platform/555-calendar-sdk

Calendar API's

Calendar Library provides API's to Create,Read,Update and delete calendar for user.

Init :

init API is used to initialize server URL. init accepts a config parameter. config is of type object, which should have a property config.URL

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.init("config")

`

Create Calendar :

createCalendar API is used to create calendar for user. we need to pass username and calendarname as parameters.

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.createCalendar("username", "calendarname")

`

Handling Response

createCalendar API returns a promise. Response will have calendar deatils if call is successful otherwise error JSON with code and reason for error.

Calendar.createCalendar("Rahul","home").then(response => {
      console.log(" Calendarlist Data ::",response)
    }).catch(error => {
      console.log("get calendarlist failed ::", error);
    });
}

## Get Calendar :

getCalendar API is used to get calendar details for user. we need to pass username as parameter.

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.getCalendar("username")

`

Handling Response

getCalendar API returns a promise. Response will have calendar deatils if call is successful otherwise error JSON with code and reason for error.

Calendar.getCalendar("Rahul").then(response => {
      console.log(" Calendarlist Data ::",response)
    }).catch(error => {
      console.log("get calendarlist failed ::", error);
    });
}

Update Calendar :

updateCalendar API is used to update calendar details for user. we need to pass calendarId and calendarName as parameters.

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.updateCalendar("calendarid","calendarname")

`

Handling Response

updateCalendar API returns a promise. Response will have calendar deatils if call is successful otherwise error JSON with code and reason for error.

Calendar.updateCalendar("1ea1f9d3b4a927b264c83c07", "home").then(response => {
      console.log(" Calendarlist updateds ::",response)
    }).catch(error => {
      console.log("get calendarlist failed ::", error);
    });
}

Delete Calendar :

deleteCalendar API is used to delete calendar of user. we need to pass calendarId as parameter.

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.deleteCalendar("calendarid")

`

Handling Response

deleteCalendar API returns a promise. Response will have calendar deatils if call is successful otherwise error JSON with code and reason for error.

Calendar.deleteCalendar("1ea1f9d3b4a927b264c83c07").then(response => {
      console.log(" Calendarlist updateds ::",response)
    }).catch(error => {
      console.log("get calendarlist failed ::", error);
    });
}

Event API's

Calendar Library provides API's to create,update,cancel and delete events in calendar for user.

Create Event :

createEvent API is used to create event in calendar for user. we need to pass eventData as parameter.

Below is the eventdata need to be passed as parameter to createEvent API.

PropertyTypeDescription
calendar_idstringUnique calendar id
subjectstringtitle of event
bodyjson
  • contentType - type of content
  • content - description of event
startjsonstart date and time of event
  • date_time - date and time
endjsonend date and time of event
  • date_time - date and time
participantsarray[Objects]
  • Event Organizer
  • Required participants
  • Optional participants
locationstringlocation of event or meeting link
recurrenceObjectDefines the type of event
allownewtime_proposalsboolallow time to change
show_asstringstate of user
import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.createEvent({eventData})

`

Handling Response

createCalendar API returns a promise. Response will have event deatils if call is successful otherwise error JSON with code and reason for error.

  let eventData = {
      "calendar_id": "8fa1f9d3b4a927b264c83c00",
      "subject": "Let's chat about chat",
      "body": {
          "contentType": "HTML",
          "content": "Talk about all things chat..."
      },
      "start": {
          "date_time": "2020-04-28T17:30:00Z"
      },
      "end": {
          "date_time": "2020-04-28T18:00:00Z"
      },
      "location": {
          "display_name": "Rob's desk"
      },
      "participants": [
          {
              "user_id": "7E163156-7762-4BEB-A1C6-729EA81755A7",
              "type": "organizer"
          },
          {
              "user_id": "7E163156-7762-4BEB-A1C6-729EA81755B8",
              "type": "required"
          }
      ],
      "recurrence": {
          "pattern": {
              "type": "weekly",
              "interval": 1,
              "days_of_week": [
                  "Tuesday"
              ]
          },
          "range": {
              "type": "endDate",
              "start_date": "2020-04-28T00:00:00Z",
              "end_date": "2020-06-28T00:00:00Z"
          }
      },
      "allow_new_time_proposals": true,
      "show_as": "busy"
  }

  Calendar.createEvent(eventData).then((response) => {
      console.log("create event response ::",response)

  })
  .catch(error => {
      console.log(error);
  })

## Update Event :

updateEvent API is used to update event for user. we need to pass userid,eventid and update event info as parameter.

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.updateEvent(userid,eventid,updatedEventInfo)

`

Handling Response

updateEvent API returns a promise. Response will have event deatils if call is successful otherwise error JSON with code and reason for error.

  Calendar.updateEvent(userid,eventid,updatedEventInfo).then((response) => {
      console.log("create event response ::",response)

  })
  .catch(error => {
      console.log(error);
  })

## Cancel Event :

cancelEvent API is used to cancel event for user. we need to pass userid,eventid as parameter.

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.cancelEvent(userid,eventid)

`

Handling Response

cancelEvent API returns a promise. Response will have event deatils if call is successful otherwise error JSON with code and reason for error.

  Calendar.cancelEvent(userid,eventid).then((response) => {
      console.log("create event response ::",response)

  })
  .catch(error => {
      console.log(error);
  })

## Delete Event :

deleteEvent API is used to delete event for user. we need to pass userid,eventid as parameter.

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.deleteEvent(userid,eventid)

`

Handling Response

deleteEvent API returns a promise. Response will have event deatils if call is successful otherwise error JSON with code and reason for error.

  Calendar.deleteEvent(userid,eventid).then((response) => {
      console.log("create event response ::",response)

  })
  .catch(error => {
      console.log(error);
  })

## List Events :

listEvents API is used to list events for user. We need to pass userId, calendarId, startDate and endDate as parameters. startDate and endDate are dates for which user wants to fetch the events.

import {Calendar} from '@555platform/555-calendar-sdk';
Calendar.listEvents(userId, calendarId, startDate, endDate)

`

Handling Response

listEvents API returns a promise. Response will have event details if call is successful otherwise error JSON with code and reason for error.

  const userId = '7E163156-7762-4BEB-A1C6-729EA81755A7';
  const calendarId = '8fa1f9d3b4a927b264c83c00';
  const startDate = '2021-06-18T00:00:00Z';
  const endDate = '2021-06-22T00:00:00Z';

  Calendar.listEvents('userId','calendarId','startDate','endDate')
  .then((response) => {
      console.log("list event response ::",response)
  })
  .catch(error => {
      console.log(" error"+error.message);
  })
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文