nylas 5.9.0 → 5.10.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/calendar.d.ts +2 -0
- package/lib/models/calendar.js +3 -0
- package/lib/models/event-notification.d.ts +11 -0
- package/lib/models/event-notification.js +65 -0
- package/lib/models/event.d.ts +2 -0
- package/lib/models/event.js +4 -0
- package/lib/models/management-account.d.ts +7 -0
- package/lib/models/management-account.js +14 -0
- package/lib/models/message.d.ts +1 -0
- package/lib/models/message.js +3 -0
- package/lib/models/restful-model-collection.d.ts +1 -0
- package/lib/models/restful-model-collection.js +5 -0
- package/lib/models/restful-model.d.ts +1 -0
- package/lib/models/restful-model.js +2 -0
- package/lib/models/scheduler-booking-request.d.ts +30 -0
- package/lib/models/scheduler-booking-request.js +133 -0
- package/lib/models/scheduler-restful-model-collection.d.ts +25 -0
- package/lib/models/scheduler-restful-model-collection.js +136 -0
- package/lib/models/scheduler-time-slot.d.ts +9 -0
- package/lib/models/scheduler-time-slot.js +52 -0
- package/lib/models/scheduler.d.ts +15 -2
- package/lib/models/scheduler.js +38 -2
- package/lib/nylas-connection.d.ts +2 -3
- package/lib/nylas-connection.js +3 -3
- package/package.json +1 -1
package/lib/models/calendar.d.ts
CHANGED
|
@@ -8,12 +8,14 @@ export default class Calendar extends RestfulModel {
|
|
|
8
8
|
timezone?: string;
|
|
9
9
|
isPrimary?: boolean;
|
|
10
10
|
jobStatusId?: string;
|
|
11
|
+
metadata?: object;
|
|
11
12
|
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
12
13
|
saveRequestBody(): {
|
|
13
14
|
name: any;
|
|
14
15
|
description: any;
|
|
15
16
|
location: any;
|
|
16
17
|
timezone: any;
|
|
18
|
+
metadata: any;
|
|
17
19
|
};
|
|
18
20
|
getJobStatus(callback?: GetCallback): Promise<import("./job-status").default>;
|
|
19
21
|
}
|
package/lib/models/calendar.js
CHANGED
|
@@ -45,6 +45,7 @@ var Calendar = /** @class */ (function (_super) {
|
|
|
45
45
|
description: calendarJSON.description,
|
|
46
46
|
location: calendarJSON.location,
|
|
47
47
|
timezone: calendarJSON.timezone,
|
|
48
|
+
metadata: calendarJSON.metadata,
|
|
48
49
|
};
|
|
49
50
|
};
|
|
50
51
|
Calendar.prototype.getJobStatus = function (callback) {
|
|
@@ -78,4 +79,6 @@ Calendar.attributes = __assign(__assign({}, restful_model_1.default.attributes),
|
|
|
78
79
|
}), jobStatusId: attributes_1.default.String({
|
|
79
80
|
modelKey: 'jobStatusId',
|
|
80
81
|
jsonKey: 'job_status_id',
|
|
82
|
+
}), metadata: attributes_1.default.Object({
|
|
83
|
+
modelKey: 'metadata',
|
|
81
84
|
}) });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import RestfulModel from './restful-model';
|
|
2
|
+
export declare class EventNotification extends RestfulModel {
|
|
3
|
+
type?: string;
|
|
4
|
+
minutesBeforeEvent?: number;
|
|
5
|
+
url?: string;
|
|
6
|
+
payload?: string;
|
|
7
|
+
subject?: string;
|
|
8
|
+
body?: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
toJSON(): any;
|
|
11
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.EventNotification = void 0;
|
|
20
|
+
var restful_model_1 = __importDefault(require("./restful-model"));
|
|
21
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
22
|
+
var EventNotification = /** @class */ (function (_super) {
|
|
23
|
+
__extends(EventNotification, _super);
|
|
24
|
+
function EventNotification() {
|
|
25
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
26
|
+
}
|
|
27
|
+
EventNotification.prototype.toJSON = function () {
|
|
28
|
+
return {
|
|
29
|
+
type: this.type,
|
|
30
|
+
minutes_before_event: this.minutesBeforeEvent,
|
|
31
|
+
url: this.url,
|
|
32
|
+
payload: this.payload,
|
|
33
|
+
subject: this.subject,
|
|
34
|
+
body: this.body,
|
|
35
|
+
message: this.message,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
return EventNotification;
|
|
39
|
+
}(restful_model_1.default));
|
|
40
|
+
exports.EventNotification = EventNotification;
|
|
41
|
+
EventNotification.collectionName = 'event_notification';
|
|
42
|
+
EventNotification.attributes = {
|
|
43
|
+
type: attributes_1.default.String({
|
|
44
|
+
modelKey: 'type',
|
|
45
|
+
}),
|
|
46
|
+
minutesBeforeEvent: attributes_1.default.Number({
|
|
47
|
+
modelKey: 'minutesBeforeEvent',
|
|
48
|
+
jsonKey: 'minutes_before_event',
|
|
49
|
+
}),
|
|
50
|
+
url: attributes_1.default.String({
|
|
51
|
+
modelKey: 'url',
|
|
52
|
+
}),
|
|
53
|
+
payload: attributes_1.default.String({
|
|
54
|
+
modelKey: 'payload',
|
|
55
|
+
}),
|
|
56
|
+
subject: attributes_1.default.String({
|
|
57
|
+
modelKey: 'subject',
|
|
58
|
+
}),
|
|
59
|
+
body: attributes_1.default.String({
|
|
60
|
+
modelKey: 'body',
|
|
61
|
+
}),
|
|
62
|
+
message: attributes_1.default.String({
|
|
63
|
+
modelKey: 'message',
|
|
64
|
+
}),
|
|
65
|
+
};
|
package/lib/models/event.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import RestfulModel, { SaveCallback } from './restful-model';
|
|
2
2
|
import EventParticipant from './event-participant';
|
|
3
3
|
import { EventConferencing } from './event-conferencing';
|
|
4
|
+
import { EventNotification } from './event-notification';
|
|
4
5
|
export default class Event extends RestfulModel {
|
|
5
6
|
calendarId?: string;
|
|
6
7
|
iCalUID?: string;
|
|
@@ -29,6 +30,7 @@ export default class Event extends RestfulModel {
|
|
|
29
30
|
masterEventId?: string;
|
|
30
31
|
originalStartTime?: number;
|
|
31
32
|
conferencing?: EventConferencing;
|
|
33
|
+
notifications?: EventNotification[];
|
|
32
34
|
metadata?: object;
|
|
33
35
|
jobStatusId?: string;
|
|
34
36
|
get start(): string | number | undefined;
|
package/lib/models/event.js
CHANGED
|
@@ -31,6 +31,7 @@ var restful_model_1 = __importDefault(require("./restful-model"));
|
|
|
31
31
|
var attributes_1 = __importDefault(require("./attributes"));
|
|
32
32
|
var event_participant_1 = __importDefault(require("./event-participant"));
|
|
33
33
|
var event_conferencing_1 = require("./event-conferencing");
|
|
34
|
+
var event_notification_1 = require("./event-notification");
|
|
34
35
|
var Event = /** @class */ (function (_super) {
|
|
35
36
|
__extends(Event, _super);
|
|
36
37
|
function Event() {
|
|
@@ -197,6 +198,9 @@ Event.attributes = __assign(__assign({}, restful_model_1.default.attributes), {
|
|
|
197
198
|
}), conferencing: attributes_1.default.Object({
|
|
198
199
|
modelKey: 'conferencing',
|
|
199
200
|
itemClass: event_conferencing_1.EventConferencing,
|
|
201
|
+
}), notifications: attributes_1.default.Collection({
|
|
202
|
+
modelKey: 'notifications',
|
|
203
|
+
itemClass: event_notification_1.EventNotification,
|
|
200
204
|
}), metadata: attributes_1.default.Object({
|
|
201
205
|
modelKey: 'metadata',
|
|
202
206
|
}), jobStatusId: attributes_1.default.String({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ManagementModel from './management-model';
|
|
2
|
+
import { SaveCallback } from './restful-model';
|
|
2
3
|
export default class ManagementAccount extends ManagementModel {
|
|
3
4
|
billingState?: string;
|
|
4
5
|
emailAddress?: string;
|
|
@@ -6,9 +7,15 @@ export default class ManagementAccount extends ManagementModel {
|
|
|
6
7
|
provider?: string;
|
|
7
8
|
syncState?: string;
|
|
8
9
|
trial?: boolean;
|
|
10
|
+
metadata?: object;
|
|
9
11
|
upgrade(): Promise<any>;
|
|
10
12
|
downgrade(): Promise<any>;
|
|
11
13
|
revokeAll(keepAccessToken?: string): Promise<any>;
|
|
12
14
|
ipAddresses(): Promise<any>;
|
|
13
15
|
tokenInfo(accessToken?: string): Promise<any>;
|
|
16
|
+
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
17
|
+
saveRequestBody(): {
|
|
18
|
+
metadata: object | undefined;
|
|
19
|
+
};
|
|
20
|
+
saveEndpoint(): string;
|
|
14
21
|
}
|
|
@@ -78,6 +78,18 @@ var ManagementAccount = /** @class */ (function (_super) {
|
|
|
78
78
|
})
|
|
79
79
|
.catch(function (err) { return Promise.reject(err); });
|
|
80
80
|
};
|
|
81
|
+
ManagementAccount.prototype.save = function (params, callback) {
|
|
82
|
+
if (params === void 0) { params = {}; }
|
|
83
|
+
return this._save(params, callback);
|
|
84
|
+
};
|
|
85
|
+
ManagementAccount.prototype.saveRequestBody = function () {
|
|
86
|
+
return {
|
|
87
|
+
metadata: this.metadata,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
ManagementAccount.prototype.saveEndpoint = function () {
|
|
91
|
+
return "/a/" + this.connection.clientId + "/accounts";
|
|
92
|
+
};
|
|
81
93
|
return ManagementAccount;
|
|
82
94
|
}(management_model_1.default));
|
|
83
95
|
exports.default = ManagementAccount;
|
|
@@ -98,4 +110,6 @@ ManagementAccount.attributes = __assign(__assign({}, management_model_1.default.
|
|
|
98
110
|
jsonKey: 'sync_state',
|
|
99
111
|
}), trial: attributes_1.default.Boolean({
|
|
100
112
|
modelKey: 'trial',
|
|
113
|
+
}), metadata: attributes_1.default.Object({
|
|
114
|
+
modelKey: 'metadata',
|
|
101
115
|
}) });
|
package/lib/models/message.d.ts
CHANGED
package/lib/models/message.js
CHANGED
|
@@ -95,6 +95,7 @@ var Message = /** @class */ (function (_super) {
|
|
|
95
95
|
}
|
|
96
96
|
json['starred'] = this.starred;
|
|
97
97
|
json['unread'] = this.unread;
|
|
98
|
+
json['metadata'] = this.metadata;
|
|
98
99
|
return json;
|
|
99
100
|
};
|
|
100
101
|
Message.prototype.save = function (params, callback) {
|
|
@@ -149,6 +150,8 @@ Message.attributes = __assign(__assign({}, restful_model_1.default.attributes),
|
|
|
149
150
|
}), labels: attributes_1.default.Collection({
|
|
150
151
|
modelKey: 'labels',
|
|
151
152
|
itemClass: folder_1.Label,
|
|
153
|
+
}), metadata: attributes_1.default.Object({
|
|
154
|
+
modelKey: 'metadata',
|
|
152
155
|
}), headers: attributes_1.default.Object({
|
|
153
156
|
modelKey: 'headers',
|
|
154
157
|
}) });
|
|
@@ -4,6 +4,7 @@ export declare type GetCallback = (error: Error | null, result?: RestfulModel) =
|
|
|
4
4
|
export default class RestfulModelCollection<T extends RestfulModel> {
|
|
5
5
|
connection: NylasConnection;
|
|
6
6
|
modelClass: typeof RestfulModel;
|
|
7
|
+
baseUrl?: string;
|
|
7
8
|
constructor(modelClass: typeof RestfulModel, connection: NylasConnection);
|
|
8
9
|
forEach(params: {
|
|
9
10
|
[key: string]: any;
|
|
@@ -70,6 +70,7 @@ var RestfulModelCollection = /** @class */ (function () {
|
|
|
70
70
|
method: 'GET',
|
|
71
71
|
path: this.path(),
|
|
72
72
|
qs: __assign({ view: 'count' }, params),
|
|
73
|
+
baseUrl: this.baseUrl,
|
|
73
74
|
})
|
|
74
75
|
.then(function (json) {
|
|
75
76
|
if (callback) {
|
|
@@ -220,6 +221,7 @@ var RestfulModelCollection = /** @class */ (function () {
|
|
|
220
221
|
qs: qs,
|
|
221
222
|
body: body,
|
|
222
223
|
path: this.path() + "/" + item.id,
|
|
224
|
+
baseUrl: this.baseUrl,
|
|
223
225
|
})
|
|
224
226
|
.then(function (data) {
|
|
225
227
|
if (callback) {
|
|
@@ -284,6 +286,7 @@ var RestfulModelCollection = /** @class */ (function () {
|
|
|
284
286
|
method: 'GET',
|
|
285
287
|
path: path,
|
|
286
288
|
qs: __assign(__assign({}, params), { offset: offset, limit: limit }),
|
|
289
|
+
baseUrl: this.baseUrl,
|
|
287
290
|
});
|
|
288
291
|
}
|
|
289
292
|
return this._getModelCollection(params, offset, limit, path);
|
|
@@ -299,6 +302,7 @@ var RestfulModelCollection = /** @class */ (function () {
|
|
|
299
302
|
method: 'GET',
|
|
300
303
|
path: this.path() + "/" + id,
|
|
301
304
|
qs: params,
|
|
305
|
+
baseUrl: this.baseUrl,
|
|
302
306
|
})
|
|
303
307
|
.then(function (json) {
|
|
304
308
|
var model = _this._createModel(json);
|
|
@@ -312,6 +316,7 @@ var RestfulModelCollection = /** @class */ (function () {
|
|
|
312
316
|
method: 'GET',
|
|
313
317
|
path: path,
|
|
314
318
|
qs: __assign(__assign({}, params), { offset: offset, limit: limit }),
|
|
319
|
+
baseUrl: this.baseUrl,
|
|
315
320
|
})
|
|
316
321
|
.then(function (jsonArray) {
|
|
317
322
|
var models = jsonArray.map(function (json) {
|
|
@@ -93,6 +93,7 @@ var RestfulModel = /** @class */ (function () {
|
|
|
93
93
|
path: this.id
|
|
94
94
|
? this.saveEndpoint() + "/" + this.id
|
|
95
95
|
: "" + this.saveEndpoint(),
|
|
96
|
+
baseUrl: this.baseUrl,
|
|
96
97
|
})
|
|
97
98
|
.then(function (json) {
|
|
98
99
|
_this.fromJSON(json);
|
|
@@ -117,6 +118,7 @@ var RestfulModel = /** @class */ (function () {
|
|
|
117
118
|
method: 'GET',
|
|
118
119
|
path: "/" + collectionName + "/" + this.id + pathSuffix,
|
|
119
120
|
qs: params,
|
|
121
|
+
baseUrl: this.baseUrl,
|
|
120
122
|
})
|
|
121
123
|
.then(function (response) {
|
|
122
124
|
if (callback) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import RestfulModel from './restful-model';
|
|
2
|
+
import SchedulerTimeSlot from './scheduler-time-slot';
|
|
3
|
+
export declare class SchedulerBookingConfirmation extends RestfulModel {
|
|
4
|
+
id?: string;
|
|
5
|
+
accountId?: string;
|
|
6
|
+
additionalFieldValues?: object;
|
|
7
|
+
calendarEventId?: string;
|
|
8
|
+
calendarId?: string;
|
|
9
|
+
editHash?: string;
|
|
10
|
+
startTime?: Date;
|
|
11
|
+
endTime?: Date;
|
|
12
|
+
isConfirmed?: boolean;
|
|
13
|
+
location?: string;
|
|
14
|
+
recipientEmail?: string;
|
|
15
|
+
recipientLocale?: string;
|
|
16
|
+
recipientName?: string;
|
|
17
|
+
recipientTz?: string;
|
|
18
|
+
title?: string;
|
|
19
|
+
}
|
|
20
|
+
export default class SchedulerBookingRequest extends RestfulModel {
|
|
21
|
+
additionalEmails?: string[];
|
|
22
|
+
additionalValues?: object;
|
|
23
|
+
email?: string;
|
|
24
|
+
locale?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
pageHostname?: string;
|
|
27
|
+
replacesBookingHash?: string;
|
|
28
|
+
slot?: SchedulerTimeSlot;
|
|
29
|
+
timezone?: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.SchedulerBookingConfirmation = void 0;
|
|
20
|
+
var restful_model_1 = __importDefault(require("./restful-model"));
|
|
21
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
22
|
+
var scheduler_time_slot_1 = __importDefault(require("./scheduler-time-slot"));
|
|
23
|
+
var SchedulerBookingConfirmation = /** @class */ (function (_super) {
|
|
24
|
+
__extends(SchedulerBookingConfirmation, _super);
|
|
25
|
+
function SchedulerBookingConfirmation() {
|
|
26
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
+
}
|
|
28
|
+
return SchedulerBookingConfirmation;
|
|
29
|
+
}(restful_model_1.default));
|
|
30
|
+
exports.SchedulerBookingConfirmation = SchedulerBookingConfirmation;
|
|
31
|
+
SchedulerBookingConfirmation.collectionName = 'booking_confirmation';
|
|
32
|
+
SchedulerBookingConfirmation.attributes = {
|
|
33
|
+
id: attributes_1.default.Number({
|
|
34
|
+
modelKey: 'id',
|
|
35
|
+
}),
|
|
36
|
+
accountId: attributes_1.default.String({
|
|
37
|
+
modelKey: 'accountId',
|
|
38
|
+
jsonKey: 'account_id',
|
|
39
|
+
}),
|
|
40
|
+
additionalFieldValues: attributes_1.default.Object({
|
|
41
|
+
modelKey: 'additionalFieldValues',
|
|
42
|
+
jsonKey: 'additional_field_values',
|
|
43
|
+
}),
|
|
44
|
+
calendarEventId: attributes_1.default.String({
|
|
45
|
+
modelKey: 'calendarEventId',
|
|
46
|
+
jsonKey: 'calendar_event_id',
|
|
47
|
+
}),
|
|
48
|
+
calendarId: attributes_1.default.String({
|
|
49
|
+
modelKey: 'calendarId',
|
|
50
|
+
jsonKey: 'calendar_id',
|
|
51
|
+
}),
|
|
52
|
+
editHash: attributes_1.default.String({
|
|
53
|
+
modelKey: 'editHash',
|
|
54
|
+
jsonKey: 'edit_hash',
|
|
55
|
+
}),
|
|
56
|
+
startTime: attributes_1.default.DateTime({
|
|
57
|
+
modelKey: 'startTime',
|
|
58
|
+
jsonKey: 'start_time',
|
|
59
|
+
}),
|
|
60
|
+
endTime: attributes_1.default.DateTime({
|
|
61
|
+
modelKey: 'endTime',
|
|
62
|
+
jsonKey: 'end_time',
|
|
63
|
+
}),
|
|
64
|
+
isConfirmed: attributes_1.default.Boolean({
|
|
65
|
+
modelKey: 'isConfirmed',
|
|
66
|
+
jsonKey: 'is_confirmed',
|
|
67
|
+
}),
|
|
68
|
+
location: attributes_1.default.String({
|
|
69
|
+
modelKey: 'location',
|
|
70
|
+
}),
|
|
71
|
+
recipientEmail: attributes_1.default.String({
|
|
72
|
+
modelKey: 'recipientEmail',
|
|
73
|
+
jsonKey: 'recipient_email',
|
|
74
|
+
}),
|
|
75
|
+
recipientLocale: attributes_1.default.String({
|
|
76
|
+
modelKey: 'recipientLocale',
|
|
77
|
+
jsonKey: 'recipient_locale',
|
|
78
|
+
}),
|
|
79
|
+
recipientName: attributes_1.default.String({
|
|
80
|
+
modelKey: 'recipientName',
|
|
81
|
+
jsonKey: 'recipient_name',
|
|
82
|
+
}),
|
|
83
|
+
recipientTz: attributes_1.default.String({
|
|
84
|
+
modelKey: 'recipientTz',
|
|
85
|
+
jsonKey: 'recipient_tz',
|
|
86
|
+
}),
|
|
87
|
+
title: attributes_1.default.String({
|
|
88
|
+
modelKey: 'title',
|
|
89
|
+
}),
|
|
90
|
+
};
|
|
91
|
+
var SchedulerBookingRequest = /** @class */ (function (_super) {
|
|
92
|
+
__extends(SchedulerBookingRequest, _super);
|
|
93
|
+
function SchedulerBookingRequest() {
|
|
94
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
95
|
+
}
|
|
96
|
+
return SchedulerBookingRequest;
|
|
97
|
+
}(restful_model_1.default));
|
|
98
|
+
exports.default = SchedulerBookingRequest;
|
|
99
|
+
SchedulerBookingRequest.collectionName = 'booking_request';
|
|
100
|
+
SchedulerBookingRequest.attributes = {
|
|
101
|
+
additionalEmails: attributes_1.default.StringList({
|
|
102
|
+
modelKey: 'additionalEmails',
|
|
103
|
+
jsonKey: 'additional_emails',
|
|
104
|
+
}),
|
|
105
|
+
additionalValues: attributes_1.default.Object({
|
|
106
|
+
modelKey: 'additionalValues',
|
|
107
|
+
jsonKey: 'additional_values',
|
|
108
|
+
}),
|
|
109
|
+
email: attributes_1.default.String({
|
|
110
|
+
modelKey: 'email',
|
|
111
|
+
}),
|
|
112
|
+
locale: attributes_1.default.String({
|
|
113
|
+
modelKey: 'locale',
|
|
114
|
+
}),
|
|
115
|
+
name: attributes_1.default.String({
|
|
116
|
+
modelKey: 'name',
|
|
117
|
+
}),
|
|
118
|
+
pageHostname: attributes_1.default.String({
|
|
119
|
+
modelKey: 'pageHostname',
|
|
120
|
+
jsonKey: 'page_hostname',
|
|
121
|
+
}),
|
|
122
|
+
replacesBookingHash: attributes_1.default.String({
|
|
123
|
+
modelKey: 'replacesBookingHash',
|
|
124
|
+
jsonKey: 'replaces_booking_hash',
|
|
125
|
+
}),
|
|
126
|
+
slot: attributes_1.default.Object({
|
|
127
|
+
modelKey: 'slot',
|
|
128
|
+
itemClass: scheduler_time_slot_1.default,
|
|
129
|
+
}),
|
|
130
|
+
timezone: attributes_1.default.String({
|
|
131
|
+
modelKey: 'timezone',
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import RestfulModelCollection from './restful-model-collection';
|
|
2
|
+
import NylasConnection from '../nylas-connection';
|
|
3
|
+
import Scheduler from './scheduler';
|
|
4
|
+
import SchedulerTimeSlot from './scheduler-time-slot';
|
|
5
|
+
import SchedulerBookingRequest, { SchedulerBookingConfirmation } from './scheduler-booking-request';
|
|
6
|
+
export declare type ProviderAvailability = {
|
|
7
|
+
busy: [{
|
|
8
|
+
end: number;
|
|
9
|
+
start: number;
|
|
10
|
+
}];
|
|
11
|
+
email: string;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
export default class SchedulerRestfulModelCollection extends RestfulModelCollection<Scheduler> {
|
|
15
|
+
connection: NylasConnection;
|
|
16
|
+
modelClass: typeof Scheduler;
|
|
17
|
+
constructor(connection: NylasConnection);
|
|
18
|
+
getGoogleAvailability(): Promise<ProviderAvailability>;
|
|
19
|
+
getOffice365Availability(): Promise<ProviderAvailability>;
|
|
20
|
+
getPageBySlug(slug: string): Promise<Scheduler>;
|
|
21
|
+
getAvailableTimeSlots(slug: string): Promise<SchedulerTimeSlot[]>;
|
|
22
|
+
bookTimeSlot(slug: string, bookingRequest: SchedulerBookingRequest): Promise<SchedulerBookingConfirmation>;
|
|
23
|
+
cancelBooking(slug: string, editHash: string, reason: string): Record<string, any>;
|
|
24
|
+
confirmBooking(slug: string, editHash: string): Promise<SchedulerBookingConfirmation>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
|
|
20
|
+
var scheduler_1 = __importDefault(require("./scheduler"));
|
|
21
|
+
var scheduler_time_slot_1 = __importDefault(require("./scheduler-time-slot"));
|
|
22
|
+
var scheduler_booking_request_1 = require("./scheduler-booking-request");
|
|
23
|
+
var SchedulerRestfulModelCollection = /** @class */ (function (_super) {
|
|
24
|
+
__extends(SchedulerRestfulModelCollection, _super);
|
|
25
|
+
function SchedulerRestfulModelCollection(connection) {
|
|
26
|
+
var _this = _super.call(this, scheduler_1.default, connection) || this;
|
|
27
|
+
_this.baseUrl = 'https://api.schedule.nylas.com';
|
|
28
|
+
_this.connection = connection;
|
|
29
|
+
_this.modelClass = scheduler_1.default;
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
SchedulerRestfulModelCollection.prototype.getGoogleAvailability = function () {
|
|
33
|
+
return this.connection.request({
|
|
34
|
+
method: 'GET',
|
|
35
|
+
path: '/schedule/availability/google',
|
|
36
|
+
headers: {
|
|
37
|
+
'Content-Type': 'application/json',
|
|
38
|
+
},
|
|
39
|
+
baseUrl: this.baseUrl,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
SchedulerRestfulModelCollection.prototype.getOffice365Availability = function () {
|
|
43
|
+
return this.connection.request({
|
|
44
|
+
method: 'GET',
|
|
45
|
+
path: '/schedule/availability/o365',
|
|
46
|
+
headers: {
|
|
47
|
+
'Content-Type': 'application/json',
|
|
48
|
+
},
|
|
49
|
+
baseUrl: this.baseUrl,
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
SchedulerRestfulModelCollection.prototype.getPageBySlug = function (slug) {
|
|
53
|
+
var _this = this;
|
|
54
|
+
return this.connection
|
|
55
|
+
.request({
|
|
56
|
+
method: 'GET',
|
|
57
|
+
path: "/schedule/" + slug + "/info",
|
|
58
|
+
headers: {
|
|
59
|
+
'Content-Type': 'application/json',
|
|
60
|
+
},
|
|
61
|
+
baseUrl: this.baseUrl,
|
|
62
|
+
})
|
|
63
|
+
.then(function (json) {
|
|
64
|
+
return Promise.resolve(new scheduler_1.default(_this.connection, json));
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
SchedulerRestfulModelCollection.prototype.getAvailableTimeSlots = function (slug) {
|
|
68
|
+
var _this = this;
|
|
69
|
+
return this.connection
|
|
70
|
+
.request({
|
|
71
|
+
method: 'GET',
|
|
72
|
+
path: "/schedule/" + slug + "/timeslots",
|
|
73
|
+
headers: {
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
},
|
|
76
|
+
baseUrl: this.baseUrl,
|
|
77
|
+
})
|
|
78
|
+
.then(function (json) {
|
|
79
|
+
var timeslots = json.map(function (timeslot) {
|
|
80
|
+
return new scheduler_time_slot_1.default(_this.connection, timeslot);
|
|
81
|
+
});
|
|
82
|
+
return Promise.resolve(timeslots);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
SchedulerRestfulModelCollection.prototype.bookTimeSlot = function (slug, bookingRequest) {
|
|
86
|
+
var _this = this;
|
|
87
|
+
return this.connection
|
|
88
|
+
.request({
|
|
89
|
+
method: 'POST',
|
|
90
|
+
path: "/schedule/" + slug + "/timeslots",
|
|
91
|
+
headers: {
|
|
92
|
+
'Content-Type': 'application/json',
|
|
93
|
+
},
|
|
94
|
+
body: bookingRequest.toJSON(),
|
|
95
|
+
baseUrl: this.baseUrl,
|
|
96
|
+
})
|
|
97
|
+
.then(function (json) {
|
|
98
|
+
return Promise.resolve(new scheduler_booking_request_1.SchedulerBookingConfirmation(_this.connection, json));
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
SchedulerRestfulModelCollection.prototype.cancelBooking = function (slug, editHash, reason) {
|
|
102
|
+
return this.connection
|
|
103
|
+
.request({
|
|
104
|
+
method: 'POST',
|
|
105
|
+
path: "/schedule/" + slug + "/" + editHash + "/cancel",
|
|
106
|
+
headers: {
|
|
107
|
+
'Content-Type': 'application/json',
|
|
108
|
+
},
|
|
109
|
+
body: {
|
|
110
|
+
reason: reason,
|
|
111
|
+
},
|
|
112
|
+
baseUrl: this.baseUrl,
|
|
113
|
+
})
|
|
114
|
+
.then(function (json) {
|
|
115
|
+
return Promise.resolve(json);
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
SchedulerRestfulModelCollection.prototype.confirmBooking = function (slug, editHash) {
|
|
119
|
+
var _this = this;
|
|
120
|
+
return this.connection
|
|
121
|
+
.request({
|
|
122
|
+
method: 'POST',
|
|
123
|
+
path: "/schedule/" + slug + "/" + editHash + "/confirm",
|
|
124
|
+
headers: {
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
},
|
|
127
|
+
body: {},
|
|
128
|
+
baseUrl: this.baseUrl,
|
|
129
|
+
})
|
|
130
|
+
.then(function (json) {
|
|
131
|
+
return Promise.resolve(new scheduler_booking_request_1.SchedulerBookingConfirmation(_this.connection, json));
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
return SchedulerRestfulModelCollection;
|
|
135
|
+
}(restful_model_collection_1.default));
|
|
136
|
+
exports.default = SchedulerRestfulModelCollection;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var restful_model_1 = __importDefault(require("./restful-model"));
|
|
20
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
21
|
+
var SchedulerTimeSlot = /** @class */ (function (_super) {
|
|
22
|
+
__extends(SchedulerTimeSlot, _super);
|
|
23
|
+
function SchedulerTimeSlot() {
|
|
24
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
+
}
|
|
26
|
+
return SchedulerTimeSlot;
|
|
27
|
+
}(restful_model_1.default));
|
|
28
|
+
exports.default = SchedulerTimeSlot;
|
|
29
|
+
SchedulerTimeSlot.collectionName = 'scheduler_slot';
|
|
30
|
+
SchedulerTimeSlot.attributes = {
|
|
31
|
+
accountId: attributes_1.default.String({
|
|
32
|
+
modelKey: 'accountId',
|
|
33
|
+
jsonKey: 'account_id',
|
|
34
|
+
}),
|
|
35
|
+
calendarId: attributes_1.default.String({
|
|
36
|
+
modelKey: 'calendarId',
|
|
37
|
+
jsonKey: 'calendar_id',
|
|
38
|
+
}),
|
|
39
|
+
hostName: attributes_1.default.String({
|
|
40
|
+
modelKey: 'hostName',
|
|
41
|
+
jsonKey: 'host_name',
|
|
42
|
+
}),
|
|
43
|
+
emails: attributes_1.default.StringList({
|
|
44
|
+
modelKey: 'emails',
|
|
45
|
+
}),
|
|
46
|
+
start: attributes_1.default.DateTime({
|
|
47
|
+
modelKey: 'start',
|
|
48
|
+
}),
|
|
49
|
+
end: attributes_1.default.DateTime({
|
|
50
|
+
modelKey: 'end',
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import RestfulModel, { SaveCallback } from './restful-model';
|
|
2
2
|
import NylasConnection from '../nylas-connection';
|
|
3
|
+
import Calendar from './calendar';
|
|
4
|
+
export declare type SchedulerUploadImageResponse = {
|
|
5
|
+
filename: string;
|
|
6
|
+
originalFilename: string;
|
|
7
|
+
publicUrl: string;
|
|
8
|
+
signedUrl: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class SchedulerAvailableCalendars extends RestfulModel {
|
|
11
|
+
calendars?: Calendar[];
|
|
12
|
+
email?: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
}
|
|
3
16
|
export default class Scheduler extends RestfulModel {
|
|
4
17
|
accessTokens?: string[];
|
|
5
18
|
appClientId?: string;
|
|
@@ -80,6 +93,6 @@ export default class Scheduler extends RestfulModel {
|
|
|
80
93
|
modifiedAt?: Date;
|
|
81
94
|
constructor(connection: NylasConnection, json?: Record<string, any>);
|
|
82
95
|
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
83
|
-
getAvailableCalendars():
|
|
84
|
-
uploadImage(contentType: string, objectName: string):
|
|
96
|
+
getAvailableCalendars(): Promise<SchedulerAvailableCalendars[]>;
|
|
97
|
+
uploadImage(contentType: string, objectName: string): Promise<SchedulerUploadImageResponse>;
|
|
85
98
|
}
|
package/lib/models/scheduler.js
CHANGED
|
@@ -27,13 +27,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.SchedulerAvailableCalendars = void 0;
|
|
30
31
|
var restful_model_1 = __importDefault(require("./restful-model"));
|
|
31
32
|
var attributes_1 = __importDefault(require("./attributes"));
|
|
33
|
+
var calendar_1 = __importDefault(require("./calendar"));
|
|
34
|
+
var SchedulerAvailableCalendars = /** @class */ (function (_super) {
|
|
35
|
+
__extends(SchedulerAvailableCalendars, _super);
|
|
36
|
+
function SchedulerAvailableCalendars() {
|
|
37
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
38
|
+
}
|
|
39
|
+
return SchedulerAvailableCalendars;
|
|
40
|
+
}(restful_model_1.default));
|
|
41
|
+
exports.SchedulerAvailableCalendars = SchedulerAvailableCalendars;
|
|
42
|
+
SchedulerAvailableCalendars.collectionName = 'scheduler_available_calendars';
|
|
43
|
+
SchedulerAvailableCalendars.attributes = {
|
|
44
|
+
calendars: attributes_1.default.Collection({
|
|
45
|
+
modelKey: 'calendars',
|
|
46
|
+
itemClass: calendar_1.default,
|
|
47
|
+
}),
|
|
48
|
+
email: attributes_1.default.String({
|
|
49
|
+
modelKey: 'email',
|
|
50
|
+
}),
|
|
51
|
+
id: attributes_1.default.String({
|
|
52
|
+
modelKey: 'id',
|
|
53
|
+
}),
|
|
54
|
+
name: attributes_1.default.String({
|
|
55
|
+
modelKey: 'name',
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
32
58
|
var Scheduler = /** @class */ (function (_super) {
|
|
33
59
|
__extends(Scheduler, _super);
|
|
34
60
|
function Scheduler(connection, json) {
|
|
35
61
|
var _this = _super.call(this, connection, json) || this;
|
|
36
|
-
|
|
62
|
+
_this.baseUrl = 'https://api.schedule.nylas.com';
|
|
37
63
|
return _this;
|
|
38
64
|
}
|
|
39
65
|
Scheduler.prototype.save = function (params, callback) {
|
|
@@ -41,15 +67,24 @@ var Scheduler = /** @class */ (function (_super) {
|
|
|
41
67
|
return this._save(params, callback);
|
|
42
68
|
};
|
|
43
69
|
Scheduler.prototype.getAvailableCalendars = function () {
|
|
70
|
+
var _this = this;
|
|
44
71
|
if (!this.id) {
|
|
45
72
|
throw new Error('Cannot get calendars for a page without an ID.');
|
|
46
73
|
}
|
|
47
|
-
return this.connection
|
|
74
|
+
return this.connection
|
|
75
|
+
.request({
|
|
48
76
|
method: 'GET',
|
|
49
77
|
path: "/manage/pages/" + this.id + "/calendars",
|
|
50
78
|
headers: {
|
|
51
79
|
'Content-Type': 'application/json',
|
|
52
80
|
},
|
|
81
|
+
baseUrl: this.baseUrl,
|
|
82
|
+
})
|
|
83
|
+
.then(function (json) {
|
|
84
|
+
var calendars = json.map(function (cal) {
|
|
85
|
+
return new SchedulerAvailableCalendars(_this.connection, cal);
|
|
86
|
+
});
|
|
87
|
+
return Promise.resolve(calendars);
|
|
53
88
|
});
|
|
54
89
|
};
|
|
55
90
|
Scheduler.prototype.uploadImage = function (contentType, objectName) {
|
|
@@ -66,6 +101,7 @@ var Scheduler = /** @class */ (function (_super) {
|
|
|
66
101
|
contentType: contentType,
|
|
67
102
|
objectName: objectName,
|
|
68
103
|
},
|
|
104
|
+
baseUrl: this.baseUrl,
|
|
69
105
|
});
|
|
70
106
|
};
|
|
71
107
|
return Scheduler;
|
|
@@ -18,7 +18,7 @@ import { Folder, Label } from './models/folder';
|
|
|
18
18
|
import { AppendOptions } from 'form-data';
|
|
19
19
|
import Neural from './models/neural';
|
|
20
20
|
import ComponentRestfulModelCollection from './models/component-restful-model-collection';
|
|
21
|
-
import
|
|
21
|
+
import SchedulerRestfulModelCollection from './models/scheduler-restful-model-collection';
|
|
22
22
|
export declare type RequestOptions = {
|
|
23
23
|
path: string;
|
|
24
24
|
method?: string;
|
|
@@ -46,7 +46,6 @@ export declare type FormDataType = {
|
|
|
46
46
|
export default class NylasConnection {
|
|
47
47
|
accessToken: string | null | undefined;
|
|
48
48
|
clientId: string | null | undefined;
|
|
49
|
-
baseUrl: string | null | undefined;
|
|
50
49
|
threads: RestfulModelCollection<Thread>;
|
|
51
50
|
contacts: ContactRestfulModelCollection;
|
|
52
51
|
messages: RestfulModelCollection<Message>;
|
|
@@ -61,7 +60,7 @@ export default class NylasConnection {
|
|
|
61
60
|
folders: RestfulModelCollection<Folder>;
|
|
62
61
|
account: RestfulModelInstance<Account>;
|
|
63
62
|
component: ComponentRestfulModelCollection;
|
|
64
|
-
scheduler:
|
|
63
|
+
scheduler: SchedulerRestfulModelCollection;
|
|
65
64
|
neural: Neural;
|
|
66
65
|
constructor(accessToken: string | null | undefined, { clientId }: {
|
|
67
66
|
clientId: string | null | undefined;
|
package/lib/nylas-connection.js
CHANGED
|
@@ -55,7 +55,7 @@ var form_data_1 = __importDefault(require("form-data"));
|
|
|
55
55
|
var neural_1 = __importDefault(require("./models/neural"));
|
|
56
56
|
var nylas_api_error_1 = __importDefault(require("./models/nylas-api-error"));
|
|
57
57
|
var component_restful_model_collection_1 = __importDefault(require("./models/component-restful-model-collection"));
|
|
58
|
-
var
|
|
58
|
+
var scheduler_restful_model_collection_1 = __importDefault(require("./models/scheduler-restful-model-collection"));
|
|
59
59
|
var PACKAGE_JSON = require('../package.json');
|
|
60
60
|
var SDK_VERSION = PACKAGE_JSON.version;
|
|
61
61
|
var SUPPORTED_API_VERSION = '2.3';
|
|
@@ -76,13 +76,13 @@ var NylasConnection = /** @class */ (function () {
|
|
|
76
76
|
this.folders = new restful_model_collection_1.default(folder_1.Folder, this);
|
|
77
77
|
this.account = new restful_model_instance_1.default(account_1.default, this);
|
|
78
78
|
this.component = new component_restful_model_collection_1.default(this);
|
|
79
|
-
this.scheduler = new
|
|
79
|
+
this.scheduler = new scheduler_restful_model_collection_1.default(this);
|
|
80
80
|
this.neural = new neural_1.default(this);
|
|
81
81
|
this.accessToken = accessToken;
|
|
82
82
|
this.clientId = clientId;
|
|
83
83
|
}
|
|
84
84
|
NylasConnection.prototype.requestOptions = function (options) {
|
|
85
|
-
var baseUrl =
|
|
85
|
+
var baseUrl = options.baseUrl ? options.baseUrl : config.apiServer;
|
|
86
86
|
var url = new url_1.URL("" + baseUrl + options.path);
|
|
87
87
|
// map querystring to search params
|
|
88
88
|
if (options.qs) {
|