@blazeo.com/calendar-client 1.0.1 → 1.0.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.
package/dist/index.mjs CHANGED
@@ -86,12 +86,12 @@ var AppointmentClient = class {
86
86
  })());
87
87
  }
88
88
  async request(path, options = {}) {
89
- const { method = "GET", headers = {}, body, query } = options;
89
+ const { method = "GET", headers = {}, body, query, skipContentType } = options;
90
90
  const url = `${this.baseUrl}${path}${buildQuery(query ?? {})}`;
91
- const reqHeaders = {
92
- "Content-Type": "application/json",
93
- ...headers
94
- };
91
+ const reqHeaders = { ...headers };
92
+ if (!skipContentType && typeof body === "string") {
93
+ reqHeaders["Content-Type"] = "application/json";
94
+ }
95
95
  const res = await this.fetchFn(url, { method, headers: reqHeaders, body });
96
96
  const text = await res.text();
97
97
  let data;
@@ -233,6 +233,41 @@ var AppointmentClient = class {
233
233
  async setEventReminder(eventId) {
234
234
  return this.request(`/event/seteventreminder/${encodeURIComponent(eventId)}`);
235
235
  }
236
+ /** POST /event/reschedule – reschedule event */
237
+ async rescheduleEvent(payload, offsetMinutes) {
238
+ const offset = offsetMinutes ?? this.getDefaultOffset();
239
+ return this.request("/event/reschedule", {
240
+ method: "POST",
241
+ headers: { offset: String(offset) },
242
+ body: JSON.stringify(payload)
243
+ });
244
+ }
245
+ /** POST /event/update – update event */
246
+ async updateEvent(payload) {
247
+ return this.request("/event/update", {
248
+ method: "POST",
249
+ body: JSON.stringify(payload)
250
+ });
251
+ }
252
+ /** POST /event/testcreate – test create (no notifications) */
253
+ async testCreateEvent(payload, offsetMinutes) {
254
+ const offset = offsetMinutes ?? this.getDefaultOffset();
255
+ return this.request("/event/testcreate", {
256
+ method: "POST",
257
+ headers: { offset: String(offset) },
258
+ body: JSON.stringify(payload)
259
+ });
260
+ }
261
+ /** POST /event/customdata/get – get custom field schema for calendar */
262
+ async getEventCustomData(calendarId, eventId) {
263
+ const query = { calendar_id: calendarId };
264
+ if (eventId) query.event_id = eventId;
265
+ return this.request("/event/customdata/get", {
266
+ method: "POST",
267
+ body: JSON.stringify({}),
268
+ query
269
+ });
270
+ }
236
271
  // ---------- Calendar ----------
237
272
  /** GET Calendar/Get – get calendar by calendar_id */
238
273
  async getCalendar(calendarId) {
@@ -258,6 +293,379 @@ var AppointmentClient = class {
258
293
  async removeCalendar(calendarId) {
259
294
  return this.request(`/Calendar/Remove`, { query: { calendar_id: calendarId } });
260
295
  }
296
+ /** POST Calendar/Event/Update – update calendar */
297
+ async updateCalendar(payload) {
298
+ return this.request("/Calendar/Event/Update", {
299
+ method: "POST",
300
+ body: JSON.stringify(payload)
301
+ });
302
+ }
303
+ /** GET Calendar/Participant/Add */
304
+ async addParticipantToCalendar(calendarId, participantId) {
305
+ return this.request("/Calendar/Participant/Add", {
306
+ query: { calendar_id: calendarId, participant_id: participantId }
307
+ });
308
+ }
309
+ /** GET Calendar/Participant/Remove */
310
+ async removeParticipantFromCalendar(calendarId, participantId) {
311
+ return this.request("/Calendar/Participant/Remove", {
312
+ query: { calendar_id: calendarId, participant_id: participantId }
313
+ });
314
+ }
315
+ /** GET Calendar/Participant/OpeningHours/Get */
316
+ async getParticipantOpeningHours(params) {
317
+ const query = {};
318
+ if (params.calendarParticipantId) query.calendarparticipant_id = params.calendarParticipantId;
319
+ if (params.participantId) query.participant_id = params.participantId;
320
+ if (params.calendarId) query.calendar_id = params.calendarId;
321
+ return this.request("/Calendar/Participant/OpeningHours/Get", { query });
322
+ }
323
+ /** POST Calendar/Participant/Availability/OpeningHour/Save */
324
+ async saveOpeningHour(payload) {
325
+ return this.request("/Calendar/Participant/Availability/OpeningHour/Save", {
326
+ method: "POST",
327
+ body: JSON.stringify(payload)
328
+ });
329
+ }
330
+ /** POST Calendar/Participant/Availability/OpeningHours/Save */
331
+ async saveOpeningHours(payload) {
332
+ return this.request("/Calendar/Participant/Availability/OpeningHours/Save", {
333
+ method: "POST",
334
+ body: JSON.stringify(payload)
335
+ });
336
+ }
337
+ /** GET Calendar/Participant/OpeningHour/Remove */
338
+ async removeParticipantOpeningHours(calendarId, participantId) {
339
+ return this.request("/Calendar/Participant/OpeningHour/Remove", {
340
+ query: { calendar_id: calendarId, participant_id: participantId }
341
+ });
342
+ }
343
+ /** GET Calendar/Participant/Availability/Add – backend expects body (AvailabilityDetail). Note: GET with body is non-standard; fetch may reject. Consider backend POST if needed. */
344
+ async addParticipantAvailability(calendarId, participantId, detail) {
345
+ return this.request("/Calendar/Participant/Availability/Add", {
346
+ method: "GET",
347
+ query: { calendar_id: calendarId, participant_id: participantId },
348
+ body: JSON.stringify(detail)
349
+ });
350
+ }
351
+ /** GET Calendar/Participant/All */
352
+ async getCalendarParticipants(calendarId) {
353
+ return this.request("/Calendar/Participant/All", {
354
+ query: { calendar_id: calendarId }
355
+ });
356
+ }
357
+ /** GET Calendar/CreateWithParticipants */
358
+ async createCalendarWithParticipants(params) {
359
+ const query = {
360
+ name: params.name,
361
+ company_key: params.companyKey,
362
+ participantids: params.participantIds.join(",")
363
+ };
364
+ if (params.description) query.description = params.description;
365
+ if (params.calendarId) query.calendar_id = params.calendarId;
366
+ return this.request("/Calendar/CreateWithParticipants", { query });
367
+ }
368
+ /** GET Calendar/EditWithParticipants */
369
+ async editCalendarWithParticipants(params) {
370
+ const query = {
371
+ calendar_id: params.calendarId,
372
+ name: params.name,
373
+ participantids: params.participantIds.join(",")
374
+ };
375
+ if (params.description) query.description = params.description;
376
+ return this.request("/Calendar/EditWithParticipants", { query });
377
+ }
378
+ /** GET Calendar/Month/Get */
379
+ async getCalendarMonth(calendarId, year, month) {
380
+ return this.request("/Calendar/Month/Get", {
381
+ query: { calendar_id: calendarId, year, month }
382
+ });
383
+ }
384
+ /** GET Calendar/Events/Get */
385
+ async getCalendarEvents(calendarId) {
386
+ return this.request("/Calendar/Events/Get", {
387
+ query: { calendar_id: calendarId }
388
+ });
389
+ }
390
+ // ---------- Participant ----------
391
+ /** GET participant/get */
392
+ async getParticipant(participantId) {
393
+ return this.request("/participant/get", { query: { participant_id: participantId } });
394
+ }
395
+ /** GET participant/participants/get */
396
+ async getParticipantsByIds(participantIds) {
397
+ return this.request("/participant/participants/get", {
398
+ query: { participantids: participantIds.join(",") }
399
+ });
400
+ }
401
+ /** GET Participant/All */
402
+ async getAllParticipants(companyKey) {
403
+ return this.request("/Participant/All", { query: { company_key: companyKey } });
404
+ }
405
+ /** GET participant/sendemail */
406
+ async sendParticipantEmail(participantId) {
407
+ return this.request("/participant/sendemail", { query: { participant_id: participantId } });
408
+ }
409
+ /** POST Participant/Add */
410
+ async addParticipant(payload, calendarId) {
411
+ const query = calendarId ? { calendar_id: calendarId } : void 0;
412
+ return this.request("/Participant/Add", {
413
+ method: "POST",
414
+ body: JSON.stringify(payload),
415
+ query
416
+ });
417
+ }
418
+ /** GET participant/remove */
419
+ async removeParticipant(participantId) {
420
+ return this.request("/participant/remove", { query: { participant_id: participantId } });
421
+ }
422
+ /** POST participant/update */
423
+ async updateParticipant(payload) {
424
+ return this.request("/participant/update", {
425
+ method: "POST",
426
+ body: JSON.stringify(payload)
427
+ });
428
+ }
429
+ /** POST participant/save */
430
+ async saveParticipant(payload) {
431
+ return this.request("/participant/save", {
432
+ method: "POST",
433
+ body: JSON.stringify(payload)
434
+ });
435
+ }
436
+ // ---------- CalendarParticipant ----------
437
+ /** GET Calendar/Participant/Get */
438
+ async getCalendarParticipant(calendarId) {
439
+ return this.request("/Calendar/Participant/Get", {
440
+ query: { calendar_id: calendarId }
441
+ });
442
+ }
443
+ /** GET Calendar/Participants/GetInfo */
444
+ async getCalendarParticipantsInfo(calendarId) {
445
+ return this.request("/Calendar/Participants/GetInfo", {
446
+ query: { calendar_id: calendarId }
447
+ });
448
+ }
449
+ /** GET Participant/calendar/get */
450
+ async getParticipantCalendars(participantId) {
451
+ return this.request("/Participant/calendar/get", {
452
+ query: { participant_id: participantId }
453
+ });
454
+ }
455
+ // ---------- CustomField ----------
456
+ /** GET CustomField/GetAll */
457
+ async getCustomFields(calendarId) {
458
+ return this.request("/CustomField/GetAll", { query: { calendar_id: calendarId } });
459
+ }
460
+ /** GET CustomField/FieldType/Get */
461
+ async getCustomFieldType(fieldType) {
462
+ return this.request("/CustomField/FieldType/Get", { query: { FieldType: fieldType } });
463
+ }
464
+ /** POST CustomField/Add */
465
+ async addCustomField(payload) {
466
+ return this.request("/CustomField/Add", {
467
+ method: "POST",
468
+ body: JSON.stringify(payload)
469
+ });
470
+ }
471
+ /** GET CustomField/FieldTypes/Get */
472
+ async getCustomFieldTypes() {
473
+ return this.request("/CustomField/FieldTypes/Get");
474
+ }
475
+ /** GET CustomField/RemoveField */
476
+ async removeCustomField(customFieldId) {
477
+ return this.request("/CustomField/RemoveField", { query: { customfield_id: customFieldId } });
478
+ }
479
+ /** GET CustomField/RemoveAllFields */
480
+ async removeAllCustomFields(calendarId) {
481
+ return this.request("/CustomField/RemoveAllFields", { query: { calendar_id: calendarId } });
482
+ }
483
+ /** GET CustomField/Form/Get */
484
+ async getCustomForm(calendarId, dataId) {
485
+ const query = { calendar_id: calendarId };
486
+ if (dataId) query.data_id = dataId;
487
+ return this.request("/CustomField/Form/Get", { query });
488
+ }
489
+ /** GET CustomField/Form/Data/Get */
490
+ async getCustomFormData(calendarId, dataId) {
491
+ const query = { calendar_id: calendarId };
492
+ if (dataId) query.data_id = dataId;
493
+ return this.request("/CustomField/Form/Data/Get", { query });
494
+ }
495
+ /** POST CustomField/Form/Save */
496
+ async saveCustomForm(calendarId, fields) {
497
+ return this.request("/CustomField/Form/Save", {
498
+ method: "POST",
499
+ body: JSON.stringify(fields),
500
+ query: { calendar_id: calendarId }
501
+ });
502
+ }
503
+ /** POST CustomField/Form/Data/Save */
504
+ async saveCustomFormData(dataId, fields) {
505
+ return this.request("/CustomField/Form/Data/Save", {
506
+ method: "POST",
507
+ body: JSON.stringify(fields),
508
+ query: { data_id: dataId }
509
+ });
510
+ }
511
+ /** POST CustomField/Form/Field/Data/Save */
512
+ async saveCustomFormFieldData(field) {
513
+ return this.request("/CustomField/Form/Field/Data/Save", {
514
+ method: "POST",
515
+ body: JSON.stringify(field)
516
+ });
517
+ }
518
+ // ---------- Setting ----------
519
+ /** GET setting/get */
520
+ async getSetting(calendarId) {
521
+ return this.request("/setting/get", { query: { calendar_id: calendarId } });
522
+ }
523
+ /** POST setting/save */
524
+ async saveSetting(payload) {
525
+ return this.request("/setting/save", {
526
+ method: "POST",
527
+ body: JSON.stringify(payload)
528
+ });
529
+ }
530
+ /** POST setting/logo/upload */
531
+ async uploadSettingLogo(calendarId, file) {
532
+ const form = new FormData();
533
+ form.append("file", file);
534
+ return this.request("/setting/logo/upload", {
535
+ method: "POST",
536
+ body: form,
537
+ query: { calendar_id: calendarId },
538
+ skipContentType: true
539
+ });
540
+ }
541
+ // ---------- Consumer ----------
542
+ /** POST Consumer/Register/EventListener */
543
+ async registerEventListener(payload) {
544
+ return this.request("/Consumer/Register/EventListener", {
545
+ method: "POST",
546
+ body: JSON.stringify(payload)
547
+ });
548
+ }
549
+ /** PUT Consumer/Update/EventListener */
550
+ async updateEventListener(payload) {
551
+ return this.request("/Consumer/Update/EventListener", {
552
+ method: "PUT",
553
+ body: JSON.stringify(payload)
554
+ });
555
+ }
556
+ /** POST Consumer/Register */
557
+ async registerConsumer(payload) {
558
+ return this.request("/Consumer/Register", {
559
+ method: "POST",
560
+ body: JSON.stringify(payload)
561
+ });
562
+ }
563
+ /** GET Consumer/Events/List */
564
+ async listEventListeners() {
565
+ return this.request("/Consumer/Events/List");
566
+ }
567
+ /** GET Consumer/List */
568
+ async listConsumers() {
569
+ return this.request("/Consumer/List");
570
+ }
571
+ // ---------- Preference ----------
572
+ /** POST /preference/{scope}/{key}/{option} */
573
+ async setPreference(scope, key, option, body) {
574
+ return this.request(`/preference/${encodeURIComponent(scope)}/${encodeURIComponent(key)}/${encodeURIComponent(option)}`, {
575
+ method: "POST",
576
+ body
577
+ });
578
+ }
579
+ /** GET /preference/scopes */
580
+ async getPreferenceScopes() {
581
+ return this.request("/preference/scopes");
582
+ }
583
+ /** GET /preference/options */
584
+ async getPreferenceOptions() {
585
+ return this.request("/preference/options");
586
+ }
587
+ /** GET /preference/options/{option} */
588
+ async getPreferenceOption(option) {
589
+ return this.request(`/preference/options/${encodeURIComponent(option)}`);
590
+ }
591
+ /** GET /preference/{option} */
592
+ async getPreference(option, keys) {
593
+ return this.request(`/preference/${encodeURIComponent(option)}`, {
594
+ query: { keys: keys.join(",") }
595
+ });
596
+ }
597
+ // ---------- Notification ----------
598
+ /** POST /notification/sms/outbound */
599
+ async sendSmsOutbound(payload) {
600
+ return this.request("/notification/sms/outbound", {
601
+ method: "POST",
602
+ body: JSON.stringify(payload)
603
+ });
604
+ }
605
+ /** GET /notification/sms/queue */
606
+ async getSmsQueue(id) {
607
+ return this.request("/notification/sms/queue", { query: { id } });
608
+ }
609
+ /** POST /notification/sms/inbound */
610
+ async smsInbound(formData) {
611
+ return this.request("/notification/sms/inbound", {
612
+ method: "POST",
613
+ body: formData,
614
+ skipContentType: true
615
+ });
616
+ }
617
+ /** POST /notification/sms/status */
618
+ async smsStatus(payload) {
619
+ return this.request("/notification/sms/status", {
620
+ method: "POST",
621
+ body: JSON.stringify(payload)
622
+ });
623
+ }
624
+ /** GET /notification/sms/outbox/send */
625
+ async sendSmsOutbox() {
626
+ return this.request("/notification/sms/outbox/send");
627
+ }
628
+ // ---------- Auth ----------
629
+ /** GET /CallBack – OAuth callback (typically used as redirect URL) */
630
+ getCallbackUrl() {
631
+ return `${this.baseUrl}/CallBack`;
632
+ }
633
+ /** POST Auth/AddParticipantCredentials */
634
+ async addParticipantCredentials(payload) {
635
+ return this.request("/Auth/AddParticipantCredentials", {
636
+ method: "POST",
637
+ body: JSON.stringify(payload)
638
+ });
639
+ }
640
+ /** GET Auth/ParticipantCredentials */
641
+ async getParticipantCredentials(participantId) {
642
+ return this.request("/Auth/ParticipantCredentials", { query: { participant_id: participantId } });
643
+ }
644
+ // ---------- Ping ----------
645
+ /** GET /ping */
646
+ async ping() {
647
+ return this.request("/ping");
648
+ }
649
+ /** GET /setup */
650
+ async setup(name) {
651
+ return this.request("/setup", { query: name ? { name } : void 0 });
652
+ }
653
+ /** GET /reset */
654
+ async reset() {
655
+ return this.request("/reset");
656
+ }
657
+ /** POST /ping */
658
+ async pingPost() {
659
+ return this.request("/ping", { method: "POST" });
660
+ }
661
+ // ---------- Schedule ----------
662
+ /** POST /schedule/calendar/ */
663
+ async scheduleCalendar(calendar) {
664
+ return this.request("/schedule/calendar/", {
665
+ method: "POST",
666
+ query: calendar ? { calendar } : void 0
667
+ });
668
+ }
261
669
  };
262
670
 
263
671
  // src/models/appointment/Calendar.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",