TypeScript typings for Google Workspace Events API v1
The Google Workspace Events API lets you subscribe to events and manage change notifications across Google Workspace applications.
For detailed description please check documentation.
Installing
Install typings for Google Workspace Events API:
npm install @types/gapi.client.workspaceevents-v1 --save-dev
Usage
You need to initialize Google API client in your code:
gapi.load('client', () => {
});
Then load api client wrapper:
gapi.client.load(
'https://workspaceevents.googleapis.com/$discovery/rest?version=v1',
() => {
}
);
gapi.client.load('workspaceevents', 'v1', () => {
});
Don't forget to authenticate your client before sending any request to resources:
var client_id = '',
scope = [
'https://www.googleapis.com/auth/chat.bot',
'https://www.googleapis.com/auth/chat.memberships',
'https://www.googleapis.com/auth/chat.memberships.readonly',
'https://www.googleapis.com/auth/chat.messages',
'https://www.googleapis.com/auth/chat.messages.reactions',
'https://www.googleapis.com/auth/chat.messages.reactions.readonly',
'https://www.googleapis.com/auth/chat.messages.readonly',
'https://www.googleapis.com/auth/chat.spaces',
'https://www.googleapis.com/auth/chat.spaces.readonly',
],
immediate = true;
gapi.auth.authorize(
{client_id: client_id, scope: scope, immediate: immediate},
authResult => {
if (authResult && !authResult.error) {
} else {
}
}
);
After that you can use Google Workspace Events API resources:
await gapi.client.workspaceevents.operations.get({name: 'name'});
await gapi.client.workspaceevents.subscriptions.create({});
await gapi.client.workspaceevents.subscriptions.delete({name: 'name'});
await gapi.client.workspaceevents.subscriptions.get({name: 'name'});
await gapi.client.workspaceevents.subscriptions.list({});
await gapi.client.workspaceevents.subscriptions.patch({name: 'name'});
await gapi.client.workspaceevents.subscriptions.reactivate({name: 'name'});