@blazeo.com/calendar-client 1.0.42 → 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 -52
- package/dist/index.mjs +74 -52
- 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
|
};
|
|
@@ -1962,12 +1984,9 @@ CompanyModel.save = async (payload) => {
|
|
|
1962
1984
|
}
|
|
1963
1985
|
return null;
|
|
1964
1986
|
};
|
|
1965
|
-
CompanyModel.purchasePhoneNumber = async (
|
|
1987
|
+
CompanyModel.purchasePhoneNumber = async (companyId) => {
|
|
1966
1988
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1967
|
-
return reqGet("/Company/PhoneNumber/Purchase", {
|
|
1968
|
-
company_key: companyKey,
|
|
1969
|
-
company_id: companyId
|
|
1970
|
-
});
|
|
1989
|
+
return reqGet("/Company/PhoneNumber/Purchase", { company_id: companyId });
|
|
1971
1990
|
};
|
|
1972
1991
|
var Company_default = CompanyModel;
|
|
1973
1992
|
|
|
@@ -2730,7 +2749,6 @@ LeadModel.getColumnSelection = async (userId) => {
|
|
|
2730
2749
|
return reqGet("/lead/columns/get", { user_id: uid });
|
|
2731
2750
|
};
|
|
2732
2751
|
LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
2733
|
-
var _a, _b;
|
|
2734
2752
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2735
2753
|
const query = { company_key: companyKey };
|
|
2736
2754
|
const userId = opts.userId ?? opts.user_id;
|
|
@@ -2757,9 +2775,13 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
2757
2775
|
}
|
|
2758
2776
|
const res = await reqGet("/lead/company/get", query);
|
|
2759
2777
|
if (res.status === "success") {
|
|
2760
|
-
const
|
|
2761
|
-
|
|
2762
|
-
|
|
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 };
|
|
2763
2785
|
}
|
|
2764
2786
|
}
|
|
2765
2787
|
return null;
|
|
@@ -3197,6 +3219,7 @@ function createRootStore(initialState = {}) {
|
|
|
3197
3219
|
CalendarLocationModel,
|
|
3198
3220
|
CalendarModel,
|
|
3199
3221
|
CalendarParticipantModel,
|
|
3222
|
+
CalendarVisibility,
|
|
3200
3223
|
CompanyModel,
|
|
3201
3224
|
ConfigModel,
|
|
3202
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
|
};
|
|
@@ -1888,12 +1909,9 @@ CompanyModel.save = async (payload) => {
|
|
|
1888
1909
|
}
|
|
1889
1910
|
return null;
|
|
1890
1911
|
};
|
|
1891
|
-
CompanyModel.purchasePhoneNumber = async (
|
|
1912
|
+
CompanyModel.purchasePhoneNumber = async (companyId) => {
|
|
1892
1913
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1893
|
-
return reqGet("/Company/PhoneNumber/Purchase", {
|
|
1894
|
-
company_key: companyKey,
|
|
1895
|
-
company_id: companyId
|
|
1896
|
-
});
|
|
1914
|
+
return reqGet("/Company/PhoneNumber/Purchase", { company_id: companyId });
|
|
1897
1915
|
};
|
|
1898
1916
|
var Company_default = CompanyModel;
|
|
1899
1917
|
|
|
@@ -2656,7 +2674,6 @@ LeadModel.getColumnSelection = async (userId) => {
|
|
|
2656
2674
|
return reqGet("/lead/columns/get", { user_id: uid });
|
|
2657
2675
|
};
|
|
2658
2676
|
LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
2659
|
-
var _a, _b;
|
|
2660
2677
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2661
2678
|
const query = { company_key: companyKey };
|
|
2662
2679
|
const userId = opts.userId ?? opts.user_id;
|
|
@@ -2683,9 +2700,13 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
2683
2700
|
}
|
|
2684
2701
|
const res = await reqGet("/lead/company/get", query);
|
|
2685
2702
|
if (res.status === "success") {
|
|
2686
|
-
const
|
|
2687
|
-
|
|
2688
|
-
|
|
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 };
|
|
2689
2710
|
}
|
|
2690
2711
|
}
|
|
2691
2712
|
return null;
|
|
@@ -3122,6 +3143,7 @@ export {
|
|
|
3122
3143
|
CalendarLocation_default as CalendarLocationModel,
|
|
3123
3144
|
Calendar_default as CalendarModel,
|
|
3124
3145
|
CalendarParticipant_default as CalendarParticipantModel,
|
|
3146
|
+
CalendarVisibility,
|
|
3125
3147
|
Company_default as CompanyModel,
|
|
3126
3148
|
ConfigModel_default as ConfigModel,
|
|
3127
3149
|
CustomField_default as CustomFieldModel,
|