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,76 @@
|
|
|
1
|
+
import Calendar from './calendar';
|
|
2
|
+
import NylasConnection from '../nylas-connection';
|
|
3
|
+
import RestfulModelCollection from './restful-model-collection';
|
|
4
|
+
export default class CalendarRestfulModelCollection extends RestfulModelCollection<Calendar> {
|
|
5
|
+
connection: NylasConnection;
|
|
6
|
+
modelClass: typeof Calendar;
|
|
7
|
+
constructor(connection: NylasConnection);
|
|
8
|
+
freeBusy(options: {
|
|
9
|
+
start_time?: string;
|
|
10
|
+
startTime?: string;
|
|
11
|
+
end_time?: string;
|
|
12
|
+
endTime?: string;
|
|
13
|
+
emails: string[];
|
|
14
|
+
}, callback?: (error: Error | null, data?: {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}) => void): Promise<any>;
|
|
17
|
+
availability(options: {
|
|
18
|
+
emails: string[];
|
|
19
|
+
duration: number;
|
|
20
|
+
interval: number;
|
|
21
|
+
start_time?: string;
|
|
22
|
+
startTime?: string;
|
|
23
|
+
end_time?: string;
|
|
24
|
+
endTime?: string;
|
|
25
|
+
free_busy?: Array<{
|
|
26
|
+
emails: string;
|
|
27
|
+
object: string;
|
|
28
|
+
time_slots: Array<{
|
|
29
|
+
object: string;
|
|
30
|
+
status: string;
|
|
31
|
+
start_time: string;
|
|
32
|
+
end_time: string;
|
|
33
|
+
}>;
|
|
34
|
+
}>;
|
|
35
|
+
open_hours: Array<{
|
|
36
|
+
emails: string[];
|
|
37
|
+
days: string[];
|
|
38
|
+
timezone: string;
|
|
39
|
+
start: string;
|
|
40
|
+
end: string;
|
|
41
|
+
object_type: string;
|
|
42
|
+
}>;
|
|
43
|
+
}, callback?: (error: Error | null, data?: {
|
|
44
|
+
[key: string]: any;
|
|
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>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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 calendar_1 = __importDefault(require("./calendar"));
|
|
20
|
+
var restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
|
|
21
|
+
var CalendarRestfulModelCollection = /** @class */ (function (_super) {
|
|
22
|
+
__extends(CalendarRestfulModelCollection, _super);
|
|
23
|
+
function CalendarRestfulModelCollection(connection) {
|
|
24
|
+
var _this = _super.call(this, calendar_1.default, connection) || this;
|
|
25
|
+
_this.connection = connection;
|
|
26
|
+
_this.modelClass = calendar_1.default;
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
CalendarRestfulModelCollection.prototype.freeBusy = function (options, callback) {
|
|
30
|
+
return this.connection
|
|
31
|
+
.request({
|
|
32
|
+
method: 'POST',
|
|
33
|
+
path: "/calendars/free-busy",
|
|
34
|
+
body: {
|
|
35
|
+
start_time: options.startTime || options.start_time,
|
|
36
|
+
end_time: options.endTime || options.end_time,
|
|
37
|
+
emails: options.emails,
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
.then(function (json) {
|
|
41
|
+
if (callback) {
|
|
42
|
+
callback(null, json);
|
|
43
|
+
}
|
|
44
|
+
return Promise.resolve(json);
|
|
45
|
+
})
|
|
46
|
+
.catch(function (err) {
|
|
47
|
+
if (callback) {
|
|
48
|
+
callback(err);
|
|
49
|
+
}
|
|
50
|
+
return Promise.reject(err);
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
CalendarRestfulModelCollection.prototype.availability = function (options, callback) {
|
|
54
|
+
return this.connection
|
|
55
|
+
.request({
|
|
56
|
+
method: 'POST',
|
|
57
|
+
path: "/calendars/availability",
|
|
58
|
+
body: {
|
|
59
|
+
emails: options.emails,
|
|
60
|
+
duration_minutes: options.duration,
|
|
61
|
+
interval_minutes: options.interval,
|
|
62
|
+
start_time: options.startTime || options.start_time,
|
|
63
|
+
end_time: options.endTime || options.end_time,
|
|
64
|
+
free_busy: options.free_busy || [],
|
|
65
|
+
open_hours: options.open_hours,
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
.then(function (json) {
|
|
69
|
+
if (callback) {
|
|
70
|
+
callback(null, json);
|
|
71
|
+
}
|
|
72
|
+
return Promise.resolve(json);
|
|
73
|
+
})
|
|
74
|
+
.catch(function (err) {
|
|
75
|
+
if (callback) {
|
|
76
|
+
callback(err);
|
|
77
|
+
}
|
|
78
|
+
return Promise.reject(err);
|
|
79
|
+
});
|
|
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
|
+
};
|
|
126
|
+
return CalendarRestfulModelCollection;
|
|
127
|
+
}(restful_model_collection_1.default));
|
|
128
|
+
exports.default = CalendarRestfulModelCollection;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import RestfulModel, { SaveCallback } from './restful-model';
|
|
2
|
+
import { GetCallback } from './restful-model-collection';
|
|
3
|
+
export default class Calendar extends RestfulModel {
|
|
4
|
+
name?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
location?: string;
|
|
8
|
+
timezone?: string;
|
|
9
|
+
isPrimary?: boolean;
|
|
10
|
+
jobStatusId?: string;
|
|
11
|
+
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
12
|
+
saveRequestBody(): {
|
|
13
|
+
name: any;
|
|
14
|
+
description: any;
|
|
15
|
+
location: any;
|
|
16
|
+
timezone: any;
|
|
17
|
+
};
|
|
18
|
+
getJobStatus(callback?: GetCallback): Promise<import("./job-status").default>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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 Calendar = /** @class */ (function (_super) {
|
|
33
|
+
__extends(Calendar, _super);
|
|
34
|
+
function Calendar() {
|
|
35
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
+
}
|
|
37
|
+
Calendar.prototype.save = function (params, callback) {
|
|
38
|
+
if (params === void 0) { params = {}; }
|
|
39
|
+
return this._save(params, callback);
|
|
40
|
+
};
|
|
41
|
+
Calendar.prototype.saveRequestBody = function () {
|
|
42
|
+
var calendarJSON = _super.prototype.saveRequestBody.call(this);
|
|
43
|
+
return {
|
|
44
|
+
name: calendarJSON.name,
|
|
45
|
+
description: calendarJSON.description,
|
|
46
|
+
location: calendarJSON.location,
|
|
47
|
+
timezone: calendarJSON.timezone,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
Calendar.prototype.getJobStatus = function (callback) {
|
|
51
|
+
if (typeof this.jobStatusId === 'undefined') {
|
|
52
|
+
var err = new Error('jobStatusId must be defined');
|
|
53
|
+
if (callback) {
|
|
54
|
+
callback(err);
|
|
55
|
+
}
|
|
56
|
+
return Promise.reject(err);
|
|
57
|
+
}
|
|
58
|
+
return this.connection.jobStatuses.find(this.jobStatusId, callback);
|
|
59
|
+
};
|
|
60
|
+
return Calendar;
|
|
61
|
+
}(restful_model_1.default));
|
|
62
|
+
exports.default = Calendar;
|
|
63
|
+
Calendar.collectionName = 'calendars';
|
|
64
|
+
Calendar.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
|
|
65
|
+
modelKey: 'name',
|
|
66
|
+
}), description: attributes_1.default.String({
|
|
67
|
+
modelKey: 'description',
|
|
68
|
+
}), readOnly: attributes_1.default.Boolean({
|
|
69
|
+
modelKey: 'readOnly',
|
|
70
|
+
jsonKey: 'read_only',
|
|
71
|
+
}), location: attributes_1.default.String({
|
|
72
|
+
modelKey: 'location',
|
|
73
|
+
}), timezone: attributes_1.default.String({
|
|
74
|
+
modelKey: 'timezone',
|
|
75
|
+
}), isPrimary: attributes_1.default.Boolean({
|
|
76
|
+
modelKey: 'isPrimary',
|
|
77
|
+
jsonKey: 'is_primary',
|
|
78
|
+
}), jobStatusId: attributes_1.default.String({
|
|
79
|
+
modelKey: 'jobStatusId',
|
|
80
|
+
jsonKey: 'job_status_id',
|
|
81
|
+
}) });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import NylasConnection from '../nylas-connection';
|
|
2
|
+
export default class Connect {
|
|
3
|
+
connection: NylasConnection;
|
|
4
|
+
clientId: string;
|
|
5
|
+
clientSecret: string;
|
|
6
|
+
constructor(connection: NylasConnection, clientId: string, clientSecret: string);
|
|
7
|
+
authorize(options?: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}): Promise<any>;
|
|
10
|
+
token(code: string): Promise<any>;
|
|
11
|
+
newAccount(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Connect = /** @class */ (function () {
|
|
4
|
+
function Connect(connection, clientId, clientSecret) {
|
|
5
|
+
this.connection = connection;
|
|
6
|
+
this.clientId = clientId;
|
|
7
|
+
this.clientSecret = clientSecret;
|
|
8
|
+
}
|
|
9
|
+
Connect.prototype.authorize = function (options) {
|
|
10
|
+
if (options === void 0) { options = {}; }
|
|
11
|
+
// https://docs.nylas.com/reference#connectauthorize
|
|
12
|
+
if (!this.clientId) {
|
|
13
|
+
throw new Error('connect.authorize() cannot be called until you provide a clientId via Nylas.config()');
|
|
14
|
+
}
|
|
15
|
+
return this.connection.request({
|
|
16
|
+
method: 'POST',
|
|
17
|
+
path: '/connect/authorize',
|
|
18
|
+
body: {
|
|
19
|
+
client_id: this.clientId,
|
|
20
|
+
name: options.name,
|
|
21
|
+
email_address: options.email_address,
|
|
22
|
+
provider: options.provider,
|
|
23
|
+
settings: options.settings,
|
|
24
|
+
scopes: options.scopes,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
Connect.prototype.token = function (code) {
|
|
29
|
+
// https://docs.nylas.com/reference#connecttoken
|
|
30
|
+
if (!this.clientId) {
|
|
31
|
+
throw new Error('connect.token() cannot be called until you provide a clientId via Nylas.config()');
|
|
32
|
+
}
|
|
33
|
+
if (!this.clientSecret) {
|
|
34
|
+
throw new Error('connect.token() cannot be called until you provide a clientSecret via Nylas.config()');
|
|
35
|
+
}
|
|
36
|
+
return this.connection.request({
|
|
37
|
+
method: 'POST',
|
|
38
|
+
path: '/connect/token',
|
|
39
|
+
body: {
|
|
40
|
+
client_id: this.clientId,
|
|
41
|
+
client_secret: this.clientSecret,
|
|
42
|
+
code: code,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
Connect.prototype.newAccount = function () {
|
|
47
|
+
// this.authorize() -> this.token()
|
|
48
|
+
};
|
|
49
|
+
return Connect;
|
|
50
|
+
}());
|
|
51
|
+
exports.default = Connect;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Contact } from './contact';
|
|
2
|
+
import NylasConnection from '../nylas-connection';
|
|
3
|
+
import RestfulModelCollection from './restful-model-collection';
|
|
4
|
+
export default class ContactRestfulModelCollection extends RestfulModelCollection<Contact> {
|
|
5
|
+
connection: NylasConnection;
|
|
6
|
+
modelClass: typeof Contact;
|
|
7
|
+
constructor(connection: NylasConnection);
|
|
8
|
+
groups(callback?: (error: Error | null, data?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}) => void): Promise<any>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 contact_1 = require("./contact");
|
|
20
|
+
var restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
|
|
21
|
+
var ContactRestfulModelCollection = /** @class */ (function (_super) {
|
|
22
|
+
__extends(ContactRestfulModelCollection, _super);
|
|
23
|
+
function ContactRestfulModelCollection(connection) {
|
|
24
|
+
var _this = _super.call(this, contact_1.Contact, connection) || this;
|
|
25
|
+
_this.connection = connection;
|
|
26
|
+
_this.modelClass = contact_1.Contact;
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
ContactRestfulModelCollection.prototype.groups = function (callback) {
|
|
30
|
+
var _this = this;
|
|
31
|
+
return this.connection
|
|
32
|
+
.request({
|
|
33
|
+
method: 'GET',
|
|
34
|
+
path: "/contacts/groups",
|
|
35
|
+
})
|
|
36
|
+
.then(function (json) {
|
|
37
|
+
var groups = json.map(function (group) {
|
|
38
|
+
return new contact_1.Group(_this.connection, group);
|
|
39
|
+
});
|
|
40
|
+
if (callback) {
|
|
41
|
+
callback(null, groups);
|
|
42
|
+
}
|
|
43
|
+
return Promise.resolve(groups);
|
|
44
|
+
})
|
|
45
|
+
.catch(function (err) {
|
|
46
|
+
if (callback) {
|
|
47
|
+
callback(err);
|
|
48
|
+
}
|
|
49
|
+
return Promise.reject(err);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
return ContactRestfulModelCollection;
|
|
53
|
+
}(restful_model_collection_1.default));
|
|
54
|
+
exports.default = ContactRestfulModelCollection;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import RestfulModel, { SaveCallback } from './restful-model';
|
|
2
|
+
export declare class EmailAddress extends RestfulModel {
|
|
3
|
+
type?: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
toJSON(): {
|
|
6
|
+
type: string | undefined;
|
|
7
|
+
email: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
declare class IMAddress extends RestfulModel {
|
|
11
|
+
type?: string;
|
|
12
|
+
imAddress?: string;
|
|
13
|
+
toJSON(): {
|
|
14
|
+
type: string | undefined;
|
|
15
|
+
im_address: string | undefined;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
declare class PhysicalAddress extends RestfulModel {
|
|
19
|
+
type?: string;
|
|
20
|
+
format?: string;
|
|
21
|
+
address?: string;
|
|
22
|
+
streetAddress?: string;
|
|
23
|
+
city?: string;
|
|
24
|
+
postalCode?: string;
|
|
25
|
+
state?: string;
|
|
26
|
+
country?: string;
|
|
27
|
+
toJSON(): {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export declare class PhoneNumber extends RestfulModel {
|
|
32
|
+
type?: string;
|
|
33
|
+
number?: string;
|
|
34
|
+
toJSON(): {
|
|
35
|
+
type: string | undefined;
|
|
36
|
+
number: string | undefined;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare class WebPage extends RestfulModel {
|
|
40
|
+
type?: string;
|
|
41
|
+
url?: string;
|
|
42
|
+
toJSON(): {
|
|
43
|
+
type: string | undefined;
|
|
44
|
+
url: string | undefined;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export declare class Group extends RestfulModel {
|
|
48
|
+
type?: string;
|
|
49
|
+
path?: string;
|
|
50
|
+
}
|
|
51
|
+
export declare class Contact extends RestfulModel {
|
|
52
|
+
givenName?: string;
|
|
53
|
+
middleName?: string;
|
|
54
|
+
surname?: string;
|
|
55
|
+
suffix?: string;
|
|
56
|
+
nickname?: string;
|
|
57
|
+
birthday?: string;
|
|
58
|
+
companyName?: string;
|
|
59
|
+
jobTitle?: string;
|
|
60
|
+
officeLocation?: string;
|
|
61
|
+
notes?: string;
|
|
62
|
+
pictureUrl?: string;
|
|
63
|
+
emailAddresses?: EmailAddress[];
|
|
64
|
+
imAddresses?: IMAddress[];
|
|
65
|
+
physicalAddresses?: PhysicalAddress[];
|
|
66
|
+
phoneNumbers?: PhoneNumber[];
|
|
67
|
+
webPages?: WebPage[];
|
|
68
|
+
groups?: Group[];
|
|
69
|
+
source?: string;
|
|
70
|
+
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
71
|
+
getPicture(params?: {
|
|
72
|
+
[key: string]: any;
|
|
73
|
+
}, callback?: (error: Error | null, result?: any) => void): Promise<any>;
|
|
74
|
+
}
|
|
75
|
+
export {};
|