@wix/bookings 1.0.72 → 1.0.73

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 (31) hide show
  1. package/build/cjs/index.d.ts +1 -0
  2. package/build/cjs/index.js +2 -1
  3. package/build/cjs/index.js.map +1 -1
  4. package/build/cjs/src/bookings-calendar-v2-external-calendar.http.d.ts +121 -0
  5. package/build/cjs/src/bookings-calendar-v2-external-calendar.http.js +347 -0
  6. package/build/cjs/src/bookings-calendar-v2-external-calendar.http.js.map +1 -0
  7. package/build/cjs/src/bookings-calendar-v2-external-calendar.public.d.ts +13 -0
  8. package/build/cjs/src/bookings-calendar-v2-external-calendar.public.js +79 -0
  9. package/build/cjs/src/bookings-calendar-v2-external-calendar.public.js.map +1 -0
  10. package/build/cjs/src/bookings-calendar-v2-external-calendar.types.d.ts +1444 -0
  11. package/build/cjs/src/bookings-calendar-v2-external-calendar.types.js +209 -0
  12. package/build/cjs/src/bookings-calendar-v2-external-calendar.types.js.map +1 -0
  13. package/build/cjs/src/bookings-calendar-v2-external-calendar.universal.d.ts +1678 -0
  14. package/build/cjs/src/bookings-calendar-v2-external-calendar.universal.js +858 -0
  15. package/build/cjs/src/bookings-calendar-v2-external-calendar.universal.js.map +1 -0
  16. package/build/es/index.d.ts +1 -0
  17. package/build/es/index.js +1 -0
  18. package/build/es/index.js.map +1 -1
  19. package/build/es/src/bookings-calendar-v2-external-calendar.http.d.ts +121 -0
  20. package/build/es/src/bookings-calendar-v2-external-calendar.http.js +335 -0
  21. package/build/es/src/bookings-calendar-v2-external-calendar.http.js.map +1 -0
  22. package/build/es/src/bookings-calendar-v2-external-calendar.public.d.ts +13 -0
  23. package/build/es/src/bookings-calendar-v2-external-calendar.public.js +48 -0
  24. package/build/es/src/bookings-calendar-v2-external-calendar.public.js.map +1 -0
  25. package/build/es/src/bookings-calendar-v2-external-calendar.types.d.ts +1444 -0
  26. package/build/es/src/bookings-calendar-v2-external-calendar.types.js +206 -0
  27. package/build/es/src/bookings-calendar-v2-external-calendar.types.js.map +1 -0
  28. package/build/es/src/bookings-calendar-v2-external-calendar.universal.d.ts +1678 -0
  29. package/build/es/src/bookings-calendar-v2-external-calendar.universal.js +827 -0
  30. package/build/es/src/bookings-calendar-v2-external-calendar.universal.js.map +1 -0
  31. package/package.json +2 -2
@@ -0,0 +1,827 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { serializer, transformError } from '@wix/metro-runtime/velo';
11
+ import * as ambassadorWixBookingsCalendarV2ExternalCalendar from './bookings-calendar-v2-external-calendar.http';
12
+ let __verbose = false;
13
+ function __log(...args) {
14
+ __verbose && console.log(...args);
15
+ }
16
+ function __inspect(obj) {
17
+ return obj;
18
+ }
19
+ export const __debug = {
20
+ verboseLogging: {
21
+ on: () => (__verbose = true),
22
+ off: () => (__verbose = false),
23
+ },
24
+ };
25
+ const _toVeloEntity = '$';
26
+ const _fromVeloEntity = '$';
27
+ export var CalendarType;
28
+ (function (CalendarType) {
29
+ CalendarType["UNDEFINED"] = "UNDEFINED";
30
+ CalendarType["GOOGLE"] = "GOOGLE";
31
+ CalendarType["I_CAL"] = "I_CAL";
32
+ /** Use `MICROSOFT` instead. */
33
+ CalendarType["OUTLOOK"] = "OUTLOOK";
34
+ /** Use `MICROSOFT` instead. */
35
+ CalendarType["OFFICE_365"] = "OFFICE_365";
36
+ CalendarType["MICROSOFT"] = "MICROSOFT";
37
+ CalendarType["OTHER"] = "OTHER";
38
+ })(CalendarType || (CalendarType = {}));
39
+ export var ConnectMethod;
40
+ (function (ConnectMethod) {
41
+ ConnectMethod["UNDEFINED"] = "UNDEFINED";
42
+ ConnectMethod["OAUTH"] = "OAUTH";
43
+ ConnectMethod["CREDENTIALS"] = "CREDENTIALS";
44
+ })(ConnectMethod || (ConnectMethod = {}));
45
+ export var ListEventFromCalendars;
46
+ (function (ListEventFromCalendars) {
47
+ /** Dont use. */
48
+ ListEventFromCalendars["UNDEFINED"] = "UNDEFINED";
49
+ /** Listing events from the external calendar is not supported. */
50
+ ListEventFromCalendars["NOT_SUPPORTED"] = "NOT_SUPPORTED";
51
+ /** Listing events from the primary external calendar only. */
52
+ ListEventFromCalendars["PRIMARY_CALENDAR_ONLY"] = "PRIMARY_CALENDAR_ONLY";
53
+ /**
54
+ * Listing events from specific external calendars.
55
+ * The external calendars can be listed using the `ExternalCalendarService.ListCalendars` API.
56
+ */
57
+ ListEventFromCalendars["SPECIFIC_CALENDARS"] = "SPECIFIC_CALENDARS";
58
+ })(ListEventFromCalendars || (ListEventFromCalendars = {}));
59
+ export var SyncToCalendar;
60
+ (function (SyncToCalendar) {
61
+ /** Dont use. */
62
+ SyncToCalendar["UNDEFINED"] = "UNDEFINED";
63
+ /** Syncing Wix calendar sessions to the external calendar is not supported. */
64
+ SyncToCalendar["NOT_SUPPORTED"] = "NOT_SUPPORTED";
65
+ /** Syncing Wix calendar sessions to the primary external calendar only. */
66
+ SyncToCalendar["PRIMARY_CALENDAR_ONLY"] = "PRIMARY_CALENDAR_ONLY";
67
+ /** Syncing Wix calendar sessions to a specific external calendar. */
68
+ SyncToCalendar["SPECIFIC_CALENDAR"] = "SPECIFIC_CALENDAR";
69
+ /** Syncing Wix calendar sessions to a new external calendar. */
70
+ SyncToCalendar["DEDICATED_CALENDAR"] = "DEDICATED_CALENDAR";
71
+ })(SyncToCalendar || (SyncToCalendar = {}));
72
+ export var Status;
73
+ (function (Status) {
74
+ /** Dont use. */
75
+ Status["UNDEFINED"] = "UNDEFINED";
76
+ /** External calendar is connected to the corresponding schedule id. */
77
+ Status["CONNECTED"] = "CONNECTED";
78
+ /** Sync in progress. */
79
+ Status["SYNC_IN_PROGRESS"] = "SYNC_IN_PROGRESS";
80
+ /** Calendars are in-sync. */
81
+ Status["SYNCED"] = "SYNCED";
82
+ /** External calender is disconnected. */
83
+ Status["DISCONNECTED"] = "DISCONNECTED";
84
+ /** The calendars sync is in error state. */
85
+ Status["ERROR"] = "ERROR";
86
+ })(Status || (Status = {}));
87
+ export var ErrorReason;
88
+ (function (ErrorReason) {
89
+ /** Empty or error reason is unknown. */
90
+ ErrorReason["UNDEFINED"] = "UNDEFINED";
91
+ /** External calendar access token revoked. */
92
+ ErrorReason["TOKEN_REVOKED"] = "TOKEN_REVOKED";
93
+ /** External calendar creation failed. */
94
+ ErrorReason["EXTERNAL_CALENDAR_CREATION_FAILED"] = "EXTERNAL_CALENDAR_CREATION_FAILED";
95
+ /** External Calendar was deleted. */
96
+ ErrorReason["EXTERNAL_CALENDAR_DELETED"] = "EXTERNAL_CALENDAR_DELETED";
97
+ })(ErrorReason || (ErrorReason = {}));
98
+ export var SyncToErrorReason;
99
+ (function (SyncToErrorReason) {
100
+ /** No sync error. */
101
+ SyncToErrorReason["UNDEFINED"] = "UNDEFINED";
102
+ /** Could not create calendar to sync sessions to. */
103
+ SyncToErrorReason["CALENDAR_CREATION_FAILURE"] = "CALENDAR_CREATION_FAILURE";
104
+ /** Calendar was deleted while sync was in progress. */
105
+ SyncToErrorReason["CALENDAR_DELETED"] = "CALENDAR_DELETED";
106
+ })(SyncToErrorReason || (SyncToErrorReason = {}));
107
+ export var Day;
108
+ (function (Day) {
109
+ /** Undefined. */
110
+ Day["UNDEFINED"] = "UNDEFINED";
111
+ /** Monday. */
112
+ Day["MON"] = "MON";
113
+ /** Tuesday. */
114
+ Day["TUE"] = "TUE";
115
+ /** Wednesday. */
116
+ Day["WED"] = "WED";
117
+ /** Thursday. */
118
+ Day["THU"] = "THU";
119
+ /** Friday. */
120
+ Day["FRI"] = "FRI";
121
+ /** Saturday. */
122
+ Day["SAT"] = "SAT";
123
+ /** Sunday. */
124
+ Day["SUN"] = "SUN";
125
+ })(Day || (Day = {}));
126
+ export var Transparency;
127
+ (function (Transparency) {
128
+ Transparency["UNDEFINED"] = "UNDEFINED";
129
+ /** The schedule can have available slots during the session. */
130
+ Transparency["FREE"] = "FREE";
131
+ /** The schedule cannot have available slots during the session. Default value. */
132
+ Transparency["BUSY"] = "BUSY";
133
+ })(Transparency || (Transparency = {}));
134
+ export var RecurringIntervalType;
135
+ (function (RecurringIntervalType) {
136
+ /** The default value. Sessions for this interval will be of type EVENT. */
137
+ RecurringIntervalType["UNDEFINED"] = "UNDEFINED";
138
+ /** A recurring interval of events */
139
+ RecurringIntervalType["EVENT"] = "EVENT";
140
+ /** Deprecated */
141
+ RecurringIntervalType["TIME_AVAILABILITY"] = "TIME_AVAILABILITY";
142
+ /** A recurring interval for availability */
143
+ RecurringIntervalType["AVAILABILITY"] = "AVAILABILITY";
144
+ })(RecurringIntervalType || (RecurringIntervalType = {}));
145
+ export var LocationType;
146
+ (function (LocationType) {
147
+ LocationType["UNDEFINED"] = "UNDEFINED";
148
+ LocationType["OWNER_BUSINESS"] = "OWNER_BUSINESS";
149
+ LocationType["OWNER_CUSTOM"] = "OWNER_CUSTOM";
150
+ LocationType["CUSTOM"] = "CUSTOM";
151
+ })(LocationType || (LocationType = {}));
152
+ /** For future use */
153
+ export var LocationStatus;
154
+ (function (LocationStatus) {
155
+ LocationStatus["ACTIVE"] = "ACTIVE";
156
+ LocationStatus["INACTIVE"] = "INACTIVE";
157
+ })(LocationStatus || (LocationStatus = {}));
158
+ /** For future use */
159
+ export var LocationsLocationType;
160
+ (function (LocationsLocationType) {
161
+ LocationsLocationType["UNKNOWN"] = "UNKNOWN";
162
+ LocationsLocationType["BRANCH"] = "BRANCH";
163
+ LocationsLocationType["OFFICES"] = "OFFICES";
164
+ LocationsLocationType["RECEPTION"] = "RECEPTION";
165
+ LocationsLocationType["HEADQUARTERS"] = "HEADQUARTERS";
166
+ })(LocationsLocationType || (LocationsLocationType = {}));
167
+ /** Enumerates the days of the week. */
168
+ export var DayOfWeek;
169
+ (function (DayOfWeek) {
170
+ DayOfWeek["MONDAY"] = "MONDAY";
171
+ DayOfWeek["TUESDAY"] = "TUESDAY";
172
+ DayOfWeek["WEDNESDAY"] = "WEDNESDAY";
173
+ DayOfWeek["THURSDAY"] = "THURSDAY";
174
+ DayOfWeek["FRIDAY"] = "FRIDAY";
175
+ DayOfWeek["SATURDAY"] = "SATURDAY";
176
+ DayOfWeek["SUNDAY"] = "SUNDAY";
177
+ })(DayOfWeek || (DayOfWeek = {}));
178
+ export var ApprovalStatus;
179
+ (function (ApprovalStatus) {
180
+ /** Default. */
181
+ ApprovalStatus["UNDEFINED"] = "UNDEFINED";
182
+ /** Pending business approval. */
183
+ ApprovalStatus["PENDING"] = "PENDING";
184
+ /** Approved by the business. */
185
+ ApprovalStatus["APPROVED"] = "APPROVED";
186
+ /** Declined by the business. */
187
+ ApprovalStatus["DECLINED"] = "DECLINED";
188
+ })(ApprovalStatus || (ApprovalStatus = {}));
189
+ export var ScheduleStatus;
190
+ (function (ScheduleStatus) {
191
+ ScheduleStatus["UNDEFINED"] = "UNDEFINED";
192
+ /** The default value when the schedule is created. */
193
+ ScheduleStatus["CREATED"] = "CREATED";
194
+ /** The schedule has been canceled. */
195
+ ScheduleStatus["CANCELLED"] = "CANCELLED";
196
+ })(ScheduleStatus || (ScheduleStatus = {}));
197
+ export var ConferenceType;
198
+ (function (ConferenceType) {
199
+ ConferenceType["UNDEFINED"] = "UNDEFINED";
200
+ /** API-generated online meeting. */
201
+ ConferenceType["ONLINE_MEETING_PROVIDER"] = "ONLINE_MEETING_PROVIDER";
202
+ /** User-defined meeting. */
203
+ ConferenceType["CUSTOM"] = "CUSTOM";
204
+ })(ConferenceType || (ConferenceType = {}));
205
+ export var SessionStatus;
206
+ (function (SessionStatus) {
207
+ SessionStatus["UNDEFINED"] = "UNDEFINED";
208
+ /** The session is confirmed. Default status. */
209
+ SessionStatus["CONFIRMED"] = "CONFIRMED";
210
+ /**
211
+ * The session is cancelled.
212
+ * A cancelled session can be the cancellation of a recurring session that should no longer be displayed or a deleted single session.
213
+ * The ListSessions returns cancelled sessions only if 'includeDelete' flag is set to true.
214
+ */
215
+ SessionStatus["CANCELLED"] = "CANCELLED";
216
+ })(SessionStatus || (SessionStatus = {}));
217
+ export var SessionType;
218
+ (function (SessionType) {
219
+ SessionType["UNDEFINED"] = "UNDEFINED";
220
+ /**
221
+ * The session creates an event on the calendar for the owner of the schedule that the session belongs to.
222
+ * Default type.
223
+ */
224
+ SessionType["EVENT"] = "EVENT";
225
+ /** The session represents a resource's available working hours. */
226
+ SessionType["WORKING_HOURS"] = "WORKING_HOURS";
227
+ /** Deprecated. please use WORKING_HOURS */
228
+ SessionType["TIME_AVAILABILITY"] = "TIME_AVAILABILITY";
229
+ /** Deprecated. The session represents a resource's available hours. please use WORKING_HOURS */
230
+ SessionType["AVAILABILITY"] = "AVAILABILITY";
231
+ })(SessionType || (SessionType = {}));
232
+ const _connectByCredentialsRequest = {};
233
+ const _connectByCredentialsResponse = {};
234
+ const _connectByOAuthRequest = {};
235
+ const _connectByOAuthResponse = {};
236
+ const _disconnectRequest = {};
237
+ const _disconnectResponse = {};
238
+ const _getConnectionRequest = {};
239
+ const _getConnectionResponse = {};
240
+ const _listCalendarsRequest = {};
241
+ const _listCalendarsResponse = {};
242
+ const _listConnectionsRequest = {};
243
+ const _listConnectionsResponse = {};
244
+ const _listEventsRequest = {};
245
+ const _listEventsResponse = {};
246
+ const _listProvidersRequest = {};
247
+ const _listProvidersResponse = {};
248
+ const _updateSyncConfigRequest = {};
249
+ const _updateSyncConfigResponse = {};
250
+ /**
251
+ * Retrieves a list of the external calendar providers for which the site supports integration.
252
+ *
253
+ *
254
+ * The list of external calendar providers includes:
255
+ *
256
+ * + External calendar providers that are supported by default, such as Google, Apple, and Microsoft.
257
+ * + External calenders for which the site owner has enabled integration by installing an app.
258
+ *
259
+ * For each external calendar provider, the list contains information about supported connection methods and features.
260
+ * For each provider, check `features.connectMethods` to find out whether to use [Connect By Credentials](#connect-by-credentials) or [Connect By OAuth](#connect-by-o-auth) to establish a connection.
261
+ * @public
262
+ * @documentationMaturity preview
263
+ */
264
+ export function listProviders() {
265
+ var _a, _b, _c;
266
+ return __awaiter(this, arguments, void 0, function* () {
267
+ const requestTransformation = {};
268
+ const responseTransformation = '$';
269
+ // @ts-ignore
270
+ const { httpClient, sideEffects } = arguments[0];
271
+ const { toAmbassadorRequest } = serializer({
272
+ rootSchema: _listProvidersRequest,
273
+ depSchemas: {},
274
+ fqdnTransformation: {
275
+ paths: [],
276
+ transformation: _fromVeloEntity,
277
+ },
278
+ customTransformation: requestTransformation,
279
+ });
280
+ const { fromJSON } = serializer({
281
+ rootSchema: _listProvidersResponse,
282
+ depSchemas: {},
283
+ fqdnTransformation: {
284
+ paths: [],
285
+ transformation: _toVeloEntity,
286
+ },
287
+ customTransformation: responseTransformation,
288
+ });
289
+ const payload = toAmbassadorRequest([]);
290
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.listProviders(payload);
291
+ __log(`"ListProviders" sending request with: ${__inspect(reqOpts)}`);
292
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
293
+ try {
294
+ const result = yield httpClient.request(reqOpts);
295
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
296
+ return fromJSON(result.data);
297
+ }
298
+ catch (err) {
299
+ const transformedError = transformError(err, requestTransformation, []);
300
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
301
+ throw transformedError;
302
+ }
303
+ });
304
+ }
305
+ /**
306
+ * Retrieves an external calendar connection by ID.
307
+ *
308
+ *
309
+ * The external calendar connection contains details of the connection between a Wix site's calendar and calendars hosted by an external provider.
310
+ *
311
+ * The `syncConfig` property contains configuration details for importing events from an external calendar, exporting events to an external calendar, or both.
312
+ * @param connectionId - ID of the connection to retrieve.
313
+ * @public
314
+ * @documentationMaturity preview
315
+ * @requiredField connectionId
316
+ */
317
+ export function getConnection(connectionId) {
318
+ var _a, _b, _c;
319
+ return __awaiter(this, arguments, void 0, function* () {
320
+ const requestTransformation = { connectionId: '$[0]' };
321
+ const responseTransformation = '$';
322
+ // @ts-ignore
323
+ const { httpClient, sideEffects } = arguments[1];
324
+ const { toAmbassadorRequest } = serializer({
325
+ rootSchema: _getConnectionRequest,
326
+ depSchemas: {},
327
+ fqdnTransformation: {
328
+ paths: [],
329
+ transformation: _fromVeloEntity,
330
+ },
331
+ customTransformation: requestTransformation,
332
+ });
333
+ const { fromJSON } = serializer({
334
+ rootSchema: _getConnectionResponse,
335
+ depSchemas: {},
336
+ fqdnTransformation: {
337
+ paths: [],
338
+ transformation: _toVeloEntity,
339
+ },
340
+ customTransformation: responseTransformation,
341
+ });
342
+ const payload = toAmbassadorRequest([connectionId]);
343
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.getConnection(payload);
344
+ __log(`"GetConnection" sending request with: ${__inspect(reqOpts)}`);
345
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
346
+ try {
347
+ const result = yield httpClient.request(reqOpts);
348
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
349
+ return fromJSON(result.data);
350
+ }
351
+ catch (err) {
352
+ const transformedError = transformError(err, requestTransformation, [
353
+ 'connectionId',
354
+ ]);
355
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
356
+ throw transformedError;
357
+ }
358
+ });
359
+ }
360
+ /**
361
+ * Retrieves a list of external calendar connections.
362
+ *
363
+ *
364
+ * Each external calendar connections contains details of a connection between a Wix site's calendar and calendars hosted by an external provider.
365
+ *
366
+ * The `syncConfig` property of each connection contains configuration details for importing events from an external calendar, exporting events to an external calendar, or both.
367
+ * @public
368
+ * @documentationMaturity preview
369
+ */
370
+ export function listConnections(options) {
371
+ var _a, _b, _c;
372
+ return __awaiter(this, arguments, void 0, function* () {
373
+ const requestTransformation = {
374
+ scheduleIds: '$[0].scheduleIds',
375
+ partialFailure: '$[0].partialFailure',
376
+ };
377
+ const responseTransformation = '$';
378
+ // @ts-ignore
379
+ const { httpClient, sideEffects } = arguments[1];
380
+ const { toAmbassadorRequest } = serializer({
381
+ rootSchema: _listConnectionsRequest,
382
+ depSchemas: {},
383
+ fqdnTransformation: {
384
+ paths: [],
385
+ transformation: _fromVeloEntity,
386
+ },
387
+ customTransformation: requestTransformation,
388
+ });
389
+ const { fromJSON } = serializer({
390
+ rootSchema: _listConnectionsResponse,
391
+ depSchemas: {},
392
+ fqdnTransformation: {
393
+ paths: [],
394
+ transformation: _toVeloEntity,
395
+ },
396
+ customTransformation: responseTransformation,
397
+ });
398
+ const payload = toAmbassadorRequest([options]);
399
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.listConnections(payload);
400
+ __log(`"ListConnections" sending request with: ${__inspect(reqOpts)}`);
401
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
402
+ try {
403
+ const result = yield httpClient.request(reqOpts);
404
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
405
+ return fromJSON(result.data);
406
+ }
407
+ catch (err) {
408
+ const transformedError = transformError(err, requestTransformation, [
409
+ 'options',
410
+ ]);
411
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
412
+ throw transformedError;
413
+ }
414
+ });
415
+ }
416
+ /**
417
+ * Connects to an external calendar using the OAuth authorization protocol.
418
+ *
419
+ *
420
+ * The authorization flow should take place as follows:
421
+ *
422
+ * 1. Send a request to the endpoint with the appropriate parameters.
423
+ * 2. Redirect the user to the URL received in the response.
424
+ * 3. The user authorizes access.
425
+ * 4. The user is redirected to the URL you provide in the `redirectUrl` body parameter, with a query parameter `connectionId` containing the new connection ID.
426
+ *
427
+ * If the attempt to connect fails, the user is still redirected to the URL you provide in the `redirectUrl` body parameter,
428
+ * but with a query parameter `error` containing one of the following values:
429
+ *
430
+ * - `reject`: The user rejected the authorization request.
431
+ * - `unsupported`: Connecting to the user's external account type is not supported by the provider.
432
+ * - `internal`: An error unrelated to the client or the request that prevents the server from fulfilling the request.
433
+ *
434
+ * Once a connection is successfully created, use [List Events](#list-events) to obtain an up-to-date list of events in the connected external calendars.
435
+ *
436
+ * This endpoint validates that the specified schedule is owned by the Wix user connecting the calendar,
437
+ * or that the caller has the Manage External Calendars or Manage Business Calendar permission scope.
438
+ *
439
+ * If the schedule's ownership changes, the connection to the external calendar is automatically disconnected.
440
+ *
441
+ * > **Note:**
442
+ * > Use [List Providers](#list-providers) to find out whether to connect to a particular provider using this endpoint or [Connect by Credentials](#connect-by-credentials).
443
+ * @param providerId - ID of the external calendar provider. Find this with the [List Providers](#list-providers) endpoint.
444
+ * @param scheduleId - ID of the schedule to connect with the external calendar account.
445
+ * @param redirectUrl - URL to redirect the user to after they authorize access to the external calendar account.
446
+ *
447
+ * If the connection is successfully established, the user is redirected to this URL with a query parameter `connectionId` containing the new connection ID.
448
+ * If the attempt to connect fails, the user is redirected to this URL with a query parameter `error` containing the error type.
449
+ * @public
450
+ * @documentationMaturity preview
451
+ * @requiredField providerId
452
+ * @requiredField redirectUrl
453
+ * @requiredField scheduleId
454
+ */
455
+ export function connectByOAuth(providerId, scheduleId, redirectUrl) {
456
+ var _a, _b, _c;
457
+ return __awaiter(this, arguments, void 0, function* () {
458
+ const requestTransformation = {
459
+ providerId: '$[0]',
460
+ scheduleId: '$[1]',
461
+ redirectUrl: '$[2]',
462
+ };
463
+ const responseTransformation = '$';
464
+ // @ts-ignore
465
+ const { httpClient, sideEffects } = arguments[3];
466
+ const { toAmbassadorRequest } = serializer({
467
+ rootSchema: _connectByOAuthRequest,
468
+ depSchemas: {},
469
+ fqdnTransformation: {
470
+ paths: [],
471
+ transformation: _fromVeloEntity,
472
+ },
473
+ customTransformation: requestTransformation,
474
+ });
475
+ const { fromJSON } = serializer({
476
+ rootSchema: _connectByOAuthResponse,
477
+ depSchemas: {},
478
+ fqdnTransformation: {
479
+ paths: [],
480
+ transformation: _toVeloEntity,
481
+ },
482
+ customTransformation: responseTransformation,
483
+ });
484
+ const payload = toAmbassadorRequest([providerId, scheduleId, redirectUrl]);
485
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.connectByOAuth(payload);
486
+ __log(`"ConnectByOAuth" sending request with: ${__inspect(reqOpts)}`);
487
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
488
+ try {
489
+ const result = yield httpClient.request(reqOpts);
490
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
491
+ return fromJSON(result.data);
492
+ }
493
+ catch (err) {
494
+ const transformedError = transformError(err, requestTransformation, [
495
+ 'providerId',
496
+ 'scheduleId',
497
+ 'redirectUrl',
498
+ ]);
499
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
500
+ throw transformedError;
501
+ }
502
+ });
503
+ }
504
+ /**
505
+ * Connects to an external calendar by directly providing the external calendar account credentials.
506
+ *
507
+ *
508
+ * Once a connection is successfully created, use [List Events](#list-events) to obtain an up-to-date list of events in the connected external calendars.
509
+ *
510
+ * This endpoint validates that the specified schedule is owned by the Wix user connecting the calendar,
511
+ * or that the caller has the Manage External Calendars or Manage Business Calendar permission scope.
512
+ *
513
+ * If the schedule's ownership changes, the connection to the external calendar is automatically disconnected.
514
+ *
515
+ * > **Note:**
516
+ * > Use [List Providers](#list-providers) to find out whether to connect to a particular provider using this endpoint or [Connect by OAuth](#connect-by-o-auth).
517
+ * @param providerId - ID of the external calendar provider. Find this with the [List Providers](#list-providers) endpoint.
518
+ * @param scheduleId - ID of the schedule to connect with the external calendar account.
519
+ * @param email - Email address for the external calendar account.
520
+ * @param password - Password for the external calendar account.
521
+ * @public
522
+ * @documentationMaturity preview
523
+ * @requiredField email
524
+ * @requiredField password
525
+ * @requiredField providerId
526
+ * @requiredField scheduleId
527
+ */
528
+ export function connectByCredentials(providerId, scheduleId, email, password) {
529
+ var _a, _b, _c;
530
+ return __awaiter(this, arguments, void 0, function* () {
531
+ const requestTransformation = {
532
+ providerId: '$[0]',
533
+ scheduleId: '$[1]',
534
+ email: '$[2]',
535
+ password: '$[3]',
536
+ };
537
+ const responseTransformation = '$';
538
+ // @ts-ignore
539
+ const { httpClient, sideEffects } = arguments[4];
540
+ const { toAmbassadorRequest } = serializer({
541
+ rootSchema: _connectByCredentialsRequest,
542
+ depSchemas: {},
543
+ fqdnTransformation: {
544
+ paths: [],
545
+ transformation: _fromVeloEntity,
546
+ },
547
+ customTransformation: requestTransformation,
548
+ });
549
+ const { fromJSON } = serializer({
550
+ rootSchema: _connectByCredentialsResponse,
551
+ depSchemas: {},
552
+ fqdnTransformation: {
553
+ paths: [],
554
+ transformation: _toVeloEntity,
555
+ },
556
+ customTransformation: responseTransformation,
557
+ });
558
+ const payload = toAmbassadorRequest([
559
+ providerId,
560
+ scheduleId,
561
+ email,
562
+ password,
563
+ ]);
564
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.connectByCredentials(payload);
565
+ __log(`"ConnectByCredentials" sending request with: ${__inspect(reqOpts)}`);
566
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
567
+ try {
568
+ const result = yield httpClient.request(reqOpts);
569
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
570
+ return fromJSON(result.data);
571
+ }
572
+ catch (err) {
573
+ const transformedError = transformError(err, requestTransformation, [
574
+ 'providerId',
575
+ 'scheduleId',
576
+ 'email',
577
+ 'password',
578
+ ]);
579
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
580
+ throw transformedError;
581
+ }
582
+ });
583
+ }
584
+ /**
585
+ * Retrieves a list of calendars belonging to the connected external calendar account.
586
+ *
587
+ *
588
+ * > **Note:**
589
+ * > Before using this endpoint, establish a connection with an external calendar using [Connect By Credentials](#connect-by-credentials) or [Connect By OAuth](#connect-by-o-auth).
590
+ * @param connectionId - ID of the external calendar connection to list calendars for.
591
+ * @public
592
+ * @documentationMaturity preview
593
+ * @requiredField connectionId
594
+ */
595
+ export function listCalendars(connectionId) {
596
+ var _a, _b, _c;
597
+ return __awaiter(this, arguments, void 0, function* () {
598
+ const requestTransformation = { connectionId: '$[0]' };
599
+ const responseTransformation = '$';
600
+ // @ts-ignore
601
+ const { httpClient, sideEffects } = arguments[1];
602
+ const { toAmbassadorRequest } = serializer({
603
+ rootSchema: _listCalendarsRequest,
604
+ depSchemas: {},
605
+ fqdnTransformation: {
606
+ paths: [],
607
+ transformation: _fromVeloEntity,
608
+ },
609
+ customTransformation: requestTransformation,
610
+ });
611
+ const { fromJSON } = serializer({
612
+ rootSchema: _listCalendarsResponse,
613
+ depSchemas: {},
614
+ fqdnTransformation: {
615
+ paths: [],
616
+ transformation: _toVeloEntity,
617
+ },
618
+ customTransformation: responseTransformation,
619
+ });
620
+ const payload = toAmbassadorRequest([connectionId]);
621
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.listCalendars(payload);
622
+ __log(`"ListCalendars" sending request with: ${__inspect(reqOpts)}`);
623
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
624
+ try {
625
+ const result = yield httpClient.request(reqOpts);
626
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
627
+ return fromJSON(result.data);
628
+ }
629
+ catch (err) {
630
+ const transformedError = transformError(err, requestTransformation, [
631
+ 'connectionId',
632
+ ]);
633
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
634
+ throw transformedError;
635
+ }
636
+ });
637
+ }
638
+ /**
639
+ * Updates the specified external calendar connection's sync configuration.
640
+ *
641
+ *
642
+ * Use Update Sync Config to update a connection's `syncConfig` property.
643
+ * The `syncConfig` property contains settings for enabling, configuring, or disabling functionality, including:
644
+ *
645
+ * + Importing events from one or more specified calendars in the connected external calendar account. If this is enabled, use [List Events](#list-events) to retrieve a list of events from the external calendar.
646
+ * + Exporting events from the Wix site's calendar to an external calendar.
647
+ *
648
+ * To see an external calendar connection's existing sync configuration, use [Get Connection](#get-connection) or [List Connections](#list-connections) and see the `syncConfig` property.
649
+ *
650
+ * > **Note:**
651
+ * > Supported functionality depends on the provider. Use [List Providers](#list-providers) to see details about providers' supported features.
652
+ * @param connectionId - ID of the external calendar connection to update.
653
+ * @param syncConfig - Updated sync configuration details.
654
+ * @public
655
+ * @documentationMaturity preview
656
+ * @requiredField connectionId
657
+ * @requiredField syncConfig
658
+ */
659
+ export function updateSyncConfig(connectionId, syncConfig, options) {
660
+ var _a, _b, _c;
661
+ return __awaiter(this, arguments, void 0, function* () {
662
+ const requestTransformation = {
663
+ connectionId: '$[0]',
664
+ syncConfig: '$[1]',
665
+ fieldMask: '$[2].fieldMask',
666
+ };
667
+ const responseTransformation = '$';
668
+ // @ts-ignore
669
+ const { httpClient, sideEffects } = arguments[3];
670
+ const { toAmbassadorRequest } = serializer({
671
+ rootSchema: _updateSyncConfigRequest,
672
+ depSchemas: {},
673
+ fqdnTransformation: {
674
+ paths: [],
675
+ transformation: _fromVeloEntity,
676
+ },
677
+ customTransformation: requestTransformation,
678
+ });
679
+ const { fromJSON } = serializer({
680
+ rootSchema: _updateSyncConfigResponse,
681
+ depSchemas: {},
682
+ fqdnTransformation: {
683
+ paths: [],
684
+ transformation: _toVeloEntity,
685
+ },
686
+ customTransformation: responseTransformation,
687
+ });
688
+ const payload = toAmbassadorRequest([connectionId, syncConfig, options]);
689
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.updateSyncConfig(payload);
690
+ __log(`"UpdateSyncConfig" sending request with: ${__inspect(reqOpts)}`);
691
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
692
+ try {
693
+ const result = yield httpClient.request(reqOpts);
694
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
695
+ return fromJSON(result.data);
696
+ }
697
+ catch (err) {
698
+ const transformedError = transformError(err, requestTransformation, [
699
+ 'connectionId',
700
+ 'syncConfig',
701
+ 'options',
702
+ ]);
703
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
704
+ throw transformedError;
705
+ }
706
+ });
707
+ }
708
+ /**
709
+ * Disconnects from an external calendar.
710
+ *
711
+ *
712
+ * When an external calendar is disconnected, the external calendar connection's `status` is changed to `DISCONNECTED`.
713
+ *
714
+ * After disconnecting, [List Events](#list-events) no longer returns events from the disconnected external calendar.
715
+ * Exported Wix calendar sessions are deleted from the external calendar.
716
+ * @param connectionId - ID of the external calendar connection to disconnect.
717
+ * @public
718
+ * @documentationMaturity preview
719
+ * @requiredField connectionId
720
+ */
721
+ export function disconnect(connectionId) {
722
+ var _a, _b, _c;
723
+ return __awaiter(this, arguments, void 0, function* () {
724
+ const requestTransformation = { connectionId: '$[0]' };
725
+ const responseTransformation = '$';
726
+ // @ts-ignore
727
+ const { httpClient, sideEffects } = arguments[1];
728
+ const { toAmbassadorRequest } = serializer({
729
+ rootSchema: _disconnectRequest,
730
+ depSchemas: {},
731
+ fqdnTransformation: {
732
+ paths: [],
733
+ transformation: _fromVeloEntity,
734
+ },
735
+ customTransformation: requestTransformation,
736
+ });
737
+ const { fromJSON } = serializer({
738
+ rootSchema: _disconnectResponse,
739
+ depSchemas: {},
740
+ fqdnTransformation: {
741
+ paths: [],
742
+ transformation: _toVeloEntity,
743
+ },
744
+ customTransformation: responseTransformation,
745
+ });
746
+ const payload = toAmbassadorRequest([connectionId]);
747
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.disconnect(payload);
748
+ __log(`"Disconnect" sending request with: ${__inspect(reqOpts)}`);
749
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
750
+ try {
751
+ const result = yield httpClient.request(reqOpts);
752
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
753
+ return fromJSON(result.data);
754
+ }
755
+ catch (err) {
756
+ const transformedError = transformError(err, requestTransformation, [
757
+ 'connectionId',
758
+ ]);
759
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
760
+ throw transformedError;
761
+ }
762
+ });
763
+ }
764
+ /**
765
+ * Retrieves a list of events from all connected external calendars, based on the provided filtering and paging.
766
+ *
767
+ *
768
+ * Use List Events to retrieve an aggregated list of events in the connected external calendars for a specified time range, sorted by start date.
769
+ *
770
+ * > **Note:**
771
+ * > Before using this endpoint, establish a connection with an external calendar using [Connect By Credentials](#connect-by-credentials) or [Connect By OAuth](#connect-by-o-auth).
772
+ * @public
773
+ * @documentationMaturity preview
774
+ */
775
+ export function listEvents(options) {
776
+ var _a, _b, _c;
777
+ return __awaiter(this, arguments, void 0, function* () {
778
+ const requestTransformation = {
779
+ from: '$[0].from',
780
+ to: '$[0].to',
781
+ scheduleIds: '$[0].scheduleIds',
782
+ userIds: '$[0].userIds',
783
+ allDay: '$[0].allDay',
784
+ fieldsets: '$[0].fieldsets',
785
+ cursorPaging: '$[0].cursorPaging',
786
+ partialFailure: '$[0].partialFailure',
787
+ };
788
+ const responseTransformation = '$';
789
+ // @ts-ignore
790
+ const { httpClient, sideEffects } = arguments[1];
791
+ const { toAmbassadorRequest } = serializer({
792
+ rootSchema: _listEventsRequest,
793
+ depSchemas: {},
794
+ fqdnTransformation: {
795
+ paths: [],
796
+ transformation: _fromVeloEntity,
797
+ },
798
+ customTransformation: requestTransformation,
799
+ });
800
+ const { fromJSON } = serializer({
801
+ rootSchema: _listEventsResponse,
802
+ depSchemas: {},
803
+ fqdnTransformation: {
804
+ paths: [],
805
+ transformation: _toVeloEntity,
806
+ },
807
+ customTransformation: responseTransformation,
808
+ });
809
+ const payload = toAmbassadorRequest([options]);
810
+ const reqOpts = ambassadorWixBookingsCalendarV2ExternalCalendar.listEvents(payload);
811
+ __log(`"ListEvents" sending request with: ${__inspect(reqOpts)}`);
812
+ (_a = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSiteCall) === null || _a === void 0 ? void 0 : _a.call(sideEffects);
813
+ try {
814
+ const result = yield httpClient.request(reqOpts);
815
+ (_b = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onSuccess) === null || _b === void 0 ? void 0 : _b.call(sideEffects, result);
816
+ return fromJSON(result.data);
817
+ }
818
+ catch (err) {
819
+ const transformedError = transformError(err, requestTransformation, [
820
+ 'options',
821
+ ]);
822
+ (_c = sideEffects === null || sideEffects === void 0 ? void 0 : sideEffects.onError) === null || _c === void 0 ? void 0 : _c.call(sideEffects, err);
823
+ throw transformedError;
824
+ }
825
+ });
826
+ }
827
+ //# sourceMappingURL=bookings-calendar-v2-external-calendar.universal.js.map