nylas 5.7.0 → 5.10.1

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 (34) hide show
  1. package/README.md +7 -7
  2. package/lib/models/calendar-restful-model-collection.d.ts +30 -0
  3. package/lib/models/calendar-restful-model-collection.js +45 -0
  4. package/lib/models/calendar.d.ts +2 -0
  5. package/lib/models/calendar.js +3 -0
  6. package/lib/models/component-restful-model-collection.d.ts +9 -0
  7. package/lib/models/component-restful-model-collection.js +34 -0
  8. package/lib/models/component.d.ts +16 -0
  9. package/lib/models/component.js +76 -0
  10. package/lib/models/event-conferencing.d.ts +3 -0
  11. package/lib/models/event-conferencing.js +4 -0
  12. package/lib/models/event-notification.d.ts +11 -0
  13. package/lib/models/event-notification.js +65 -0
  14. package/lib/models/event.d.ts +3 -0
  15. package/lib/models/event.js +17 -0
  16. package/lib/models/management-account.d.ts +7 -0
  17. package/lib/models/management-account.js +14 -0
  18. package/lib/models/message.d.ts +1 -0
  19. package/lib/models/message.js +3 -0
  20. package/lib/models/restful-model-collection.d.ts +1 -0
  21. package/lib/models/restful-model-collection.js +5 -0
  22. package/lib/models/restful-model.d.ts +1 -0
  23. package/lib/models/restful-model.js +3 -1
  24. package/lib/models/scheduler-booking-request.d.ts +31 -0
  25. package/lib/models/scheduler-booking-request.js +147 -0
  26. package/lib/models/scheduler-restful-model-collection.d.ts +25 -0
  27. package/lib/models/scheduler-restful-model-collection.js +136 -0
  28. package/lib/models/scheduler-time-slot.d.ts +9 -0
  29. package/lib/models/scheduler-time-slot.js +52 -0
  30. package/lib/models/scheduler.d.ts +98 -0
  31. package/lib/models/scheduler.js +140 -0
  32. package/lib/nylas-connection.d.ts +5 -0
  33. package/lib/nylas-connection.js +8 -3
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -2,16 +2,15 @@
2
2
 
