@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.js CHANGED
@@ -129,12 +129,12 @@ var AppointmentClient = class {
129
129
  })());
130
130
  }
131
131
  async request(path, options = {}) {
132
- const { method = "GET", headers = {}, body, query } = options;
132
+ const { method = "GET", headers = {}, body, query, skipContentType } = options;
133
133
  const url = `${this.baseUrl}${path}${buildQuery(query ?? {})}`;
134
- const reqHeaders = {
135
- "Content-Type": "application/json",
136
- ...headers
137
- };
134
+ const reqHeaders = { ...headers };
135
+ if (!skipContentType && typeof body === "string") {
136
+ reqHeaders["Content-Type"] = "application/json";
137
+ }
138
138
  const res = await this.fetchFn(url, { method, headers: reqHeaders, body });
139
139
  const text = await res.text();
140
140
  let data;
@@ -276,6 +276,41 @@ var AppointmentClient = class {
276
276
  async setEventReminder(eventId) {
277
277
  return this.request(`/event/seteventreminder/${encodeURIComponent(eventId)}`);
278
278
  }
279
+ /** POST /event/reschedule – reschedule event */
280
+ async rescheduleEvent(payload, offsetMinutes) {
281
+ const offset = offsetMinutes ?? this.getDefaultOffset();
282
+ return this.request("/event/reschedule", {
283
+ method: "POST",
284
+ headers: { offset: String(offset) },
285
+ body: JSON.stringify(payload)
286
+ });
287
+ }
288
+ /** POST /event/update – update event */
289
+ async updateEvent(payload) {
290
+ return this.request("/event/update", {
291
+ method: "POST",
292
+ body: JSON.stringify(payload)
293
+ });
294
+ }
295
+ /** POST /event/testcreate – test create (no notifications) */
296
+ async testCreateEvent(payload, offsetMinutes) {
297
+ const offset = offsetMinutes ?? this.getDefaultOffset();
298
+ return this.request("/event/testcreate", {
299
+ method: "POST",
300
+ headers: { offset: String(offset) },
301
+ body: JSON.stringify(payload)
302
+ });
303
+ }
304
+ /** POST /event/customdata/get – get custom field schema for calendar */
305
+ async getEventCustomData(calendarId, eventId) {
306
+ const query = { calendar_id: calendarId };
307
+ if (eventId) query.event_id = eventId;
308
+ return this.request("/event/customdata/get", {
309
+ method: "POST",
310
+ body: JSON.stringify({}),
311
+ query
312
+ });
313
+ }
279
314
  // ---------- Calendar ----------
280
315
  /** GET Calendar/Get – get calendar by calendar_id */
281
316
  async getCalendar(calendarId) {
@@ -301,6 +336,379 @@ var AppointmentClient = class {
301
336
  async removeCalendar(calendarId) {
302
337
  return this.request(`/Calendar/Remove`, { query: { calendar_id: calendarId } });
303
338
  }
339
+ /** POST Calendar/Event/Update – update calendar */
340
+ async updateCalendar(payload) {
341
+ return this.request("/Calendar/Event/Update", {
342
+ method: "POST",
343
+ body: JSON.stringify(payload)
344
+ });
345
+ }
346
+ /** GET Calendar/Participant/Add */
347
+ async addParticipantToCalendar(calendarId, participantId) {
348
+ return this.request("/Calendar/Participant/Add", {
349
+ query: { calendar_id: calendarId, participant_id: participantId }
350
+ });
351
+ }
352
+ /** GET Calendar/Participant/Remove */
353
+ async removeParticipantFromCalendar(calendarId, participantId) {
354
+ return this.request("/Calendar/Participant/Remove", {
355
+ query: { calendar_id: calendarId, participant_id: participantId }
356
+ });
357
+ }
358
+ /** GET Calendar/Participant/OpeningHours/Get */
359
+ async getParticipantOpeningHours(params) {
360
+ const query = {};
361
+ if (params.calendarParticipantId) query.calendarparticipant_id = params.calendarParticipantId;
362
+ if (params.participantId) query.participant_id = params.participantId;
363
+ if (params.calendarId) query.calendar_id = params.calendarId;
364
+ return this.request("/Calendar/Participant/OpeningHours/Get", { query });
365
+ }
366
+ /** POST Calendar/Participant/Availability/OpeningHour/Save */
367
+ async saveOpeningHour(payload) {
368
+ return this.request("/Calendar/Participant/Availability/OpeningHour/Save", {
369
+ method: "POST",
370
+ body: JSON.stringify(payload)
371
+ });
372
+ }
373
+ /** POST Calendar/Participant/Availability/OpeningHours/Save */
374
+ async saveOpeningHours(payload) {
375
+ return this.request("/Calendar/Participant/Availability/OpeningHours/Save", {
376
+ method: "POST",
377
+ body: JSON.stringify(payload)
378
+ });
379
+ }
380
+ /** GET Calendar/Participant/OpeningHour/Remove */
381
+ async removeParticipantOpeningHours(calendarId, participantId) {
382
+ return this.request("/Calendar/Participant/OpeningHour/Remove", {
383
+ query: { calendar_id: calendarId, participant_id: participantId }
384
+ });
385
+ }
386
+ /** GET Calendar/Participant/Availability/Add – backend expects body (AvailabilityDetail). Note: GET with body is non-standard; fetch may reject. Consider backend POST if needed. */
387
+ async addParticipantAvailability(calendarId, participantId, detail) {
388
+ return this.request("/Calendar/Participant/Availability/Add", {
389
+ method: "GET",
390
+ query: { calendar_id: calendarId, participant_id: participantId },
391
+ body: JSON.stringify(detail)
392
+ });
393
+ }
394
+ /** GET Calendar/Participant/All */
395
+ async getCalendarParticipants(calendarId) {
396
+ return this.request("/Calendar/Participant/All", {
397
+ query: { calendar_id: calendarId }
398
+ });
399
+ }
400
+ /** GET Calendar/CreateWithParticipants */
401
+ async createCalendarWithParticipants(params) {
402
+ const query = {
403
+ name: params.name,
404
+ company_key: params.companyKey,
405
+ participantids: params.participantIds.join(",")
406
+ };
407
+ if (params.description) query.description = params.description;
408
+ if (params.calendarId) query.calendar_id = params.calendarId;
409
+ return this.request("/Calendar/CreateWithParticipants", { query });
410
+ }
411
+ /** GET Calendar/EditWithParticipants */
412
+ async editCalendarWithParticipants(params) {
413
+ const query = {
414
+ calendar_id: params.calendarId,
415
+ name: params.name,
416
+ participantids: params.participantIds.join(",")
417
+ };
418
+ if (params.description) query.description = params.description;
419
+ return this.request("/Calendar/EditWithParticipants", { query });
420
+ }
421
+ /** GET Calendar/Month/Get */
422
+ async getCalendarMonth(calendarId, year, month) {
423
+ return this.request("/Calendar/Month/Get", {
424
+ query: { calendar_id: calendarId, year, month }
425
+ });
426
+ }
427
+ /** GET Calendar/Events/Get */
428
+ async getCalendarEvents(calendarId) {
429
+ return this.request("/Calendar/Events/Get", {
430
+ query: { calendar_id: calendarId }
431
+ });
432
+ }
433
+ // ---------- Participant ----------
434
+ /** GET participant/get */
435
+ async getParticipant(participantId) {
436
+ return this.request("/participant/get", { query: { participant_id: participantId } });
437
+ }
438
+ /** GET participant/participants/get */
439
+ async getParticipantsByIds(participantIds) {
440
+ return this.request("/participant/participants/get", {
441
+ query: { participantids: participantIds.join(",") }
442
+ });
443
+ }
444
+ /** GET Participant/All */
445
+ async getAllParticipants(companyKey) {
446
+ return this.request("/Participant/All", { query: { company_key: companyKey } });
447
+ }
448
+ /** GET participant/sendemail */
449
+ async sendParticipantEmail(participantId) {
450
+ return this.request("/participant/sendemail", { query: { participant_id: participantId } });
451
+ }
452
+ /** POST Participant/Add */
453
+ async addParticipant(payload, calendarId) {
454
+ const query = calendarId ? { calendar_id: calendarId } : void 0;
455
+ return this.request("/Participant/Add", {
456
+ method: "POST",
457
+ body: JSON.stringify(payload),
458
+ query
459
+ });
460
+ }
461
+ /** GET participant/remove */
462
+ async removeParticipant(participantId) {
463
+ return this.request("/participant/remove", { query: { participant_id: participantId } });
464
+ }
465
+ /** POST participant/update */
466
+ async updateParticipant(payload) {
467
+ return this.request("/participant/update", {
468
+ method: "POST",
469
+ body: JSON.stringify(payload)
470
+ });
471
+ }
472
+ /** POST participant/save */
473
+ async saveParticipant(payload) {
474
+ return this.request("/participant/save", {
475
+ method: "POST",
476
+ body: JSON.stringify(payload)
477
+ });
478
+ }
479
+ // ---------- CalendarParticipant ----------
480
+ /** GET Calendar/Participant/Get */
481
+ async getCalendarParticipant(calendarId) {
482
+ return this.request("/Calendar/Participant/Get", {
483
+ query: { calendar_id: calendarId }
484
+ });
485
+ }
486
+ /** GET Calendar/Participants/GetInfo */
487
+ async getCalendarParticipantsInfo(calendarId) {
488
+ return this.request("/Calendar/Participants/GetInfo", {
489
+ query: { calendar_id: calendarId }
490
+ });
491
+ }
492
+ /** GET Participant/calendar/get */
493
+ async getParticipantCalendars(participantId) {
494
+ return this.request("/Participant/calendar/get", {
495
+ query: { participant_id: participantId }
496
+ });
497
+ }
498
+ // ---------- CustomField ----------
499
+ /** GET CustomField/GetAll */
500
+ async getCustomFields(calendarId) {
501
+ return this.request("/CustomField/GetAll", { query: { calendar_id: calendarId } });
502
+ }
503
+ /** GET CustomField/FieldType/Get */
504
+ async getCustomFieldType(fieldType) {
505
+ return this.request("/CustomField/FieldType/Get", { query: { FieldType: fieldType } });
506
+ }
507
+ /** POST CustomField/Add */
508
+ async addCustomField(payload) {
509
+ return this.request("/CustomField/Add", {
510
+ method: "POST",
511
+ body: JSON.stringify(payload)
512
+ });
513
+ }
514
+ /** GET CustomField/FieldTypes/Get */
515
+ async getCustomFieldTypes() {
516
+ return this.request("/CustomField/FieldTypes/Get");
517
+ }
518
+ /** GET CustomField/RemoveField */
519
+ async removeCustomField(customFieldId) {
520
+ return this.request("/CustomField/RemoveField", { query: { customfield_id: customFieldId } });
521
+ }
522
+ /** GET CustomField/RemoveAllFields */
523
+ async removeAllCustomFields(calendarId) {
524
+ return this.request("/CustomField/RemoveAllFields", { query: { calendar_id: calendarId } });
525
+ }
526
+ /** GET CustomField/Form/Get */
527
+ async getCustomForm(calendarId, dataId) {
528
+ const query = { calendar_id: calendarId };
529
+ if (dataId) query.data_id = dataId;
530
+ return this.request("/CustomField/Form/Get", { query });
531
+ }
532
+ /** GET CustomField/Form/Data/Get */
533
+ async getCustomFormData(calendarId, dataId) {
534
+ const query = { calendar_id: calendarId };
535
+ if (dataId) query.data_id = dataId;
536
+ return this.request("/CustomField/Form/Data/Get", { query });
537
+ }
538
+ /** POST CustomField/Form/Save */
539
+ async saveCustomForm(calendarId, fields) {
540
+ return this.request("/CustomField/Form/Save", {
541
+ method: "POST",
542
+ body: JSON.stringify(fields),
543
+ query: { calendar_id: calendarId }
544
+ });
545
+ }
546
+ /** POST CustomField/Form/Data/Save */
547
+ async saveCustomFormData(dataId, fields) {
548
+ return this.request("/CustomField/Form/Data/Save", {
549
+ method: "POST",
550
+ body: JSON.stringify(fields),
551
+ query: { data_id: dataId }
552
+ });
553
+ }
554
+ /** POST CustomField/Form/Field/Data/Save */
555
+ async saveCustomFormFieldData(field) {
556
+ return this.request("/CustomField/Form/Field/Data/Save", {
557
+ method: "POST",
558
+ body: JSON.stringify(field)
559
+ });
560
+ }
561
+ // ---------- Setting ----------
562
+ /** GET setting/get */
563
+ async getSetting(calendarId) {
564
+ return this.request("/setting/get", { query: { calendar_id: calendarId } });
565
+ }
566
+ /** POST setting/save */
567
+ async saveSetting(payload) {
568
+ return this.request("/setting/save", {
569
+ method: "POST",
570
+ body: JSON.stringify(payload)
571
+ });
572
+ }
573
+ /** POST setting/logo/upload */
574
+ async uploadSettingLogo(calendarId, file) {
575
+ const form = new FormData();
576
+ form.append("file", file);
577
+ return this.request("/setting/logo/upload", {
578
+ method: "POST",
579
+ body: form,
580
+ query: { calendar_id: calendarId },
581
+ skipContentType: true
582
+ });
583
+ }
584
+ // ---------- Consumer ----------
585
+ /** POST Consumer/Register/EventListener */
586
+ async registerEventListener(payload) {
587
+ return this.request("/Consumer/Register/EventListener", {
588
+ method: "POST",
589
+ body: JSON.stringify(payload)
590
+ });
591
+ }
592
+ /** PUT Consumer/Update/EventListener */
593
+ async updateEventListener(payload) {
594
+ return this.request("/Consumer/Update/EventListener", {
595
+ method: "PUT",
596
+ body: JSON.stringify(payload)
597
+ });
598
+ }
599
+ /** POST Consumer/Register */
600
+ async registerConsumer(payload) {
601
+ return this.request("/Consumer/Register", {
602
+ method: "POST",
603
+ body: JSON.stringify(payload)
604
+ });
605
+ }
606
+ /** GET Consumer/Events/List */
607
+ async listEventListeners() {
608
+ return this.request("/Consumer/Events/List");
609
+ }
610
+ /** GET Consumer/List */
611
+ async listConsumers() {
612
+ return this.request("/Consumer/List");
613
+ }
614
+ // ---------- Preference ----------
615
+ /** POST /preference/{scope}/{key}/{option} */
616
+ async setPreference(scope, key, option, body) {
617
+ return this.request(`/preference/${encodeURIComponent(scope)}/${encodeURIComponent(key)}/${encodeURIComponent(option)}`, {
618
+ method: "POST",
619
+ body
620
+ });
621
+ }
622
+ /** GET /preference/scopes */
623
+ async getPreferenceScopes() {
624
+ return this.request("/preference/scopes");
625
+ }
626
+ /** GET /preference/options */
627
+ async getPreferenceOptions() {
628
+ return this.request("/preference/options");
629
+ }
630
+ /** GET /preference/options/{option} */
631
+ async getPreferenceOption(option) {
632
+ return this.request(`/preference/options/${encodeURIComponent(option)}`);
633
+ }
634
+ /** GET /preference/{option} */
635
+ async getPreference(option, keys) {
636
+ return this.request(`/preference/${encodeURIComponent(option)}`, {
637
+ query: { keys: keys.join(",") }
638
+ });
639
+ }
640
+ // ---------- Notification ----------
641
+ /** POST /notification/sms/outbound */
642
+ async sendSmsOutbound(payload) {
643
+ return this.request("/notification/sms/outbound", {
644
+ method: "POST",
645
+ body: JSON.stringify(payload)
646
+ });
647
+ }
648
+ /** GET /notification/sms/queue */
649
+ async getSmsQueue(id) {
650
+ return this.request("/notification/sms/queue", { query: { id } });
651
+ }
652
+ /** POST /notification/sms/inbound */
653
+ async smsInbound(formData) {
654
+ return this.request("/notification/sms/inbound", {
655
+ method: "POST",
656
+ body: formData,
657
+ skipContentType: true
658
+ });
659
+ }
660
+ /** POST /notification/sms/status */
661
+ async smsStatus(payload) {
662
+ return this.request("/notification/sms/status", {
663
+ method: "POST",
664
+ body: JSON.stringify(payload)
665
+ });
666
+ }
667
+ /** GET /notification/sms/outbox/send */
668
+ async sendSmsOutbox() {
669
+ return this.request("/notification/sms/outbox/send");
670
+ }
671
+ // ---------- Auth ----------
672
+ /** GET /CallBack – OAuth callback (typically used as redirect URL) */
673
+ getCallbackUrl() {
674
+ return `${this.baseUrl}/CallBack`;
675
+ }
676
+ /** POST Auth/AddParticipantCredentials */
677
+ async addParticipantCredentials(payload) {
678
+ return this.request("/Auth/AddParticipantCredentials", {
679
+ method: "POST",
680
+ body: JSON.stringify(payload)
681
+ });
682
+ }
683
+ /** GET Auth/ParticipantCredentials */
684
+ async getParticipantCredentials(participantId) {
685
+ return this.request("/Auth/ParticipantCredentials", { query: { participant_id: participantId } });
686
+ }
687
+ // ---------- Ping ----------
688
+ /** GET /ping */
689
+ async ping() {
690
+ return this.request("/ping");
691
+ }
692
+ /** GET /setup */
693
+ async setup(name) {
694
+ return this.request("/setup", { query: name ? { name } : void 0 });
695
+ }
696
+ /** GET /reset */
697
+ async reset() {
698
+ return this.request("/reset");
699
+ }
700
+ /** POST /ping */
701
+ async pingPost() {
702
+ return this.request("/ping", { method: "POST" });
703
+ }
704
+ // ---------- Schedule ----------
705
+ /** POST /schedule/calendar/ */
706
+ async scheduleCalendar(calendar) {
707
+ return this.request("/schedule/calendar/", {
708
+ method: "POST",
709
+ query: calendar ? { calendar } : void 0
710
+ });
711
+ }
304
712
  };
305
713
 
306
714
  // src/models/appointment/Calendar.ts