Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event and webhook models #535

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Unreleased
* Added support for `/v3/connect/tokeninfo` endpoint
* Models can now directly be imported from the top-level `nylas` package
* Fixed inaccuracies in event and webhook models

### 7.0.0 / 2024-02-05
* **BREAKING CHANGE**: Node SDK v7 supports the Nylas API v3 exclusively, dropping support for any endpoints that are not available in v3.
Expand Down
16 changes: 8 additions & 8 deletions src/models/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ export interface Event {
* If the event participants are able to edit the event.
*/
readOnly: boolean;
/**
* Unix timestamp when the event was created.
*/
createdAt: number;
/**
* Unix timestamp when the event was last updated.
*/
updatedAt: number;
/**
* List of participants invited to the event. Participants may also be rooms or resources.
*/
Expand Down Expand Up @@ -110,6 +102,14 @@ export interface Event {
* Status of the event.
*/
status?: Status;
/**
* Unix timestamp when the event was created.
*/
createdAt?: number;
/**
* Unix timestamp when the event was last updated.
*/
updatedAt?: number;
}

/**
Expand Down
15 changes: 10 additions & 5 deletions src/models/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export interface Webhook {
/**
* The url to send webhooks to.
*/
callbackUrl: string;
webhookUrl: string;
/**
* The status of the new destination.
*/
status: 'active' | 'failing' | 'failed' | 'pause';
status: WebhookStatus;
/**
* The time the status field was last updated, represented as a Unix timestamp in seconds.
*/
Expand All @@ -37,7 +37,7 @@ export interface Webhook {
/**
* The email addresses that Nylas notifies when a webhook is down for a while.
*/
notificationEmailAddress?: string;
notificationEmailAddresses?: string[];
}

/**
Expand Down Expand Up @@ -94,15 +94,15 @@ export interface CreateWebhookRequest {
/**
* The url to send webhooks to.
*/
callbackUrl: string;
webhookUrl: string;
/**
* A human-readable description of the webhook destination.
*/
description?: string;
/**
* The email addresses that Nylas notifies when a webhook is down for a while.
*/
notificationEmailAddress?: string;
notificationEmailAddresses?: string[];
}

/**
Expand All @@ -127,3 +127,8 @@ export enum WebhookTriggers {
MessageSendSuccess = 'message.send_success',
MessageSendFailed = 'message.send_failed',
}

/**
* Enum representing the available webhook statuses.
*/
export type WebhookStatus = 'active' | 'failing' | 'failed' | 'pause';
8 changes: 4 additions & 4 deletions tests/resources/webhooks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ describe('Webhooks', () => {
await webhooks.create({
requestBody: {
triggerTypes: [WebhookTriggers.CalendarCreated],
callbackUrl: 'https://test.callback.com',
webhookUrl: 'https://test.callback.com',
description: "My Webhook's Description",
notificationEmailAddress: '[email protected]',
notificationEmailAddresses: ['[email protected]'],
},
overrides: {
apiUri: 'https://test.api.nylas.com',
Expand All @@ -84,9 +84,9 @@ describe('Webhooks', () => {
path: '/v3/webhooks',
body: {
triggerTypes: [WebhookTriggers.CalendarCreated],
callbackUrl: 'https://test.callback.com',
webhookUrl: 'https://test.callback.com',
description: "My Webhook's Description",
notificationEmailAddress: '[email protected]',
notificationEmailAddresses: ['[email protected]'],
},
overrides: {
apiUri: 'https://test.api.nylas.com',
Expand Down
Loading