nylas 5.9.0 → 5.10.3

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.
Files changed (38) hide show
  1. package/lib/models/attributes.d.ts +5 -2
  2. package/lib/models/attributes.js +28 -4
  3. package/lib/models/calendar.d.ts +2 -0
  4. package/lib/models/calendar.js +4 -0
  5. package/lib/models/component.d.ts +2 -0
  6. package/lib/models/component.js +13 -0
  7. package/lib/models/contact.d.ts +1 -0
  8. package/lib/models/contact.js +4 -0
  9. package/lib/models/event-notification.d.ts +11 -0
  10. package/lib/models/event-notification.js +65 -0
  11. package/lib/models/event-participant.js +1 -0
  12. package/lib/models/event.d.ts +3 -0
  13. package/lib/models/event.js +11 -0
  14. package/lib/models/folder.d.ts +1 -0
  15. package/lib/models/folder.js +4 -0
  16. package/lib/models/job-status.d.ts +3 -0
  17. package/lib/models/job-status.js +12 -0
  18. package/lib/models/management-account.d.ts +7 -0
  19. package/lib/models/management-account.js +14 -0
  20. package/lib/models/message.d.ts +2 -0
  21. package/lib/models/message.js +7 -0
  22. package/lib/models/restful-model-collection.d.ts +1 -0
  23. package/lib/models/restful-model-collection.js +5 -0
  24. package/lib/models/restful-model.d.ts +1 -0
  25. package/lib/models/restful-model.js +7 -2
  26. package/lib/models/scheduler-booking-request.d.ts +31 -0
  27. package/lib/models/scheduler-booking-request.js +147 -0
  28. package/lib/models/scheduler-restful-model-collection.d.ts +25 -0
  29. package/lib/models/scheduler-restful-model-collection.js +136 -0
  30. package/lib/models/scheduler-time-slot.d.ts +9 -0
  31. package/lib/models/scheduler-time-slot.js +52 -0
  32. package/lib/models/scheduler.d.ts +17 -4
  33. package/lib/models/scheduler.js +38 -2
  34. package/lib/nylas-connection.d.ts +2 -3
  35. package/lib/nylas-connection.js +3 -3
  36. package/lib/nylas.d.ts +1 -0
  37. package/lib/nylas.js +3 -0
  38. package/package.json +1 -1
@@ -10,6 +10,7 @@ export declare class Attribute {
10
10
  });
11
11
  toJSON(val: any): any;
12
12
  fromJSON(val: any, _parent: any): any;
13
+ saveRequestBody(val: any): any;
13
14
  }
14
15
  declare class AttributeObject extends Attribute {
15
16
  itemClass?: typeof RestfulModel;
@@ -19,8 +20,9 @@ declare class AttributeObject extends Attribute {
19
20
  itemClass?: typeof RestfulModel;
20
21
  readOnly?: boolean;
21
22
  });
22
- toJSON(val: any): any;
23
+ toJSON(val: any, saveRequestBody?: boolean): any;
23
24
  fromJSON(val: any, _parent: any): any;
25
+ saveRequestBody(val: any): any;
24
26
  }
25
27
  declare class AttributeNumber extends Attribute {
26
28
  toJSON(val: any): any;
@@ -54,8 +56,9 @@ declare class AttributeCollection extends Attribute {
54
56
  itemClass: typeof RestfulModel;
55
57
  readOnly?: boolean;
56
58
  });
57
- toJSON(vals: any): any[];
59
+ toJSON(vals: any, saveRequestBody?: boolean): any[];
58
60
  fromJSON(json: any, _parent: any): RestfulModel[];
61
+ saveRequestBody(val: any): any[] | undefined;
59
62
  }
