-
Notifications
You must be signed in to change notification settings - Fork 116
/
webhooks.ts
134 lines (127 loc) · 3.13 KB
/
webhooks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* Interface representing a Nylas Webhook object.
*/
export interface Webhook {
/**
* Globally unique object identifier.
*/
id: string;
/**
* List of events that triggers the webhook.
*/
triggerTypes: WebhookTriggers[];
/**
* The url to send webhooks to.
*/
webhookUrl: string;
/**
* The status of the new destination.
*/
status: WebhookStatus;
/**
* The time the status field was last updated, represented as a Unix timestamp in seconds.
*/
statusUpdatedAt: number;
/**
* The time the status field was created, represented as a Unix timestamp in seconds
*/
createdAt: number;
/**
* The time the status field was last updated, represented as a Unix timestamp in seconds.
*/
updatedAt: number;
/**
* A human-readable description of the webhook destination.
*/
description?: string;
/**
* The email addresses that Nylas notifies when a webhook is down for a while.
*/
notificationEmailAddresses?: string[];
}
/**
* Class representing a Nylas webhook with secret.
*/
export interface WebhookWithSecret extends Webhook {
/**
* A secret value used to encode the X-Nylas-Signature header on webhook requests.
*/
webhookSecret: string;
}
/**
* Class representing a Nylas webhook delete response.
*/
export interface WebhookDeleteResponse {
/**
* ID of the request.
*/
requestId: string;
/**
* Object containing the webhook deletion status.
*/
data?: {
/**
* The status of the webhook deletion.
*/
status: 'success';
};
}
/**
* Class representing the response for getting a list of webhook ip addresses.
*/
export interface WebhookIpAddressesResponse {
/**
* The IP addresses that Nylas send you webhook from.
*/
ipAddresses: string[];
/**
* UNIX timestamp when Nylas updated the list of IP addresses.
*/
updatedAt: number;
}
/**
* Class representation of a Nylas create webhook request.
*/
export interface CreateWebhookRequest {
/**
* List of events that triggers the webhook.
*/
triggerTypes: WebhookTriggers[];
/**
* The url to send webhooks to.
*/
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.
*/
notificationEmailAddresses?: string[];
}
/**
* Class representation of a Nylas update webhook request.
*/
export type UpdateWebhookRequest = Partial<CreateWebhookRequest>;
/**
* Enum representing the available webhook triggers.
*/
export enum WebhookTriggers {
CalendarCreated = 'calendar.created',
CalendarUpdated = 'calendar.updated',
CalendarDeleted = 'calendar.deleted',
EventCreated = 'event.created',
EventUpdated = 'event.updated',
EventDeleted = 'event.deleted',
GrantCreated = 'grant.created',
GrantUpdated = 'grant.updated',
GrantDeleted = 'grant.deleted',
GrantExpired = 'grant.expired',
MessageSendSuccess = 'message.send_success',
MessageSendFailed = 'message.send_failed',
}
/**
* Enum representing the available webhook statuses.
*/
export type WebhookStatus = 'active' | 'failing' | 'failed' | 'pause';