nylas 7.0.0-beta.0 → 7.0.0-beta.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 (204) hide show
  1. package/README.md +27 -19
  2. package/lib/cjs/apiClient.js +114 -0
  3. package/lib/cjs/config.js +32 -0
  4. package/lib/cjs/models/applicationDetails.js +2 -0
  5. package/lib/cjs/models/auth.js +2 -0
  6. package/lib/cjs/models/availability.js +11 -0
  7. package/lib/cjs/models/calendars.js +2 -0
  8. package/lib/cjs/models/error.js +53 -0
  9. package/lib/cjs/models/events.js +2 -0
  10. package/lib/cjs/models/grants.js +2 -0
  11. package/lib/cjs/models/listQueryParams.js +2 -0
  12. package/lib/cjs/models/redirectUri.js +2 -0
  13. package/lib/cjs/models/response.js +2 -0
  14. package/lib/cjs/models/webhooks.js +18 -0
  15. package/lib/cjs/nylas.js +34 -0
  16. package/lib/cjs/package.json +3 -0
  17. package/lib/cjs/resources/applications.js +30 -0
  18. package/lib/cjs/resources/auth.js +153 -0
  19. package/lib/cjs/resources/calendars.js +78 -0
  20. package/lib/cjs/resources/events.js +69 -0
  21. package/lib/cjs/resources/grants.js +65 -0
  22. package/lib/cjs/resources/redirectUris.js +64 -0
  23. package/lib/cjs/resources/resource.js +111 -0
  24. package/lib/cjs/resources/webhooks.js +98 -0
  25. package/lib/cjs/utils.js +58 -0
  26. package/lib/cjs/version.js +5 -0
  27. package/lib/esm/apiClient.js +111 -0
  28. package/lib/esm/config.js +29 -0
  29. package/lib/esm/models/applicationDetails.js +1 -0
  30. package/lib/esm/models/auth.js +1 -0
  31. package/lib/esm/models/availability.js +8 -0
  32. package/lib/esm/models/calendars.js +1 -0
  33. package/lib/esm/models/error.js +45 -0
  34. package/lib/esm/models/events.js +1 -0
  35. package/lib/esm/models/grants.js +1 -0
  36. package/lib/esm/models/listQueryParams.js +1 -0
  37. package/lib/esm/models/redirectUri.js +1 -0
  38. package/lib/esm/models/response.js +1 -0
  39. package/lib/esm/models/webhooks.js +15 -0
  40. package/lib/esm/nylas.js +31 -0
  41. package/lib/esm/package.json +3 -0
  42. package/lib/esm/resources/applications.js +26 -0
  43. package/lib/esm/resources/auth.js +149 -0
  44. package/lib/esm/resources/calendars.js +74 -0
  45. package/lib/esm/resources/events.js +65 -0
  46. package/lib/esm/resources/grants.js +61 -0
  47. package/lib/esm/resources/redirectUris.js +60 -0
  48. package/lib/esm/resources/resource.js +107 -0
  49. package/lib/esm/resources/webhooks.js +94 -0
  50. package/lib/esm/utils.js +53 -0
  51. package/lib/esm/version.js +2 -0
  52. package/lib/types/apiClient.d.ts +65 -0
  53. package/lib/types/config.d.ts +50 -0
  54. package/lib/types/models/applicationDetails.d.ts +93 -0
  55. package/lib/types/models/auth.d.ts +196 -0
  56. package/lib/types/models/availability.d.ts +159 -0
  57. package/lib/types/models/calendars.d.ts +121 -0
  58. package/lib/types/models/error.d.ts +104 -0
  59. package/lib/types/models/events.d.ts +494 -0
  60. package/lib/types/models/grants.d.ts +134 -0
  61. package/lib/types/models/listQueryParams.d.ts +4 -0
  62. package/lib/types/models/redirectUri.d.ts +71 -0
  63. package/lib/types/models/response.d.ts +40 -0
  64. package/lib/types/models/webhooks.d.ts +45 -0
  65. package/lib/types/nylas.d.ts +44 -0
  66. package/lib/types/resources/applications.d.ts +26 -0
  67. package/lib/types/resources/auth.d.ts +66 -0
  68. package/lib/types/resources/calendars.d.ts +97 -0
  69. package/lib/types/resources/events.d.ts +87 -0
  70. package/lib/types/resources/grants.d.ts +63 -0
  71. package/lib/types/resources/redirectUris.d.ts +63 -0
  72. package/lib/types/resources/resource.d.ts +55 -0
  73. package/lib/types/resources/webhooks.d.ts +79 -0
  74. package/lib/types/utils.d.ts +22 -0
  75. package/lib/types/version.d.ts +1 -0
  76. package/package.json +33 -42
  77. package/lib/config.d.ts +0 -70
  78. package/lib/config.js +0 -68
  79. package/lib/models/access-token.d.ts +0 -18
  80. package/lib/models/access-token.js +0 -56
  81. package/lib/models/account.d.ts +0 -27
  82. package/lib/models/account.js +0 -73
  83. package/lib/models/application-details.d.ts +0 -14
  84. package/lib/models/application-details.js +0 -47
  85. package/lib/models/attributes.d.ts +0 -151
  86. package/lib/models/attributes.js +0 -382
  87. package/lib/models/calendar-availability.d.ts +0 -76
  88. package/lib/models/calendar-availability.js +0 -121
  89. package/lib/models/calendar-restful-model-collection.d.ts +0 -17
  90. package/lib/models/calendar-restful-model-collection.js +0 -181
  91. package/lib/models/calendar.d.ts +0 -31
  92. package/lib/models/calendar.js +0 -93
  93. package/lib/models/component-restful-model-collection.d.ts +0 -9
  94. package/lib/models/component-restful-model-collection.js +0 -34
  95. package/lib/models/component.d.ts +0 -37
  96. package/lib/models/component.js +0 -91
  97. package/lib/models/connect.d.ts +0 -73
  98. package/lib/models/connect.js +0 -193
  99. package/lib/models/contact-restful-model-collection.d.ts +0 -9
  100. package/lib/models/contact-restful-model-collection.js +0 -60
  101. package/lib/models/contact.d.ts +0 -129
  102. package/lib/models/contact.js +0 -289
  103. package/lib/models/delta-collection.d.ts +0 -17
  104. package/lib/models/delta-collection.js +0 -139
  105. package/lib/models/delta-stream.d.ts +0 -32
  106. package/lib/models/delta-stream.js +0 -250
  107. package/lib/models/delta.d.ts +0 -28
  108. package/lib/models/delta.js +0 -88
  109. package/lib/models/deltas.d.ts +0 -17
  110. package/lib/models/deltas.js +0 -49
  111. package/lib/models/draft.d.ts +0 -27
  112. package/lib/models/draft.js +0 -156
  113. package/lib/models/email-participant.d.ts +0 -13
  114. package/lib/models/email-participant.js +0 -46
  115. package/lib/models/event-conferencing.d.ts +0 -34
  116. package/lib/models/event-conferencing.js +0 -71
  117. package/lib/models/event-notification.d.ts +0 -27
  118. package/lib/models/event-notification.js +0 -62
  119. package/lib/models/event-participant.d.ts +0 -19
  120. package/lib/models/event-participant.js +0 -56
  121. package/lib/models/event.d.ts +0 -96
  122. package/lib/models/event.js +0 -297
  123. package/lib/models/file.d.ts +0 -29
  124. package/lib/models/file.js +0 -136
  125. package/lib/models/folder.d.ts +0 -21
  126. package/lib/models/folder.js +0 -69
  127. package/lib/models/free-busy.d.ts +0 -58
  128. package/lib/models/free-busy.js +0 -132
  129. package/lib/models/job-status-restful-model-collection.d.ts +0 -9
  130. package/lib/models/job-status-restful-model-collection.js +0 -38
  131. package/lib/models/job-status.d.ts +0 -24
  132. package/lib/models/job-status.js +0 -68
  133. package/lib/models/management-account.d.ts +0 -63
  134. package/lib/models/management-account.js +0 -187
  135. package/lib/models/management-model-collection.d.ts +0 -10
  136. package/lib/models/management-model-collection.js +0 -39
  137. package/lib/models/management-model.d.ts +0 -6
  138. package/lib/models/management-model.js +0 -29
  139. package/lib/models/message-restful-model-collection.d.ts +0 -26
  140. package/lib/models/message-restful-model-collection.js +0 -80
  141. package/lib/models/message.d.ts +0 -57
  142. package/lib/models/message.js +0 -173
  143. package/lib/models/model-collection.d.ts +0 -25
  144. package/lib/models/model-collection.js +0 -201
  145. package/lib/models/model.d.ts +0 -12
  146. package/lib/models/model.js +0 -64
  147. package/lib/models/neural-categorizer.d.ts +0 -28
  148. package/lib/models/neural-categorizer.js +0 -139
  149. package/lib/models/neural-clean-conversation.d.ts +0 -16
  150. package/lib/models/neural-clean-conversation.js +0 -114
  151. package/lib/models/neural-ocr.d.ts +0 -14
  152. package/lib/models/neural-ocr.js +0 -50
  153. package/lib/models/neural-sentiment-analysis.d.ts +0 -20
  154. package/lib/models/neural-sentiment-analysis.js +0 -56
  155. package/lib/models/neural-signature-contact.d.ts +0 -43
  156. package/lib/models/neural-signature-contact.js +0 -142
  157. package/lib/models/neural-signature-extraction.d.ts +0 -17
  158. package/lib/models/neural-signature-extraction.js +0 -54
  159. package/lib/models/neural.d.ts +0 -36
  160. package/lib/models/neural.js +0 -163
  161. package/lib/models/nylas-api-error.d.ts +0 -26
  162. package/lib/models/nylas-api-error.js +0 -61
  163. package/lib/models/outbox-job-status.d.ts +0 -20
  164. package/lib/models/outbox-job-status.js +0 -64
  165. package/lib/models/outbox-message.d.ts +0 -16
  166. package/lib/models/outbox-message.js +0 -54
  167. package/lib/models/outbox.d.ts +0 -35
  168. package/lib/models/outbox.js +0 -158
  169. package/lib/models/resource.d.ts +0 -22
  170. package/lib/models/resource.js +0 -66
  171. package/lib/models/restful-model-collection.d.ts +0 -15
  172. package/lib/models/restful-model-collection.js +0 -169
  173. package/lib/models/restful-model-instance.d.ts +0 -9
  174. package/lib/models/restful-model-instance.js +0 -37
  175. package/lib/models/restful-model.d.ts +0 -36
  176. package/lib/models/restful-model.js +0 -146
  177. package/lib/models/scheduler-booking-request.d.ts +0 -64
  178. package/lib/models/scheduler-booking-request.js +0 -148
  179. package/lib/models/scheduler-restful-model-collection.d.ts +0 -26
  180. package/lib/models/scheduler-restful-model-collection.js +0 -133
  181. package/lib/models/scheduler-time-slot.d.ts +0 -20
  182. package/lib/models/scheduler-time-slot.js +0 -53
  183. package/lib/models/scheduler.d.ts +0 -226
  184. package/lib/models/scheduler.js +0 -446
  185. package/lib/models/thread.d.ts +0 -49
  186. package/lib/models/thread.js +0 -127
  187. package/lib/models/webhook-notification.d.ts +0 -108
  188. package/lib/models/webhook-notification.js +0 -239
  189. package/lib/models/webhook.d.ts +0 -50
  190. package/lib/models/webhook.js +0 -101
  191. package/lib/models/when.d.ts +0 -23
  192. package/lib/models/when.js +0 -65
  193. package/lib/nylas-connection.d.ts +0 -71
  194. package/lib/nylas-connection.js +0 -258
  195. package/lib/nylas.d.ts +0 -57
  196. package/lib/nylas.js +0 -210
  197. package/lib/server-bindings/express-binding.d.ts +0 -18
  198. package/lib/server-bindings/express-binding.js +0 -163
  199. package/lib/server-bindings/server-binding.d.ts +0 -65
  200. package/lib/server-bindings/server-binding.js +0 -87
  201. package/lib/services/routes.d.ts +0 -26
  202. package/lib/services/routes.js +0 -95
  203. package/lib/services/tunnel.d.ts +0 -29
  204. package/lib/services/tunnel.js +0 -112
