Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-google-calendar-api

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-calendar-api - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

8

dist/ApiCalendar.d.ts

@@ -84,2 +84,10 @@ interface ConfigApiCalendar {

/**
* Create Calendar event with video conference
* @param {string} calendarId for the event.
* @param {object} event with start and end dateTime
* @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
* @returns {any}
*/
createEventWithVideoConference(event: any, calendarId?: string, sendUpdates?: "all" | "externalOnly" | "none"): any;
/**
* Delete an event in the calendar.

@@ -86,0 +94,0 @@ * @param {string} eventId of the event to delete.

142

dist/ApiCalendar.js

@@ -0,3 +1,6 @@

"use strict";
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;

@@ -19,2 +22,3 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;

};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {

@@ -33,2 +37,22 @@ for (var name in all)

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -70,2 +94,5 @@ // src/ApiCalendar.ts

}
/**
* Auth to the google Api.
*/
initGapiClient() {

@@ -84,2 +111,6 @@ gapi.client.init({

}
/**
* Init Google Api
* And create gapi in global
*/
handleClientLoad() {

@@ -99,4 +130,4 @@ const scriptGoogle = document.createElement("script");

};
scriptGoogle.onload = async () => {
this.tokenClient = await google.accounts.oauth2.initTokenClient({
scriptGoogle.onload = () => __async(this, null, function* () {
this.tokenClient = yield google.accounts.oauth2.initTokenClient({
client_id: this.config.clientId,

@@ -108,4 +139,7 @@ scope: this.config.scope,

});
};
});
}
/**
* Sign in Google user account
*/
handleAuthClick() {

@@ -125,5 +159,13 @@ if (gapi && this.tokenClient) {

}
/**
* Set the default attribute calendar
* @param {string} newCalendar
*/
setCalendar(newCalendar) {
this.calendar = newCalendar;
}
/**
* Execute the callback function when gapi is loaded
* @param callback
*/
onLoad(callback) {

@@ -136,2 +178,5 @@ if (gapi) {

}
/**
* Sign out user google account
*/
handleSignoutClick() {

@@ -150,2 +195,8 @@ if (gapi) {

}
/**
* List all events in the calendar
* @param {number} maxResults to see
* @param {string} calendarId to see by default use the calendar attribute
* @returns {any}
*/
listUpcomingEvents(maxResults, calendarId = this.calendar) {

@@ -155,3 +206,3 @@ if (gapi) {

calendarId,
timeMin: new Date().toISOString(),
timeMin: (/* @__PURE__ */ new Date()).toISOString(),
showDeleted: false,

@@ -167,2 +218,9 @@ singleEvents: true,

}
/**
* List all events in the calendar queried by custom query options
* See all available options here https://developers.google.com/calendar/v3/reference/events/list
* @param {object} queryOptions to see
* @param {string} calendarId to see by default use the calendar attribute
* @returns {any}
*/
listEvents(queryOptions, calendarId = this.calendar) {

@@ -178,2 +236,11 @@ if (gapi) {

}
/**
* Create an event from the current time for a certain period
* @param {number} time in minutes for the event
* @param {string} summary of the event
* @param {string} description of the event
* @param {string} calendarId
* @param {string} timeZone The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".)
* @returns {any}
*/
createEventFromNow({ time, summary, description = "" }, calendarId = this.calendar, timeZone = "Europe/Paris") {

@@ -184,7 +251,7 @@ const event = {

start: {
dateTime: new Date().toISOString(),
dateTime: (/* @__PURE__ */ new Date()).toISOString(),
timeZone
},
end: {
dateTime: new Date(new Date().getTime() + time * 6e4).toISOString(),
dateTime: new Date((/* @__PURE__ */ new Date()).getTime() + time * 6e4).toISOString(),
timeZone

@@ -195,2 +262,9 @@ }

}
/**
* Create Calendar event
* @param {string} calendarId for the event.
* @param {object} event with start and end dateTime
* @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
* @returns {any}
*/
createEvent(event, calendarId = this.calendar, sendUpdates = "none") {

@@ -201,3 +275,5 @@ if (gapi.client.getToken()) {

resource: event,
sendUpdates
//@ts-ignore the @types/gapi.calendar package is not up to date(https://developers.google.com/calendar/api/v3/reference/events/insert)
sendUpdates,
conferenceDataVersion: 1
});

@@ -209,2 +285,31 @@ } else {

}
/**
* Create Calendar event with video conference
* @param {string} calendarId for the event.
* @param {object} event with start and end dateTime
* @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
* @returns {any}
*/
createEventWithVideoConference(event, calendarId = this.calendar, sendUpdates = "none") {
return this.createEvent(
__spreadProps(__spreadValues({}, event), {
conferenceData: {
createRequest: {
requestId: crypto.randomUUID(),
conferenceSolutionKey: {
type: "hangoutsMeet"
}
}
}
}),
calendarId,
sendUpdates
);
}
/**
* Delete an event in the calendar.
* @param {string} eventId of the event to delete.
* @param {string} calendarId where the event is.
* @returns {any} Promise resolved when the event is deleted.
*/
deleteEvent(eventId, calendarId = this.calendar) {

@@ -221,2 +326,10 @@ if (gapi) {

}
/**
* Update Calendar event
* @param {string} calendarId for the event.
* @param {string} eventId of the event.
* @param {object} event with details to update, e.g. summary
* @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
* @returns {any}
*/
updateEvent(event, eventId, calendarId = this.calendar, sendUpdates = "none") {

@@ -235,2 +348,8 @@ if (gapi) {

}
/**
* Get Calendar event
* @param {string} calendarId for the event.
* @param {string} eventId specifies individual event
* @returns {any}
*/
getEvent(eventId, calendarId = this.calendar) {

@@ -247,2 +366,6 @@ if (gapi) {

}
/**
* Get Calendar List
* @returns {any}
*/
listCalendars() {

@@ -256,2 +379,7 @@ if (gapi) {

}
/**
* Create Calendar
* @param {string} summary, title of the calendar.
* @returns {any}
*/
createCalendar(summary) {

@@ -258,0 +386,0 @@ if (gapi) {

16

package.json
{
"name": "react-google-calendar-api",
"version": "2.2.0",
"version": "2.2.1",
"description": "An api to manage your google calendar",

@@ -43,10 +43,10 @@ "main": "./dist/ApiCalendar.js",

"devDependencies": {
"@types/gapi": "^0.0.42",
"@types/gapi": "^0.0.44",
"@types/gapi.calendar": "^3.0.6",
"@types/google.accounts": "^0.0.1",
"@types/jest": "^27.5.1",
"@types/node": "^9.6.39",
"jest": "^28.1.0",
"linted": "0.0.2",
"ts-jest": "^28.0.3",
"@types/google.accounts": "^0.0.6",
"@types/jest": "^29.4.0",
"@types/node": "^18.13.0",
"jest": "^29.4.2",
"linted": "1.0.5",
"ts-jest": "^29.0.5",
"tslint": "^6.1.3",

@@ -53,0 +53,0 @@ "tsup": "^6.0.1",

@@ -13,2 +13,3 @@ # react-google-calendar-api

Npm
```

@@ -19,2 +20,3 @@ npm install --save react-google-calendar-api

yarn
```

@@ -30,14 +32,14 @@ yarn add react-google-calendar-api

```javascript
import ApiCalendar from 'react-google-calendar-api';
import ApiCalendar from "react-google-calendar-api";
const config = {
"clientId": "<CLIENT_ID>",
"apiKey": "<API_KEY>",
"scope": "https://www.googleapis.com/auth/calendar",
"discoveryDocs": [
"https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"
]
}
clientId: "<CLIENT_ID>",
apiKey: "<API_KEY>",
scope: "https://www.googleapis.com/auth/calendar",
discoveryDocs: [
"https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest",
],
};
const apiCalendar = new ApiCalendar(config)
const apiCalendar = new ApiCalendar(config);
```

@@ -138,3 +140,3 @@

*/
public createEvent(event: object, calendarId: string = this.calendar, sendUpdates: string = 'none',): any {
public createEvent(event: object, calendarId: string = this.calendar, sendUpdates: string = 'none',): any
```

@@ -157,24 +159,42 @@

### Create Event With Video Conference:
```javascript
/**
* Create Calendar event with video conference
* @param {object} event with start and end dateTime
* @param {string} calendarId for the event.
* @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
* @returns {any}
*/
public createEventWithVideoConference(
event: any,
calendarId: string = this.calendar,
sendUpdates: "all" | "externalOnly" | "none" = "none"
): any
```
#### Example
```javascript
import ApiCalendar from 'react-google-calendar-api';
import ApiCalendar from "react-google-calendar-api";
const config = {
"clientId": "<CLIENT_ID>",
"apiKey": "<API_KEY>",
"scope": "https://www.googleapis.com/auth/calendar",
"discoveryDocs": [
"https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"
]
}
clientId: "<CLIENT_ID>",
apiKey: "<API_KEY>",
scope: "https://www.googleapis.com/auth/calendar",
discoveryDocs: [
"https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest",
],
};
const apiCalendar = new ApiCalendar(config)
const apiCalendar = new ApiCalendar(config);
const eventFromNow: object = {
summary: 'Poc Dev From Now',
summary: "Poc Dev From Now",
time: 480,
};
apiCalendar.createEventFromNow(eventFromNow)
apiCalendar
.createEventFromNow(eventFromNow)
.then((result: object) => {

@@ -186,2 +206,23 @@ console.log(result);

});
const eventWithVideoConference: object = {
summary: "Event With Google Meet Conference",
start: {
dateTime: new Date().toISOString(),
timeZone: "Europe/Paris",
},
end: {
dateTime: new Date(new Date().getTime() + 3600000).toISOString(),
timeZone: "Europe/Paris",
},
};
apiCalendar
.createEventWithVideoConference(eventWithVideoConference)
.then((result: object) => {
console.log(result);
})
.catch((error: any) => {
console.log(error);
});
```

@@ -210,2 +251,3 @@

### List All Events:
```javascript

@@ -221,3 +263,5 @@ /**

```
#### Example
```javascript

@@ -254,6 +298,6 @@ // The user need to signIn with Handle AuthClick before

const event = {
summary: 'New Event Title',
summary: "New Event Title",
};
apiCalendar.updateEvent(event, '2eo85lmjkkd2i63uo3lhi8a2cq').then(console.log);
apiCalendar.updateEvent(event, "2eo85lmjkkd2i63uo3lhi8a2cq").then(console.log);
```

@@ -276,3 +320,3 @@

```javascript
apiCalendar.deleteEvent('2eo85lmjkkd2i63uo3lhi8a2cq').then(console.log);
apiCalendar.deleteEvent("2eo85lmjkkd2i63uo3lhi8a2cq").then(console.log);
```

@@ -295,3 +339,3 @@

```javascript
apiCalendar.getEvent('2eo85lmjkkd2i63uo3lhi8a2cq').then(console.log);
```
apiCalendar.getEvent("2eo85lmjkkd2i63uo3lhi8a2cq").then(console.log);
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc