nylas 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/models/access-token.d.ts +2 -0
- package/lib/models/access-token.js +21 -21
- package/lib/models/account.d.ts +4 -0
- package/lib/models/account.js +25 -25
- package/lib/models/application-details.d.ts +2 -0
- package/lib/models/application-details.js +14 -14
- package/lib/models/calendar-availability.d.ts +9 -3
- package/lib/models/calendar-availability.js +41 -41
- package/lib/models/calendar-restful-model-collection.d.ts +2 -0
- package/lib/models/calendar-restful-model-collection.js +72 -55
- package/lib/models/calendar.d.ts +3 -0
- package/lib/models/calendar.js +24 -24
- package/lib/models/component.d.ts +3 -0
- package/lib/models/component.js +33 -33
- package/lib/models/connect.d.ts +3 -0
- package/lib/models/connect.js +47 -47
- package/lib/models/contact.d.ts +9 -0
- package/lib/models/contact.js +144 -144
- package/lib/models/draft.d.ts +3 -0
- package/lib/models/draft.js +10 -10
- package/lib/models/email-participant.d.ts +2 -0
- package/lib/models/email-participant.js +8 -8
- package/lib/models/event-conferencing.d.ts +3 -0
- package/lib/models/event-conferencing.js +30 -30
- package/lib/models/event-notification.d.ts +2 -0
- package/lib/models/event-notification.js +24 -24
- package/lib/models/event-participant.d.ts +6 -0
- package/lib/models/event-participant.js +19 -12
- package/lib/models/event.d.ts +17 -0
- package/lib/models/event.js +92 -61
- package/lib/models/file.d.ts +3 -0
- package/lib/models/file.js +21 -21
- package/lib/models/folder.d.ts +4 -0
- package/lib/models/folder.js +13 -13
- package/lib/models/free-busy.d.ts +15 -1
- package/lib/models/free-busy.js +51 -29
- package/lib/models/job-status.d.ts +3 -0
- package/lib/models/job-status.js +20 -20
- package/lib/models/management-account.d.ts +5 -0
- package/lib/models/management-account.js +46 -46
- package/lib/models/message.d.ts +3 -0
- package/lib/models/message.js +54 -54
- package/lib/models/model.d.ts +1 -0
- package/lib/models/model.js +5 -0
- package/lib/models/neural-categorizer.d.ts +4 -0
- package/lib/models/neural-categorizer.js +21 -21
- package/lib/models/neural-clean-conversation.d.ts +3 -0
- package/lib/models/neural-clean-conversation.js +7 -7
- package/lib/models/neural-ocr.d.ts +3 -0
- package/lib/models/neural-ocr.js +7 -7
- package/lib/models/neural-sentiment-analysis.d.ts +3 -0
- package/lib/models/neural-sentiment-analysis.js +21 -21
- package/lib/models/neural-signature-contact.d.ts +4 -0
- package/lib/models/neural-signature-contact.js +39 -39
- package/lib/models/neural-signature-extraction.d.ts +3 -0
- package/lib/models/neural-signature-extraction.js +10 -10
- package/lib/models/neural.d.ts +2 -0
- package/lib/models/neural.js +26 -26
- package/lib/models/resource.d.ts +3 -0
- package/lib/models/resource.js +31 -31
- package/lib/models/restful-model.d.ts +2 -1
- package/lib/models/restful-model.js +15 -20
- package/lib/models/scheduler-booking-request.d.ts +3 -0
- package/lib/models/scheduler-booking-request.js +93 -93
- package/lib/models/scheduler-time-slot.d.ts +2 -0
- package/lib/models/scheduler-time-slot.js +23 -23
- package/lib/models/scheduler.d.ts +10 -0
- package/lib/models/scheduler.js +247 -247
- package/lib/models/thread.d.ts +3 -0
- package/lib/models/thread.js +50 -50
- package/lib/models/webhook.d.ts +3 -0
- package/lib/models/webhook.js +23 -23
- package/lib/models/when.d.ts +3 -0
- package/lib/models/when.js +35 -27
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Model from './model';
|
|
2
|
+
import { Attribute } from './attributes';
|
|
2
3
|
export declare type AccessTokenProperties = {
|
|
3
4
|
accessToken: string;
|
|
4
5
|
accountId: string;
|
|
@@ -12,5 +13,6 @@ export default class AccessToken extends Model implements AccessTokenProperties
|
|
|
12
13
|
emailAddress: string;
|
|
13
14
|
provider: string;
|
|
14
15
|
tokenType: string;
|
|
16
|
+
static attributes: Record<string, Attribute>;
|
|
15
17
|
constructor(props?: AccessTokenProperties);
|
|
16
18
|
}
|
|
@@ -30,27 +30,27 @@ var AccessToken = /** @class */ (function (_super) {
|
|
|
30
30
|
_this.initAttributes(props);
|
|
31
31
|
return _this;
|
|
32
32
|
}
|
|
33
|
+
AccessToken.attributes = {
|
|
34
|
+
accessToken: attributes_1.default.String({
|
|
35
|
+
modelKey: 'accessToken',
|
|
36
|
+
jsonKey: 'access_token',
|
|
37
|
+
}),
|
|
38
|
+
accountId: attributes_1.default.String({
|
|
39
|
+
modelKey: 'accountId',
|
|
40
|
+
jsonKey: 'account_id',
|
|
41
|
+
}),
|
|
42
|
+
emailAddress: attributes_1.default.String({
|
|
43
|
+
modelKey: 'emailAddress',
|
|
44
|
+
jsonKey: 'email_address',
|
|
45
|
+
}),
|
|
46
|
+
provider: attributes_1.default.String({
|
|
47
|
+
modelKey: 'provider',
|
|
48
|
+
}),
|
|
49
|
+
tokenType: attributes_1.default.String({
|
|
50
|
+
modelKey: 'tokenType',
|
|
51
|
+
jsonKey: 'token_type',
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
33
54
|
return AccessToken;
|
|
34
55
|
}(model_1.default));
|
|
35
56
|
exports.default = AccessToken;
|
|
36
|
-
AccessToken.attributes = {
|
|
37
|
-
accessToken: attributes_1.default.String({
|
|
38
|
-
modelKey: 'accessToken',
|
|
39
|
-
jsonKey: 'access_token',
|
|
40
|
-
}),
|
|
41
|
-
accountId: attributes_1.default.String({
|
|
42
|
-
modelKey: 'accountId',
|
|
43
|
-
jsonKey: 'account_id',
|
|
44
|
-
}),
|
|
45
|
-
emailAddress: attributes_1.default.String({
|
|
46
|
-
modelKey: 'emailAddress',
|
|
47
|
-
jsonKey: 'email_address',
|
|
48
|
-
}),
|
|
49
|
-
provider: attributes_1.default.String({
|
|
50
|
-
modelKey: 'provider',
|
|
51
|
-
}),
|
|
52
|
-
tokenType: attributes_1.default.String({
|
|
53
|
-
modelKey: 'tokenType',
|
|
54
|
-
jsonKey: 'token_type',
|
|
55
|
-
}),
|
|
56
|
-
};
|
package/lib/models/account.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import RestfulModel from './restful-model';
|
|
2
|
+
import { Attribute } from './attributes';
|
|
2
3
|
import NylasConnection from '../nylas-connection';
|
|
3
4
|
export declare type AccountProperties = {
|
|
4
5
|
name: string;
|
|
@@ -19,5 +20,8 @@ export default class Account extends RestfulModel implements AccountProperties {
|
|
|
19
20
|
linkedAt: Date;
|
|
20
21
|
accessToken: string;
|
|
21
22
|
billingState?: string;
|
|
23
|
+
static collectionName: string;
|
|
24
|
+
static endpointName: string;
|
|
25
|
+
static attributes: Record<string, Attribute>;
|
|
22
26
|
constructor(connection: NylasConnection, props?: AccountProperties);
|
|
23
27
|
}
|
package/lib/models/account.js
CHANGED
|
@@ -43,31 +43,31 @@ var Account = /** @class */ (function (_super) {
|
|
|
43
43
|
_this.initAttributes(props);
|
|
44
44
|
return _this;
|
|
45
45
|
}
|
|
46
|
+
Account.collectionName = 'accounts';
|
|
47
|
+
Account.endpointName = 'account';
|
|
48
|
+
Account.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
|
|
49
|
+
modelKey: 'name',
|
|
50
|
+
}), emailAddress: attributes_1.default.String({
|
|
51
|
+
modelKey: 'emailAddress',
|
|
52
|
+
jsonKey: 'email_address',
|
|
53
|
+
}), provider: attributes_1.default.String({
|
|
54
|
+
modelKey: 'provider',
|
|
55
|
+
}), organizationUnit: attributes_1.default.String({
|
|
56
|
+
modelKey: 'organizationUnit',
|
|
57
|
+
jsonKey: 'organization_unit',
|
|
58
|
+
}), syncState: attributes_1.default.String({
|
|
59
|
+
modelKey: 'syncState',
|
|
60
|
+
jsonKey: 'sync_state',
|
|
61
|
+
}), billingState: attributes_1.default.String({
|
|
62
|
+
modelKey: 'billingState',
|
|
63
|
+
jsonKey: 'billing_state',
|
|
64
|
+
}), linkedAt: attributes_1.default.DateTime({
|
|
65
|
+
modelKey: 'linkedAt',
|
|
66
|
+
jsonKey: 'linked_at',
|
|
67
|
+
}), accessToken: attributes_1.default.String({
|
|
68
|
+
modelKey: 'accessToken',
|
|
69
|
+
jsonKey: 'access_token',
|
|
70
|
+
}) });
|
|
46
71
|
return Account;
|
|
47
72
|
}(restful_model_1.default));
|
|
48
73
|
exports.default = Account;
|
|
49
|
-
Account.collectionName = 'accounts';
|
|
50
|
-
Account.endpointName = 'account';
|
|
51
|
-
Account.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
|
|
52
|
-
modelKey: 'name',
|
|
53
|
-
}), emailAddress: attributes_1.default.String({
|
|
54
|
-
modelKey: 'emailAddress',
|
|
55
|
-
jsonKey: 'email_address',
|
|
56
|
-
}), provider: attributes_1.default.String({
|
|
57
|
-
modelKey: 'provider',
|
|
58
|
-
}), organizationUnit: attributes_1.default.String({
|
|
59
|
-
modelKey: 'organizationUnit',
|
|
60
|
-
jsonKey: 'organization_unit',
|
|
61
|
-
}), syncState: attributes_1.default.String({
|
|
62
|
-
modelKey: 'syncState',
|
|
63
|
-
jsonKey: 'sync_state',
|
|
64
|
-
}), billingState: attributes_1.default.String({
|
|
65
|
-
modelKey: 'billingState',
|
|
66
|
-
jsonKey: 'billing_state',
|
|
67
|
-
}), linkedAt: attributes_1.default.DateTime({
|
|
68
|
-
modelKey: 'linkedAt',
|
|
69
|
-
jsonKey: 'linked_at',
|
|
70
|
-
}), accessToken: attributes_1.default.String({
|
|
71
|
-
modelKey: 'accessToken',
|
|
72
|
-
jsonKey: 'access_token',
|
|
73
|
-
}) });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Model from './model';
|
|
2
|
+
import { Attribute } from './attributes';
|
|
2
3
|
export declare type ApplicationDetailsProperties = {
|
|
3
4
|
applicationName?: string;
|
|
4
5
|
iconUrl?: string;
|
|
@@ -8,5 +9,6 @@ export default class ApplicationDetails extends Model implements ApplicationDeta
|
|
|
8
9
|
applicationName: string;
|
|
9
10
|
iconUrl: string;
|
|
10
11
|
redirectUris: string[];
|
|
12
|
+
static attributes: Record<string, Attribute>;
|
|
11
13
|
constructor(props?: ApplicationDetailsProperties);
|
|
12
14
|
}
|
|
@@ -28,20 +28,20 @@ var ApplicationDetails = /** @class */ (function (_super) {
|
|
|
28
28
|
_this.initAttributes(props);
|
|
29
29
|
return _this;
|
|
30
30
|
}
|
|
31
|
+
ApplicationDetails.attributes = {
|
|
32
|
+
applicationName: attributes_1.default.String({
|
|
33
|
+
modelKey: 'applicationName',
|
|
34
|
+
jsonKey: 'application_name',
|
|
35
|
+
}),
|
|
36
|
+
iconUrl: attributes_1.default.String({
|
|
37
|
+
modelKey: 'iconUrl',
|
|
38
|
+
jsonKey: 'icon_url',
|
|
39
|
+
}),
|
|
40
|
+
redirectUris: attributes_1.default.StringList({
|
|
41
|
+
modelKey: 'redirectUris',
|
|
42
|
+
jsonKey: 'redirect_uris',
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
31
45
|
return ApplicationDetails;
|
|
32
46
|
}(model_1.default));
|
|
33
47
|
exports.default = ApplicationDetails;
|
|
34
|
-
ApplicationDetails.attributes = {
|
|
35
|
-
applicationName: attributes_1.default.String({
|
|
36
|
-
modelKey: 'applicationName',
|
|
37
|
-
jsonKey: 'application_name',
|
|
38
|
-
}),
|
|
39
|
-
iconUrl: attributes_1.default.String({
|
|
40
|
-
modelKey: 'iconUrl',
|
|
41
|
-
jsonKey: 'icon_url',
|
|
42
|
-
}),
|
|
43
|
-
redirectUris: attributes_1.default.StringList({
|
|
44
|
-
modelKey: 'redirectUris',
|
|
45
|
-
jsonKey: 'redirect_uris',
|
|
46
|
-
}),
|
|
47
|
-
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Model from './model';
|
|
2
|
-
import {
|
|
2
|
+
import { Attribute } from './attributes';
|
|
3
|
+
import { FreeBusyProperties, TimeSlot, TimeSlotProperties, FreeBusyCalendarProperties } from './free-busy';
|
|
3
4
|
export declare enum RoundRobin {
|
|
4
5
|
MaxAvailability = "max-availability",
|
|
5
6
|
MaxFairness = "max-fairness"
|
|
@@ -22,13 +23,15 @@ declare type AvailabilityQuery = {
|
|
|
22
23
|
tentativeBusy?: boolean;
|
|
23
24
|
freeBusy?: FreeBusyProperties[];
|
|
24
25
|
openHours?: OpenHoursProperties[];
|
|
26
|
+
calendars?: FreeBusyCalendarProperties[];
|
|
25
27
|
};
|
|
26
28
|
export declare type SingleAvailabilityQuery = AvailabilityQuery & {
|
|
27
|
-
emails
|
|
29
|
+
emails?: string[];
|
|
30
|
+
eventCollectionId?: string;
|
|
28
31
|
roundRobin?: RoundRobin;
|
|
29
32
|
};
|
|
30
33
|
export declare type ConsecutiveAvailabilityQuery = AvailabilityQuery & {
|
|
31
|
-
emails
|
|
34
|
+
emails?: Array<string[]>;
|
|
32
35
|
};
|
|
33
36
|
export declare type OpenHoursProperties = {
|
|
34
37
|
emails: string[];
|
|
@@ -44,6 +47,7 @@ export declare class OpenHours extends Model implements OpenHoursProperties {
|
|
|
44
47
|
timezone: string;
|
|
45
48
|
start: string;
|
|
46
49
|
end: string;
|
|
50
|
+
static attributes: Record<string, Attribute>;
|
|
47
51
|
constructor(props?: OpenHoursProperties);
|
|
48
52
|
}
|
|
49
53
|
export declare type CalendarConsecutiveAvailabilityProperties = {
|
|
@@ -55,6 +59,7 @@ export declare class CalendarConsecutiveAvailability extends Model implements Ca
|
|
|
55
59
|
emails: string[];
|
|
56
60
|
startTime: number;
|
|
57
61
|
endTime: number;
|
|
62
|
+
static attributes: Record<string, Attribute>;
|
|
58
63
|
constructor(props?: CalendarConsecutiveAvailabilityProperties);
|
|
59
64
|
}
|
|
60
65
|
export declare type CalendarAvailabilityProperties = {
|
|
@@ -63,6 +68,7 @@ export declare type CalendarAvailabilityProperties = {
|
|
|
63
68
|
export default class CalendarAvailability extends Model implements CalendarAvailabilityProperties {
|
|
64
69
|
object: string;
|
|
65
70
|
timeSlots: TimeSlot[];
|
|
71
|
+
static attributes: Record<string, Attribute>;
|
|
66
72
|
constructor(props?: CalendarAvailabilityProperties);
|
|
67
73
|
}
|
|
68
74
|
export {};
|
|
@@ -47,30 +47,30 @@ var OpenHours = /** @class */ (function (_super) {
|
|
|
47
47
|
_this.initAttributes(props);
|
|
48
48
|
return _this;
|
|
49
49
|
}
|
|
50
|
+
OpenHours.attributes = {
|
|
51
|
+
objectType: attributes_1.default.String({
|
|
52
|
+
modelKey: 'objectType',
|
|
53
|
+
jsonKey: 'object_type',
|
|
54
|
+
}),
|
|
55
|
+
emails: attributes_1.default.StringList({
|
|
56
|
+
modelKey: 'emails',
|
|
57
|
+
}),
|
|
58
|
+
days: attributes_1.default.NumberList({
|
|
59
|
+
modelKey: 'days',
|
|
60
|
+
}),
|
|
61
|
+
timezone: attributes_1.default.String({
|
|
62
|
+
modelKey: 'timezone',
|
|
63
|
+
}),
|
|
64
|
+
start: attributes_1.default.String({
|
|
65
|
+
modelKey: 'start',
|
|
66
|
+
}),
|
|
67
|
+
end: attributes_1.default.String({
|
|
68
|
+
modelKey: 'end',
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
50
71
|
return OpenHours;
|
|
51
72
|
}(model_1.default));
|
|
52
73
|
exports.OpenHours = OpenHours;
|
|
53
|
-
OpenHours.attributes = {
|
|
54
|
-
objectType: attributes_1.default.String({
|
|
55
|
-
modelKey: 'objectType',
|
|
56
|
-
jsonKey: 'object_type',
|
|
57
|
-
}),
|
|
58
|
-
emails: attributes_1.default.StringList({
|
|
59
|
-
modelKey: 'emails',
|
|
60
|
-
}),
|
|
61
|
-
days: attributes_1.default.NumberList({
|
|
62
|
-
modelKey: 'days',
|
|
63
|
-
}),
|
|
64
|
-
timezone: attributes_1.default.String({
|
|
65
|
-
modelKey: 'timezone',
|
|
66
|
-
}),
|
|
67
|
-
start: attributes_1.default.String({
|
|
68
|
-
modelKey: 'start',
|
|
69
|
-
}),
|
|
70
|
-
end: attributes_1.default.String({
|
|
71
|
-
modelKey: 'end',
|
|
72
|
-
}),
|
|
73
|
-
};
|
|
74
74
|
var CalendarConsecutiveAvailability = /** @class */ (function (_super) {
|
|
75
75
|
__extends(CalendarConsecutiveAvailability, _super);
|
|
76
76
|
function CalendarConsecutiveAvailability(props) {
|
|
@@ -81,22 +81,22 @@ var CalendarConsecutiveAvailability = /** @class */ (function (_super) {
|
|
|
81
81
|
_this.initAttributes(props);
|
|
82
82
|
return _this;
|
|
83
83
|
}
|
|
84
|
+
CalendarConsecutiveAvailability.attributes = {
|
|
85
|
+
emails: attributes_1.default.StringList({
|
|
86
|
+
modelKey: 'emails',
|
|
87
|
+
}),
|
|
88
|
+
startTime: attributes_1.default.Number({
|
|
89
|
+
modelKey: 'startTime',
|
|
90
|
+
jsonKey: 'start_time',
|
|
91
|
+
}),
|
|
92
|
+
endTime: attributes_1.default.Number({
|
|
93
|
+
modelKey: 'endTime',
|
|
94
|
+
jsonKey: 'end_time',
|
|
95
|
+
}),
|
|
96
|
+
};
|
|
84
97
|
return CalendarConsecutiveAvailability;
|
|
85
98
|
}(model_1.default));
|
|
86
99
|
exports.CalendarConsecutiveAvailability = CalendarConsecutiveAvailability;
|
|
87
|
-
CalendarConsecutiveAvailability.attributes = {
|
|
88
|
-
emails: attributes_1.default.StringList({
|
|
89
|
-
modelKey: 'emails',
|
|
90
|
-
}),
|
|
91
|
-
startTime: attributes_1.default.Number({
|
|
92
|
-
modelKey: 'startTime',
|
|
93
|
-
jsonKey: 'start_time',
|
|
94
|
-
}),
|
|
95
|
-
endTime: attributes_1.default.Number({
|
|
96
|
-
modelKey: 'endTime',
|
|
97
|
-
jsonKey: 'end_time',
|
|
98
|
-
}),
|
|
99
|
-
};
|
|
100
100
|
var CalendarAvailability = /** @class */ (function (_super) {
|
|
101
101
|
__extends(CalendarAvailability, _super);
|
|
102
102
|
function CalendarAvailability(props) {
|
|
@@ -106,13 +106,13 @@ var CalendarAvailability = /** @class */ (function (_super) {
|
|
|
106
106
|
_this.initAttributes(props);
|
|
107
107
|
return _this;
|
|
108
108
|
}
|
|
109
|
+
CalendarAvailability.attributes = {
|
|
110
|
+
timeSlots: attributes_1.default.Collection({
|
|
111
|
+
modelKey: 'timeSlots',
|
|
112
|
+
jsonKey: 'time_slots',
|
|
113
|
+
itemClass: free_busy_1.TimeSlot,
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
109
116
|
return CalendarAvailability;
|
|
110
117
|
}(model_1.default));
|
|
111
118
|
exports.default = CalendarAvailability;
|
|
112
|
-
CalendarAvailability.attributes = {
|
|
113
|
-
timeSlots: attributes_1.default.Collection({
|
|
114
|
-
modelKey: 'timeSlots',
|
|
115
|
-
jsonKey: 'time_slots',
|
|
116
|
-
itemClass: free_busy_1.TimeSlot,
|
|
117
|
-
}),
|
|
118
|
-
};
|
|
@@ -12,4 +12,6 @@ export default class CalendarRestfulModelCollection extends RestfulModelCollecti
|
|
|
12
12
|
consecutiveAvailability(options: ConsecutiveAvailabilityQuery, callback?: (error: Error | null, data?: {
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
}) => void): Promise<CalendarConsecutiveAvailability>;
|
|
15
|
+
private buildAvailabilityPayload;
|
|
16
|
+
private queryIsValid;
|
|
15
17
|
}
|
|
@@ -12,6 +12,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
12
12
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
13
|
};
|
|
14
14
|
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
15
26
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
28
|
};
|
|
@@ -25,7 +36,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
37
|
var calendar_1 = __importDefault(require("./calendar"));
|
|
27
38
|
var restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
|
|
28
|
-
var free_busy_1 =
|
|
39
|
+
var free_busy_1 = __importStar(require("./free-busy"));
|
|
29
40
|
var calendar_availability_1 = __importStar(require("./calendar-availability"));
|
|
30
41
|
var CalendarRestfulModelCollection = /** @class */ (function (_super) {
|
|
31
42
|
__extends(CalendarRestfulModelCollection, _super);
|
|
@@ -36,6 +47,10 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
|
|
|
36
47
|
return _this;
|
|
37
48
|
}
|
|
38
49
|
CalendarRestfulModelCollection.prototype.freeBusy = function (options, callback) {
|
|
50
|
+
this.queryIsValid(options);
|
|
51
|
+
var calendarsJson = options.calendars
|
|
52
|
+
? options.calendars.map(function (cal) { return new free_busy_1.FreeBusyCalendar(cal).toJSON(true); })
|
|
53
|
+
: [];
|
|
39
54
|
return this.connection
|
|
40
55
|
.request({
|
|
41
56
|
method: 'POST',
|
|
@@ -43,7 +58,8 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
|
|
|
43
58
|
body: {
|
|
44
59
|
start_time: options.startTime.toString(),
|
|
45
60
|
end_time: options.endTime.toString(),
|
|
46
|
-
emails: options.emails,
|
|
61
|
+
emails: options.emails || [],
|
|
62
|
+
calendars: calendarsJson,
|
|
47
63
|
},
|
|
48
64
|
})
|
|
49
65
|
.then(function (json) {
|
|
@@ -65,29 +81,12 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
|
|
|
65
81
|
});
|
|
66
82
|
};
|
|
67
83
|
CalendarRestfulModelCollection.prototype.availability = function (options, callback) {
|
|
68
|
-
|
|
69
|
-
var freeBusyJson = options.freeBusy
|
|
70
|
-
? options.freeBusy.map(function (fb) { return new free_busy_1.default(fb).toJSON(true); })
|
|
71
|
-
: [];
|
|
72
|
-
var openHoursJson = options.openHours
|
|
73
|
-
? options.openHours.map(function (oh) { return new calendar_availability_1.OpenHours(oh).toJSON(true); })
|
|
74
|
-
: [];
|
|
84
|
+
this.queryIsValid(options);
|
|
75
85
|
return this.connection
|
|
76
86
|
.request({
|
|
77
87
|
method: 'POST',
|
|
78
88
|
path: "/calendars/availability",
|
|
79
|
-
body: {
|
|
80
|
-
emails: options.emails,
|
|
81
|
-
duration_minutes: options.duration,
|
|
82
|
-
interval_minutes: options.interval,
|
|
83
|
-
start_time: options.startTime,
|
|
84
|
-
end_time: options.endTime,
|
|
85
|
-
buffer: options.buffer,
|
|
86
|
-
tentative_busy: options.tentativeBusy,
|
|
87
|
-
round_robin: options.roundRobin,
|
|
88
|
-
free_busy: freeBusyJson,
|
|
89
|
-
open_hours: openHoursJson,
|
|
90
|
-
},
|
|
89
|
+
body: __assign(__assign({}, this.buildAvailabilityPayload(options)), { event_collection_id: options.eventCollectionId, round_robin: options.roundRobin }),
|
|
91
90
|
})
|
|
92
91
|
.then(function (json) {
|
|
93
92
|
if (callback) {
|
|
@@ -103,48 +102,34 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
|
|
|
103
102
|
});
|
|
104
103
|
};
|
|
105
104
|
CalendarRestfulModelCollection.prototype.consecutiveAvailability = function (options, callback) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
105
|
+
this.queryIsValid(options);
|
|
106
|
+
if (options.emails) {
|
|
107
|
+
// If open hours contains any emails not present in the main emails key
|
|
108
|
+
// or in the free busy email list as this would raise an error on the API side
|
|
109
|
+
var freeBusyEmails = options.freeBusy
|
|
110
|
+
? options.freeBusy.map(function (fb) { return fb.email; })
|
|
111
|
+
: [];
|
|
112
|
+
if (options.openHours) {
|
|
113
|
+
for (var _i = 0, _a = options.openHours; _i < _a.length; _i++) {
|
|
114
|
+
var openHour = _a[_i];
|
|
115
|
+
var _loop_1 = function (email) {
|
|
116
|
+
if (!options.emails.some(function (row) { return row.includes(email); }) &&
|
|
117
|
+
!freeBusyEmails.includes(email)) {
|
|
118
|
+
throw new Error('Open Hours cannot contain an email not present in the main email list or the free busy email list.');
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
for (var _b = 0, _c = openHour.emails; _b < _c.length; _b++) {
|
|
122
|
+
var email = _c[_b];
|
|
123
|
+
_loop_1(email);
|
|
118
124
|
}
|
|
119
|
-
};
|
|
120
|
-
for (var _b = 0, _c = openHour.emails; _b < _c.length; _b++) {
|
|
121
|
-
var email = _c[_b];
|
|
122
|
-
_loop_1(email);
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
// Instantiate objects from properties to get JSON formatted for the API call
|
|
127
|
-
var freeBusyJson = options.freeBusy
|
|
128
|
-
? options.freeBusy.map(function (fb) { return new free_busy_1.default(fb).toJSON(true); })
|
|
129
|
-
: [];
|
|
130
|
-
var openHoursJson = options.openHours
|
|
131
|
-
? options.openHours.map(function (oh) { return new calendar_availability_1.OpenHours(oh).toJSON(true); })
|
|
132
|
-
: [];
|
|
133
128
|
return this.connection
|
|
134
129
|
.request({
|
|
135
130
|
method: 'POST',
|
|
136
131
|
path: "/calendars/availability/consecutive",
|
|
137
|
-
body:
|
|
138
|
-
emails: options.emails,
|
|
139
|
-
duration_minutes: options.duration,
|
|
140
|
-
interval_minutes: options.interval,
|
|
141
|
-
start_time: options.startTime,
|
|
142
|
-
end_time: options.endTime,
|
|
143
|
-
buffer: options.buffer,
|
|
144
|
-
tentative_busy: options.tentativeBusy,
|
|
145
|
-
free_busy: freeBusyJson,
|
|
146
|
-
open_hours: openHoursJson,
|
|
147
|
-
},
|
|
132
|
+
body: this.buildAvailabilityPayload(options),
|
|
148
133
|
})
|
|
149
134
|
.then(function (json) {
|
|
150
135
|
if (callback) {
|
|
@@ -159,6 +144,38 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
|
|
|
159
144
|
return Promise.reject(err);
|
|
160
145
|
});
|
|
161
146
|
};
|
|
147
|
+
CalendarRestfulModelCollection.prototype.buildAvailabilityPayload = function (options) {
|
|
148
|
+
// Instantiate objects from properties to get JSON formatted for the API call
|
|
149
|
+
var freeBusyJson = options.freeBusy
|
|
150
|
+
? options.freeBusy.map(function (fb) { return new free_busy_1.default(fb).toJSON(true); })
|
|
151
|
+
: [];
|
|
152
|
+
var openHoursJson = options.openHours
|
|
153
|
+
? options.openHours.map(function (oh) { return new calendar_availability_1.OpenHours(oh).toJSON(true); })
|
|
154
|
+
: [];
|
|
155
|
+
var calendarsJson = options.calendars
|
|
156
|
+
? options.calendars.map(function (cal) { return new free_busy_1.FreeBusyCalendar(cal).toJSON(true); })
|
|
157
|
+
: [];
|
|
158
|
+
return {
|
|
159
|
+
emails: options.emails,
|
|
160
|
+
duration_minutes: options.duration,
|
|
161
|
+
interval_minutes: options.interval,
|
|
162
|
+
start_time: options.startTime,
|
|
163
|
+
end_time: options.endTime,
|
|
164
|
+
buffer: options.buffer,
|
|
165
|
+
tentative_busy: options.tentativeBusy,
|
|
166
|
+
free_busy: freeBusyJson,
|
|
167
|
+
open_hours: openHoursJson,
|
|
168
|
+
calendars: calendarsJson,
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
// Helper function to check if a query is valid
|
|
172
|
+
CalendarRestfulModelCollection.prototype.queryIsValid = function (query) {
|
|
173
|
+
if ((!query.emails || query.emails.length == 0) &&
|
|
174
|
+
(!query.calendars || query.calendars.length == 0)) {
|
|
175
|
+
throw new Error("Must set either 'emails' or 'calendars' in the query.");
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
178
|
+
};
|
|
162
179
|
return CalendarRestfulModelCollection;
|
|
163
180
|
}(restful_model_collection_1.default));
|
|
164
181
|
exports.default = CalendarRestfulModelCollection;
|
package/lib/models/calendar.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import RestfulModel, { SaveCallback } from './restful-model';
|
|
2
2
|
import { GetCallback } from './model-collection';
|
|
3
|
+
import { Attribute } from './attributes';
|
|
3
4
|
import NylasConnection from '../nylas-connection';
|
|
4
5
|
import JobStatus from './job-status';
|
|
5
6
|
export declare type CalendarProperties = {
|
|
@@ -21,6 +22,8 @@ export default class Calendar extends RestfulModel implements CalendarProperties
|
|
|
21
22
|
isPrimary?: boolean;
|
|
22
23
|
jobStatusId?: string;
|
|
23
24
|
metadata?: object;
|
|
25
|
+
static collectionName: string;
|
|
26
|
+
static attributes: Record<string, Attribute>;
|
|
24
27
|
constructor(connection: NylasConnection, props?: CalendarProperties);
|
|
25
28
|
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
26
29
|
saveRequestBody(): Record<string, unknown>;
|
package/lib/models/calendar.js
CHANGED
|
@@ -64,30 +64,30 @@ var Calendar = /** @class */ (function (_super) {
|
|
|
64
64
|
}
|
|
65
65
|
return this.connection.jobStatuses.find(this.jobStatusId, callback);
|
|
66
66
|
};
|
|
67
|
+
Calendar.collectionName = 'calendars';
|
|
68
|
+
Calendar.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
|
|
69
|
+
modelKey: 'name',
|
|
70
|
+
}), description: attributes_1.default.String({
|
|
71
|
+
modelKey: 'description',
|
|
72
|
+
}), readOnly: attributes_1.default.Boolean({
|
|
73
|
+
modelKey: 'readOnly',
|
|
74
|
+
jsonKey: 'read_only',
|
|
75
|
+
readOnly: true,
|
|
76
|
+
}), location: attributes_1.default.String({
|
|
77
|
+
modelKey: 'location',
|
|
78
|
+
}), timezone: attributes_1.default.String({
|
|
79
|
+
modelKey: 'timezone',
|
|
80
|
+
}), isPrimary: attributes_1.default.Boolean({
|
|
81
|
+
modelKey: 'isPrimary',
|
|
82
|
+
jsonKey: 'is_primary',
|
|
83
|
+
readOnly: true,
|
|
84
|
+
}), jobStatusId: attributes_1.default.String({
|
|
85
|
+
modelKey: 'jobStatusId',
|
|
86
|
+
jsonKey: 'job_status_id',
|
|
87
|
+
readOnly: true,
|
|
88
|
+
}), metadata: attributes_1.default.Object({
|
|
89
|
+
modelKey: 'metadata',
|
|
90
|
+
}) });
|
|
67
91
|
return Calendar;
|
|
68
92
|
}(restful_model_1.default));
|
|
69
93
|
exports.default = Calendar;
|
|
70
|
-
Calendar.collectionName = 'calendars';
|
|
71
|
-
Calendar.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
|
|
72
|
-
modelKey: 'name',
|
|
73
|
-
}), description: attributes_1.default.String({
|
|
74
|
-
modelKey: 'description',
|
|
75
|
-
}), readOnly: attributes_1.default.Boolean({
|
|
76
|
-
modelKey: 'readOnly',
|
|
77
|
-
jsonKey: 'read_only',
|
|
78
|
-
readOnly: true,
|
|
79
|
-
}), location: attributes_1.default.String({
|
|
80
|
-
modelKey: 'location',
|
|
81
|
-
}), timezone: attributes_1.default.String({
|
|
82
|
-
modelKey: 'timezone',
|
|
83
|
-
}), isPrimary: attributes_1.default.Boolean({
|
|
84
|
-
modelKey: 'isPrimary',
|
|
85
|
-
jsonKey: 'is_primary',
|
|
86
|
-
readOnly: true,
|
|
87
|
-
}), jobStatusId: attributes_1.default.String({
|
|
88
|
-
modelKey: 'jobStatusId',
|
|
89
|
-
jsonKey: 'job_status_id',
|
|
90
|
-
readOnly: true,
|
|
91
|
-
}), metadata: attributes_1.default.Object({
|
|
92
|
-
modelKey: 'metadata',
|
|
93
|
-
}) });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import RestfulModel, { SaveCallback } from './restful-model';
|
|
2
|
+
import { Attribute } from './attributes';
|
|
2
3
|
import NylasConnection from '../nylas-connection';
|
|
3
4
|
export declare type ComponentProperties = {
|
|
4
5
|
name?: string;
|
|
@@ -27,6 +28,8 @@ export default class Component extends RestfulModel implements ComponentProperti
|
|
|
27
28
|
accessToken?: string;
|
|
28
29
|
createdAt?: Date;
|
|
29
30
|
updatedAt?: Date;
|
|
31
|
+
static collectionName: string;
|
|
32
|
+
static attributes: Record<string, Attribute>;
|
|
30
33
|
constructor(connection: NylasConnection, props?: ComponentProperties);
|
|
31
34
|
saveEndpoint(): string;
|
|
32
35
|
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|