@blazeo.com/calendar-client 1.0.43 → 1.0.44
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.d.ts +13 -2
- package/dist/index.js +75 -65
- package/dist/index.mjs +74 -65
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -100,6 +100,11 @@ export type EventSearchResult = {
|
|
|
100
100
|
totalCount: number;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
export type LeadCompanyResult = {
|
|
104
|
+
leads: unknown[];
|
|
105
|
+
totalCount: number;
|
|
106
|
+
};
|
|
107
|
+
|
|
103
108
|
export const EventModel: {
|
|
104
109
|
get(eventId: string): Promise<unknown>;
|
|
105
110
|
getByExternalId(externalEventId: string): Promise<unknown>;
|
|
@@ -211,7 +216,7 @@ export const CompanyModel: {
|
|
|
211
216
|
get(companyKey: string): Promise<unknown>;
|
|
212
217
|
getAll(): Promise<unknown[] | null>;
|
|
213
218
|
save(payload: object): Promise<unknown>;
|
|
214
|
-
purchasePhoneNumber(
|
|
219
|
+
purchasePhoneNumber(companyId: string): Promise<{
|
|
215
220
|
status: string;
|
|
216
221
|
data?: PhoneNumberPurchaseResult;
|
|
217
222
|
message?: string;
|
|
@@ -371,10 +376,16 @@ export const LeadModel: {
|
|
|
371
376
|
sort_column?: string;
|
|
372
377
|
/** Same as `sortOrder` (sent as `sort_dir` on the wire). */
|
|
373
378
|
sort_dir?: 'asc' | 'desc' | string;
|
|
379
|
+
searchColumn?: string;
|
|
380
|
+
search_column?: string;
|
|
381
|
+
column?: string;
|
|
382
|
+
searchText?: string;
|
|
383
|
+
search_text?: string;
|
|
384
|
+
search?: string;
|
|
374
385
|
page?: number;
|
|
375
386
|
page_size?: number;
|
|
376
387
|
}
|
|
377
|
-
): Promise<
|
|
388
|
+
): Promise<LeadCompanyResult | null>;
|
|
378
389
|
/** Empty snapshot is valid: `LeadModel.create({}, { env })` after configure() */
|
|
379
390
|
create(snapshot?: object, options?: { env?: object }): unknown;
|
|
380
391
|
};
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(index_exports, {
|
|
|
31
31
|
CalendarLocationModel: () => CalendarLocation_default,
|
|
32
32
|
CalendarModel: () => Calendar_default,
|
|
33
33
|
CalendarParticipantModel: () => CalendarParticipant_default,
|
|
34
|
+
CalendarVisibility: () => CalendarVisibility,
|
|
34
35
|
CompanyModel: () => Company_default,
|
|
35
36
|
ConfigModel: () => ConfigModel_default,
|
|
36
37
|
CustomFieldModel: () => CustomField_default,
|
|
@@ -378,6 +379,10 @@ var LocationType = {
|
|
|
378
379
|
Phone: 2,
|
|
379
380
|
Custom: 3
|
|
380
381
|
};
|
|
382
|
+
var CalendarVisibility = {
|
|
383
|
+
Public: 0,
|
|
384
|
+
Private: 1
|
|
385
|
+
};
|
|
381
386
|
|
|
382
387
|
// src/models/appointment/Event.js
|
|
383
388
|
var import_mobx_state_tree4 = require("mobx-state-tree");
|
|
@@ -1042,6 +1047,9 @@ var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
|
1042
1047
|
bufferTime: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
1043
1048
|
bufferTimeUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
1044
1049
|
bookingLimit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
1050
|
+
isPersonal: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.boolean, false),
|
|
1051
|
+
visibility: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, CalendarVisibility.Private),
|
|
1052
|
+
ownerParticipantId: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
1045
1053
|
createdOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
1046
1054
|
modifiedOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string)
|
|
1047
1055
|
}).actions((self) => {
|
|
@@ -1052,35 +1060,28 @@ var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
|
1052
1060
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1053
1061
|
const res = await reqGet("/Calendar/Get", { calendar_id: self.calendarId });
|
|
1054
1062
|
if (res.status === "success" && res.data) {
|
|
1055
|
-
(
|
|
1063
|
+
applyCalendarResponse(self, res.data);
|
|
1056
1064
|
}
|
|
1057
1065
|
return res;
|
|
1058
1066
|
},
|
|
1059
1067
|
/** POST Calendar/Create – create or update calendar */
|
|
1060
1068
|
async create() {
|
|
1061
|
-
const payload =
|
|
1062
|
-
calendarId: self.calendarId || void 0,
|
|
1063
|
-
companyKey: self.companyKey ?? void 0,
|
|
1064
|
-
name: self.name ?? void 0,
|
|
1065
|
-
timeZoneId: self.timeZoneId ?? void 0,
|
|
1066
|
-
purpose: self.purpose,
|
|
1067
|
-
description: self.description ?? void 0,
|
|
1068
|
-
assignmentMethod: self.assignmentMethod,
|
|
1069
|
-
duration: self.duration,
|
|
1070
|
-
durationUnit: self.durationUnit,
|
|
1071
|
-
minimumBookingNotice: self.minimumBookingNotice,
|
|
1072
|
-
minimumBookingNoticeUnit: self.minimumBookingNoticeUnit,
|
|
1073
|
-
minimumCancelationNotice: self.minimumCancelationNotice,
|
|
1074
|
-
minimumCancelationNoticeUnit: self.minimumCancelationNoticeUnit,
|
|
1075
|
-
futureLimit: self.futureLimit,
|
|
1076
|
-
futureLimitUnit: self.futureLimitUnit,
|
|
1077
|
-
bufferTime: self.bufferTime,
|
|
1078
|
-
bufferTimeUnit: self.bufferTimeUnit,
|
|
1079
|
-
bookingLimit: self.bookingLimit
|
|
1080
|
-
};
|
|
1069
|
+
const payload = buildCalendarPayload(self);
|
|
1081
1070
|
const res = await reqPost("/Calendar/Create", payload);
|
|
1082
1071
|
if (res.status === "success" && res.data) {
|
|
1083
|
-
self,
|
|
1072
|
+
applyCalendarResponse(self, res.data);
|
|
1073
|
+
}
|
|
1074
|
+
return res;
|
|
1075
|
+
},
|
|
1076
|
+
/** POST Calendar/Personal/Create – create personal calendar (requires ownerParticipantId) */
|
|
1077
|
+
async createPersonal() {
|
|
1078
|
+
if (!self.ownerParticipantId) {
|
|
1079
|
+
return { status: "failure", message: "ownerParticipantId required" };
|
|
1080
|
+
}
|
|
1081
|
+
const payload = buildCalendarPayload(self);
|
|
1082
|
+
const res = await reqPost("/Calendar/Personal/Create", payload);
|
|
1083
|
+
if (res.status === "success" && res.data) {
|
|
1084
|
+
applyCalendarResponse(self, res.data);
|
|
1084
1085
|
}
|
|
1085
1086
|
return res;
|
|
1086
1087
|
},
|
|
@@ -1091,27 +1092,12 @@ var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
|
1091
1092
|
},
|
|
1092
1093
|
/** POST Calendar/Event/Update */
|
|
1093
1094
|
async update() {
|
|
1094
|
-
const payload = {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
description: self.description ?? void 0,
|
|
1101
|
-
assignmentMethod: self.assignmentMethod,
|
|
1102
|
-
duration: self.duration,
|
|
1103
|
-
durationUnit: self.durationUnit,
|
|
1104
|
-
minimumBookingNotice: self.minimumBookingNotice,
|
|
1105
|
-
minimumBookingNoticeUnit: self.minimumBookingNoticeUnit,
|
|
1106
|
-
minimumCancelationNotice: self.minimumCancelationNotice,
|
|
1107
|
-
minimumCancelationNoticeUnit: self.minimumCancelationNoticeUnit,
|
|
1108
|
-
futureLimit: self.futureLimit,
|
|
1109
|
-
futureLimitUnit: self.futureLimitUnit,
|
|
1110
|
-
bufferTime: self.bufferTime,
|
|
1111
|
-
bufferTimeUnit: self.bufferTimeUnit,
|
|
1112
|
-
bookingLimit: self.bookingLimit
|
|
1113
|
-
};
|
|
1114
|
-
return reqPost("/Calendar/Event/Update", payload);
|
|
1095
|
+
const payload = buildCalendarPayload(self, { requireCalendarId: true });
|
|
1096
|
+
const res = await reqPost("/Calendar/Event/Update", payload);
|
|
1097
|
+
if (res.status === "success" && res.data) {
|
|
1098
|
+
applyCalendarResponse(self, res.data);
|
|
1099
|
+
}
|
|
1100
|
+
return res;
|
|
1115
1101
|
},
|
|
1116
1102
|
/** GET Calendar/Participant/Add */
|
|
1117
1103
|
async addParticipant(participantId) {
|
|
@@ -1238,6 +1224,39 @@ var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
|
1238
1224
|
}
|
|
1239
1225
|
};
|
|
1240
1226
|
});
|
|
1227
|
+
function buildCalendarPayload(self, { requireCalendarId = false } = {}) {
|
|
1228
|
+
const payload = {
|
|
1229
|
+
calendarId: requireCalendarId ? self.calendarId : self.calendarId || void 0,
|
|
1230
|
+
companyKey: self.companyKey ?? void 0,
|
|
1231
|
+
name: self.name ?? void 0,
|
|
1232
|
+
timeZoneId: self.timeZoneId ?? void 0,
|
|
1233
|
+
purpose: self.purpose,
|
|
1234
|
+
description: self.description ?? void 0,
|
|
1235
|
+
assignmentMethod: self.assignmentMethod,
|
|
1236
|
+
duration: self.duration,
|
|
1237
|
+
durationUnit: self.durationUnit,
|
|
1238
|
+
minimumBookingNotice: self.minimumBookingNotice,
|
|
1239
|
+
minimumBookingNoticeUnit: self.minimumBookingNoticeUnit,
|
|
1240
|
+
minimumCancelationNotice: self.minimumCancelationNotice,
|
|
1241
|
+
minimumCancelationNoticeUnit: self.minimumCancelationNoticeUnit,
|
|
1242
|
+
futureLimit: self.futureLimit,
|
|
1243
|
+
futureLimitUnit: self.futureLimitUnit,
|
|
1244
|
+
bufferTime: self.bufferTime,
|
|
1245
|
+
bufferTimeUnit: self.bufferTimeUnit,
|
|
1246
|
+
bookingLimit: self.bookingLimit
|
|
1247
|
+
};
|
|
1248
|
+
if (self.isPersonal) payload.isPersonal = true;
|
|
1249
|
+
if (self.visibility != null) payload.visibility = self.visibility;
|
|
1250
|
+
if (self.ownerParticipantId != null && self.ownerParticipantId !== "") {
|
|
1251
|
+
payload.ownerParticipantId = self.ownerParticipantId;
|
|
1252
|
+
}
|
|
1253
|
+
return payload;
|
|
1254
|
+
}
|
|
1255
|
+
function applyCalendarResponse(self, data) {
|
|
1256
|
+
if (!data) return;
|
|
1257
|
+
const raw = (data == null ? void 0 : data.data) ?? (data == null ? void 0 : data.Data) ?? data;
|
|
1258
|
+
(0, import_mobx_state_tree8.applySnapshot)(self, mapCalendarFromApi({ ...raw, calendarId: (raw == null ? void 0 : raw.calendarId) ?? (raw == null ? void 0 : raw.CalendarId) ?? (raw == null ? void 0 : raw.calendar_id) ?? self.calendarId }));
|
|
1259
|
+
}
|
|
1241
1260
|
function mapCalendarFromApi(d) {
|
|
1242
1261
|
if (!d) return d;
|
|
1243
1262
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1262,6 +1281,9 @@ function mapCalendarFromApi(d) {
|
|
|
1262
1281
|
bufferTime: n(pick2("bufferTime", "BufferTime", "buffer_time")),
|
|
1263
1282
|
bufferTimeUnit: n(pick2("bufferTimeUnit", "BufferTimeUnit", "buffer_time_unit")),
|
|
1264
1283
|
bookingLimit: n(pick2("bookingLimit", "BookingLimit", "booking_limit")),
|
|
1284
|
+
isPersonal: pick2("isPersonal", "IsPersonal", "is_personal") ?? false,
|
|
1285
|
+
visibility: n(pick2("visibility", "Visibility")) ?? CalendarVisibility.Private,
|
|
1286
|
+
ownerParticipantId: pick2("ownerParticipantId", "OwnerParticipantId", "owner_participant_id") ?? null,
|
|
1265
1287
|
createdOn: pick2("createdOn", "CreatedOn", "created_on"),
|
|
1266
1288
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
|
|
1267
1289
|
};
|
|
@@ -1430,19 +1452,6 @@ CalendarModel.editWithParticipants = async (calendarId, name, participantIds, de
|
|
|
1430
1452
|
}
|
|
1431
1453
|
return null;
|
|
1432
1454
|
};
|
|
1433
|
-
CalendarModel.setup = async (payload) => {
|
|
1434
|
-
var _a, _b, _c;
|
|
1435
|
-
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
1436
|
-
const res = await reqPost("/Calendar/Setup", payload);
|
|
1437
|
-
if (res.status === "success") {
|
|
1438
|
-
const calendarId = ((_a = res.data) == null ? void 0 : _a.calendarId) ?? ((_b = res.data) == null ? void 0 : _b.calendar_id) ?? (payload == null ? void 0 : payload.calendarId) ?? (payload == null ? void 0 : payload.calendar_id);
|
|
1439
|
-
if (calendarId) {
|
|
1440
|
-
const calendar = await CalendarModel.get(calendarId);
|
|
1441
|
-
return { calendar, created: !!((_c = res.data) == null ? void 0 : _c.created), raw: res };
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
return { calendar: null, created: false, raw: res };
|
|
1445
|
-
};
|
|
1446
1455
|
var Calendar_default = CalendarModel;
|
|
1447
1456
|
|
|
1448
1457
|
// src/models/appointment/Availability.js
|
|
@@ -1975,12 +1984,9 @@ CompanyModel.save = async (payload) => {
|
|
|
1975
1984
|
}
|
|
1976
1985
|
return null;
|
|
1977
1986
|
};
|
|
1978
|
-
CompanyModel.purchasePhoneNumber = async (
|
|
1987
|
+
CompanyModel.purchasePhoneNumber = async (companyId) => {
|
|
1979
1988
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1980
|
-
return reqGet("/Company/PhoneNumber/Purchase", {
|
|
1981
|
-
company_key: companyKey,
|
|
1982
|
-
company_id: companyId
|
|
1983
|
-
});
|
|
1989
|
+
return reqGet("/Company/PhoneNumber/Purchase", { company_id: companyId });
|
|
1984
1990
|
};
|
|
1985
1991
|
var Company_default = CompanyModel;
|
|
1986
1992
|
|
|
@@ -2743,7 +2749,6 @@ LeadModel.getColumnSelection = async (userId) => {
|
|
|
2743
2749
|
return reqGet("/lead/columns/get", { user_id: uid });
|
|
2744
2750
|
};
|
|
2745
2751
|
LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
2746
|
-
var _a, _b;
|
|
2747
2752
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2748
2753
|
const query = { company_key: companyKey };
|
|
2749
2754
|
const userId = opts.userId ?? opts.user_id;
|
|
@@ -2770,9 +2775,13 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
2770
2775
|
}
|
|
2771
2776
|
const res = await reqGet("/lead/company/get", query);
|
|
2772
2777
|
if (res.status === "success") {
|
|
2773
|
-
const
|
|
2774
|
-
|
|
2775
|
-
|
|
2778
|
+
const payload = res.data ?? {};
|
|
2779
|
+
const leadsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.Leads) ? payload.Leads : Array.isArray(payload.leads) ? payload.leads : null;
|
|
2780
|
+
if (leadsRaw) {
|
|
2781
|
+
const leads = leadsRaw.map((l) => LeadModel.create(mapLeadFromApi(l), { env: getConfig() }));
|
|
2782
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
2783
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : leads.length;
|
|
2784
|
+
return { leads, totalCount };
|
|
2776
2785
|
}
|
|
2777
2786
|
}
|
|
2778
2787
|
return null;
|
|
@@ -3210,6 +3219,7 @@ function createRootStore(initialState = {}) {
|
|
|
3210
3219
|
CalendarLocationModel,
|
|
3211
3220
|
CalendarModel,
|
|
3212
3221
|
CalendarParticipantModel,
|
|
3222
|
+
CalendarVisibility,
|
|
3213
3223
|
CompanyModel,
|
|
3214
3224
|
ConfigModel,
|
|
3215
3225
|
CustomFieldModel,
|
package/dist/index.mjs
CHANGED
|
@@ -304,6 +304,10 @@ var LocationType = {
|
|
|
304
304
|
Phone: 2,
|
|
305
305
|
Custom: 3
|
|
306
306
|
};
|
|
307
|
+
var CalendarVisibility = {
|
|
308
|
+
Public: 0,
|
|
309
|
+
Private: 1
|
|
310
|
+
};
|
|
307
311
|
|
|
308
312
|
// src/models/appointment/Event.js
|
|
309
313
|
import { types as types4, getEnv, applySnapshot } from "mobx-state-tree";
|
|
@@ -968,6 +972,9 @@ var CalendarModel = types8.model("Calendar", {
|
|
|
968
972
|
bufferTime: types8.optional(types8.number, 0),
|
|
969
973
|
bufferTimeUnit: types8.optional(types8.number, Unit.Minutes),
|
|
970
974
|
bookingLimit: types8.optional(types8.number, 0),
|
|
975
|
+
isPersonal: types8.optional(types8.boolean, false),
|
|
976
|
+
visibility: types8.optional(types8.number, CalendarVisibility.Private),
|
|
977
|
+
ownerParticipantId: types8.maybeNull(types8.string),
|
|
971
978
|
createdOn: types8.maybeNull(types8.string),
|
|
972
979
|
modifiedOn: types8.maybeNull(types8.string)
|
|
973
980
|
}).actions((self) => {
|
|
@@ -978,35 +985,28 @@ var CalendarModel = types8.model("Calendar", {
|
|
|
978
985
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
979
986
|
const res = await reqGet("/Calendar/Get", { calendar_id: self.calendarId });
|
|
980
987
|
if (res.status === "success" && res.data) {
|
|
981
|
-
|
|
988
|
+
applyCalendarResponse(self, res.data);
|
|
982
989
|
}
|
|
983
990
|
return res;
|
|
984
991
|
},
|
|
985
992
|
/** POST Calendar/Create – create or update calendar */
|
|
986
993
|
async create() {
|
|
987
|
-
const payload =
|
|
988
|
-
calendarId: self.calendarId || void 0,
|
|
989
|
-
companyKey: self.companyKey ?? void 0,
|
|
990
|
-
name: self.name ?? void 0,
|
|
991
|
-
timeZoneId: self.timeZoneId ?? void 0,
|
|
992
|
-
purpose: self.purpose,
|
|
993
|
-
description: self.description ?? void 0,
|
|
994
|
-
assignmentMethod: self.assignmentMethod,
|
|
995
|
-
duration: self.duration,
|
|
996
|
-
durationUnit: self.durationUnit,
|
|
997
|
-
minimumBookingNotice: self.minimumBookingNotice,
|
|
998
|
-
minimumBookingNoticeUnit: self.minimumBookingNoticeUnit,
|
|
999
|
-
minimumCancelationNotice: self.minimumCancelationNotice,
|
|
1000
|
-
minimumCancelationNoticeUnit: self.minimumCancelationNoticeUnit,
|
|
1001
|
-
futureLimit: self.futureLimit,
|
|
1002
|
-
futureLimitUnit: self.futureLimitUnit,
|
|
1003
|
-
bufferTime: self.bufferTime,
|
|
1004
|
-
bufferTimeUnit: self.bufferTimeUnit,
|
|
1005
|
-
bookingLimit: self.bookingLimit
|
|
1006
|
-
};
|
|
994
|
+
const payload = buildCalendarPayload(self);
|
|
1007
995
|
const res = await reqPost("/Calendar/Create", payload);
|
|
1008
996
|
if (res.status === "success" && res.data) {
|
|
1009
|
-
self,
|
|
997
|
+
applyCalendarResponse(self, res.data);
|
|
998
|
+
}
|
|
999
|
+
return res;
|
|
1000
|
+
},
|
|
1001
|
+
/** POST Calendar/Personal/Create – create personal calendar (requires ownerParticipantId) */
|
|
1002
|
+
async createPersonal() {
|
|
1003
|
+
if (!self.ownerParticipantId) {
|
|
1004
|
+
return { status: "failure", message: "ownerParticipantId required" };
|
|
1005
|
+
}
|
|
1006
|
+
const payload = buildCalendarPayload(self);
|
|
1007
|
+
const res = await reqPost("/Calendar/Personal/Create", payload);
|
|
1008
|
+
if (res.status === "success" && res.data) {
|
|
1009
|
+
applyCalendarResponse(self, res.data);
|
|
1010
1010
|
}
|
|
1011
1011
|
return res;
|
|
1012
1012
|
},
|
|
@@ -1017,27 +1017,12 @@ var CalendarModel = types8.model("Calendar", {
|
|
|
1017
1017
|
},
|
|
1018
1018
|
/** POST Calendar/Event/Update */
|
|
1019
1019
|
async update() {
|
|
1020
|
-
const payload = {
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
description: self.description ?? void 0,
|
|
1027
|
-
assignmentMethod: self.assignmentMethod,
|
|
1028
|
-
duration: self.duration,
|
|
1029
|
-
durationUnit: self.durationUnit,
|
|
1030
|
-
minimumBookingNotice: self.minimumBookingNotice,
|
|
1031
|
-
minimumBookingNoticeUnit: self.minimumBookingNoticeUnit,
|
|
1032
|
-
minimumCancelationNotice: self.minimumCancelationNotice,
|
|
1033
|
-
minimumCancelationNoticeUnit: self.minimumCancelationNoticeUnit,
|
|
1034
|
-
futureLimit: self.futureLimit,
|
|
1035
|
-
futureLimitUnit: self.futureLimitUnit,
|
|
1036
|
-
bufferTime: self.bufferTime,
|
|
1037
|
-
bufferTimeUnit: self.bufferTimeUnit,
|
|
1038
|
-
bookingLimit: self.bookingLimit
|
|
1039
|
-
};
|
|
1040
|
-
return reqPost("/Calendar/Event/Update", payload);
|
|
1020
|
+
const payload = buildCalendarPayload(self, { requireCalendarId: true });
|
|
1021
|
+
const res = await reqPost("/Calendar/Event/Update", payload);
|
|
1022
|
+
if (res.status === "success" && res.data) {
|
|
1023
|
+
applyCalendarResponse(self, res.data);
|
|
1024
|
+
}
|
|
1025
|
+
return res;
|
|
1041
1026
|
},
|
|
1042
1027
|
/** GET Calendar/Participant/Add */
|
|
1043
1028
|
async addParticipant(participantId) {
|
|
@@ -1164,6 +1149,39 @@ var CalendarModel = types8.model("Calendar", {
|
|
|
1164
1149
|
}
|
|
1165
1150
|
};
|
|
1166
1151
|
});
|
|
1152
|
+
function buildCalendarPayload(self, { requireCalendarId = false } = {}) {
|
|
1153
|
+
const payload = {
|
|
1154
|
+
calendarId: requireCalendarId ? self.calendarId : self.calendarId || void 0,
|
|
1155
|
+
companyKey: self.companyKey ?? void 0,
|
|
1156
|
+
name: self.name ?? void 0,
|
|
1157
|
+
timeZoneId: self.timeZoneId ?? void 0,
|
|
1158
|
+
purpose: self.purpose,
|
|
1159
|
+
description: self.description ?? void 0,
|
|
1160
|
+
assignmentMethod: self.assignmentMethod,
|
|
1161
|
+
duration: self.duration,
|
|
1162
|
+
durationUnit: self.durationUnit,
|
|
1163
|
+
minimumBookingNotice: self.minimumBookingNotice,
|
|
1164
|
+
minimumBookingNoticeUnit: self.minimumBookingNoticeUnit,
|
|
1165
|
+
minimumCancelationNotice: self.minimumCancelationNotice,
|
|
1166
|
+
minimumCancelationNoticeUnit: self.minimumCancelationNoticeUnit,
|
|
1167
|
+
futureLimit: self.futureLimit,
|
|
1168
|
+
futureLimitUnit: self.futureLimitUnit,
|
|
1169
|
+
bufferTime: self.bufferTime,
|
|
1170
|
+
bufferTimeUnit: self.bufferTimeUnit,
|
|
1171
|
+
bookingLimit: self.bookingLimit
|
|
1172
|
+
};
|
|
1173
|
+
if (self.isPersonal) payload.isPersonal = true;
|
|
1174
|
+
if (self.visibility != null) payload.visibility = self.visibility;
|
|
1175
|
+
if (self.ownerParticipantId != null && self.ownerParticipantId !== "") {
|
|
1176
|
+
payload.ownerParticipantId = self.ownerParticipantId;
|
|
1177
|
+
}
|
|
1178
|
+
return payload;
|
|
1179
|
+
}
|
|
1180
|
+
function applyCalendarResponse(self, data) {
|
|
1181
|
+
if (!data) return;
|
|
1182
|
+
const raw = (data == null ? void 0 : data.data) ?? (data == null ? void 0 : data.Data) ?? data;
|
|
1183
|
+
applySnapshot2(self, mapCalendarFromApi({ ...raw, calendarId: (raw == null ? void 0 : raw.calendarId) ?? (raw == null ? void 0 : raw.CalendarId) ?? (raw == null ? void 0 : raw.calendar_id) ?? self.calendarId }));
|
|
1184
|
+
}
|
|
1167
1185
|
function mapCalendarFromApi(d) {
|
|
1168
1186
|
if (!d) return d;
|
|
1169
1187
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1188,6 +1206,9 @@ function mapCalendarFromApi(d) {
|
|
|
1188
1206
|
bufferTime: n(pick2("bufferTime", "BufferTime", "buffer_time")),
|
|
1189
1207
|
bufferTimeUnit: n(pick2("bufferTimeUnit", "BufferTimeUnit", "buffer_time_unit")),
|
|
1190
1208
|
bookingLimit: n(pick2("bookingLimit", "BookingLimit", "booking_limit")),
|
|
1209
|
+
isPersonal: pick2("isPersonal", "IsPersonal", "is_personal") ?? false,
|
|
1210
|
+
visibility: n(pick2("visibility", "Visibility")) ?? CalendarVisibility.Private,
|
|
1211
|
+
ownerParticipantId: pick2("ownerParticipantId", "OwnerParticipantId", "owner_participant_id") ?? null,
|
|
1191
1212
|
createdOn: pick2("createdOn", "CreatedOn", "created_on"),
|
|
1192
1213
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
|
|
1193
1214
|
};
|
|
@@ -1356,19 +1377,6 @@ CalendarModel.editWithParticipants = async (calendarId, name, participantIds, de
|
|
|
1356
1377
|
}
|
|
1357
1378
|
return null;
|
|
1358
1379
|
};
|
|
1359
|
-
CalendarModel.setup = async (payload) => {
|
|
1360
|
-
var _a, _b, _c;
|
|
1361
|
-
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
1362
|
-
const res = await reqPost("/Calendar/Setup", payload);
|
|
1363
|
-
if (res.status === "success") {
|
|
1364
|
-
const calendarId = ((_a = res.data) == null ? void 0 : _a.calendarId) ?? ((_b = res.data) == null ? void 0 : _b.calendar_id) ?? (payload == null ? void 0 : payload.calendarId) ?? (payload == null ? void 0 : payload.calendar_id);
|
|
1365
|
-
if (calendarId) {
|
|
1366
|
-
const calendar = await CalendarModel.get(calendarId);
|
|
1367
|
-
return { calendar, created: !!((_c = res.data) == null ? void 0 : _c.created), raw: res };
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
return { calendar: null, created: false, raw: res };
|
|
1371
|
-
};
|
|
1372
1380
|
var Calendar_default = CalendarModel;
|
|
1373
1381
|
|
|
1374
1382
|
// src/models/appointment/Availability.js
|
|
@@ -1901,12 +1909,9 @@ CompanyModel.save = async (payload) => {
|
|
|
1901
1909
|
}
|
|
1902
1910
|
return null;
|
|
1903
1911
|
};
|
|
1904
|
-
CompanyModel.purchasePhoneNumber = async (
|
|
1912
|
+
CompanyModel.purchasePhoneNumber = async (companyId) => {
|
|
1905
1913
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1906
|
-
return reqGet("/Company/PhoneNumber/Purchase", {
|
|
1907
|
-
company_key: companyKey,
|
|
1908
|
-
company_id: companyId
|
|
1909
|
-
});
|
|
1914
|
+
return reqGet("/Company/PhoneNumber/Purchase", { company_id: companyId });
|
|
1910
1915
|
};
|
|
1911
1916
|
var Company_default = CompanyModel;
|
|
1912
1917
|
|
|
@@ -2669,7 +2674,6 @@ LeadModel.getColumnSelection = async (userId) => {
|
|
|
2669
2674
|
return reqGet("/lead/columns/get", { user_id: uid });
|
|
2670
2675
|
};
|
|
2671
2676
|
LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
2672
|
-
var _a, _b;
|
|
2673
2677
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2674
2678
|
const query = { company_key: companyKey };
|
|
2675
2679
|
const userId = opts.userId ?? opts.user_id;
|
|
@@ -2696,9 +2700,13 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
2696
2700
|
}
|
|
2697
2701
|
const res = await reqGet("/lead/company/get", query);
|
|
2698
2702
|
if (res.status === "success") {
|
|
2699
|
-
const
|
|
2700
|
-
|
|
2701
|
-
|
|
2703
|
+
const payload = res.data ?? {};
|
|
2704
|
+
const leadsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.Leads) ? payload.Leads : Array.isArray(payload.leads) ? payload.leads : null;
|
|
2705
|
+
if (leadsRaw) {
|
|
2706
|
+
const leads = leadsRaw.map((l) => LeadModel.create(mapLeadFromApi(l), { env: getConfig() }));
|
|
2707
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
2708
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : leads.length;
|
|
2709
|
+
return { leads, totalCount };
|
|
2702
2710
|
}
|
|
2703
2711
|
}
|
|
2704
2712
|
return null;
|
|
@@ -3135,6 +3143,7 @@ export {
|
|
|
3135
3143
|
CalendarLocation_default as CalendarLocationModel,
|
|
3136
3144
|
Calendar_default as CalendarModel,
|
|
3137
3145
|
CalendarParticipant_default as CalendarParticipantModel,
|
|
3146
|
+
CalendarVisibility,
|
|
3138
3147
|
Company_default as CompanyModel,
|
|
3139
3148
|
ConfigModel_default as ConfigModel,
|
|
3140
3149
|
CustomField_default as CustomFieldModel,
|