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.
- package/LICENSE.txt +22 -0
- package/README.md +65 -0
- package/lib/config.d.ts +4 -0
- package/lib/config.js +13 -0
- package/lib/models/account.d.ts +10 -0
- package/lib/models/account.js +61 -0
- package/lib/models/attributes.d.ts +104 -0
- package/lib/models/attributes.js +266 -0
- package/lib/models/calendar-restful-model-collection.d.ts +76 -0
- package/lib/models/calendar-restful-model-collection.js +128 -0
- package/lib/models/calendar.d.ts +19 -0
- package/lib/models/calendar.js +81 -0
- package/lib/models/connect.d.ts +12 -0
- package/lib/models/connect.js +51 -0
- package/lib/models/contact-restful-model-collection.d.ts +11 -0
- package/lib/models/contact-restful-model-collection.js +54 -0
- package/lib/models/contact.d.ts +75 -0
- package/lib/models/contact.js +245 -0
- package/lib/models/delta-stream.d.ts +30 -0
- package/lib/models/delta-stream.js +225 -0
- package/lib/models/delta.d.ts +11 -0
- package/lib/models/delta.js +91 -0
- package/lib/models/draft.d.ts +24 -0
- package/lib/models/draft.js +145 -0
- package/lib/models/email-participant.d.ts +6 -0
- package/lib/models/email-participant.js +44 -0
- package/lib/models/event-conferencing.d.ts +24 -0
- package/lib/models/event-conferencing.js +84 -0
- package/lib/models/event-participant.d.ts +7 -0
- package/lib/models/event-participant.js +47 -0
- package/lib/models/event.d.ts +45 -0
- package/lib/models/event.js +206 -0
- package/lib/models/file.d.ts +18 -0
- package/lib/models/file.js +151 -0
- package/lib/models/folder.d.ts +14 -0
- package/lib/models/folder.js +70 -0
- package/lib/models/job-status.d.ts +7 -0
- package/lib/models/job-status.js +51 -0
- package/lib/models/management-account.d.ts +14 -0
- package/lib/models/management-account.js +101 -0
- package/lib/models/management-model-collection.d.ts +11 -0
- package/lib/models/management-model-collection.js +35 -0
- package/lib/models/management-model.d.ts +8 -0
- package/lib/models/management-model.js +29 -0
- package/lib/models/message.d.ts +32 -0
- package/lib/models/message.js +154 -0
- package/lib/models/neural-categorizer.d.ts +18 -0
- package/lib/models/neural-categorizer.js +140 -0
- package/lib/models/neural-clean-conversation.d.ts +7 -0
- package/lib/models/neural-clean-conversation.js +110 -0
- package/lib/models/neural-ocr.d.ts +5 -0
- package/lib/models/neural-ocr.js +46 -0
- package/lib/models/neural-sentiment-analysis.d.ts +8 -0
- package/lib/models/neural-sentiment-analysis.js +49 -0
- package/lib/models/neural-signature-contact.d.ts +37 -0
- package/lib/models/neural-signature-contact.js +141 -0
- package/lib/models/neural-signature-extraction.d.ts +7 -0
- package/lib/models/neural-signature-extraction.js +50 -0
- package/lib/models/neural.d.ts +22 -0
- package/lib/models/neural.js +124 -0
- package/lib/models/nylas-api-error.d.ts +28 -0
- package/lib/models/nylas-api-error.js +61 -0
- package/lib/models/resource.d.ts +9 -0
- package/lib/models/resource.js +59 -0
- package/lib/models/restful-model-collection.d.ts +59 -0
- package/lib/models/restful-model-collection.js +325 -0
- package/lib/models/restful-model-instance.d.ts +11 -0
- package/lib/models/restful-model-instance.js +37 -0
- package/lib/models/restful-model.d.ts +48 -0
- package/lib/models/restful-model.js +153 -0
- package/lib/models/thread.d.ts +30 -0
- package/lib/models/thread.js +112 -0
- package/lib/models/webhook.d.ts +15 -0
- package/lib/models/webhook.js +71 -0
- package/lib/nylas-connection.d.ts +67 -0
- package/lib/nylas-connection.js +235 -0
- package/lib/nylas.d.ts +38 -0
- package/lib/nylas.js +178 -0
- package/package.json +76 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import NylasConnection from '../nylas-connection';
|
|
2
|
+
import RestfulModel from './restful-model';
|
|
3
|
+
export default class RestfulModelInstance<T extends RestfulModel> {
|
|
4
|
+
connection: NylasConnection;
|
|
5
|
+
modelClass: typeof RestfulModel;
|
|
6
|
+
constructor(modelClass: typeof RestfulModel, connection: NylasConnection);
|
|
7
|
+
path(): string;
|
|
8
|
+
get(params?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}): Promise<T>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var nylas_connection_1 = __importDefault(require("../nylas-connection"));
|
|
7
|
+
var RestfulModelInstance = /** @class */ (function () {
|
|
8
|
+
function RestfulModelInstance(modelClass, connection) {
|
|
9
|
+
this.modelClass = modelClass;
|
|
10
|
+
this.connection = connection;
|
|
11
|
+
if (!(this.connection instanceof nylas_connection_1.default)) {
|
|
12
|
+
throw new Error('Connection object not provided');
|
|
13
|
+
}
|
|
14
|
+
if (!this.modelClass) {
|
|
15
|
+
throw new Error('Model class not provided');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
RestfulModelInstance.prototype.path = function () {
|
|
19
|
+
return "/" + this.modelClass.endpointName;
|
|
20
|
+
};
|
|
21
|
+
RestfulModelInstance.prototype.get = function (params) {
|
|
22
|
+
var _this = this;
|
|
23
|
+
if (params === void 0) { params = {}; }
|
|
24
|
+
return this.connection
|
|
25
|
+
.request({
|
|
26
|
+
method: 'GET',
|
|
27
|
+
path: this.path(),
|
|
28
|
+
qs: params,
|
|
29
|
+
})
|
|
30
|
+
.then(function (json) {
|
|
31
|
+
var model = new _this.modelClass(_this.connection, json);
|
|
32
|
+
return Promise.resolve(model);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
return RestfulModelInstance;
|
|
36
|
+
}());
|
|
37
|
+
exports.default = RestfulModelInstance;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Attribute } from './attributes';
|
|
2
|
+
import NylasConnection from '../nylas-connection';
|
|
3
|
+
export declare type SaveCallback = (error: Error | null, result?: RestfulModel) => void;
|
|
4
|
+
interface RestfulModelJSON {
|
|
5
|
+
id: string;
|
|
6
|
+
object: string;
|
|
7
|
+
accountId: string;
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export default class RestfulModel {
|
|
11
|
+
static endpointName: string;
|
|
12
|
+
static collectionName: string;
|
|
13
|
+
static attributes: {
|
|
14
|
+
[key: string]: Attribute;
|
|
15
|
+
};
|
|
16
|
+
accountId?: string;
|
|
17
|
+
connection: NylasConnection;
|
|
18
|
+
id?: string;
|
|
19
|
+
object?: string;
|
|
20
|
+
constructor(connection: NylasConnection, json?: Partial<RestfulModelJSON>);
|
|
21
|
+
attributes(): {
|
|
22
|
+
[key: string]: Attribute;
|
|
23
|
+
};
|
|
24
|
+
isEqual(other: RestfulModel): boolean;
|
|
25
|
+
fromJSON(json?: Partial<RestfulModelJSON>): this;
|
|
26
|
+
toJSON(enforceReadOnly?: boolean): any;
|
|
27
|
+
pathPrefix(): string;
|
|
28
|
+
saveEndpoint(): string;
|
|
29
|
+
saveRequestBody(): any;
|
|
30
|
+
deleteRequestQueryString(_params: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}): {};
|
|
33
|
+
deleteRequestBody(_params: {
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}): {};
|
|
36
|
+
deleteRequestOptions(params: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}): {
|
|
39
|
+
body: {};
|
|
40
|
+
qs: {};
|
|
41
|
+
};
|
|
42
|
+
toString(): string;
|
|
43
|
+
_save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
44
|
+
_get(params?: {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}, callback?: (error: Error | null, result?: any) => void, pathSuffix?: string): Promise<any>;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
7
|
+
var nylas_connection_1 = __importDefault(require("../nylas-connection"));
|
|
8
|
+
var RestfulModel = /** @class */ (function () {
|
|
9
|
+
function RestfulModel(connection, json) {
|
|
10
|
+
this.connection = connection;
|
|
11
|
+
if (!(this.connection instanceof nylas_connection_1.default)) {
|
|
12
|
+
throw new Error('Connection object not provided');
|
|
13
|
+
}
|
|
14
|
+
if (json) {
|
|
15
|
+
this.fromJSON(json);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
RestfulModel.prototype.attributes = function () {
|
|
19
|
+
return this.constructor.attributes;
|
|
20
|
+
};
|
|
21
|
+
RestfulModel.prototype.isEqual = function (other) {
|
|
22
|
+
return ((other ? other.id : undefined) === this.id &&
|
|
23
|
+
(other ? other.constructor : undefined) === this.constructor);
|
|
24
|
+
};
|
|
25
|
+
RestfulModel.prototype.fromJSON = function (json) {
|
|
26
|
+
if (json === void 0) { json = {}; }
|
|
27
|
+
var attributes = this.attributes();
|
|
28
|
+
for (var attrName in attributes) {
|
|
29
|
+
var attr = attributes[attrName];
|
|
30
|
+
if (json[attr.jsonKey] !== undefined) {
|
|
31
|
+
this[attrName] = attr.fromJSON(json[attr.jsonKey], this);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return this;
|
|
35
|
+
};
|
|
36
|
+
RestfulModel.prototype.toJSON = function (enforceReadOnly) {
|
|
37
|
+
var json = {};
|
|
38
|
+
var attributes = this.attributes();
|
|
39
|
+
for (var attrName in attributes) {
|
|
40
|
+
if (!attributes[attrName].readOnly || enforceReadOnly !== true) {
|
|
41
|
+
var attr = attributes[attrName];
|
|
42
|
+
json[attr.jsonKey] = attr.toJSON(this[attrName]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return json;
|
|
46
|
+
};
|
|
47
|
+
// Subclasses should override this method.
|
|
48
|
+
RestfulModel.prototype.pathPrefix = function () {
|
|
49
|
+
return '';
|
|
50
|
+
};
|
|
51
|
+
RestfulModel.prototype.saveEndpoint = function () {
|
|
52
|
+
var collectionName = this.constructor.collectionName;
|
|
53
|
+
return this.pathPrefix() + "/" + collectionName;
|
|
54
|
+
};
|
|
55
|
+
// saveRequestBody is used by save(). It returns a JSON dict containing only the
|
|
56
|
+
// fields the API allows updating. Subclasses should override this method.
|
|
57
|
+
RestfulModel.prototype.saveRequestBody = function () {
|
|
58
|
+
return this.toJSON(true);
|
|
59
|
+
};
|
|
60
|
+
// deleteRequestQueryString is used by delete(). Subclasses should override this method.
|
|
61
|
+
RestfulModel.prototype.deleteRequestQueryString = function (_params) {
|
|
62
|
+
return {};
|
|
63
|
+
};
|
|
64
|
+
// deleteRequestBody is used by delete(). Subclasses should override this method.
|
|
65
|
+
RestfulModel.prototype.deleteRequestBody = function (_params) {
|
|
66
|
+
return {};
|
|
67
|
+
};
|
|
68
|
+
// deleteRequestOptions is used by delete(). Subclasses should override this method.
|
|
69
|
+
RestfulModel.prototype.deleteRequestOptions = function (params) {
|
|
70
|
+
return {
|
|
71
|
+
body: this.deleteRequestBody(params),
|
|
72
|
+
qs: this.deleteRequestQueryString(params),
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
RestfulModel.prototype.toString = function () {
|
|
76
|
+
return JSON.stringify(this.toJSON());
|
|
77
|
+
};
|
|
78
|
+
// Not every model needs to have a save function, but those who
|
|
79
|
+
// do shouldn't have to reimplement the same boilerplate.
|
|
80
|
+
// They should instead define a save() function which calls _save.
|
|
81
|
+
RestfulModel.prototype._save = function (params, callback) {
|
|
82
|
+
var _this = this;
|
|
83
|
+
if (params === void 0) { params = {}; }
|
|
84
|
+
if (typeof params === 'function') {
|
|
85
|
+
callback = params;
|
|
86
|
+
params = {};
|
|
87
|
+
}
|
|
88
|
+
return this.connection
|
|
89
|
+
.request({
|
|
90
|
+
method: this.id ? 'PUT' : 'POST',
|
|
91
|
+
body: this.saveRequestBody(),
|
|
92
|
+
qs: params,
|
|
93
|
+
path: this.id
|
|
94
|
+
? this.saveEndpoint() + "/" + this.id
|
|
95
|
+
: "" + this.saveEndpoint(),
|
|
96
|
+
})
|
|
97
|
+
.then(function (json) {
|
|
98
|
+
_this.fromJSON(json);
|
|
99
|
+
if (callback) {
|
|
100
|
+
callback(null, _this);
|
|
101
|
+
}
|
|
102
|
+
return Promise.resolve(_this);
|
|
103
|
+
})
|
|
104
|
+
.catch(function (err) {
|
|
105
|
+
if (callback) {
|
|
106
|
+
callback(err);
|
|
107
|
+
}
|
|
108
|
+
return Promise.reject(err);
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
RestfulModel.prototype._get = function (params, callback, pathSuffix) {
|
|
112
|
+
if (params === void 0) { params = {}; }
|
|
113
|
+
if (pathSuffix === void 0) { pathSuffix = ''; }
|
|
114
|
+
var collectionName = this.constructor.collectionName;
|
|
115
|
+
return this.connection
|
|
116
|
+
.request({
|
|
117
|
+
method: 'GET',
|
|
118
|
+
path: "/" + collectionName + "/" + this.id + pathSuffix,
|
|
119
|
+
qs: params,
|
|
120
|
+
})
|
|
121
|
+
.then(function (response) {
|
|
122
|
+
if (callback) {
|
|
123
|
+
callback(null, response);
|
|
124
|
+
}
|
|
125
|
+
return Promise.resolve(response);
|
|
126
|
+
})
|
|
127
|
+
.catch(function (err) {
|
|
128
|
+
if (callback) {
|
|
129
|
+
callback(err);
|
|
130
|
+
}
|
|
131
|
+
return Promise.reject(err);
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
RestfulModel.endpointName = ''; // overrridden in subclasses
|
|
135
|
+
RestfulModel.collectionName = ''; // overrridden in subclasses
|
|
136
|
+
return RestfulModel;
|
|
137
|
+
}());
|
|
138
|
+
exports.default = RestfulModel;
|
|
139
|
+
RestfulModel.attributes = {
|
|
140
|
+
id: attributes_1.default.String({
|
|
141
|
+
modelKey: 'id',
|
|
142
|
+
readOnly: true,
|
|
143
|
+
}),
|
|
144
|
+
object: attributes_1.default.String({
|
|
145
|
+
modelKey: 'object',
|
|
146
|
+
readOnly: true,
|
|
147
|
+
}),
|
|
148
|
+
accountId: attributes_1.default.String({
|
|
149
|
+
modelKey: 'accountId',
|
|
150
|
+
jsonKey: 'account_id',
|
|
151
|
+
readOnly: true,
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Message from './message';
|
|
2
|
+
import RestfulModel, { SaveCallback } from './restful-model';
|
|
3
|
+
import EmailParticipant from './email-participant';
|
|
4
|
+
import { Label, Folder } from './folder';
|
|
5
|
+
export default class Thread extends RestfulModel {
|
|
6
|
+
subject?: string;
|
|
7
|
+
participants?: EmailParticipant[];
|
|
8
|
+
lastMessageTimestamp?: Date;
|
|
9
|
+
lastMessageReceivedTimestamp?: Date;
|
|
10
|
+
lastMessageSentTimestamp?: Date;
|
|
11
|
+
firstMessageTimestamp?: Date;
|
|
12
|
+
snippet?: string;
|
|
13
|
+
unread?: boolean;
|
|
14
|
+
starred?: boolean;
|
|
15
|
+
hasAttachments?: boolean;
|
|
16
|
+
version?: string;
|
|
17
|
+
folders?: Folder[];
|
|
18
|
+
labels?: Label[];
|
|
19
|
+
messageIds?: string[];
|
|
20
|
+
draftIds?: string[];
|
|
21
|
+
messages?: Message[];
|
|
22
|
+
drafts?: Message[];
|
|
23
|
+
fromJSON(json: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}): this;
|
|
26
|
+
saveRequestBody(): {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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 message_1 = __importDefault(require("./message"));
|
|
31
|
+
var restful_model_1 = __importDefault(require("./restful-model"));
|
|
32
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
33
|
+
var email_participant_1 = __importDefault(require("./email-participant"));
|
|
34
|
+
var folder_1 = require("./folder");
|
|
35
|
+
var Thread = /** @class */ (function (_super) {
|
|
36
|
+
__extends(Thread, _super);
|
|
37
|
+
function Thread() {
|
|
38
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
39
|
+
}
|
|
40
|
+
Thread.prototype.fromJSON = function (json) {
|
|
41
|
+
_super.prototype.fromJSON.call(this, json);
|
|
42
|
+
return this;
|
|
43
|
+
};
|
|
44
|
+
Thread.prototype.saveRequestBody = function () {
|
|
45
|
+
var json = {};
|
|
46
|
+
if (this.labels) {
|
|
47
|
+
json['label_ids'] = this.labels.map(function (label) { return label.id; });
|
|
48
|
+
}
|
|
49
|
+
else if (this.folders && this.folders.length === 1) {
|
|
50
|
+
json['folder_id'] = this.folders[0].id;
|
|
51
|
+
}
|
|
52
|
+
json['starred'] = this.starred;
|
|
53
|
+
json['unread'] = this.unread;
|
|
54
|
+
return json;
|
|
55
|
+
};
|
|
56
|
+
Thread.prototype.save = function (params, callback) {
|
|
57
|
+
if (params === void 0) { params = {}; }
|
|
58
|
+
return this._save(params, callback);
|
|
59
|
+
};
|
|
60
|
+
return Thread;
|
|
61
|
+
}(restful_model_1.default));
|
|
62
|
+
exports.default = Thread;
|
|
63
|
+
Thread.collectionName = 'threads';
|
|
64
|
+
Thread.attributes = __assign(__assign({}, restful_model_1.default.attributes), { subject: attributes_1.default.String({
|
|
65
|
+
modelKey: 'subject',
|
|
66
|
+
}), participants: attributes_1.default.Collection({
|
|
67
|
+
modelKey: 'participants',
|
|
68
|
+
itemClass: email_participant_1.default,
|
|
69
|
+
}), lastMessageTimestamp: attributes_1.default.DateTime({
|
|
70
|
+
modelKey: 'lastMessageTimestamp',
|
|
71
|
+
jsonKey: 'last_message_timestamp',
|
|
72
|
+
}), lastMessageReceivedTimestamp: attributes_1.default.DateTime({
|
|
73
|
+
modelKey: 'lastMessageReceivedTimestamp',
|
|
74
|
+
jsonKey: 'last_message_received_timestamp',
|
|
75
|
+
}), lastMessageSentTimestamp: attributes_1.default.DateTime({
|
|
76
|
+
modelKey: 'lastMessageSentTimestamp',
|
|
77
|
+
jsonKey: 'last_message_sent_timestamp',
|
|
78
|
+
}), firstMessageTimestamp: attributes_1.default.DateTime({
|
|
79
|
+
modelKey: 'firstMessageTimestamp',
|
|
80
|
+
jsonKey: 'first_message_timestamp',
|
|
81
|
+
}), snippet: attributes_1.default.String({
|
|
82
|
+
modelKey: 'snippet',
|
|
83
|
+
}), unread: attributes_1.default.Boolean({
|
|
84
|
+
modelKey: 'unread',
|
|
85
|
+
}), starred: attributes_1.default.Boolean({
|
|
86
|
+
modelKey: 'starred',
|
|
87
|
+
}), hasAttachments: attributes_1.default.Boolean({
|
|
88
|
+
modelKey: 'has_attachments',
|
|
89
|
+
}), version: attributes_1.default.String({
|
|
90
|
+
modelKey: 'version',
|
|
91
|
+
jsonKey: 'version',
|
|
92
|
+
}), folders: attributes_1.default.Collection({
|
|
93
|
+
modelKey: 'folders',
|
|
94
|
+
itemClass: folder_1.Folder,
|
|
95
|
+
jsonKey: 'folders',
|
|
96
|
+
}), labels: attributes_1.default.Collection({
|
|
97
|
+
modelKey: 'labels',
|
|
98
|
+
itemClass: folder_1.Label,
|
|
99
|
+
jsonKey: 'labels',
|
|
100
|
+
}), messageIds: attributes_1.default.StringList({
|
|
101
|
+
modelKey: 'messageIds',
|
|
102
|
+
jsonKey: 'message_ids',
|
|
103
|
+
}), draftIds: attributes_1.default.StringList({
|
|
104
|
+
modelKey: 'draftIds',
|
|
105
|
+
jsonKey: 'draft_ids',
|
|
106
|
+
}), messages: attributes_1.default.Collection({
|
|
107
|
+
modelKey: 'messages',
|
|
108
|
+
itemClass: message_1.default,
|
|
109
|
+
}), drafts: attributes_1.default.Collection({
|
|
110
|
+
modelKey: 'drafts',
|
|
111
|
+
itemClass: message_1.default,
|
|
112
|
+
}) });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import ManagementModel from './management-model';
|
|
2
|
+
import { SaveCallback } from './restful-model';
|
|
3
|
+
export default class Webhook extends ManagementModel {
|
|
4
|
+
id?: string;
|
|
5
|
+
applicationId?: string;
|
|
6
|
+
callbackUrl?: string;
|
|
7
|
+
state?: string;
|
|
8
|
+
triggers?: string[];
|
|
9
|
+
version?: string;
|
|
10
|
+
pathPrefix(): string;
|
|
11
|
+
saveRequestBody(): {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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 management_model_1 = __importDefault(require("./management-model"));
|
|
20
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
21
|
+
var Webhook = /** @class */ (function (_super) {
|
|
22
|
+
__extends(Webhook, _super);
|
|
23
|
+
function Webhook() {
|
|
24
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
+
}
|
|
26
|
+
Webhook.prototype.pathPrefix = function () {
|
|
27
|
+
return "/a/" + this.clientId;
|
|
28
|
+
};
|
|
29
|
+
Webhook.prototype.saveRequestBody = function () {
|
|
30
|
+
var json = {};
|
|
31
|
+
// We can only update the state of an existing webhook
|
|
32
|
+
if (this.id) {
|
|
33
|
+
json['state'] = this.state;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
json['callback_url'] = this.callbackUrl;
|
|
37
|
+
json['state'] = this.state ? this.state : 'active';
|
|
38
|
+
json['triggers'] = Webhook.attributes.triggers.toJSON(this.triggers);
|
|
39
|
+
}
|
|
40
|
+
return json;
|
|
41
|
+
};
|
|
42
|
+
Webhook.prototype.save = function (params, callback) {
|
|
43
|
+
if (params === void 0) { params = {}; }
|
|
44
|
+
return this._save(params, callback);
|
|
45
|
+
};
|
|
46
|
+
return Webhook;
|
|
47
|
+
}(management_model_1.default));
|
|
48
|
+
exports.default = Webhook;
|
|
49
|
+
Webhook.collectionName = 'webhooks';
|
|
50
|
+
Webhook.attributes = {
|
|
51
|
+
id: attributes_1.default.String({
|
|
52
|
+
modelKey: 'id',
|
|
53
|
+
}),
|
|
54
|
+
applicationId: attributes_1.default.String({
|
|
55
|
+
modelKey: 'applicationId',
|
|
56
|
+
jsonKey: 'application_id',
|
|
57
|
+
}),
|
|
58
|
+
callbackUrl: attributes_1.default.String({
|
|
59
|
+
modelKey: 'callbackUrl',
|
|
60
|
+
jsonKey: 'callback_url',
|
|
61
|
+
}),
|
|
62
|
+
state: attributes_1.default.String({
|
|
63
|
+
modelKey: 'state',
|
|
64
|
+
}),
|
|
65
|
+
triggers: attributes_1.default.StringList({
|
|
66
|
+
modelKey: 'triggers',
|
|
67
|
+
}),
|
|
68
|
+
version: attributes_1.default.String({
|
|
69
|
+
modelKey: 'version',
|
|
70
|
+
}),
|
|
71
|
+
};
|