@555platform/555-calendar-sdk v1.0.1
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.
Property | Type | Description |
---|---|---|
calendar_id | string | Unique calendar id |
subject | string | title of event |
body | json | contentType - type of contentcontent - description of event |
start | json | start date and time of event date_time - date and time |
end | json | end date and time of event date_time - date and time |
participants | arrayObjects | Event OrganizerRequired participantsOptional participants |
location | string | location of event or meeting link |
recurrence | Object | Defines the type of event |
allow_new_time_proposals | bool | allow time to change |
show_as | string | state 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);
})