60
63
  declare const Attributes: {
61
64
  Number(__0: {
@@ -38,6 +38,12 @@ var Attribute = /** @class */ (function () {
38
38
  Attribute.prototype.fromJSON = function (val, _parent) {
39
39
  return val || null;
40
40
  };
41
+ Attribute.prototype.saveRequestBody = function (val) {
42
+ if (this.readOnly) {
43
+ return;
44
+ }
45
+ return this.toJSON(val);
46
+ };
41
47
  return Attribute;
42
48
  }());
43
49
  exports.Attribute = Attribute;
@@ -49,11 +55,14 @@ var AttributeObject = /** @class */ (function (_super) {
49
55
  _this.itemClass = itemClass;
50
56
  return _this;
51
57
  }
52
- AttributeObject.prototype.toJSON = function (val) {
58
+ AttributeObject.prototype.toJSON = function (val, saveRequestBody) {
53
59
  if (!val) {
54
60
  return val;
55
61
  }
56
- if (val.toJSON != null) {
62
+ if (saveRequestBody === true && val.saveRequestBody != null) {
63
+ return val.saveRequestBody();
64
+ }
65
+ else if (val.toJSON != null) {
57
66
  return val.toJSON();
58
67
  }
59
68
  return val;
@@ -64,6 +73,12 @@ var AttributeObject = /** @class */ (function (_super) {
64
73
  }
65
74
  return new this.itemClass(_parent.connection, val);
66
75
  };
76
+ AttributeObject.prototype.saveRequestBody = function (val) {
77
+ if (this.readOnly) {
78
+ return;
79
+ }
80
+ return this.toJSON(val, true);
81
+ };
67
82
  return AttributeObject;
68
83
  }(Attribute));
69
84
  var AttributeNumber = /** @class */ (function (_super) {
@@ -175,14 +190,17 @@ var AttributeCollection = /** @class */ (function (_super) {
175
190
  _this.itemClass = itemClass;
176
191
  return _this;
177
192
  }
178
- AttributeCollection.prototype.toJSON = function (vals) {
193
+ AttributeCollection.prototype.toJSON = function (vals, saveRequestBody) {
179
194
  if (!vals) {
180
195
  return [];
181
196
  }
182
197
  var json = [];
183
198
  for (var _i = 0, vals_1 = vals; _i < vals_1.length; _i++) {
184
199
  var val = vals_1[_i];
185
- if (val.toJSON != null) {
200
+ if (saveRequestBody === true && val.saveRequestBody != null) {
201
+ json.push(val.saveRequestBody());
202
+ }
203
+ else if (val.toJSON != null) {
186
204
  json.push(val.toJSON());
187
205
  }
188
206
  else {
@@ -203,6 +221,12 @@ var AttributeCollection = /** @class */ (function (_super) {
203
221
  }
204
222
  return objs;
205
223
  };
224
+ AttributeCollection.prototype.saveRequestBody = function (val) {
225
+ if (this.readOnly) {
226
+ return;
227
+ }
228
+ return this.toJSON(val, true);
229
+ };
206
230
  return AttributeCollection;
207
231
  }(Attribute));
208
232
  var Attributes = {
@@ -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
  }
@@ -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,7 @@ 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
+ readOnly: true,
83
+ }), metadata: attributes_1.default.Object({
84
+ modelKey: 'metadata',
81
85
  }) });
@@ -9,8 +9,10 @@ export default class Component extends RestfulModel {
9
9
  publicAccountId?: string;
10
10
  publicTokenId?: string;
11
11
  publicApplicationId?: string;
12
+ accessToken?: string;
12
13
  createdAt?: Date;
13
14
  updatedAt?: Date;
14
15
  saveEndpoint(): string;
15
16
  save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
17
+ saveRequestBody(): any;
16
18
  }
@@ -41,6 +41,16 @@ var Component = /** @class */ (function (_super) {
41
41
  if (params === void 0) { params = {}; }
42
42
  return this._save(params, callback);
43
43
  };
44
+ Component.prototype.saveRequestBody = function () {
45
+ var json = _super.prototype.saveRequestBody.call(this);
46
+ if (this.id) {
47
+ // Cannot cannot send these values after creation
48
+ delete json.access_token;
49
+ delete json.public_application_id;
50
+ delete json.type;
51
+ }
52
+ return json;
53
+ };
44
54
  return Component;
45
55
  }(restful_model_1.default));
46
56
  exports.default = Component;
@@ -67,6 +77,9 @@ Component.attributes = __assign(__assign({}, restful_model_1.default.attributes)
67
77
  }), publicApplicationId: attributes_1.default.String({
68
78
  modelKey: 'publicApplicationId',
69
79
  jsonKey: 'public_application_id',
80
+ }), accessToken: attributes_1.default.String({
81
+ modelKey: 'accessToken',
82
+ jsonKey: 'access_token',
70
83
  }), createdAt: attributes_1.default.Date({
71
84
  modelKey: 'createdAt',
72
85
  jsonKey: 'created_at',
@@ -67,6 +67,7 @@ export declare class Contact extends RestfulModel {
67
67
  webPages?: WebPage[];
68
68
  groups?: Group[];
69
69
  source?: string;
70
+ jobStatusId?: string;
70
71
  save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
71
72
  getPicture(params?: {
72
73
  [key: string]: any;
@@ -242,4 +242,8 @@ Contact.attributes = __assign(__assign({}, restful_model_1.default.attributes),
242
242
  itemClass: Group,
243
243
  }), source: attributes_1.default.String({
244
244
  modelKey: 'source',
245
+ }), jobStatusId: attributes_1.default.String({
246
+ modelKey: 'jobStatusId',
247
+ jsonKey: 'job_status_id',
248
+ readOnly: true,
245
249
  }) });
@@ -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
+ };
@@ -43,5 +43,6 @@ EventParticipant.attributes = {
43
43
  }),
44
44
  status: attributes_1.default.String({
45
45
  modelKey: 'status',
46
+ readOnly: true,
46
47
  }),
47
48
  };
@@ -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;
@@ -41,5 +43,6 @@ export default class Event extends RestfulModel {
41
43
  [key: string]: any;
42
44
  };
43
45
  save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
46
+ saveRequestBody(): any;
44
47
  rsvp(status: string, comment: string, callback?: (error: Error | null, data?: Event) => void): Promise<this>;
45
48
  }
@@ -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() {
@@ -125,6 +126,13 @@ var Event = /** @class */ (function (_super) {
125
126
  }
126
127
  return this._save(params, callback);
127
128
  };
129
+ Event.prototype.saveRequestBody = function () {
130
+ var json = _super.prototype.saveRequestBody.call(this);
131
+ if (json.when && json.when.object) {
132
+ delete json.when.object;
133
+ }
134
+ return json;
135
+ };
128
136
  Event.prototype.rsvp = function (status, comment, callback) {
129
137
  var _this = this;
130
138
  return this.connection
@@ -197,6 +205,9 @@ Event.attributes = __assign(__assign({}, restful_model_1.default.attributes), {
197
205
  }), conferencing: attributes_1.default.Object({
198
206
  modelKey: 'conferencing',
199
207
  itemClass: event_conferencing_1.EventConferencing,
208
+ }), notifications: attributes_1.default.Collection({
209
+ modelKey: 'notifications',
210
+ itemClass: event_notification_1.EventNotification,
200
211
  }), metadata: attributes_1.default.Object({
201
212
  modelKey: 'metadata',
202
213
  }), jobStatusId: attributes_1.default.String({
@@ -2,6 +2,7 @@ import RestfulModel, { SaveCallback } from './restful-model';
2
2
  export declare class Folder extends RestfulModel {
3
3
  displayName?: string;
4
4
  name?: string;
5
+ jobStatusId?: string;
5
6
  saveRequestBody(): {
6
7
  [key: string]: any;
7
8
  };
@@ -55,6 +55,10 @@ Folder.attributes = __assign(__assign({}, restful_model_1.default.attributes), {
55
55
  }), displayName: attributes_1.default.String({
56
56
  modelKey: 'displayName',
57
57
  jsonKey: 'display_name',
58
+ }), jobStatusId: attributes_1.default.String({
59
+ modelKey: 'jobStatusId',
60
+ jsonKey: 'job_status_id',
61
+ readOnly: true,
58
62
  }) });
59
63
  var Label = /** @class */ (function (_super) {
60
64
  __extends(Label, _super);
@@ -1,7 +1,10 @@
1
1
  import RestfulModel from './restful-model';
2
+ import Message from './message';
2
3
  export default class JobStatus extends RestfulModel {
3
4
  action?: string;
4
5
  createdAt?: Date;
5
6
  jobStatusId?: string;
6
7
  status?: string;
8
+ originalData?: Message;
9
+ isSuccessful(): boolean;
7
10
  }
@@ -34,18 +34,30 @@ var JobStatus = /** @class */ (function (_super) {
34
34
  function JobStatus() {
35
35
  return _super !== null && _super.apply(this, arguments) || this;
36
36
  }
37
+ // Returns the status of a job as a boolean
38
+ JobStatus.prototype.isSuccessful = function () {
39
+ return this.status === 'successful';
40
+ };
37
41
  return JobStatus;
38
42
  }(restful_model_1.default));
39
43
  exports.default = JobStatus;
40
44
  JobStatus.collectionName = 'job-statuses';
41
45
  JobStatus.attributes = __assign(__assign({}, restful_model_1.default.attributes), { action: attributes_1.default.String({
42
46
  modelKey: 'action',
47
+ readOnly: true,
43
48
  }), createdAt: attributes_1.default.DateTime({
44
49
  modelKey: 'createdAt',
45
50
  jsonKey: 'created_at',
51
+ readOnly: true,
46
52
  }), jobStatusId: attributes_1.default.String({
47
53
  modelKey: 'jobStatusId',
48
54
  jsonKey: 'job_status_id',
55
+ readOnly: true,
49
56
  }), status: attributes_1.default.String({
50
57
  modelKey: 'status',
58
+ readOnly: true,
59
+ }), originalData: attributes_1.default.Object({
60
+ modelKey: 'originalData',
61
+ jsonKey: 'original_data',
62
+ readOnly: true,
51
63
  }) });
@@ -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
  }) });
@@ -20,10 +20,12 @@ export default class Message extends RestfulModel {
20
20
  events?: Event[];
21
21
  folder?: Folder;
22
22
  labels?: Label[];
23
+ metadata?: object;
23
24
  headers?: {
24
25
  [key: string]: string;
25
26
  };
26
27
  failures?: any;
28
+ jobStatusId?: string;
27
29
  participants(): EmailParticipant[];
28
30
  fileIds(): (string | undefined)[];
29
31
  getRaw(): Promise<any>;
@@ -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,12 @@ 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',
157
+ }), jobStatusId: attributes_1.default.String({
158
+ modelKey: 'jobStatusId',
159
+ jsonKey: 'job_status_id',
160
+ readOnly: true,
154
161
  }) });
@@ -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) {
@@ -17,6 +17,7 @@ export default class RestfulModel {
17
17
  connection: NylasConnection;
18
18
  id?: string;
19
19
  object?: string;
20
+ baseUrl?: string;
20
21
  constructor(connection: NylasConnection, json?: Partial<RestfulModelJSON>);
21
22
  attributes(): {
22
23
  [key: string]: Attribute;
@@ -37,8 +37,11 @@ var RestfulModel = /** @class */ (function () {
37
37
  var json = {};
38
38
  var attributes = this.attributes();
39
39
  for (var attrName in attributes) {
40
- if (!attributes[attrName].readOnly || enforceReadOnly !== true) {
41
- var attr = attributes[attrName];
40
+ var attr = attributes[attrName];
41
+ if (enforceReadOnly === true) {
42
+ json[attr.jsonKey] = attr.saveRequestBody(this[attrName]);
43
+ }
44
+ else {
42
45
  json[attr.jsonKey] = attr.toJSON(this[attrName]);
43
46
  }
44
47
  }
@@ -93,6 +96,7 @@ var RestfulModel = /** @class */ (function () {
93
96
  path: this.id
94
97
  ? this.saveEndpoint() + "/" + this.id
95
98
  : "" + this.saveEndpoint(),
99
+ baseUrl: this.baseUrl,
96
100
  })
97
101
  .then(function (json) {
98
102
  _this.fromJSON(json);
@@ -117,6 +121,7 @@ var RestfulModel = /** @class */ (function () {
117
121
  method: 'GET',
118
122
  path: "/" + collectionName + "/" + this.id + pathSuffix,
119
123
  qs: params,
124
+ baseUrl: this.baseUrl,
120
125
  })
121
126
  .then(function (response) {
122
127
  if (callback) {
@@ -0,0 +1,31 @@
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
+ toJSON(enforceReadOnly?: boolean): Record<string, any>;
31
+ }
@@ -0,0 +1,147 @@
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
+ /*
97
+ * The booking endpoint requires additional_values and additional_emails
98
+ to exist regardless if they are empty or not
99
+ */
100
+ SchedulerBookingRequest.prototype.toJSON = function (enforceReadOnly) {
101
+ var json = _super.prototype.toJSON.call(this, enforceReadOnly);
102
+ if (!this.additionalEmails) {
103
+ json['additional_emails'] = [];
104
+ }
105
+ if (!this.additionalValues) {
106
+ json['additional_values'] = {};
107
+ }
108
+ return json;
109
+ };
110
+ return SchedulerBookingRequest;
111
+ }(restful_model_1.default));
112
+ exports.default = SchedulerBookingRequest;
113
+ SchedulerBookingRequest.collectionName = 'booking_request';
114
+ SchedulerBookingRequest.attributes = {
115
+ additionalEmails: attributes_1.default.StringList({
116
+ modelKey: 'additionalEmails',
117
+ jsonKey: 'additional_emails',
118
+ }),
119
+ additionalValues: attributes_1.default.Object({
120
+ modelKey: 'additionalValues',
121
+ jsonKey: 'additional_values',
122
+ }),
123
+ email: attributes_1.default.String({
124
+ modelKey: 'email',
125
+ }),
126
+ locale: attributes_1.default.String({
127
+ modelKey: 'locale',
128
+ }),
129
+ name: attributes_1.default.String({
130
+ modelKey: 'name',
131
+ }),
132
+ pageHostname: attributes_1.default.String({
133
+ modelKey: 'pageHostname',
134
+ jsonKey: 'page_hostname',
135
+ }),
136
+ replacesBookingHash: attributes_1.default.String({
137
+ modelKey: 'replacesBookingHash',
138
+ jsonKey: 'replaces_booking_hash',
139
+ }),
140
+ slot: attributes_1.default.Object({
141
+ modelKey: 'slot',
142
+ itemClass: scheduler_time_slot_1.default,
143
+ }),
144
+ timezone: attributes_1.default.String({
145
+ modelKey: 'timezone',
146
+ }),
147
+ };
@@ -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,9 @@
1
+ import RestfulModel from './restful-model';
2
+ export default class SchedulerTimeSlot extends RestfulModel {
3
+ accountId?: string;
4
+ calendarId?: string;
5
+ hostName?: string;
6
+ emails?: string[];
7
+ start?: Date;
8
+ end?: Date;
9
+ }
@@ -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;
@@ -41,7 +54,7 @@ export default class Scheduler extends RestfulModel {
41
54
  name_field_hidden: boolean;
42
55
  opening_hours: Array<{
43
56
  account_id?: string;
44
- days?: string;
57
+ days?: string[];
45
58
  end?: string;
46
59
  start?: string;
47
60
  }>;
@@ -59,7 +72,7 @@ export default class Scheduler extends RestfulModel {
59
72
  title?: string;
60
73
  };
61
74
  expire_after?: {
62
- date?: number;
75
+ date?: Date;
63
76
  uses?: number;
64
77
  };
65
78
  locale?: 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(): Record<string, any>;
84
- uploadImage(contentType: string, objectName: string): Record<string, any>;
96
+ getAvailableCalendars(): Promise<SchedulerAvailableCalendars[]>;
97
+ uploadImage(contentType: string, objectName: string): Promise<SchedulerUploadImageResponse>;
85
98
  }
@@ -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
- connection.baseUrl = 'https://api.schedule.nylas.com';
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.request({
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 Scheduler from './models/scheduler';
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: RestfulModelCollection<Scheduler>;
63
+ scheduler: SchedulerRestfulModelCollection;
65
64
  neural: Neural;
66
65
  constructor(accessToken: string | null | undefined, { clientId }: {
67
66
  clientId: string | null | undefined;
@@ -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 scheduler_1 = __importDefault(require("./models/scheduler"));
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 restful_model_collection_1.default(scheduler_1.default, this);
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 = this.baseUrl ? this.baseUrl : config.apiServer;
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) {
package/lib/nylas.d.ts CHANGED
@@ -32,6 +32,7 @@ declare class Nylas {
32
32
  redirectURI?: string;
33
33
  loginHint?: string;
34
34
  state?: string;
35
+ provider?: string;
35
36
  scopes?: string[];
36
37
  }): string;
37
38
  }
package/lib/nylas.js CHANGED
@@ -170,6 +170,9 @@ var Nylas = /** @class */ (function () {
170
170
  if (options.scopes != null) {
171
171
  url += "&scopes=" + options.scopes.join(',');
172
172
  }
173
+ if (options.provider != null) {
174
+ url += "&provider=" + options.provider;
175
+ }
173
176
  return url;
174
177
  };
175
178
  Nylas.clientId = '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nylas",
3
- "version": "5.9.0",
3
+ "version": "5.10.3",
4
4
  "description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
5
5
  "main": "lib/nylas.js",
6
6
  "types": "lib/nylas.d.ts",