nylas 5.8.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.
Files changed (79) hide show
  1. package/LICENSE.txt +22 -0
  2. package/README.md +65 -0
  3. package/lib/config.d.ts +4 -0
  4. package/lib/config.js +13 -0
  5. package/lib/models/account.d.ts +10 -0
  6. package/lib/models/account.js +61 -0
  7. package/lib/models/attributes.d.ts +104 -0
  8. package/lib/models/attributes.js +266 -0
  9. package/lib/models/calendar-restful-model-collection.d.ts +76 -0
  10. package/lib/models/calendar-restful-model-collection.js +128 -0
  11. package/lib/models/calendar.d.ts +19 -0
  12. package/lib/models/calendar.js +81 -0
  13. package/lib/models/connect.d.ts +12 -0
  14. package/lib/models/connect.js +51 -0
  15. package/lib/models/contact-restful-model-collection.d.ts +11 -0
  16. package/lib/models/contact-restful-model-collection.js +54 -0
  17. package/lib/models/contact.d.ts +75 -0
  18. package/lib/models/contact.js +245 -0
  19. package/lib/models/delta-stream.d.ts +30 -0
  20. package/lib/models/delta-stream.js +225 -0
  21. package/lib/models/delta.d.ts +11 -0
  22. package/lib/models/delta.js +91 -0
  23. package/lib/models/draft.d.ts +24 -0
  24. package/lib/models/draft.js +145 -0
  25. package/lib/models/email-participant.d.ts +6 -0
  26. package/lib/models/email-participant.js +44 -0
  27. package/lib/models/event-conferencing.d.ts +24 -0
  28. package/lib/models/event-conferencing.js +84 -0
  29. package/lib/models/event-participant.d.ts +7 -0
  30. package/lib/models/event-participant.js +47 -0
  31. package/lib/models/event.d.ts +45 -0
  32. package/lib/models/event.js +206 -0
  33. package/lib/models/file.d.ts +18 -0
  34. package/lib/models/file.js +151 -0
  35. package/lib/models/folder.d.ts +14 -0
  36. package/lib/models/folder.js +70 -0
  37. package/lib/models/job-status.d.ts +7 -0
  38. package/lib/models/job-status.js +51 -0
  39. package/lib/models/management-account.d.ts +14 -0
  40. package/lib/models/management-account.js +101 -0
  41. package/lib/models/management-model-collection.d.ts +11 -0
  42. package/lib/models/management-model-collection.js +35 -0
  43. package/lib/models/management-model.d.ts +8 -0
  44. package/lib/models/management-model.js +29 -0
  45. package/lib/models/message.d.ts +32 -0
  46. package/lib/models/message.js +154 -0
  47. package/lib/models/neural-categorizer.d.ts +18 -0
  48. package/lib/models/neural-categorizer.js +140 -0
  49. package/lib/models/neural-clean-conversation.d.ts +7 -0
  50. package/lib/models/neural-clean-conversation.js +110 -0
  51. package/lib/models/neural-ocr.d.ts +5 -0
  52. package/lib/models/neural-ocr.js +46 -0
  53. package/lib/models/neural-sentiment-analysis.d.ts +8 -0
  54. package/lib/models/neural-sentiment-analysis.js +49 -0
  55. package/lib/models/neural-signature-contact.d.ts +37 -0
  56. package/lib/models/neural-signature-contact.js +141 -0
  57. package/lib/models/neural-signature-extraction.d.ts +7 -0
  58. package/lib/models/neural-signature-extraction.js +50 -0
  59. package/lib/models/neural.d.ts +22 -0
  60. package/lib/models/neural.js +124 -0
  61. package/lib/models/nylas-api-error.d.ts +28 -0
  62. package/lib/models/nylas-api-error.js +61 -0
  63. package/lib/models/resource.d.ts +9 -0
  64. package/lib/models/resource.js +59 -0
  65. package/lib/models/restful-model-collection.d.ts +59 -0
  66. package/lib/models/restful-model-collection.js +325 -0
  67. package/lib/models/restful-model-instance.d.ts +11 -0
  68. package/lib/models/restful-model-instance.js +37 -0
  69. package/lib/models/restful-model.d.ts +48 -0
  70. package/lib/models/restful-model.js +153 -0
  71. package/lib/models/thread.d.ts +30 -0
  72. package/lib/models/thread.js +112 -0
  73. package/lib/models/webhook.d.ts +15 -0
  74. package/lib/models/webhook.js +71 -0
  75. package/lib/nylas-connection.d.ts +67 -0
  76. package/lib/nylas-connection.js +235 -0
  77. package/lib/nylas.d.ts +38 -0
  78. package/lib/nylas.js +178 -0
  79. package/package.json +76 -0
