nylas 5.8.0 → 5.10.2

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 (32) hide show
  1. package/lib/models/attributes.d.ts +5 -2
  2. package/lib/models/attributes.js +28 -4
  3. package/lib/models/calendar.d.ts +2 -0
  4. package/lib/models/calendar.js +3 -0
  5. package/lib/models/component-restful-model-collection.d.ts +9 -0
  6. package/lib/models/component-restful-model-collection.js +34 -0
  7. package/lib/models/component.d.ts +18 -0
  8. package/lib/models/component.js +89 -0
  9. package/lib/models/event-notification.d.ts +11 -0
  10. package/lib/models/event-notification.js +65 -0
  11. package/lib/models/event-participant.js +1 -0
  12. package/lib/models/event.d.ts +3 -0
  13. package/lib/models/event.js +11 -0
  14. package/lib/models/management-account.d.ts +7 -0
  15. package/lib/models/management-account.js +14 -0
  16. package/lib/models/message.d.ts +1 -0
  17. package/lib/models/message.js +3 -0
  18. package/lib/models/restful-model-collection.d.ts +1 -0
  19. package/lib/models/restful-model-collection.js +5 -0
  20. package/lib/models/restful-model.d.ts +1 -0
  21. package/lib/models/restful-model.js +7 -2
  22. package/lib/models/scheduler-booking-request.d.ts +31 -0
  23. package/lib/models/scheduler-booking-request.js +147 -0
  24. package/lib/models/scheduler-restful-model-collection.d.ts +25 -0
  25. package/lib/models/scheduler-restful-model-collection.js +136 -0
  26. package/lib/models/scheduler-time-slot.d.ts +9 -0
  27. package/lib/models/scheduler-time-slot.js +52 -0
  28. package/lib/models/scheduler.d.ts +98 -0
  29. package/lib/models/scheduler.js +140 -0
  30. package/lib/nylas-connection.d.ts +5 -0
  31. package/lib/nylas-connection.js +7 -2
  32. package/package.json +1 -1
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.SchedulerBookingConfirmation = void 0;
20
+ var restful_model_1 = __importDefault(require("./restful-model"));
21
+ var attributes_1 = __importDefault(require("./attributes"));
22
+ var scheduler_time_slot_1 = __importDefault(require("./scheduler-time-slot"));
23
+ var SchedulerBookingConfirmation = /** @class */ (function (_super) {
24
+ __extends(SchedulerBookingConfirmation, _super);
25
+ function SchedulerBookingConfirmation() {
26
+ return _super !== null && _super.apply(this, arguments) || this;
27
+ }
28
+ return SchedulerBookingConfirmation;
29
+ }(restful_model_1.default));
30
+ exports.SchedulerBookingConfirmation = SchedulerBookingConfirmation;
31
+ SchedulerBookingConfirmation.collectionName = 'booking_confirmation';
32
+ SchedulerBookingConfirmation.attributes = {
33
+ id: attributes_1.default.Number({
34
+ modelKey: 'id',
35
+ }),
36
+ accountId: attributes_1.default.String({
37
+ modelKey: 'accountId',
38
+ jsonKey: 'account_id',
39
+ }),
40
+ additionalFieldValues: attributes_1.default.Object({
41
+ modelKey: 'additionalFieldValues',
42
+ jsonKey: 'additional_field_values',
43
+ }),
44
+ calendarEventId: attributes_1.default.String({
45
+ modelKey: 'calendarEventId',
46
+ jsonKey: 'calendar_event_id',
47
+ }),
48
+ calendarId: attributes_1.default.String({
49
+ modelKey: 'calendarId',
50
+ jsonKey: 'calendar_id',
51
+ }),
52
+ editHash: attributes_1.default.String({
53
+ modelKey: 'editHash',
54
+ jsonKey: 'edit_hash',
55
+ }),
56
+ startTime: attributes_1.default.DateTime({
57
+ modelKey: 'startTime',
58
+ jsonKey: 'start_time',
59
+ }),
60
+ endTime: attributes_1.default.DateTime({
61
+ modelKey: 'endTime',
62
+ jsonKey: 'end_time',
63
+ }),
64
+ isConfirmed: attributes_1.default.Boolean({
65
+ modelKey: 'isConfirmed',
66
+ jsonKey: 'is_confirmed',
67
+ }),
68
+ location: attributes_1.default.String({
69
+ modelKey: 'location',
70
+ }),
71
+ recipientEmail: attributes_1.default.String({
72
+ modelKey: 'recipientEmail',
73
+ jsonKey: 'recipient_email',
74
+ }),
75
+ recipientLocale: attributes_1.default.String({
76
+ modelKey: 'recipientLocale',
77
+ jsonKey: 'recipient_locale',
78
+ }),
79
+ recipientName: attributes_1.default.String({
80
+ modelKey: 'recipientName',
81
+ jsonKey: 'recipient_name',
82
+ }),
83
+ recipientTz: attributes_1.default.String({
84
+ modelKey: 'recipientTz',
85
+ jsonKey: 'recipient_tz',
86
+ }),
87
+ title: attributes_1.default.String({
88
+ modelKey: 'title',
89
+ }),
90
+ };
91
+ var SchedulerBookingRequest = /** @class */ (function (_super) {
92
+ __extends(SchedulerBookingRequest, _super);
93
+ function SchedulerBookingRequest() {
94
+ return _super !== null && _super.apply(this, arguments) || this;
95
+ }
96
+ /*
97
+ * The booking endpoint requires additional_values and additional_emails
98
+ to exist regardless if they are empty or not
99
+ */
100
+ SchedulerBookingRequest.prototype.toJSON = function (enforceReadOnly) {
101
+ var json = _super.prototype.toJSON.call(this, enforceReadOnly);
102
+ if (!this.additionalEmails) {
103
+ json['additional_emails'] = [];
104
+ }
105
+ if (!this.additionalValues) {
106
+ json['additional_values'] = {};
107
+ }
108
+ return json;
109
+ };
110
+ return SchedulerBookingRequest;
111
+ }(restful_model_1.default));
112
+ exports.default = SchedulerBookingRequest;
113
+ SchedulerBookingRequest.collectionName = 'booking_request';
114
+ SchedulerBookingRequest.attributes = {
115
+ additionalEmails: attributes_1.default.StringList({
116
+ modelKey: 'additionalEmails',
117
+ jsonKey: 'additional_emails',
118
+ }),
119
+ additionalValues: attributes_1.default.Object({
120
+ modelKey: 'additionalValues',
121
+ jsonKey: 'additional_values',
122
+ }),
123
+ email: attributes_1.default.String({
124
+ modelKey: 'email',
125
+ }),
126
+ locale: attributes_1.default.String({
127
+ modelKey: 'locale',
128
+ }),
129
+ name: attributes_1.default.String({
130
+ modelKey: 'name',
131
+ }),
132
+ pageHostname: attributes_1.default.String({
133
+ modelKey: 'pageHostname',
134
+ jsonKey: 'page_hostname',
135
+ }),
136
+ replacesBookingHash: attributes_1.default.String({
137
+ modelKey: 'replacesBookingHash',
138
+ jsonKey: 'replaces_booking_hash',
139
+ }),
140
+ slot: attributes_1.default.Object({
141
+ modelKey: 'slot',
142
+ itemClass: scheduler_time_slot_1.default,
143
+ }),
144
+ timezone: attributes_1.default.String({
145
+ modelKey: 'timezone',
146
+ }),
147
+ };
@@ -0,0 +1,25 @@
1
+ import RestfulModelCollection from './restful-model-collection';
2
+ import NylasConnection from '../nylas-connection';
3
+ import Scheduler from './scheduler';
4
+ import SchedulerTimeSlot from './scheduler-time-slot';
5
+ import SchedulerBookingRequest, { SchedulerBookingConfirmation } from './scheduler-booking-request';
6
+ export declare type ProviderAvailability = {
7
+ busy: [{
8
+ end: number;
9
+ start: number;
10
+ }];
11
+ email: string;
12
+ name: string;
13
+ };
14
+ export default class SchedulerRestfulModelCollection extends RestfulModelCollection<Scheduler> {
15
+ connection: NylasConnection;
16
+ modelClass: typeof Scheduler;
17
+ constructor(connection: NylasConnection);
18
+ getGoogleAvailability(): Promise<ProviderAvailability>;
19
+ getOffice365Availability(): Promise<ProviderAvailability>;
20
+ getPageBySlug(slug: string): Promise<Scheduler>;
21
+ getAvailableTimeSlots(slug: string): Promise<SchedulerTimeSlot[]>;
22
+ bookTimeSlot(slug: string, bookingRequest: SchedulerBookingRequest): Promise<SchedulerBookingConfirmation>;
23
+ cancelBooking(slug: string, editHash: string, reason: string): Record<string, any>;
24
+ confirmBooking(slug: string, editHash: string): Promise<SchedulerBookingConfirmation>;
25
+ }
@@ -0,0 +1,136 @@
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 scheduler_1 = __importDefault(require("./scheduler"));
21
+ var scheduler_time_slot_1 = __importDefault(require("./scheduler-time-slot"));
22
+ var scheduler_booking_request_1 = require("./scheduler-booking-request");
23
+ var SchedulerRestfulModelCollection = /** @class */ (function (_super) {
24
+ __extends(SchedulerRestfulModelCollection, _super);
25
+ function SchedulerRestfulModelCollection(connection) {
26
+ var _this = _super.call(this, scheduler_1.default, connection) || this;
27
+ _this.baseUrl = 'https://api.schedule.nylas.com';
28
+ _this.connection = connection;
29
+ _this.modelClass = scheduler_1.default;
30
+ return _this;
31
+ }
32
+ SchedulerRestfulModelCollection.prototype.getGoogleAvailability = function () {
33
+ return this.connection.request({
34
+ method: 'GET',
35
+ path: '/schedule/availability/google',
36
+ headers: {
37
+ 'Content-Type': 'application/json',
38
+ },
39
+ baseUrl: this.baseUrl,
40
+ });
41
+ };
42
+ SchedulerRestfulModelCollection.prototype.getOffice365Availability = function () {
43
+ return this.connection.request({
44
+ method: 'GET',
45
+ path: '/schedule/availability/o365',
46
+ headers: {
47
+ 'Content-Type': 'application/json',
48
+ },
49
+ baseUrl: this.baseUrl,
50
+ });
51
+ };
52
+ SchedulerRestfulModelCollection.prototype.getPageBySlug = function (slug) {
53
+ var _this = this;
54
+ return this.connection
55
+ .request({
56
+ method: 'GET',
57
+ path: "/schedule/" + slug + "/info",
58
+ headers: {
59
+ 'Content-Type': 'application/json',
60
+ },
61
+ baseUrl: this.baseUrl,
62
+ })
63
+ .then(function (json) {
64
+ return Promise.resolve(new scheduler_1.default(_this.connection, json));
65
+ });
66
+ };
67
+ SchedulerRestfulModelCollection.prototype.getAvailableTimeSlots = function (slug) {
68
+ var _this = this;
69
+ return this.connection
70
+ .request({
71
+ method: 'GET',
72
+ path: "/schedule/" + slug + "/timeslots",
73
+ headers: {
74
+ 'Content-Type': 'application/json',
75
+ },
76
+ baseUrl: this.baseUrl,
77
+ })
78
+ .then(function (json) {
79
+ var timeslots = json.map(function (timeslot) {
80
+ return new scheduler_time_slot_1.default(_this.connection, timeslot);
81
+ });
82
+ return Promise.resolve(timeslots);
83
+ });
84
+ };
85
+ SchedulerRestfulModelCollection.prototype.bookTimeSlot = function (slug, bookingRequest) {
86
+ var _this = this;
87
+ return this.connection
88
+ .request({
89
+ method: 'POST',
90
+ path: "/schedule/" + slug + "/timeslots",
91
+ headers: {
92
+ 'Content-Type': 'application/json',
93
+ },
94
+ body: bookingRequest.toJSON(),
95
+ baseUrl: this.baseUrl,
96
+ })
97
+ .then(function (json) {
98
+ return Promise.resolve(new scheduler_booking_request_1.SchedulerBookingConfirmation(_this.connection, json));
99
+ });
100
+ };
101
+ SchedulerRestfulModelCollection.prototype.cancelBooking = function (slug, editHash, reason) {
102
+ return this.connection
103
+ .request({
104
+ method: 'POST',
105
+ path: "/schedule/" + slug + "/" + editHash + "/cancel",
106
+ headers: {
107
+ 'Content-Type': 'application/json',
108
+ },
109
+ body: {
110
+ reason: reason,
111
+ },
112
+ baseUrl: this.baseUrl,
113
+ })
114
+ .then(function (json) {
115
+ return Promise.resolve(json);
116
+ });
117
+ };
118
+ SchedulerRestfulModelCollection.prototype.confirmBooking = function (slug, editHash) {
119
+ var _this = this;
120
+ return this.connection
121
+ .request({
122
+ method: 'POST',
123
+ path: "/schedule/" + slug + "/" + editHash + "/confirm",
124
+ headers: {
125
+ 'Content-Type': 'application/json',
126
+ },
127
+ body: {},
128
+ baseUrl: this.baseUrl,
129
+ })
130
+ .then(function (json) {
131
+ return Promise.resolve(new scheduler_booking_request_1.SchedulerBookingConfirmation(_this.connection, json));
132
+ });
133
+ };
134
+ return SchedulerRestfulModelCollection;
135
+ }(restful_model_collection_1.default));
136
+ exports.default = SchedulerRestfulModelCollection;
@@ -0,0 +1,9 @@
1
+ import RestfulModel from './restful-model';
2
+ export default class SchedulerTimeSlot extends RestfulModel {
3
+ accountId?: string;
4
+ calendarId?: string;
5
+ hostName?: string;
6
+ emails?: string[];
7
+ start?: Date;
8
+ end?: Date;
9
+ }
@@ -0,0 +1,52 @@
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 SchedulerTimeSlot = /** @class */ (function (_super) {
22
+ __extends(SchedulerTimeSlot, _super);
23
+ function SchedulerTimeSlot() {
24
+ return _super !== null && _super.apply(this, arguments) || this;
25
+ }
26
+ return SchedulerTimeSlot;
27
+ }(restful_model_1.default));
28
+ exports.default = SchedulerTimeSlot;
29
+ SchedulerTimeSlot.collectionName = 'scheduler_slot';
30
+ SchedulerTimeSlot.attributes = {
31
+ accountId: attributes_1.default.String({
32
+ modelKey: 'accountId',
33
+ jsonKey: 'account_id',
34
+ }),
35
+ calendarId: attributes_1.default.String({
36
+ modelKey: 'calendarId',
37
+ jsonKey: 'calendar_id',
38
+ }),
39
+ hostName: attributes_1.default.String({
40
+ modelKey: 'hostName',
41
+ jsonKey: 'host_name',
42
+ }),
43
+ emails: attributes_1.default.StringList({
44
+ modelKey: 'emails',
45
+ }),
46
+ start: attributes_1.default.DateTime({
47
+ modelKey: 'start',
48
+ }),
49
+ end: attributes_1.default.DateTime({
50
+ modelKey: 'end',
51
+ }),
52
+ };
@@ -0,0 +1,98 @@
1
+ import RestfulModel, { SaveCallback } from './restful-model';
2
+ import NylasConnection from '../nylas-connection';
3
+ import Calendar from './calendar';
4
+ export declare type SchedulerUploadImageResponse = {
5
+ filename: string;
6
+ originalFilename: string;
7
+ publicUrl: string;
8
+ signedUrl: string;
9
+ };
10
+ export declare class SchedulerAvailableCalendars extends RestfulModel {
11
+ calendars?: Calendar[];
12
+ email?: string;
13
+ id?: string;
14
+ name?: string;
15
+ }
16
+ export default class Scheduler extends RestfulModel {
17
+ accessTokens?: string[];
18
+ appClientId?: string;
19
+ appOrganizationId?: number;
20
+ config?: {
21
+ appearance?: {
22
+ color?: string;
23
+ company_name?: string;
24
+ logo?: string;
25
+ privacy_policy_redirect?: string;
26
+ show_autoschedule?: boolean;
27
+ show_nylas_branding?: boolean;
28
+ show_timezone_options?: boolean;
29
+ submit_text?: string;
30
+ thank_you_redirect?: string;
31
+ thank_you_text?: string;
32
+ thank_you_text_secondary?: string;
33
+ };
34
+ booking?: {
35
+ additional_fields: Array<{
36
+ dropdown_options?: string[];
37
+ label?: string;
38
+ multi_select_options?: string[];
39
+ name?: string;
40
+ order?: number;
41
+ pattern?: string;
42
+ required?: boolean;
43
+ type?: string;
44
+ }>;
45
+ available_days_in_future: number;
46
+ calendar_invite_to_guests: boolean;
47
+ cancellation_policy: string;
48
+ confirmation_emails_to_guests: boolean;
49
+ confirmation_emails_to_host: boolean;
50
+ confirmation_method: string;
51
+ min_booking_notice: number;
52
+ min_buffer: number;
53
+ min_cancellation_notice: number;
54
+ name_field_hidden: boolean;
55
+ opening_hours: Array<{
56
+ account_id?: string;
57
+ days?: string[];
58
+ end?: string;
59
+ start?: string;
60
+ }>;
61
+ scheduling_method: string;
62
+ };
63
+ calendar_ids?: {
64
+ [accountId: string]: {
65
+ availability?: string[];
66
+ booking?: string;
67
+ };
68
+ };
69
+ event?: {
70
+ duration?: number;
71
+ location?: string;
72
+ title?: string;
73
+ };
74
+ expire_after?: {
75
+ date?: Date;
76
+ uses?: number;
77
+ };
78
+ locale?: string;
79
+ locale_for_guests?: string;
80
+ reminders?: Array<{
81
+ delivery_method?: string;
82
+ delivery_recipient?: string;
83
+ email_subject?: string;
84
+ time_before_event?: number;
85
+ webhook_url?: string;
86
+ }>;
87
+ timezone?: string;
88
+ };
89
+ editToken?: string;
90
+ name?: string;
91
+ slug?: string;
92
+ createdAt?: Date;
93
+ modifiedAt?: Date;
94
+ constructor(connection: NylasConnection, json?: Record<string, any>);
95
+ save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
96
+ getAvailableCalendars(): Promise<SchedulerAvailableCalendars[]>;
97
+ uploadImage(contentType: string, objectName: string): Promise<SchedulerUploadImageResponse>;
98
+ }
@@ -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 __importDefault = (this && this.__importDefault) || function (mod) {
27
+ return (mod && mod.__esModule) ? mod : { "default": mod };
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.SchedulerAvailableCalendars = void 0;
31
+ var restful_model_1 = __importDefault(require("./restful-model"));
32
+ var attributes_1 = __importDefault(require("./attributes"));
33
+ var calendar_1 = __importDefault(require("./calendar"));
34
+ var SchedulerAvailableCalendars = /** @class */ (function (_super) {
35
+ __extends(SchedulerAvailableCalendars, _super);
36
+ function SchedulerAvailableCalendars() {
37
+ return _super !== null && _super.apply(this, arguments) || this;
38
+ }
39
+ return SchedulerAvailableCalendars;
40
+ }(restful_model_1.default));
41
+ exports.SchedulerAvailableCalendars = SchedulerAvailableCalendars;
42
+ SchedulerAvailableCalendars.collectionName = 'scheduler_available_calendars';
43
+ SchedulerAvailableCalendars.attributes = {
44
+ calendars: attributes_1.default.Collection({
45
+ modelKey: 'calendars',
46
+ itemClass: calendar_1.default,
47
+ }),
48
+ email: attributes_1.default.String({
49
+ modelKey: 'email',
50
+ }),
51
+ id: attributes_1.default.String({
52
+ modelKey: 'id',
53
+ }),
54
+ name: attributes_1.default.String({
55
+ modelKey: 'name',
56
+ }),
57
+ };
58
+ var Scheduler = /** @class */ (function (_super) {
59
+ __extends(Scheduler, _super);
60
+ function Scheduler(connection, json) {
61
+ var _this = _super.call(this, connection, json) || this;
62
+ _this.baseUrl = 'https://api.schedule.nylas.com';
63
+ return _this;
64
+ }
65
+ Scheduler.prototype.save = function (params, callback) {
66
+ if (params === void 0) { params = {}; }
67
+ return this._save(params, callback);
68
+ };
69
+ Scheduler.prototype.getAvailableCalendars = function () {
70
+ var _this = this;
71
+ if (!this.id) {
72
+ throw new Error('Cannot get calendars for a page without an ID.');
73
+ }
74
+ return this.connection
75
+ .request({
76
+ method: 'GET',
77
+ path: "/manage/pages/" + this.id + "/calendars",
78
+ headers: {
79
+ 'Content-Type': 'application/json',
80
+ },
81
+ baseUrl: this.baseUrl,
82
+ })
83
+ .then(function (json) {
84
+ var calendars = json.map(function (cal) {
85
+ return new SchedulerAvailableCalendars(_this.connection, cal);
86
+ });
87
+ return Promise.resolve(calendars);
88
+ });
89
+ };
90
+ Scheduler.prototype.uploadImage = function (contentType, objectName) {
91
+ if (!this.id) {
92
+ throw new Error('Cannot upload an image to a page without an ID.');
93
+ }
94
+ return this.connection.request({
95
+ method: 'PUT',
96
+ path: "/manage/pages/" + this.id + "/upload-image",
97
+ headers: {
98
+ 'Content-Type': 'application/json',
99
+ },
100
+ body: {
101
+ contentType: contentType,
102
+ objectName: objectName,
103
+ },
104
+ baseUrl: this.baseUrl,
105
+ });
106
+ };
107
+ return Scheduler;
108
+ }(restful_model_1.default));
109
+ exports.default = Scheduler;
110
+ Scheduler.collectionName = 'manage/pages';
111
+ Scheduler.attributes = __assign(__assign({}, restful_model_1.default.attributes), { accessTokens: attributes_1.default.StringList({
112
+ modelKey: 'accessTokens',
113
+ jsonKey: 'access_tokens',
114
+ }), appClientId: attributes_1.default.String({
115
+ modelKey: 'appClientId',
116
+ jsonKey: 'app_client_id',
117
+ readOnly: true,
118
+ }), appOrganizationId: attributes_1.default.Number({
119
+ modelKey: 'appOrganizationId',
120
+ jsonKey: 'app_organization_id',
121
+ readOnly: true,
122
+ }), config: attributes_1.default.Object({
123
+ modelKey: 'config',
124
+ }), editToken: attributes_1.default.String({
125
+ modelKey: 'editToken',
126
+ jsonKey: 'edit_token',
127
+ readOnly: true,
128
+ }), name: attributes_1.default.String({
129
+ modelKey: 'name',
130
+ }), slug: attributes_1.default.String({
131
+ modelKey: 'slug',
132
+ }), createdAt: attributes_1.default.Date({
133
+ modelKey: 'createdAt',
134
+ jsonKey: 'created_at',
135
+ readOnly: true,
136
+ }), modifiedAt: attributes_1.default.Date({
137
+ modelKey: 'modifiedAt',
138
+ jsonKey: 'modified_at',
139
+ readOnly: true,
140
+ }) });
@@ -17,6 +17,8 @@ import Delta from './models/delta';
17
17
  import { Folder, Label } from './models/folder';
18
18
  import { AppendOptions } from 'form-data';
19
19
  import Neural from './models/neural';
20
+ import ComponentRestfulModelCollection from './models/component-restful-model-collection';
21
+ import SchedulerRestfulModelCollection from './models/scheduler-restful-model-collection';
20
22
  export declare type RequestOptions = {
21
23
  path: string;
22
24
  method?: string;
@@ -32,6 +34,7 @@ export declare type RequestOptions = {
32
34
  [key: string]: FormDataType;
33
35
  };
34
36
  body?: any;
37
+ baseUrl?: string;
35
38
  url?: URL;
36
39
  };
37
40
  export declare type FormDataType = {
@@ -56,6 +59,8 @@ export default class NylasConnection {
56
59
  labels: RestfulModelCollection<Label>;
57
60
  folders: RestfulModelCollection<Folder>;
58
61
  account: RestfulModelInstance<Account>;
62
+ component: ComponentRestfulModelCollection;
63
+ scheduler: SchedulerRestfulModelCollection;
59
64
  neural: Neural;
60
65
  constructor(accessToken: string | null | undefined, { clientId }: {
61
66
  clientId: string | null | undefined;
@@ -54,6 +54,8 @@ var folder_1 = require("./models/folder");
54
54
  var form_data_1 = __importDefault(require("form-data"));
55
55
  var neural_1 = __importDefault(require("./models/neural"));
56
56
  var nylas_api_error_1 = __importDefault(require("./models/nylas-api-error"));
57
+ var component_restful_model_collection_1 = __importDefault(require("./models/component-restful-model-collection"));
58
+ var scheduler_restful_model_collection_1 = __importDefault(require("./models/scheduler-restful-model-collection"));
57
59
  var PACKAGE_JSON = require('../package.json');
58
60
  var SDK_VERSION = PACKAGE_JSON.version;
59
61
  var SUPPORTED_API_VERSION = '2.3';
@@ -73,12 +75,15 @@ var NylasConnection = /** @class */ (function () {
73
75
  this.labels = new restful_model_collection_1.default(folder_1.Label, this);
74
76
  this.folders = new restful_model_collection_1.default(folder_1.Folder, this);
75
77
  this.account = new restful_model_instance_1.default(account_1.default, this);
78
+ this.component = new component_restful_model_collection_1.default(this);
79
+ this.scheduler = new scheduler_restful_model_collection_1.default(this);
76
80
  this.neural = new neural_1.default(this);
77
81
  this.accessToken = accessToken;
78
82
  this.clientId = clientId;
79
83
  }
80
84
  NylasConnection.prototype.requestOptions = function (options) {
81
- var url = new url_1.URL("" + config.apiServer + options.path);
85
+ var baseUrl = options.baseUrl ? options.baseUrl : config.apiServer;
86
+ var url = new url_1.URL("" + baseUrl + options.path);
82
87
  // map querystring to search params
83
88
  if (options.qs) {
84
89
  for (var _i = 0, _a = Object.entries(options.qs); _i < _a.length; _i++) {
@@ -110,7 +115,7 @@ var NylasConnection = /** @class */ (function () {
110
115
  }
111
116
  options.url = url;
112
117
  var headers = __assign({}, options.headers);
113
- var user = options.path.substr(0, 3) === '/a/'
118
+ var user = options.path.substr(0, 3) === '/a/' || options.path.includes('/component')
114
119
  ? config.clientSecret
115
120
  : this.accessToken;
116
121
  if (user) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nylas",
3
- "version": "5.8.0",
3
+ "version": "5.10.2",
4
4
  "description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
5
5
  "main": "lib/nylas.js",
6
6
  "types": "lib/nylas.d.ts",