@blazeo.com/calendar-client 1.0.7 → 1.0.9
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 +146 -146
- package/dist/index.js +48 -2
- package/dist/index.mjs +48 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
/** @blazeo.com/calendar-client - type declarations */
|
|
2
|
-
|
|
3
|
-
export function configure(env: { baseUrl?: string; consumer?: string; fetch?: typeof fetch; getDefaultOffset?: () => number }): void;
|
|
4
|
-
export function getConfig(): { baseUrl?: string; consumer?: string; fetch?: typeof fetch; getDefaultOffset?: () => number } | null;
|
|
5
|
-
export function setBaseUrl(baseUrl: string): void;
|
|
6
|
-
export function setConsumer(consumer: string): void;
|
|
7
|
-
export function getConfigStore(): unknown;
|
|
8
|
-
|
|
9
|
-
export const ConfigModel: unknown;
|
|
10
|
-
|
|
11
|
-
export const CalendarModel: {
|
|
12
|
-
get(calendarId: string): Promise<unknown>;
|
|
13
|
-
getRaw(calendarId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
14
|
-
getByCompany(companyKey: string): Promise<unknown[]>;
|
|
15
|
-
getTimeZones(): Promise<unknown>;
|
|
16
|
-
getTimeZone(timezoneId: string): Promise<unknown>;
|
|
17
|
-
getParticipants(calendarId: string): Promise<unknown>;
|
|
18
|
-
getCalendarParticipant(calendarId: string): Promise<unknown>;
|
|
19
|
-
getParticipantsInfo(calendarId: string): Promise<unknown>;
|
|
20
|
-
getMonth(calendarId: string, year: number, month: number): Promise<unknown>;
|
|
21
|
-
getEvents(calendarId: string): Promise<unknown>;
|
|
22
|
-
createWithParticipants(name: string, companyKey: string, participantIds: string[], description: string, calendarId?: string): Promise<unknown>;
|
|
23
|
-
editWithParticipants(calendarId: string, name: string, participantIds: string[], description: string): Promise<unknown>;
|
|
24
|
-
create(snapshot: object, options?: { env?: object }): unknown;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const EventModel: {
|
|
28
|
-
get(eventId: string): Promise<unknown>;
|
|
29
|
-
getByExternalId(externalEventId: string): Promise<unknown>;
|
|
30
|
-
getRoundRobinParticipant(calendarId: string): Promise<unknown>;
|
|
31
|
-
getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
|
|
32
|
-
getDaySelectable(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<boolean>;
|
|
33
|
-
getByVisitorEmail(email: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
|
|
34
|
-
getByVisitorPhone(phone: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
|
|
35
|
-
getAvailability(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<unknown[]>;
|
|
36
|
-
cancel(eventId: string): Promise<unknown>;
|
|
37
|
-
getCancellable(eventId: string): Promise<boolean>;
|
|
38
|
-
createEvent(payload: object, offsetMinutes?: number): Promise<unknown>;
|
|
39
|
-
reschedule(payload: object, offsetMinutes?: number): Promise<unknown>;
|
|
40
|
-
updateEvent(payload: object): Promise<unknown>;
|
|
41
|
-
createTest(payload: object, offsetMinutes?: number): Promise<unknown>;
|
|
42
|
-
getCustomData(calendarId: string, eventId?: string): Promise<unknown>;
|
|
43
|
-
setReminder(eventId: string): Promise<unknown>;
|
|
44
|
-
setAttendeeStatus(eventId: string, attendeeStatus: number | string): Promise<unknown>;
|
|
45
|
-
create(snapshot: object, options?: { env?: object }): unknown;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const AvailabilityModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
49
|
-
export const AvailabilityDetailModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
50
|
-
export const CalendarParticipantModel: {
|
|
51
|
-
getByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
52
|
-
getInfoByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
53
|
-
getByParticipant(participantId: string): Promise<unknown[] | null>;
|
|
54
|
-
create(snapshot: object, options?: { env?: object }): unknown;
|
|
55
|
-
};
|
|
56
|
-
export const ParticipantModel: {
|
|
57
|
-
get(participantId: string): Promise<unknown>;
|
|
58
|
-
getByIds(participantIds: string[] | string): Promise<unknown[] | null>;
|
|
59
|
-
getAll(companyKey: string): Promise<unknown[] | null>;
|
|
60
|
-
add(payload: object, calendarId?: string): Promise<unknown>;
|
|
61
|
-
remove(participantId: string): Promise<unknown>;
|
|
62
|
-
update(payload: object): Promise<unknown>;
|
|
63
|
-
save(payload: object): Promise<unknown>;
|
|
64
|
-
sendEmail(participantId: string): Promise<unknown>;
|
|
65
|
-
create(snapshot: object, options?: { env?: object }): unknown;
|
|
66
|
-
};
|
|
67
|
-
export const OpeningHourModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
68
|
-
export const TimeSlotModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
69
|
-
export const TimeFrameModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
70
|
-
export const SettingModel: {
|
|
71
|
-
get(calendarId: string): Promise<unknown>;
|
|
72
|
-
save(payload: object): Promise<unknown>;
|
|
73
|
-
uploadLogo(calendarId: string, file: File | Blob): Promise<unknown>;
|
|
74
|
-
create(snapshot: object, options?: { env?: object }): unknown;
|
|
75
|
-
};
|
|
76
|
-
export const CompanyModel: {
|
|
77
|
-
get(companyKey: string): Promise<unknown>;
|
|
78
|
-
getAll(): Promise<unknown[] | null>;
|
|
79
|
-
save(payload: object): Promise<unknown>;
|
|
80
|
-
create(snapshot: object, options?: { env?: object }): unknown;
|
|
81
|
-
};
|
|
82
|
-
export const CalendarDayModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
83
|
-
export const ParticipantInfoModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
84
|
-
export const PreferenceModel: {
|
|
85
|
-
getScopes(): Promise<string[] | null>;
|
|
86
|
-
getOptions(): Promise<string[] | null>;
|
|
87
|
-
getOptionTemplate(option: string): Promise<unknown>;
|
|
88
|
-
get(option: string, keys: string | string[]): Promise<unknown>;
|
|
89
|
-
set(scope: string, key: string, option: string, body: string | object): Promise<unknown>;
|
|
90
|
-
delete(preferenceId: string): Promise<unknown>;
|
|
91
|
-
create(snapshot: object, options?: { env?: object }): unknown;
|
|
92
|
-
};
|
|
93
|
-
export const PreferenceScope: Record<string, number>;
|
|
94
|
-
|
|
95
|
-
export const FlowModel: {
|
|
96
|
-
getRaw(flowId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
97
|
-
list(companyKey: string, includeDeleted?: boolean): Promise<unknown[] | null>;
|
|
98
|
-
get(flowId: string): Promise<unknown>;
|
|
99
|
-
createFlow(payload: object): Promise<unknown>;
|
|
100
|
-
updateFlow(payload: object): Promise<unknown>;
|
|
101
|
-
delete(flowId: string): Promise<unknown>;
|
|
102
|
-
duplicate(flowId: string, newName?: string): Promise<unknown>;
|
|
103
|
-
getAppearance(flowId: string): Promise<unknown>;
|
|
104
|
-
saveAppearance(payload: object): Promise<unknown>;
|
|
105
|
-
getEmbed(flowId: string): Promise<unknown>;
|
|
106
|
-
saveEmbed(payload: object): Promise<unknown>;
|
|
107
|
-
getPublic(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
|
|
108
|
-
getPreview(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
|
|
109
|
-
/** Empty snapshot is valid: `FlowModel.create({}, { env })` after configure() */
|
|
110
|
-
create(snapshot?: object, options?: { env?: object }): unknown;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export const LeadModel: {
|
|
114
|
-
getRaw(leadId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
115
|
-
get(leadId: string): Promise<unknown>;
|
|
116
|
-
getByEmail(email: string, companyKey: string): Promise<unknown>;
|
|
117
|
-
getByCompany(
|
|
118
|
-
companyKey: string,
|
|
119
|
-
opts?: {
|
|
120
|
-
skip?: number;
|
|
121
|
-
take?: number;
|
|
122
|
-
/** Maps to API query `sort`. */
|
|
123
|
-
sortBy?: string;
|
|
124
|
-
/** Maps to API query `sort_dir` (`asc` / `desc`). */
|
|
125
|
-
sortOrder?: 'ASC' | 'DESC' | 'asc' | 'desc' | string;
|
|
126
|
-
/** Same as `sortBy` (sent as `sort` on the wire). */
|
|
127
|
-
sort?: string;
|
|
128
|
-
sort_column?: string;
|
|
129
|
-
/** Same as `sortOrder` (sent as `sort_dir` on the wire). */
|
|
130
|
-
sort_dir?: 'asc' | 'desc' | string;
|
|
131
|
-
page?: number;
|
|
132
|
-
page_size?: number;
|
|
133
|
-
}
|
|
134
|
-
): Promise<unknown[] | null>;
|
|
135
|
-
/** Empty snapshot is valid: `LeadModel.create({}, { env })` after configure() */
|
|
136
|
-
create(snapshot?: object, options?: { env?: object }): unknown;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export const RootStore: unknown;
|
|
140
|
-
export function createRootStore(initialState?: object): unknown;
|
|
141
|
-
|
|
142
|
-
export const Unit: Record<string, number>;
|
|
143
|
-
export const AssignmentMethod: Record<string, number>;
|
|
144
|
-
export const AttendeeStatus: Record<string, number>;
|
|
145
|
-
export const RecurringFrequency: Record<string, number>;
|
|
146
|
-
export const DayOfWeek: Record<string, number>;
|
|
1
|
+
/** @blazeo.com/calendar-client - type declarations */
|
|
2
|
+
|
|
3
|
+
export function configure(env: { baseUrl?: string; consumer?: string; fetch?: typeof fetch; getDefaultOffset?: () => number }): void;
|
|
4
|
+
export function getConfig(): { baseUrl?: string; consumer?: string; fetch?: typeof fetch; getDefaultOffset?: () => number } | null;
|
|
5
|
+
export function setBaseUrl(baseUrl: string): void;
|
|
6
|
+
export function setConsumer(consumer: string): void;
|
|
7
|
+
export function getConfigStore(): unknown;
|
|
8
|
+
|
|
9
|
+
export const ConfigModel: unknown;
|
|
10
|
+
|
|
11
|
+
export const CalendarModel: {
|
|
12
|
+
get(calendarId: string): Promise<unknown>;
|
|
13
|
+
getRaw(calendarId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
14
|
+
getByCompany(companyKey: string): Promise<unknown[]>;
|
|
15
|
+
getTimeZones(): Promise<unknown>;
|
|
16
|
+
getTimeZone(timezoneId: string): Promise<unknown>;
|
|
17
|
+
getParticipants(calendarId: string): Promise<unknown>;
|
|
18
|
+
getCalendarParticipant(calendarId: string): Promise<unknown>;
|
|
19
|
+
getParticipantsInfo(calendarId: string): Promise<unknown>;
|
|
20
|
+
getMonth(calendarId: string, year: number, month: number): Promise<unknown>;
|
|
21
|
+
getEvents(calendarId: string): Promise<unknown>;
|
|
22
|
+
createWithParticipants(name: string, companyKey: string, participantIds: string[], description: string, calendarId?: string): Promise<unknown>;
|
|
23
|
+
editWithParticipants(calendarId: string, name: string, participantIds: string[], description: string): Promise<unknown>;
|
|
24
|
+
create(snapshot: object, options?: { env?: object }): unknown;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const EventModel: {
|
|
28
|
+
get(eventId: string): Promise<unknown>;
|
|
29
|
+
getByExternalId(externalEventId: string): Promise<unknown>;
|
|
30
|
+
getRoundRobinParticipant(calendarId: string): Promise<unknown>;
|
|
31
|
+
getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
|
|
32
|
+
getDaySelectable(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<boolean>;
|
|
33
|
+
getByVisitorEmail(email: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
|
|
34
|
+
getByVisitorPhone(phone: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
|
|
35
|
+
getAvailability(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<unknown[]>;
|
|
36
|
+
cancel(eventId: string): Promise<unknown>;
|
|
37
|
+
getCancellable(eventId: string): Promise<boolean>;
|
|
38
|
+
createEvent(payload: object, offsetMinutes?: number): Promise<unknown>;
|
|
39
|
+
reschedule(payload: object, offsetMinutes?: number): Promise<unknown>;
|
|
40
|
+
updateEvent(payload: object): Promise<unknown>;
|
|
41
|
+
createTest(payload: object, offsetMinutes?: number): Promise<unknown>;
|
|
42
|
+
getCustomData(calendarId: string, eventId?: string): Promise<unknown>;
|
|
43
|
+
setReminder(eventId: string): Promise<unknown>;
|
|
44
|
+
setAttendeeStatus(eventId: string, attendeeStatus: number | string): Promise<unknown>;
|
|
45
|
+
create(snapshot: object, options?: { env?: object }): unknown;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const AvailabilityModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
49
|
+
export const AvailabilityDetailModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
50
|
+
export const CalendarParticipantModel: {
|
|
51
|
+
getByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
52
|
+
getInfoByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
53
|
+
getByParticipant(participantId: string): Promise<unknown[] | null>;
|
|
54
|
+
create(snapshot: object, options?: { env?: object }): unknown;
|
|
55
|
+
};
|
|
56
|
+
export const ParticipantModel: {
|
|
57
|
+
get(participantId: string): Promise<unknown>;
|
|
58
|
+
getByIds(participantIds: string[] | string): Promise<unknown[] | null>;
|
|
59
|
+
getAll(companyKey: string): Promise<unknown[] | null>;
|
|
60
|
+
add(payload: object, calendarId?: string): Promise<unknown>;
|
|
61
|
+
remove(participantId: string): Promise<unknown>;
|
|
62
|
+
update(payload: object): Promise<unknown>;
|
|
63
|
+
save(payload: object): Promise<unknown>;
|
|
64
|
+
sendEmail(participantId: string): Promise<unknown>;
|
|
65
|
+
create(snapshot: object, options?: { env?: object }): unknown;
|
|
66
|
+
};
|
|
67
|
+
export const OpeningHourModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
68
|
+
export const TimeSlotModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
69
|
+
export const TimeFrameModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
70
|
+
export const SettingModel: {
|
|
71
|
+
get(calendarId: string): Promise<unknown>;
|
|
72
|
+
save(payload: object): Promise<unknown>;
|
|
73
|
+
uploadLogo(calendarId: string, file: File | Blob): Promise<unknown>;
|
|
74
|
+
create(snapshot: object, options?: { env?: object }): unknown;
|
|
75
|
+
};
|
|
76
|
+
export const CompanyModel: {
|
|
77
|
+
get(companyKey: string): Promise<unknown>;
|
|
78
|
+
getAll(): Promise<unknown[] | null>;
|
|
79
|
+
save(payload: object): Promise<unknown>;
|
|
80
|
+
create(snapshot: object, options?: { env?: object }): unknown;
|
|
81
|
+
};
|
|
82
|
+
export const CalendarDayModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
83
|
+
export const ParticipantInfoModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
84
|
+
export const PreferenceModel: {
|
|
85
|
+
getScopes(): Promise<string[] | null>;
|
|
86
|
+
getOptions(): Promise<string[] | null>;
|
|
87
|
+
getOptionTemplate(option: string): Promise<unknown>;
|
|
88
|
+
get(option: string, keys: string | string[]): Promise<unknown>;
|
|
89
|
+
set(scope: string, key: string, option: string, body: string | object): Promise<unknown>;
|
|
90
|
+
delete(preferenceId: string): Promise<unknown>;
|
|
91
|
+
create(snapshot: object, options?: { env?: object }): unknown;
|
|
92
|
+
};
|
|
93
|
+
export const PreferenceScope: Record<string, number>;
|
|
94
|
+
|
|
95
|
+
export const FlowModel: {
|
|
96
|
+
getRaw(flowId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
97
|
+
list(companyKey: string, includeDeleted?: boolean): Promise<unknown[] | null>;
|
|
98
|
+
get(flowId: string): Promise<unknown>;
|
|
99
|
+
createFlow(payload: object): Promise<unknown>;
|
|
100
|
+
updateFlow(payload: object): Promise<unknown>;
|
|
101
|
+
delete(flowId: string): Promise<unknown>;
|
|
102
|
+
duplicate(flowId: string, newName?: string): Promise<unknown>;
|
|
103
|
+
getAppearance(flowId: string): Promise<unknown>;
|
|
104
|
+
saveAppearance(payload: object): Promise<unknown>;
|
|
105
|
+
getEmbed(flowId: string): Promise<unknown>;
|
|
106
|
+
saveEmbed(payload: object): Promise<unknown>;
|
|
107
|
+
getPublic(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
|
|
108
|
+
getPreview(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
|
|
109
|
+
/** Empty snapshot is valid: `FlowModel.create({}, { env })` after configure() */
|
|
110
|
+
create(snapshot?: object, options?: { env?: object }): unknown;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const LeadModel: {
|
|
114
|
+
getRaw(leadId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
115
|
+
get(leadId: string): Promise<unknown>;
|
|
116
|
+
getByEmail(email: string, companyKey: string): Promise<unknown>;
|
|
117
|
+
getByCompany(
|
|
118
|
+
companyKey: string,
|
|
119
|
+
opts?: {
|
|
120
|
+
skip?: number;
|
|
121
|
+
take?: number;
|
|
122
|
+
/** Maps to API query `sort`. */
|
|
123
|
+
sortBy?: string;
|
|
124
|
+
/** Maps to API query `sort_dir` (`asc` / `desc`). */
|
|
125
|
+
sortOrder?: 'ASC' | 'DESC' | 'asc' | 'desc' | string;
|
|
126
|
+
/** Same as `sortBy` (sent as `sort` on the wire). */
|
|
127
|
+
sort?: string;
|
|
128
|
+
sort_column?: string;
|
|
129
|
+
/** Same as `sortOrder` (sent as `sort_dir` on the wire). */
|
|
130
|
+
sort_dir?: 'asc' | 'desc' | string;
|
|
131
|
+
page?: number;
|
|
132
|
+
page_size?: number;
|
|
133
|
+
}
|
|
134
|
+
): Promise<unknown[] | null>;
|
|
135
|
+
/** Empty snapshot is valid: `LeadModel.create({}, { env })` after configure() */
|
|
136
|
+
create(snapshot?: object, options?: { env?: object }): unknown;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const RootStore: unknown;
|
|
140
|
+
export function createRootStore(initialState?: object): unknown;
|
|
141
|
+
|
|
142
|
+
export const Unit: Record<string, number>;
|
|
143
|
+
export const AssignmentMethod: Record<string, number>;
|
|
144
|
+
export const AttendeeStatus: Record<string, number>;
|
|
145
|
+
export const RecurringFrequency: Record<string, number>;
|
|
146
|
+
export const DayOfWeek: Record<string, number>;
|
package/dist/index.js
CHANGED
|
@@ -497,6 +497,48 @@ EventModel.getByVisitorPhone = async (phone, opts = {}) => {
|
|
|
497
497
|
}
|
|
498
498
|
return null;
|
|
499
499
|
};
|
|
500
|
+
EventModel.getByDateRangeWithFilters = async (startDateFrom, startDateTo, opts = {}) => {
|
|
501
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
502
|
+
const query = {
|
|
503
|
+
start_date_from: startDateFrom,
|
|
504
|
+
start_date_to: startDateTo
|
|
505
|
+
};
|
|
506
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
507
|
+
if (opts.companyKey != null && opts.companyKey !== "") query.company_key = opts.companyKey;
|
|
508
|
+
if (opts.calendarId != null && opts.calendarId !== "") query.calendar_id = opts.calendarId;
|
|
509
|
+
if (opts.participantId != null && opts.participantId !== "") query.participant_id = opts.participantId;
|
|
510
|
+
if (opts.visitorName != null && opts.visitorName !== "") query.visitor_name = opts.visitorName;
|
|
511
|
+
if (opts.visitorEmail != null && opts.visitorEmail !== "") query.visitor_email = opts.visitorEmail;
|
|
512
|
+
if (opts.visitorPhone != null && opts.visitorPhone !== "") query.visitor_phone = opts.visitorPhone;
|
|
513
|
+
if (opts.title != null && opts.title !== "") query.title = opts.title;
|
|
514
|
+
if (opts.search != null && opts.search !== "") query.search = opts.search;
|
|
515
|
+
if (opts.attendeeStatus != null && opts.attendeeStatus !== "") query.attendee_status = opts.attendeeStatus;
|
|
516
|
+
if (opts.eventSource != null && opts.eventSource !== "") query.event_source = opts.eventSource;
|
|
517
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
518
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
519
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
520
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
521
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
522
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
523
|
+
}
|
|
524
|
+
if (opts.page != null) {
|
|
525
|
+
query.page = opts.page;
|
|
526
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
527
|
+
} else {
|
|
528
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
529
|
+
if (opts.take != null) query.take = opts.take;
|
|
530
|
+
}
|
|
531
|
+
const res = await reqGet("/event/search/daterange/get", query, { headers: { offset: String(offset) } });
|
|
532
|
+
if (res.status !== "success") {
|
|
533
|
+
return { events: [], totalCount: 0 };
|
|
534
|
+
}
|
|
535
|
+
const payload = res.data ?? {};
|
|
536
|
+
const eventsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.Events) ? payload.Events : Array.isArray(payload.events) ? payload.events : [];
|
|
537
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
538
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : eventsRaw.length;
|
|
539
|
+
const events = eventsRaw.map((e) => EventModel.create(mapEventFromApi(e), { env: getConfig() }));
|
|
540
|
+
return { events, totalCount };
|
|
541
|
+
};
|
|
500
542
|
EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
|
|
501
543
|
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
502
544
|
const query = { calendar_id: calendarId, year, month, day };
|
|
@@ -1822,6 +1864,7 @@ LeadModel.getByEmail = async (email, companyKey) => {
|
|
|
1822
1864
|
return null;
|
|
1823
1865
|
};
|
|
1824
1866
|
LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
1867
|
+
var _a, _b;
|
|
1825
1868
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1826
1869
|
const query = { company_key: companyKey };
|
|
1827
1870
|
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
@@ -1839,8 +1882,11 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
1839
1882
|
if (opts.take != null) query.take = opts.take;
|
|
1840
1883
|
}
|
|
1841
1884
|
const res = await reqGet("/lead/company/get", query);
|
|
1842
|
-
if (res.status === "success"
|
|
1843
|
-
|
|
1885
|
+
if (res.status === "success") {
|
|
1886
|
+
const leads = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.Leads) ? res.data.Leads : Array.isArray((_b = res.data) == null ? void 0 : _b.leads) ? res.data.leads : null;
|
|
1887
|
+
if (leads) {
|
|
1888
|
+
return leads.map((l) => LeadModel.create(mapLeadFromApi(l), { env: getConfig() }));
|
|
1889
|
+
}
|
|
1844
1890
|
}
|
|
1845
1891
|
return null;
|
|
1846
1892
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -444,6 +444,48 @@ EventModel.getByVisitorPhone = async (phone, opts = {}) => {
|
|
|
444
444
|
}
|
|
445
445
|
return null;
|
|
446
446
|
};
|
|
447
|
+
EventModel.getByDateRangeWithFilters = async (startDateFrom, startDateTo, opts = {}) => {
|
|
448
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
449
|
+
const query = {
|
|
450
|
+
start_date_from: startDateFrom,
|
|
451
|
+
start_date_to: startDateTo
|
|
452
|
+
};
|
|
453
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
454
|
+
if (opts.companyKey != null && opts.companyKey !== "") query.company_key = opts.companyKey;
|
|
455
|
+
if (opts.calendarId != null && opts.calendarId !== "") query.calendar_id = opts.calendarId;
|
|
456
|
+
if (opts.participantId != null && opts.participantId !== "") query.participant_id = opts.participantId;
|
|
457
|
+
if (opts.visitorName != null && opts.visitorName !== "") query.visitor_name = opts.visitorName;
|
|
458
|
+
if (opts.visitorEmail != null && opts.visitorEmail !== "") query.visitor_email = opts.visitorEmail;
|
|
459
|
+
if (opts.visitorPhone != null && opts.visitorPhone !== "") query.visitor_phone = opts.visitorPhone;
|
|
460
|
+
if (opts.title != null && opts.title !== "") query.title = opts.title;
|
|
461
|
+
if (opts.search != null && opts.search !== "") query.search = opts.search;
|
|
462
|
+
if (opts.attendeeStatus != null && opts.attendeeStatus !== "") query.attendee_status = opts.attendeeStatus;
|
|
463
|
+
if (opts.eventSource != null && opts.eventSource !== "") query.event_source = opts.eventSource;
|
|
464
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
465
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
466
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
467
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
468
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
469
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
470
|
+
}
|
|
471
|
+
if (opts.page != null) {
|
|
472
|
+
query.page = opts.page;
|
|
473
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
474
|
+
} else {
|
|
475
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
476
|
+
if (opts.take != null) query.take = opts.take;
|
|
477
|
+
}
|
|
478
|
+
const res = await reqGet("/event/search/daterange/get", query, { headers: { offset: String(offset) } });
|
|
479
|
+
if (res.status !== "success") {
|
|
480
|
+
return { events: [], totalCount: 0 };
|
|
481
|
+
}
|
|
482
|
+
const payload = res.data ?? {};
|
|
483
|
+
const eventsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.Events) ? payload.Events : Array.isArray(payload.events) ? payload.events : [];
|
|
484
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
485
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : eventsRaw.length;
|
|
486
|
+
const events = eventsRaw.map((e) => EventModel.create(mapEventFromApi(e), { env: getConfig() }));
|
|
487
|
+
return { events, totalCount };
|
|
488
|
+
};
|
|
447
489
|
EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
|
|
448
490
|
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
449
491
|
const query = { calendar_id: calendarId, year, month, day };
|
|
@@ -1769,6 +1811,7 @@ LeadModel.getByEmail = async (email, companyKey) => {
|
|
|
1769
1811
|
return null;
|
|
1770
1812
|
};
|
|
1771
1813
|
LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
1814
|
+
var _a, _b;
|
|
1772
1815
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1773
1816
|
const query = { company_key: companyKey };
|
|
1774
1817
|
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
@@ -1786,8 +1829,11 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
1786
1829
|
if (opts.take != null) query.take = opts.take;
|
|
1787
1830
|
}
|
|
1788
1831
|
const res = await reqGet("/lead/company/get", query);
|
|
1789
|
-
if (res.status === "success"
|
|
1790
|
-
|
|
1832
|
+
if (res.status === "success") {
|
|
1833
|
+
const leads = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.Leads) ? res.data.Leads : Array.isArray((_b = res.data) == null ? void 0 : _b.leads) ? res.data.leads : null;
|
|
1834
|
+
if (leads) {
|
|
1835
|
+
return leads.map((l) => LeadModel.create(mapLeadFromApi(l), { env: getConfig() }));
|
|
1836
|
+
}
|
|
1791
1837
|
}
|
|
1792
1838
|
return null;
|
|
1793
1839
|
};
|