@@ -1,36 +0,0 @@
1
- import { Attribute } from './attributes';
2
- import NylasConnection from '../nylas-connection';
3
- import Model from './model';
4
- export declare type SaveCallback = (error: Error | null, result?: RestfulModel) => void;
5
- interface RestfulModelJSON {
6
- id: string;
7
- object: string;
8
- accountId: string;
9
- [key: string]: any;
10
- }
11
- declare type requestOptions = {
12
- body: Record<string, unknown>;
13
- qs: Record<string, unknown>;
14
- };
15
- export default class RestfulModel extends Model {
16
- static endpointName: string;
17
- static collectionName: string;
18
- accountId?: string;
19
- connection: NylasConnection;
20
- id?: string;
21
- object?: string;
22
- baseUrl?: string;
23
- static attributes: Record<string, Attribute>;
24
- constructor(connection: NylasConnection, props?: Partial<RestfulModelJSON>);
25
- static propsFromJSON(json: Partial<RestfulModelJSON> | undefined, parent: unknown): Partial<RestfulModelJSON>;
26
- isEqual(other: RestfulModel): boolean;
27
- fromJSON(json?: Partial<RestfulModelJSON>): this;
28
- pathPrefix(): string;
29
- saveEndpoint(): string;
30
- deleteRequestQueryString(_params: Record<string, unknown>): Record<string, unknown>;
31
- deleteRequestBody(_params: Record<string, unknown>): Record<string, unknown>;
32
- deleteRequestOptions(params: Record<string, unknown>): requestOptions;
33
- protected save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
34
- protected get(params?: Record<string, any>, callback?: (error: Error | null, result?: any) => void, pathSuffix?: string): Promise<any>;
35
- }
36
- export {};
@@ -1,146 +0,0 @@
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 model_1 = __importDefault(require("./model"));
21
- var RestfulModel = /** @class */ (function (_super) {
22
- __extends(RestfulModel, _super);
23
- function RestfulModel(connection, props) {
24
- var _this = _super.call(this) || this;
25
- _this.connection = connection;
26
- if (!_this.connection) {
27
- throw new Error('Connection object not provided');
28
- }
29
- _this.id = (props === null || props === void 0 ? void 0 : props.id) ? props.id : undefined;
30
- _this.accountId = (props === null || props === void 0 ? void 0 : props.accountId) ? props.accountId : undefined;
31
- _this.object = (props === null || props === void 0 ? void 0 : props.object) ? props.object : undefined;
32
- return _this;
33
- }
34
- RestfulModel.propsFromJSON = function (json, parent) {
35
- if (json === void 0) { json = {}; }
36
- return _super.propsFromJSON.call(this, json, parent);
37
- };
38
- RestfulModel.prototype.isEqual = function (other) {
39
- return ((other ? other.id : undefined) === this.id &&
40
- (other ? other.constructor : undefined) === this.constructor);
41
- };
42
- RestfulModel.prototype.fromJSON = function (json) {
43
- if (json === void 0) { json = {}; }
44
- return _super.prototype.fromJSON.call(this, json);
45
- };
46
- // Subclasses should override this method.
47
- RestfulModel.prototype.pathPrefix = function () {
48
- return '';
49
- };
50
- RestfulModel.prototype.saveEndpoint = function () {
51
- var collectionName = this.constructor.collectionName;
52
- return this.pathPrefix() + "/" + collectionName;
53
- };
54
- // deleteRequestQueryString is used by delete(). Subclasses should override this method.
55
- RestfulModel.prototype.deleteRequestQueryString = function (_params) {
56
- return {};
57
- };
58
- // deleteRequestBody is used by delete(). Subclasses should override this method.
59
- RestfulModel.prototype.deleteRequestBody = function (_params) {
60
- return {};
61
- };
62
- // deleteRequestOptions is used by delete(). Subclasses should override this method.
63
- RestfulModel.prototype.deleteRequestOptions = function (params) {
64
- return {
65
- body: this.deleteRequestBody(params),
66
- qs: this.deleteRequestQueryString(params),
67
- };
68
- };
69
- // Not every model needs to have a save function, but those who
70
- // do shouldn't have to reimplement the same boilerplate.
71
- // They should instead define a save() function which calls _save.
72
- RestfulModel.prototype.save = function (params, callback) {
73
- var _this = this;
74
- if (params === void 0) { params = {}; }
75
- if (typeof params === 'function') {
76
- callback = params;
77
- params = {};
78
- }
79
- return this.connection
80
- .request({
81
- method: this.id ? 'PUT' : 'POST',
82
- body: this.saveRequestBody(),
83
- qs: params,
84
- path: this.id
85
- ? this.saveEndpoint() + "/" + this.id
86
- : "" + this.saveEndpoint(),
87
- baseUrl: this.baseUrl,
88
- })
89
- .then(function (json) {
90
- var newModel = _this.fromJSON(json);
91
- if (callback) {
92
- callback(null, _this);
93
- }
94
- return Promise.resolve(newModel);
95
- })
96
- .catch(function (err) {
97
- if (callback) {
98
- callback(err);
99
- }
100
- return Promise.reject(err);
101
- });
102
- };
103
- RestfulModel.prototype.get = function (params, callback, pathSuffix) {
104
- if (params === void 0) { params = {}; }
105
- if (pathSuffix === void 0) { pathSuffix = ''; }
106
- var collectionName = this.constructor.collectionName;
107
- return this.connection
108
- .request({
109
- method: 'GET',
110
- path: "/" + collectionName + "/" + this.id + pathSuffix,
111
- qs: params,
112
- baseUrl: this.baseUrl,
113
- })
114
- .then(function (response) {
115
- if (callback) {
116
- callback(null, response);
117
- }
118
- return Promise.resolve(response);
119
- })
120
- .catch(function (err) {
121
- if (callback) {
122
- callback(err);
123
- }
124
- return Promise.reject(err);
125
- });
126
- };
127
- RestfulModel.endpointName = ''; // overrridden in subclasses
128
- RestfulModel.collectionName = ''; // overrridden in subclasses
129
- RestfulModel.attributes = {
130
- id: attributes_1.default.String({
131
- modelKey: 'id',
132
- readOnly: true,
133
- }),
134
- object: attributes_1.default.String({
135
- modelKey: 'object',
136
- readOnly: true,
137
- }),
138
- accountId: attributes_1.default.String({
139
- modelKey: 'accountId',
140
- jsonKey: 'account_id',
141
- readOnly: true,
142
- }),
143
- };
144
- return RestfulModel;
145
- }(model_1.default));
146
- exports.default = RestfulModel;
@@ -1,64 +0,0 @@
1
- import { Attribute } from './attributes';
2
- import SchedulerTimeSlot from './scheduler-time-slot';
3
- import Model from './model';
4
- export declare type SchedulerBookingConfirmationProperties = {
5
- id?: string;
6
- accountId?: string;
7
- additionalFieldValues?: object;
8
- calendarEventId?: string;
9
- calendarId?: string;
10
- editHash?: string;
11
- startTime?: Date;
12
- endTime?: Date;
13
- isConfirmed?: boolean;
14
- location?: string;
15
- recipientEmail?: string;
16
- recipientLocale?: string;
17
- recipientName?: string;
18
- recipientTz?: string;
19
- title?: string;
20
- };
21
- export declare class SchedulerBookingConfirmation extends Model implements SchedulerBookingConfirmationProperties {
22
- id?: string;
23
- accountId?: string;
24
- additionalFieldValues?: object;
25
- calendarEventId?: string;
26
- calendarId?: string;
27
- editHash?: string;
28
- startTime?: Date;
29
- endTime?: Date;
30
- isConfirmed?: boolean;
31
- location?: string;
32
- recipientEmail?: string;
33
- recipientLocale?: string;
34
- recipientName?: string;
35
- recipientTz?: string;
36
- title?: string;
37
- static attributes: Record<string, Attribute>;
38
- constructor(props?: SchedulerBookingConfirmationProperties);
39
- }
40
- export declare type SchedulerBookingRequestProperties = {
41
- additionalEmails?: string[];
42
- additionalValues?: object;
43
- email?: string;
44
- locale?: string;
45
- name?: string;
46
- pageHostname?: string;
47
- replacesBookingHash?: string;
48
- slot?: SchedulerTimeSlot;
49
- timezone?: string;
50
- };
51
- export default class SchedulerBookingRequest extends Model implements SchedulerBookingRequestProperties {
52
- additionalEmails?: string[];
53
- additionalValues?: object;
54
- email?: string;
55
- locale?: string;
56
- name?: string;
57
- pageHostname?: string;
58
- replacesBookingHash?: string;
59
- slot?: SchedulerTimeSlot;
60
- timezone?: string;
61
- static attributes: Record<string, Attribute>;
62
- constructor(props?: SchedulerBookingRequestProperties);
63
- toJSON(enforceReadOnly?: boolean): Record<string, any>;
64
- }
@@ -1,148 +0,0 @@
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 scheduler_time_slot_1 = __importDefault(require("./scheduler-time-slot"));
21
- var model_1 = __importDefault(require("./model"));
22
- var SchedulerBookingConfirmation = /** @class */ (function (_super) {
23
- __extends(SchedulerBookingConfirmation, _super);
24
- function SchedulerBookingConfirmation(props) {
25
- var _this = _super.call(this) || this;
26
- _this.initAttributes(props);
27
- return _this;
28
- }
29
- SchedulerBookingConfirmation.attributes = {
30
- id: attributes_1.default.Number({
31
- modelKey: 'id',
32
- }),
33
- accountId: attributes_1.default.String({
34
- modelKey: 'accountId',
35
- jsonKey: 'account_id',
36
- }),
37
- additionalFieldValues: attributes_1.default.Object({
38
- modelKey: 'additionalFieldValues',
39
- jsonKey: 'additional_field_values',
40
- }),
41
- calendarEventId: attributes_1.default.String({
42
- modelKey: 'calendarEventId',
43
- jsonKey: 'calendar_event_id',
44
- }),
45
- calendarId: attributes_1.default.String({
46
- modelKey: 'calendarId',
47
- jsonKey: 'calendar_id',
48
- }),
49
- editHash: attributes_1.default.String({
50
- modelKey: 'editHash',
51
- jsonKey: 'edit_hash',
52
- }),
53
- startTime: attributes_1.default.DateTime({
54
- modelKey: 'startTime',
55
- jsonKey: 'start_time',
56
- }),
57
- endTime: attributes_1.default.DateTime({
58
- modelKey: 'endTime',
59
- jsonKey: 'end_time',
60
- }),
61
- isConfirmed: attributes_1.default.Boolean({
62
- modelKey: 'isConfirmed',
63
- jsonKey: 'is_confirmed',
64
- }),
65
- location: attributes_1.default.String({
66
- modelKey: 'location',
67
- }),
68
- recipientEmail: attributes_1.default.String({
69
- modelKey: 'recipientEmail',
70
- jsonKey: 'recipient_email',
71
- }),
72
- recipientLocale: attributes_1.default.String({
73
- modelKey: 'recipientLocale',
74
- jsonKey: 'recipient_locale',
75
- }),
76
- recipientName: attributes_1.default.String({
77
- modelKey: 'recipientName',
78
- jsonKey: 'recipient_name',
79
- }),
80
- recipientTz: attributes_1.default.String({
81
- modelKey: 'recipientTz',
82
- jsonKey: 'recipient_tz',
83
- }),
84
- title: attributes_1.default.String({
85
- modelKey: 'title',
86
- }),
87
- };
88
- return SchedulerBookingConfirmation;
89
- }(model_1.default));
90
- exports.SchedulerBookingConfirmation = SchedulerBookingConfirmation;
91
- var SchedulerBookingRequest = /** @class */ (function (_super) {
92
- __extends(SchedulerBookingRequest, _super);
93
- function SchedulerBookingRequest(props) {
94
- var _this = _super.call(this) || this;
95
- _this.initAttributes(props);
96
- return _this;
97
- }
98
- /*
99
- * The booking endpoint requires additional_values and additional_emails
100
- to exist regardless if they are empty or not
101
- */
102
- SchedulerBookingRequest.prototype.toJSON = function (enforceReadOnly) {
103
- var json = _super.prototype.toJSON.call(this, enforceReadOnly);
104
- if (!this.additionalEmails) {
105
- json['additional_emails'] = [];
106
- }
107
- if (!this.additionalValues) {
108
- json['additional_values'] = {};
109
- }
110
- return json;
111
- };
112
- SchedulerBookingRequest.attributes = {
113
- additionalEmails: attributes_1.default.StringList({
114
- modelKey: 'additionalEmails',
115
- jsonKey: 'additional_emails',
116
- }),
117
- additionalValues: attributes_1.default.Object({
118
- modelKey: 'additionalValues',
119
- jsonKey: 'additional_values',
120
- }),
121
- email: attributes_1.default.String({
122
- modelKey: 'email',
123
- }),
124
- locale: attributes_1.default.String({
125
- modelKey: 'locale',
126
- }),
127
- name: attributes_1.default.String({
128
- modelKey: 'name',
129
- }),
130
- pageHostname: attributes_1.default.String({
131
- modelKey: 'pageHostname',
132
- jsonKey: 'page_hostname',
133
- }),
134
- replacesBookingHash: attributes_1.default.String({
135
- modelKey: 'replacesBookingHash',
136
- jsonKey: 'replaces_booking_hash',
137
- }),
138
- slot: attributes_1.default.Object({
139
- modelKey: 'slot',
140
- itemClass: scheduler_time_slot_1.default,
141
- }),
142
- timezone: attributes_1.default.String({
143
- modelKey: 'timezone',
144
- }),
145
- };
146
- return SchedulerBookingRequest;
147
- }(model_1.default));
148
- exports.default = SchedulerBookingRequest;
@@ -1,26 +0,0 @@
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
- baseUrl: string;
18
- constructor(connection: NylasConnection);
19
- getGoogleAvailability(): Promise<ProviderAvailability>;
20
- getOffice365Availability(): Promise<ProviderAvailability>;
21
- getPageBySlug(slug: string): Promise<Scheduler>;
22
- getAvailableTimeSlots(slug: string): Promise<SchedulerTimeSlot[]>;
23
- bookTimeSlot(slug: string, bookingRequest: SchedulerBookingRequest): Promise<SchedulerBookingConfirmation>;
24
- cancelBooking(slug: string, editHash: string, reason: string): Record<string, any>;
25
- confirmBooking(slug: string, editHash: string): Promise<SchedulerBookingConfirmation>;
26
- }
@@ -1,133 +0,0 @@
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).fromJSON(json));
65
- });
66
- };
67
- SchedulerRestfulModelCollection.prototype.getAvailableTimeSlots = function (slug) {
68
- return this.connection
69
- .request({
70
- method: 'GET',
71
- path: "/schedule/" + slug + "/timeslots",
72
- headers: {
73
- 'Content-Type': 'application/json',
74
- },
75
- baseUrl: this.baseUrl,
76
- })
77
- .then(function (json) {
78
- var timeslots = json.map(function (timeslot) {
79
- return new scheduler_time_slot_1.default().fromJSON(timeslot);
80
- });
81
- return Promise.resolve(timeslots);
82
- });
83
- };
84
- SchedulerRestfulModelCollection.prototype.bookTimeSlot = function (slug, bookingRequest) {
85
- return this.connection
86
- .request({
87
- method: 'POST',
88
- path: "/schedule/" + slug + "/timeslots",
89
- headers: {
90
- 'Content-Type': 'application/json',
91
- },
92
- body: bookingRequest.toJSON(),
93
- baseUrl: this.baseUrl,
94
- })
95
- .then(function (json) {
96
- return Promise.resolve(new scheduler_booking_request_1.SchedulerBookingConfirmation().fromJSON(json));
97
- });
98
- };
99
- SchedulerRestfulModelCollection.prototype.cancelBooking = function (slug, editHash, reason) {
100
- return this.connection
101
- .request({
102
- method: 'POST',
103
- path: "/schedule/" + slug + "/" + editHash + "/cancel",
104
- headers: {
105
- 'Content-Type': 'application/json',
106
- },
107
- body: {
108
- reason: reason,
109
- },
110
- baseUrl: this.baseUrl,
111
- })
112
- .then(function (json) {
113
- return Promise.resolve(json);
114
- });
115
- };
116
- SchedulerRestfulModelCollection.prototype.confirmBooking = function (slug, editHash) {
117
- return this.connection
118
- .request({
119
- method: 'POST',
120
- path: "/schedule/" + slug + "/" + editHash + "/confirm",
121
- headers: {
122
- 'Content-Type': 'application/json',
123
- },
124
- body: {},
125
- baseUrl: this.baseUrl,
126
- })
127
- .then(function (json) {
128
- return Promise.resolve(new scheduler_booking_request_1.SchedulerBookingConfirmation().fromJSON(json));
129
- });
130
- };
131
- return SchedulerRestfulModelCollection;
132
- }(restful_model_collection_1.default));
133
- exports.default = SchedulerRestfulModelCollection;
@@ -1,20 +0,0 @@
1
- import { Attribute } from './attributes';
2
- import Model from './model';
3
- export declare type SchedulerTimeSlotProperties = {
4
- accountId?: string;
5
- calendarId?: string;
6
- hostName?: string;
7
- emails?: string[];
8
- start?: Date;
9
- end?: Date;
10
- };
11
- export default class SchedulerTimeSlot extends Model implements SchedulerTimeSlotProperties {
12
- accountId?: string;
13
- calendarId?: string;
14
- hostName?: string;
15
- emails?: string[];
16
- start?: Date;
17
- end?: Date;
18
- static attributes: Record<string, Attribute>;
19
- constructor(props?: SchedulerTimeSlotProperties);
20
- }
@@ -1,53 +0,0 @@
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 model_1 = __importDefault(require("./model"));
21
- var SchedulerTimeSlot = /** @class */ (function (_super) {
22
- __extends(SchedulerTimeSlot, _super);
23
- function SchedulerTimeSlot(props) {
24
- var _this = _super.call(this) || this;
25
- _this.initAttributes(props);
26
- return _this;
27
- }
28
- SchedulerTimeSlot.attributes = {
29
- accountId: attributes_1.default.String({
30
- modelKey: 'accountId',
31
- jsonKey: 'account_id',
32
- }),
33
- calendarId: attributes_1.default.String({
34
- modelKey: 'calendarId',
35
- jsonKey: 'calendar_id',
36
- }),
37
- hostName: attributes_1.default.String({
38
- modelKey: 'hostName',
39
- jsonKey: 'host_name',
40
- }),
41
- emails: attributes_1.default.StringList({
42
- modelKey: 'emails',
43
- }),
44
- start: attributes_1.default.DateTime({
45
- modelKey: 'start',
46
- }),
47
- end: attributes_1.default.DateTime({
48
- modelKey: 'end',
49
- }),
50
- };
51
- return SchedulerTimeSlot;
52
- }(model_1.default));
53
- exports.default = SchedulerTimeSlot;