3
3
  [![Travis build status](https://travis-ci.org/nylas/nylas-nodejs.svg?branch=master)](https://travis-ci.org/nylas/nylas-nodejs)
4
4
 
5
- This is the GitHub repository for the Nylas Node SDK and this repo is primarily for anyone who wants to make contributions to the SDK or install it from source. If you are looking to use Node to access the Nylas Email, Calendar, or Contacts API you should refer to our official [Node SDK Quickstart Guide](https://docs.nylas.com/docs/quickstart-node).
5
+ This is the GitHub repository for the Nylas Node SDK and this repo is primarily for anyone who wants to make contributions to the SDK or install it from source. If you are looking to use Node to access the Nylas Email, Calendar, or Contacts API you should refer to our official [Node SDK Quickstart Guide](https://developer.nylas.com/docs/developer-tools/sdk/node-sdk/).
6
6
 
7
- The Nylas Communications Platform provides REST APIs for [Email](https://docs.nylas.com/docs/quickstart-email), [Calendar](https://docs.nylas.com/docs/quickstart-calendar), and [Contacts](https://docs.nylas.com/docs/quickstart-contacts), and the Node SDK is the quickest way to build your integration using JavaScript.
7
+ The Nylas Communications Platform provides REST APIs for [Email](https://developer.nylas.com/docs/connectivity/email/), [Calendar](https://developer.nylas.com/docs/connectivity/calendar/), and [Contacts](https://developer.nylas.com/docs/connectivity/contacts/), and the Node SDK is the quickest way to build your integration using JavaScript.
8
8
 
9
9
  Here are some resources to help you get started:
10
10
 
11
- - [Nylas SDK Tutorials](https://docs.nylas.com/docs/tutorials#section-node-js)
12
- - [Get Started with the Nylas Communications Platform](https://docs.nylas.com/docs/getting-started)
13
- - [Sign up for your Nylas developer account.](https://nylas.com/register)
14
- - [Nylas API Reference](https://docs.nylas.com/reference)
11
+ - [Nylas SDK Tutorials](https://developer.nylas.com/docs/the-basics/tutorials/nodejs/)
12
+ - [Quickstart](https://developer.nylas.com/docs/the-basics/quickstart/)
13
+ - [Nylas API Reference](https://developer.nylas.com/docs/api/)
15
14
 
16
15
 
17
16
  # Install
@@ -30,6 +29,7 @@ git clone https://github.com/nylas/nylas-nodejs.git
30
29
  cd nylas-nodejs
31
30
  npm install
32
31
  ```
32
+
33
33
  # Usage
34
34
 
35
35
  Every resource (i.e., messages, events, contacts) is accessed via an instance of `Nylas`. Before making any requests, be sure to call `config` and initialize the `Nylas` instance with your `clientId` and `clientSecret`. Then, call `with` and pass it your `accessToken`. The `accessToken` allows `Nylas` to make requests for a given account's resources.
@@ -52,7 +52,7 @@ nylas.threads.list({}).then(threads => {
52
52
  });
53
53
  ```
54
54
 
55
- For more information about how to use the Nylas Node SDK, [take a look at our quickstart guide](https://docs.nylas.com/docs/quickstart-node).
55
+ For more information about how to use the Nylas Node SDK, [take a look at our quickstart guide](https://developer.nylas.com/docs/developer-tools/sdk/node-sdk/).
56
56
 
57
57
  # Contributing
58
58
 
@@ -43,4 +43,34 @@ export default class CalendarRestfulModelCollection extends RestfulModelCollecti
43
43
  }, callback?: (error: Error | null, data?: {
44
44
  [key: string]: any;
45
45
  }) => void): Promise<any>;
46
+ consecutiveAvailability(options: {
47
+ emails: Array<string[]>;
48
+ duration: number;
49
+ interval: number;
50
+ start_time?: number;
51
+ startTime?: number;
52
+ end_time?: number;
53
+ endTime?: number;
54
+ buffer?: number;
55
+ free_busy?: Array<{
56
+ email: string;
57
+ object: string;
58
+ time_slots: Array<{
59
+ object: string;
60
+ status: string;
61
+ start_time: number;
62
+ end_time: number;
63
+ }>;
64
+ }>;
65
+ open_hours: Array<{
66
+ emails: string[];
67
+ days: number[];
68
+ timezone: string;
69
+ start: string;
70
+ end: string;
71
+ object_type: string;
72
+ }>;
73
+ }, callback?: (error: Error | null, data?: {
74
+ [key: string]: any;
75
+ }) => void): Promise<any>;
46
76
  }
@@ -78,6 +78,51 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
78
78
  return Promise.reject(err);
79
79
  });
80
80
  };
81
+ CalendarRestfulModelCollection.prototype.consecutiveAvailability = function (options, callback) {
82
+ var freeBusyEmails = options.free_busy
83
+ ? options.free_busy.map(function (freeBusy) { return freeBusy.email; })
84
+ : [];
85
+ for (var _i = 0, _a = options.open_hours; _i < _a.length; _i++) {
86
+ var openHour = _a[_i];
87
+ var _loop_1 = function (email) {
88
+ if (!options.emails.some(function (row) { return row.includes(email); }) &&
89
+ !freeBusyEmails.includes(email)) {
90
+ throw new Error('Open Hours cannot contain an email not present in the main email list or the free busy email list.');
91
+ }
92
+ };
93
+ for (var _b = 0, _c = openHour.emails; _b < _c.length; _b++) {
94
+ var email = _c[_b];
95
+ _loop_1(email);
96
+ }
97
+ }
98
+ return this.connection
99
+ .request({
100
+ method: 'POST',
101
+ path: "/calendars/availability/consecutive",
102
+ body: {
103
+ emails: options.emails,
104
+ duration_minutes: options.duration,
105
+ interval_minutes: options.interval,
106
+ start_time: options.startTime || options.start_time,
107
+ end_time: options.endTime || options.end_time,
108
+ buffer: options.buffer,
109
+ free_busy: options.free_busy || [],
110
+ open_hours: options.open_hours,
111
+ },
112
+ })
113
+ .then(function (json) {
114
+ if (callback) {
115
+ callback(null, json);
116
+ }
117
+ return Promise.resolve(json);
118
+ })
119
+ .catch(function (err) {
120
+ if (callback) {
121
+ callback(err);
122
+ }
123
+ return Promise.reject(err);
124
+ });
125
+ };
81
126
  return CalendarRestfulModelCollection;
82
127
  }(restful_model_collection_1.default));
83
128
  exports.default = CalendarRestfulModelCollection;
@@ -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,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,9 @@
1
+ import RestfulModelCollection from './restful-model-collection';
2
+ import NylasConnection from '../nylas-connection';
3
+ import Component from './component';
4
+ export default class ComponentRestfulModelCollection extends RestfulModelCollection<Component> {
5
+ connection: NylasConnection;
6
+ modelClass: typeof Component;
7
+ constructor(connection: NylasConnection);
8
+ path(): string;
9
+ }
@@ -0,0 +1,34 @@
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 component_1 = __importDefault(require("./component"));
21
+ var ComponentRestfulModelCollection = /** @class */ (function (_super) {
22
+ __extends(ComponentRestfulModelCollection, _super);
23
+ function ComponentRestfulModelCollection(connection) {
24
+ var _this = _super.call(this, component_1.default, connection) || this;
25
+ _this.connection = connection;
26
+ _this.modelClass = component_1.default;
27
+ return _this;
28
+ }
29
+ ComponentRestfulModelCollection.prototype.path = function () {
30
+ return "/component/" + this.connection.clientId;
31
+ };
32
+ return ComponentRestfulModelCollection;
33
+ }(restful_model_collection_1.default));
34
+ exports.default = ComponentRestfulModelCollection;
@@ -0,0 +1,16 @@
1
+ import RestfulModel, { SaveCallback } from './restful-model';
2
+ export default class Component extends RestfulModel {
3
+ name?: string;
4
+ type?: string;
5
+ action?: number;
6
+ active?: boolean;
7
+ settings?: object;
8
+ allowedDomains?: string[];
9
+ publicAccountId?: string;
10
+ publicTokenId?: string;
11
+ publicApplicationId?: string;
12
+ createdAt?: Date;
13
+ updatedAt?: Date;
14
+ saveEndpoint(): string;
15
+ save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
16
+ }
@@ -0,0 +1,76 @@
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 __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
+ };
26
+ var __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ var restful_model_1 = __importDefault(require("./restful-model"));
31
+ var attributes_1 = __importDefault(require("./attributes"));
32
+ var Component = /** @class */ (function (_super) {
33
+ __extends(Component, _super);
34
+ function Component() {
35
+ return _super !== null && _super.apply(this, arguments) || this;
36
+ }
37
+ Component.prototype.saveEndpoint = function () {
38
+ return "/component/" + this.connection.clientId;
39
+ };
40
+ Component.prototype.save = function (params, callback) {
41
+ if (params === void 0) { params = {}; }
42
+ return this._save(params, callback);
43
+ };
44
+ return Component;
45
+ }(restful_model_1.default));
46
+ exports.default = Component;
47
+ Component.collectionName = 'component';
48
+ Component.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
49
+ modelKey: 'name',
50
+ }), type: attributes_1.default.String({
51
+ modelKey: 'type',
52
+ }), action: attributes_1.default.Number({
53
+ modelKey: 'action',
54
+ }), active: attributes_1.default.Boolean({
55
+ modelKey: 'active',
56
+ }), settings: attributes_1.default.Object({
57
+ modelKey: 'settings',
58
+ }), allowedDomains: attributes_1.default.StringList({
59
+ modelKey: 'allowedDomains',
60
+ jsonKey: 'allowed_domains',
61
+ }), publicAccountId: attributes_1.default.String({
62
+ modelKey: 'publicAccountId',
63
+ jsonKey: 'public_account_id',
64
+ }), publicTokenId: attributes_1.default.String({
65
+ modelKey: 'publicTokenId',
66
+ jsonKey: 'public_token_id',
67
+ }), publicApplicationId: attributes_1.default.String({
68
+ modelKey: 'publicApplicationId',
69
+ jsonKey: 'public_application_id',
70
+ }), createdAt: attributes_1.default.Date({
71
+ modelKey: 'createdAt',
72
+ jsonKey: 'created_at',
73
+ }), updatedAt: attributes_1.default.Date({
74
+ modelKey: 'updatedAt',
75
+ jsonKey: 'updated_at',
76
+ }) });
@@ -16,6 +16,9 @@ declare class EventConferencingDetails extends RestfulModel {
16
16
  export declare class EventConferencing extends RestfulModel {
17
17
  details?: EventConferencingDetails;
18
18
  provider?: string;
19
+ autocreate?: {
20
+ settings?: object;
21
+ };
19
22
  toJSON(): any;
20
23
  }
21
24
  export {};
@@ -63,6 +63,7 @@ var EventConferencing = /** @class */ (function (_super) {
63
63
  return {
64
64
  details: this.details,
65
65
  provider: this.provider,
66
+ autocreate: this.autocreate,
66
67
  };
67
68
  };
68
69
  return EventConferencing;
@@ -77,4 +78,7 @@ EventConferencing.attributes = {
77
78
  provider: attributes_1.default.String({
78
79
  modelKey: 'provider',
79
80
  }),
81
+ autocreate: attributes_1.default.Object({
82
+ modelKey: 'autocreate',
83
+ }),
80
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
+ };
@@ -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,7 +30,9 @@ 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;
35
+ jobStatusId?: string;
33
36
  get start(): string | number | undefined;
34
37
  set start(val: string | number | undefined);
35
38
  get end(): string | number | undefined;
@@ -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() {
@@ -118,6 +119,11 @@ var Event = /** @class */ (function (_super) {
118
119
  };
119
120
  Event.prototype.save = function (params, callback) {
120
121
  if (params === void 0) { params = {}; }
122
+ if (this.conferencing &&
123
+ this.conferencing.details &&
124
+ this.conferencing.autocreate) {
125
+ return Promise.reject(new Error("Cannot set both 'details' and 'autocreate' in conferencing object."));
126
+ }
121
127
  return this._save(params, callback);
122
128
  };
123
129
  Event.prototype.rsvp = function (status, comment, callback) {
@@ -152,15 +158,18 @@ Event.attributes = __assign(__assign({}, restful_model_1.default.attributes), {
152
158
  }), iCalUID: attributes_1.default.String({
153
159
  modelKey: 'iCalUID',
154
160
  jsonKey: 'ical_uid',
161
+ readOnly: true,
155
162
  }), messageId: attributes_1.default.String({
156
163
  modelKey: 'messageId',
157
164
  jsonKey: 'message_id',
165
+ readOnly: true,
158
166
  }), title: attributes_1.default.String({
159
167
  modelKey: 'title',
160
168
  }), description: attributes_1.default.String({
161
169
  modelKey: 'description',
162
170
  }), owner: attributes_1.default.String({
163
171
  modelKey: 'owner',
172
+ readOnly: true,
164
173
  }), participants: attributes_1.default.Collection({
165
174
  modelKey: 'participants',
166
175
  itemClass: event_participant_1.default,
@@ -175,6 +184,7 @@ Event.attributes = __assign(__assign({}, restful_model_1.default.attributes), {
175
184
  modelKey: 'busy',
176
185
  }), status: attributes_1.default.String({
177
186
  modelKey: 'status',
187
+ readOnly: true,
178
188
  }), recurrence: attributes_1.default.Object({
179
189
  modelKey: 'recurrence',
180
190
  }), masterEventId: attributes_1.default.String({
@@ -188,6 +198,13 @@ Event.attributes = __assign(__assign({}, restful_model_1.default.attributes), {
188
198
  }), conferencing: attributes_1.default.Object({
189
199
  modelKey: 'conferencing',
190
200
  itemClass: event_conferencing_1.EventConferencing,
201
+ }), notifications: attributes_1.default.Collection({
202
+ modelKey: 'notifications',
203
+ itemClass: event_notification_1.EventNotification,
191
204
  }), metadata: attributes_1.default.Object({
192
205
  modelKey: 'metadata',
206
+ }), jobStatusId: attributes_1.default.String({
207
+ modelKey: 'jobStatusId',
208
+ jsonKey: 'job_status_id',
209
+ readOnly: true,
193
210
  }) });
@@ -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,6 +20,7 @@ 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
  };
@@ -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) {
@@ -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,7 +37,7 @@ var RestfulModel = /** @class */ (function () {
37
37
  var json = {};
38
38
  var attributes = this.attributes();
39
39
  for (var attrName in attributes) {
40
- if (!enforceReadOnly || !attributes[attrName].readOnly) {
40
+ if (!attributes[attrName].readOnly || enforceReadOnly !== true) {
41
41
  var attr = attributes[attrName];
42
42
  json[attr.jsonKey] = attr.toJSON(this[attrName]);
43
43
  }
@@ -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) {