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,18 @@
1
+ import Message from './message';
2
+ import RestfulModel from './restful-model';
3
+ export declare class Categorize extends RestfulModel {
4
+ category?: string;
5
+ categorizedAt?: Date;
6
+ modelVersion?: string;
7
+ subcategories?: string[];
8
+ toJSON(): {
9
+ category: string | undefined;
10
+ categorized_at: Date | undefined;
11
+ model_version: string | undefined;
12
+ subcategories: string[] | undefined;
13
+ };
14
+ }
15
+ export default class NeuralCategorizer extends Message {
16
+ categorizer?: Categorize;
17
+ reCategorize(category: string): Promise<NeuralCategorizer>;
18
+ }
@@ -0,0 +1,140 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
+ return new (P || (P = Promise))(function (resolve, reject) {
29
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
33
+ });
34
+ };
35
+ var __generator = (this && this.__generator) || function (thisArg, body) {
36
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
+ function verb(n) { return function (v) { return step([n, v]); }; }
39
+ function step(op) {
40
+ if (f) throw new TypeError("Generator is already executing.");
41
+ while (_) try {
42
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43
+ if (y = 0, t) op = [op[0] & 2, t.value];
44
+ switch (op[0]) {
45
+ case 0: case 1: t = op; break;
46
+ case 4: _.label++; return { value: op[1], done: false };
47
+ case 5: _.label++; y = op[1]; op = [0]; continue;
48
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
+ default:
50
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
+ if (t[2]) _.ops.pop();
55
+ _.trys.pop(); continue;
56
+ }
57
+ op = body.call(thisArg, _);
58
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
+ }
61
+ };
62
+ var __importDefault = (this && this.__importDefault) || function (mod) {
63
+ return (mod && mod.__esModule) ? mod : { "default": mod };
64
+ };
65
+ Object.defineProperty(exports, "__esModule", { value: true });
66
+ exports.Categorize = void 0;
67
+ var attributes_1 = __importDefault(require("./attributes"));
68
+ var message_1 = __importDefault(require("./message"));
69
+ var restful_model_1 = __importDefault(require("./restful-model"));
70
+ var Categorize = /** @class */ (function (_super) {
71
+ __extends(Categorize, _super);
72
+ function Categorize() {
73
+ return _super !== null && _super.apply(this, arguments) || this;
74
+ }
75
+ Categorize.prototype.toJSON = function () {
76
+ return {
77
+ category: this.category,
78
+ categorized_at: this.categorizedAt,
79
+ model_version: this.modelVersion,
80
+ subcategories: this.subcategories,
81
+ };
82
+ };
83
+ return Categorize;
84
+ }(restful_model_1.default));
85
+ exports.Categorize = Categorize;
86
+ Categorize.collectionName = 'categorize';
87
+ Categorize.attributes = {
88
+ category: attributes_1.default.String({
89
+ modelKey: 'category',
90
+ }),
91
+ categorizedAt: attributes_1.default.DateTime({
92
+ modelKey: 'categorizedAt',
93
+ jsonKey: 'categorized_at',
94
+ }),
95
+ modelVersion: attributes_1.default.String({
96
+ modelKey: 'modelVersion',
97
+ jsonKey: 'model_version',
98
+ }),
99
+ subcategories: attributes_1.default.StringList({
100
+ modelKey: 'subcategories',
101
+ }),
102
+ };
103
+ var NeuralCategorizer = /** @class */ (function (_super) {
104
+ __extends(NeuralCategorizer, _super);
105
+ function NeuralCategorizer() {
106
+ return _super !== null && _super.apply(this, arguments) || this;
107
+ }
108
+ NeuralCategorizer.prototype.reCategorize = function (category) {
109
+ var _this = this;
110
+ return this.connection
111
+ .request({
112
+ method: 'POST',
113
+ path: '/neural/categorize/feedback',
114
+ body: { message_id: this.id, category: category },
115
+ headers: {
116
+ 'Content-Type': 'application/json',
117
+ },
118
+ })
119
+ .then(function (json) { return __awaiter(_this, void 0, void 0, function () {
120
+ var categorizeResponse;
121
+ return __generator(this, function (_a) {
122
+ switch (_a.label) {
123
+ case 0: return [4 /*yield*/, this.connection.neural.categorize([
124
+ json['message_id'],
125
+ ])];
126
+ case 1:
127
+ categorizeResponse = _a.sent();
128
+ return [2 /*return*/, categorizeResponse[0]];
129
+ }
130
+ });
131
+ }); });
132
+ };
133
+ return NeuralCategorizer;
134
+ }(message_1.default));
135
+ exports.default = NeuralCategorizer;
136
+ NeuralCategorizer.collectionName = 'categorizer';
137
+ NeuralCategorizer.attributes = __assign(__assign({}, message_1.default.attributes), { categorizer: attributes_1.default.Object({
138
+ modelKey: 'categorizer',
139
+ itemClass: Categorize,
140
+ }) });
@@ -0,0 +1,7 @@
1
+ import Message from './message';
2
+ import File from './file';
3
+ export default class NeuralCleanConversation extends Message {
4
+ conversation?: string;
5
+ modelVersion?: string;
6
+ extractImages(): Promise<File[]>;
7
+ }
@@ -0,0 +1,110 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
+ return new (P || (P = Promise))(function (resolve, reject) {
29
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
33
+ });
34
+ };
35
+ var __generator = (this && this.__generator) || function (thisArg, body) {
36
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
+ function verb(n) { return function (v) { return step([n, v]); }; }
39
+ function step(op) {
40
+ if (f) throw new TypeError("Generator is already executing.");
41
+ while (_) try {
42
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43
+ if (y = 0, t) op = [op[0] & 2, t.value];
44
+ switch (op[0]) {
45
+ case 0: case 1: t = op; break;
46
+ case 4: _.label++; return { value: op[1], done: false };
47
+ case 5: _.label++; y = op[1]; op = [0]; continue;
48
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
+ default:
50
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
+ if (t[2]) _.ops.pop();
55
+ _.trys.pop(); continue;
56
+ }
57
+ op = body.call(thisArg, _);
58
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
+ }
61
+ };
62
+ var __importDefault = (this && this.__importDefault) || function (mod) {
63
+ return (mod && mod.__esModule) ? mod : { "default": mod };
64
+ };
65
+ Object.defineProperty(exports, "__esModule", { value: true });
66
+ var message_1 = __importDefault(require("./message"));
67
+ var attributes_1 = __importDefault(require("./attributes"));
68
+ var IMAGE_REGEX = /[(']cid:(.)*[)']/g;
69
+ var NeuralCleanConversation = /** @class */ (function (_super) {
70
+ __extends(NeuralCleanConversation, _super);
71
+ function NeuralCleanConversation() {
72
+ return _super !== null && _super.apply(this, arguments) || this;
73
+ }
74
+ NeuralCleanConversation.prototype.extractImages = function () {
75
+ var _this = this;
76
+ var f = [];
77
+ if (this.conversation) {
78
+ var fileIds = this.conversation.match(IMAGE_REGEX);
79
+ if (fileIds) {
80
+ // After applying the regex, if there are IDs found they would be
81
+ // in the form of => 'cid:xxxx' (including apostrophes), so we discard
82
+ // everything before and after the file ID (denoted as xxxx above)
83
+ fileIds.forEach(function (id) { return __awaiter(_this, void 0, void 0, function () {
84
+ var parsedId, file;
85
+ return __generator(this, function (_a) {
86
+ switch (_a.label) {
87
+ case 0:
88
+ parsedId = id.substring(5, id.length - 1);
89
+ return [4 /*yield*/, this.connection.files.find(parsedId)];
90
+ case 1:
91
+ file = _a.sent();
92
+ f.push(file);
93
+ return [2 /*return*/];
94
+ }
95
+ });
96
+ }); });
97
+ }
98
+ }
99
+ return Promise.resolve(f);
100
+ };
101
+ return NeuralCleanConversation;
102
+ }(message_1.default));
103
+ exports.default = NeuralCleanConversation;
104
+ NeuralCleanConversation.collectionName = 'conversation';
105
+ NeuralCleanConversation.attributes = __assign(__assign({}, message_1.default.attributes), { conversation: attributes_1.default.String({
106
+ modelKey: 'conversation',
107
+ }), modelVersion: attributes_1.default.String({
108
+ modelKey: 'modelVersion',
109
+ jsonKey: 'model_version',
110
+ }) });
@@ -0,0 +1,5 @@
1
+ import File from './file';
2
+ export default class NeuralOcr extends File {
3
+ ocr?: string[];
4
+ processedPages?: number;
5
+ }
@@ -0,0 +1,46 @@
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 attributes_1 = __importDefault(require("./attributes"));
31
+ var file_1 = __importDefault(require("./file"));
32
+ var NeuralOcr = /** @class */ (function (_super) {
33
+ __extends(NeuralOcr, _super);
34
+ function NeuralOcr() {
35
+ return _super !== null && _super.apply(this, arguments) || this;
36
+ }
37
+ return NeuralOcr;
38
+ }(file_1.default));
39
+ exports.default = NeuralOcr;
40
+ NeuralOcr.collectionName = 'ocr';
41
+ NeuralOcr.attributes = __assign(__assign({}, file_1.default.attributes), { ocr: attributes_1.default.StringList({
42
+ modelKey: 'ocr',
43
+ }), processedPages: attributes_1.default.Number({
44
+ modelKey: 'processedPages',
45
+ jsonKey: 'processed_pages',
46
+ }) });
@@ -0,0 +1,8 @@
1
+ import RestfulModel from './restful-model';
2
+ export default class NeuralSentimentAnalysis extends RestfulModel {
3
+ account_id?: string;
4
+ sentiment?: string;
5
+ sentimentScore?: number;
6
+ processedLength?: number;
7
+ text?: string;
8
+ }
@@ -0,0 +1,49 @@
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 attributes_1 = __importDefault(require("./attributes"));
20
+ var restful_model_1 = __importDefault(require("./restful-model"));
21
+ var NeuralSentimentAnalysis = /** @class */ (function (_super) {
22
+ __extends(NeuralSentimentAnalysis, _super);
23
+ function NeuralSentimentAnalysis() {
24
+ return _super !== null && _super.apply(this, arguments) || this;
25
+ }
26
+ return NeuralSentimentAnalysis;
27
+ }(restful_model_1.default));
28
+ exports.default = NeuralSentimentAnalysis;
29
+ NeuralSentimentAnalysis.collectionName = 'sentiment';
30
+ NeuralSentimentAnalysis.attributes = {
31
+ accountId: attributes_1.default.String({
32
+ modelKey: 'accountId',
33
+ jsonKey: 'account_id',
34
+ }),
35
+ sentiment: attributes_1.default.String({
36
+ modelKey: 'sentiment',
37
+ }),
38
+ sentimentScore: attributes_1.default.Number({
39
+ modelKey: 'sentimentScore',
40
+ jsonKey: 'sentiment_score',
41
+ }),
42
+ processedLength: attributes_1.default.Number({
43
+ modelKey: 'processedLength',
44
+ jsonKey: 'processed_length',
45
+ }),
46
+ text: attributes_1.default.String({
47
+ modelKey: 'text',
48
+ }),
49
+ };
@@ -0,0 +1,37 @@
1
+ import RestfulModel from './restful-model';
2
+ import { Contact } from './contact';
3
+ declare class Link extends RestfulModel {
4
+ description?: string;
5
+ url?: string;
6
+ toJSON(): {
7
+ description: string | undefined;
8
+ url: string | undefined;
9
+ };
10
+ }
11
+ declare class Name extends RestfulModel {
12
+ firstName?: string;
13
+ lastName?: string;
14
+ toJSON(): {
15
+ type: string | undefined;
16
+ email: string | undefined;
17
+ };
18
+ }
19
+ export default class NeuralSignatureContact extends RestfulModel {
20
+ jobTitles?: string[];
21
+ links?: Link[];
22
+ phoneNumbers?: string[];
23
+ emails?: string[];
24
+ names?: Name[];
25
+ toJSON(): {
26
+ job_titles: string[] | undefined;
27
+ links: Link[] | undefined;
28
+ phone_numbers: string[] | undefined;
29
+ emails: string[] | undefined;
30
+ names: {
31
+ type: string | undefined;
32
+ email: string | undefined;
33
+ }[] | undefined;
34
+ };
35
+ toContactObject(): Contact;
36
+ }
37
+ export {};
@@ -0,0 +1,141 @@
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 contact_1 = require("./contact");
22
+ var Link = /** @class */ (function (_super) {
23
+ __extends(Link, _super);
24
+ function Link() {
25
+ return _super !== null && _super.apply(this, arguments) || this;
26
+ }
27
+ Link.prototype.toJSON = function () {
28
+ return {
29
+ description: this.description,
30
+ url: this.url,
31
+ };
32
+ };
33
+ return Link;
34
+ }(restful_model_1.default));
35
+ Link.collectionName = 'link';
36
+ Link.attributes = {
37
+ description: attributes_1.default.String({
38
+ modelKey: 'description',
39
+ }),
40
+ url: attributes_1.default.String({
41
+ modelKey: 'url',
42
+ }),
43
+ };
44
+ var Name = /** @class */ (function (_super) {
45
+ __extends(Name, _super);
46
+ function Name() {
47
+ return _super !== null && _super.apply(this, arguments) || this;
48
+ }
49
+ Name.prototype.toJSON = function () {
50
+ return {
51
+ type: this.firstName,
52
+ email: this.lastName,
53
+ };
54
+ };
55
+ return Name;
56
+ }(restful_model_1.default));
57
+ Name.collectionName = 'name';
58
+ Name.attributes = {
59
+ firstName: attributes_1.default.String({
60
+ modelKey: 'firstName',
61
+ jsonKey: 'first_name',
62
+ }),
63
+ lastName: attributes_1.default.String({
64
+ modelKey: 'lastName',
65
+ jsonKey: 'last_name',
66
+ }),
67
+ };
68
+ var NeuralSignatureContact = /** @class */ (function (_super) {
69
+ __extends(NeuralSignatureContact, _super);
70
+ function NeuralSignatureContact() {
71
+ return _super !== null && _super.apply(this, arguments) || this;
72
+ }
73
+ NeuralSignatureContact.prototype.toJSON = function () {
74
+ return {
75
+ job_titles: this.jobTitles,
76
+ links: this.links,
77
+ phone_numbers: this.phoneNumbers,
78
+ emails: this.emails,
79
+ names: this.names ? this.names.map(function (name) { return name.toJSON(); }) : this.names,
80
+ };
81
+ };
82
+ NeuralSignatureContact.prototype.toContactObject = function () {
83
+ var _this = this;
84
+ var contact = new contact_1.Contact(this.connection);
85
+ if (this.names) {
86
+ contact.givenName = this.names[0].firstName;
87
+ contact.surname = this.names[0].lastName;
88
+ }
89
+ if (this.jobTitles) {
90
+ contact.jobTitle = this.jobTitles[0];
91
+ }
92
+ if (this.emails) {
93
+ var contactEmails_1 = [];
94
+ this.emails.forEach(function (email) {
95
+ return contactEmails_1.push(new contact_1.EmailAddress(_this.connection, { type: 'personal', email: email }));
96
+ });
97
+ contact.emailAddresses = contactEmails_1;
98
+ }
99
+ if (this.phoneNumbers) {
100
+ var contactNumbers_1 = [];
101
+ this.phoneNumbers.forEach(function (number) {
102
+ return contactNumbers_1.push(new contact_1.PhoneNumber(_this.connection, { type: 'mobile', number: number }));
103
+ });
104
+ contact.phoneNumbers = contactNumbers_1;
105
+ }
106
+ if (this.links) {
107
+ var webPages_1 = [];
108
+ this.links.forEach(function (link) {
109
+ if (link['url']) {
110
+ webPages_1.push(new contact_1.WebPage(_this.connection, { type: 'homepage', url: link['url'] }));
111
+ }
112
+ });
113
+ contact.webPages = webPages_1;
114
+ }
115
+ return contact;
116
+ };
117
+ return NeuralSignatureContact;
118
+ }(restful_model_1.default));
119
+ exports.default = NeuralSignatureContact;
120
+ NeuralSignatureContact.collectionName = 'signature_contact';
121
+ NeuralSignatureContact.attributes = {
122
+ jobTitles: attributes_1.default.StringList({
123
+ modelKey: 'jobTitles',
124
+ jsonKey: 'job_titles',
125
+ }),
126
+ links: attributes_1.default.Collection({
127
+ modelKey: 'links',
128
+ itemClass: Link,
129
+ }),
130
+ phoneNumbers: attributes_1.default.StringList({
131
+ modelKey: 'phoneNumbers',
132
+ jsonKey: 'phone_numbers',
133
+ }),
134
+ emails: attributes_1.default.StringList({
135
+ modelKey: 'emails',
136
+ }),
137
+ names: attributes_1.default.Collection({
138
+ modelKey: 'names',
139
+ itemClass: Name,
140
+ }),
141
+ };