@@ -0,0 +1,14 @@
1
+ import RestfulModel, { SaveCallback } from './restful-model';
2
+ export declare class Folder extends RestfulModel {
3
+ displayName?: string;
4
+ name?: string;
5
+ saveRequestBody(): {
6
+ [key: string]: any;
7
+ };
8
+ save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
9
+ }
10
+ export declare class Label extends Folder {
11
+ saveRequestBody(): {
12
+ display_name: string | undefined;
13
+ };
14
+ }
@@ -0,0 +1,70 @@
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
+ exports.Label = exports.Folder = void 0;
31
+ var restful_model_1 = __importDefault(require("./restful-model"));
32
+ var attributes_1 = __importDefault(require("./attributes"));
33
+ var Folder = /** @class */ (function (_super) {
34
+ __extends(Folder, _super);
35
+ function Folder() {
36
+ return _super !== null && _super.apply(this, arguments) || this;
37
+ }
38
+ Folder.prototype.saveRequestBody = function () {
39
+ var json = {};
40
+ json['display_name'] = this.displayName;
41
+ json['name'] = this.name;
42
+ return json;
43
+ };
44
+ Folder.prototype.save = function (params, callback) {
45
+ if (params === void 0) { params = {}; }
46
+ return this._save(params, callback);
47
+ };
48
+ return Folder;
49
+ }(restful_model_1.default));
50
+ exports.Folder = Folder;
51
+ Folder.collectionName = 'folders';
52
+ Folder.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
53
+ modelKey: 'name',
54
+ jsonKey: 'name',
55
+ }), displayName: attributes_1.default.String({
56
+ modelKey: 'displayName',
57
+ jsonKey: 'display_name',
58
+ }) });
59
+ var Label = /** @class */ (function (_super) {
60
+ __extends(Label, _super);
61
+ function Label() {
62
+ return _super !== null && _super.apply(this, arguments) || this;
63
+ }
64
+ Label.prototype.saveRequestBody = function () {
65
+ return { display_name: this.displayName };
66
+ };
67
+ return Label;
68
+ }(Folder));
69
+ exports.Label = Label;
70
+ Label.collectionName = 'labels';
@@ -0,0 +1,7 @@
1
+ import RestfulModel from './restful-model';
2
+ export default class JobStatus extends RestfulModel {
3
+ action?: string;
4
+ createdAt?: Date;
5
+ jobStatusId?: string;
6
+ status?: string;
7
+ }
@@ -0,0 +1,51 @@
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 JobStatus = /** @class */ (function (_super) {
33
+ __extends(JobStatus, _super);
34
+ function JobStatus() {
35
+ return _super !== null && _super.apply(this, arguments) || this;
36
+ }
37
+ return JobStatus;
38
+ }(restful_model_1.default));
39
+ exports.default = JobStatus;
40
+ JobStatus.collectionName = 'job-statuses';
41
+ JobStatus.attributes = __assign(__assign({}, restful_model_1.default.attributes), { action: attributes_1.default.String({
42
+ modelKey: 'action',
43
+ }), createdAt: attributes_1.default.DateTime({
44
+ modelKey: 'createdAt',
45
+ jsonKey: 'created_at',
46
+ }), jobStatusId: attributes_1.default.String({
47
+ modelKey: 'jobStatusId',
48
+ jsonKey: 'job_status_id',
49
+ }), status: attributes_1.default.String({
50
+ modelKey: 'status',
51
+ }) });
@@ -0,0 +1,14 @@
1
+ import ManagementModel from './management-model';
2
+ export default class ManagementAccount extends ManagementModel {
3
+ billingState?: string;
4
+ emailAddress?: string;
5
+ namespaceId?: string;
6
+ provider?: string;
7
+ syncState?: string;
8
+ trial?: boolean;
9
+ upgrade(): Promise<any>;
10
+ downgrade(): Promise<any>;
11
+ revokeAll(keepAccessToken?: string): Promise<any>;
12
+ ipAddresses(): Promise<any>;
13
+ tokenInfo(accessToken?: string): Promise<any>;
14
+ }
@@ -0,0 +1,101 @@
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 management_model_1 = __importDefault(require("./management-model"));
31
+ var attributes_1 = __importDefault(require("./attributes"));
32
+ var ManagementAccount = /** @class */ (function (_super) {
33
+ __extends(ManagementAccount, _super);
34
+ function ManagementAccount() {
35
+ return _super !== null && _super.apply(this, arguments) || this;
36
+ }
37
+ ManagementAccount.prototype.upgrade = function () {
38
+ return this.connection
39
+ .request({
40
+ method: 'POST',
41
+ path: "/a/" + this.clientId + "/" + this.constructor.collectionName + "/" + this.id + "/upgrade",
42
+ })
43
+ .catch(function (err) { return Promise.reject(err); });
44
+ };
45
+ ManagementAccount.prototype.downgrade = function () {
46
+ return this.connection
47
+ .request({
48
+ method: 'POST',
49
+ path: "/a/" + this.clientId + "/" + this.constructor.collectionName + "/" + this.id + "/downgrade",
50
+ })
51
+ .catch(function (err) { return Promise.reject(err); });
52
+ };
53
+ ManagementAccount.prototype.revokeAll = function (keepAccessToken) {
54
+ return this.connection
55
+ .request({
56
+ method: 'POST',
57
+ path: "/a/" + this.clientId + "/" + this.constructor.collectionName + "/" + this.id + "/revoke-all",
58
+ body: { keep_access_token: keepAccessToken },
59
+ })
60
+ .catch(function (err) { return Promise.reject(err); });
61
+ };
62
+ ManagementAccount.prototype.ipAddresses = function () {
63
+ return this.connection
64
+ .request({
65
+ method: 'GET',
66
+ path: "/a/" + this.clientId + "/ip_addresses",
67
+ })
68
+ .catch(function (err) { return Promise.reject(err); });
69
+ };
70
+ ManagementAccount.prototype.tokenInfo = function (accessToken) {
71
+ return this.connection
72
+ .request({
73
+ method: 'POST',
74
+ path: "/a/" + this.clientId + "/" + this.constructor.collectionName + "/" + this.id + "/token-info",
75
+ body: {
76
+ access_token: accessToken,
77
+ },
78
+ })
79
+ .catch(function (err) { return Promise.reject(err); });
80
+ };
81
+ return ManagementAccount;
82
+ }(management_model_1.default));
83
+ exports.default = ManagementAccount;
84
+ ManagementAccount.collectionName = 'accounts';
85
+ ManagementAccount.attributes = __assign(__assign({}, management_model_1.default.attributes), { billingState: attributes_1.default.String({
86
+ modelKey: 'billingState',
87
+ jsonKey: 'billing_state',
88
+ }), emailAddress: attributes_1.default.String({
89
+ modelKey: 'emailAddress',
90
+ jsonKey: 'email',
91
+ }), namespaceId: attributes_1.default.String({
92
+ modelKey: 'namespaceId',
93
+ jsonKey: 'namespace_id',
94
+ }), provider: attributes_1.default.String({
95
+ modelKey: 'provider',
96
+ }), syncState: attributes_1.default.String({
97
+ modelKey: 'syncState',
98
+ jsonKey: 'sync_state',
99
+ }), trial: attributes_1.default.Boolean({
100
+ modelKey: 'trial',
101
+ }) });
@@ -0,0 +1,11 @@
1
+ import ManagementModel from './management-model';
2
+ import NylasConnection from '../nylas-connection';
3
+ import RestfulModelCollection from './restful-model-collection';
4
+ export default class ManagementModelCollection<T extends ManagementModel> extends RestfulModelCollection<T> {
5
+ clientId: string;
6
+ constructor(modelClass: typeof ManagementModel, connection: NylasConnection, clientId: string);
7
+ path(): string;
8
+ _createModel(json: {
9
+ [key: string]: any;
10
+ }): any;
11
+ }
@@ -0,0 +1,35 @@
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 ManagementModelCollection = /** @class */ (function (_super) {
21
+ __extends(ManagementModelCollection, _super);
22
+ function ManagementModelCollection(modelClass, connection, clientId) {
23
+ var _this = _super.call(this, modelClass, connection) || this;
24
+ _this.clientId = clientId;
25
+ return _this;
26
+ }
27
+ ManagementModelCollection.prototype.path = function () {
28
+ return "/a/" + this.clientId + "/" + this.modelClass.collectionName;
29
+ };
30
+ ManagementModelCollection.prototype._createModel = function (json) {
31
+ return new this.modelClass(this.connection, this.clientId, json);
32
+ };
33
+ return ManagementModelCollection;
34
+ }(restful_model_collection_1.default));
35
+ exports.default = ManagementModelCollection;
@@ -0,0 +1,8 @@
1
+ import RestfulModel from './restful-model';
2
+ import NylasConnection from '../nylas-connection';
3
+ export default class ManagementModel extends RestfulModel {
4
+ clientId: string;
5
+ constructor(connection: NylasConnection, clientId: string, json: {
6
+ [key: string]: any;
7
+ });
8
+ }
@@ -0,0 +1,29 @@
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 ManagementModel = /** @class */ (function (_super) {
21
+ __extends(ManagementModel, _super);
22
+ function ManagementModel(connection, clientId, json) {
23
+ var _this = _super.call(this, connection, json) || this;
24
+ _this.clientId = clientId;
25
+ return _this;
26
+ }
27
+ return ManagementModel;
28
+ }(restful_model_1.default));
29
+ exports.default = ManagementModel;
@@ -0,0 +1,32 @@
1
+ import RestfulModel, { SaveCallback } from './restful-model';
2
+ import File from './file';
3
+ import Event from './event';
4
+ import EmailParticipant from './email-participant';
5
+ import { Label, Folder } from './folder';
6
+ export default class Message extends RestfulModel {
7
+ subject?: string;
8
+ from?: EmailParticipant[];
9
+ replyTo?: EmailParticipant[];
10
+ to?: EmailParticipant[];
11
+ cc?: EmailParticipant[];
12
+ bcc?: EmailParticipant[];
13
+ date?: Date;
14
+ threadId?: string;
15
+ snippet?: string;
16
+ body?: string;
17
+ unread?: boolean;
18
+ starred?: boolean;
19
+ files?: File[];
20
+ events?: Event[];
21
+ folder?: Folder;
22
+ labels?: Label[];
23
+ headers?: {
24
+ [key: string]: string;
25
+ };
26
+ failures?: any;
27
+ participants(): EmailParticipant[];
28
+ fileIds(): (string | undefined)[];
29
+ getRaw(): Promise<any>;
30
+ saveRequestBody(): any;
31
+ save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
32
+ }
@@ -0,0 +1,154 @@
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 __spreadArrays = (this && this.__spreadArrays) || function () {
27
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
28
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
29
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
30
+ r[k] = a[j];
31
+ return r;
32
+ };
33
+ var __importDefault = (this && this.__importDefault) || function (mod) {
34
+ return (mod && mod.__esModule) ? mod : { "default": mod };
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ var restful_model_1 = __importDefault(require("./restful-model"));
38
+ var attributes_1 = __importDefault(require("./attributes"));
39
+ var file_1 = __importDefault(require("./file"));
40
+ var event_1 = __importDefault(require("./event"));
41
+ var email_participant_1 = __importDefault(require("./email-participant"));
42
+ var folder_1 = require("./folder");
43
+ var Message = /** @class */ (function (_super) {
44
+ __extends(Message, _super);
45
+ function Message() {
46
+ return _super !== null && _super.apply(this, arguments) || this;
47
+ }
48
+ // We calculate the list of participants instead of grabbing it from
49
+ // a parent because it is a better source of ground truth, and saves us
50
+ // from more dependencies.
51
+ Message.prototype.participants = function () {
52
+ var participants = {};
53
+ var to = this.to || [];
54
+ var cc = this.cc || [];
55
+ var from = this.from || [];
56
+ var contacts = Array.from(new Set(__spreadArrays(to, cc, from)));
57
+ for (var _i = 0, contacts_1 = contacts; _i < contacts_1.length; _i++) {
58
+ var contact = contacts_1[_i];
59
+ if (contact && (contact.email ? contact.email.length : '') > 0) {
60
+ if (contact) {
61
+ participants[(contact.email || ''.toLowerCase().trim()) + " " + (contact.name || '')
62
+ .toLowerCase()
63
+ .trim()] = contact;
64
+ }
65
+ }
66
+ }
67
+ return Object.values(participants);
68
+ };
69
+ Message.prototype.fileIds = function () {
70
+ return this.files ? this.files.map(function (file) { return file.id; }) : [];
71
+ };
72
+ Message.prototype.getRaw = function () {
73
+ return this.connection
74
+ .request({
75
+ method: 'GET',
76
+ headers: {
77
+ Accept: 'message/rfc822',
78
+ },
79
+ path: "/" + Message.collectionName + "/" + this.id,
80
+ })
81
+ .catch(function (err) { return Promise.reject(err); });
82
+ };
83
+ Message.prototype.saveRequestBody = function () {
84
+ // It's possible to update most of the fields of a draft.
85
+ if (this.constructor.name === 'Draft') {
86
+ return _super.prototype.saveRequestBody.call(this);
87
+ }
88
+ // Messages are more limited, though.
89
+ var json = {};
90
+ if (this.labels) {
91
+ json['label_ids'] = Array.from(this.labels).map(function (label) { return label.id; });
92
+ }
93
+ else if (this.folder) {
94
+ json['folder_id'] = this.folder.id;
95
+ }
96
+ json['starred'] = this.starred;
97
+ json['unread'] = this.unread;
98
+ return json;
99
+ };
100
+ Message.prototype.save = function (params, callback) {
101
+ if (params === void 0) { params = {}; }
102
+ return this._save(params, callback);
103
+ };
104
+ return Message;
105
+ }(restful_model_1.default));
106
+ exports.default = Message;
107
+ Message.collectionName = 'messages';
108
+ Message.attributes = __assign(__assign({}, restful_model_1.default.attributes), { subject: attributes_1.default.String({
109
+ modelKey: 'subject',
110
+ }), from: attributes_1.default.Collection({
111
+ modelKey: 'from',
112
+ itemClass: email_participant_1.default,
113
+ }), replyTo: attributes_1.default.Collection({
114
+ modelKey: 'replyTo',
115
+ jsonKey: 'reply_to',
116
+ itemClass: email_participant_1.default,
117
+ }), to: attributes_1.default.Collection({
118
+ modelKey: 'to',
119
+ itemClass: email_participant_1.default,
120
+ }), cc: attributes_1.default.Collection({
121
+ modelKey: 'cc',
122
+ itemClass: email_participant_1.default,
123
+ }), bcc: attributes_1.default.Collection({
124
+ modelKey: 'bcc',
125
+ itemClass: email_participant_1.default,
126
+ }), date: attributes_1.default.DateTime({
127
+ modelKey: 'date',
128
+ }), threadId: attributes_1.default.String({
129
+ modelKey: 'threadId',
130
+ jsonKey: 'thread_id',
131
+ }), snippet: attributes_1.default.String({
132
+ modelKey: 'snippet',
133
+ }), body: attributes_1.default.String({
134
+ modelKey: 'body',
135
+ }), unread: attributes_1.default.Boolean({
136
+ modelKey: 'unread',
137
+ }), starred: attributes_1.default.Boolean({
138
+ modelKey: 'starred',
139
+ }), files: attributes_1.default.Collection({
140
+ modelKey: 'files',
141
+ itemClass: file_1.default,
142
+ readOnly: true,
143
+ }), events: attributes_1.default.Collection({
144
+ modelKey: 'events',
145
+ itemClass: event_1.default,
146
+ }), folder: attributes_1.default.Object({
147
+ modelKey: 'folder',
148
+ itemClass: folder_1.Folder,
149
+ }), labels: attributes_1.default.Collection({
150
+ modelKey: 'labels',
151
+ itemClass: folder_1.Label,
152
+ }), headers: attributes_1.default.Object({
153
+ modelKey: 'headers',
154
+ }) });