@withaevum/sdk 0.0.1

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.
@@ -0,0 +1,437 @@
1
+ /**
2
+ * Helper function to normalize day names
3
+ * Converts various formats (monday, MO, Monday) to standard weekday names
4
+ */
5
+ function normalizeDayName(day) {
6
+ const normalized = day.toLowerCase().trim();
7
+ const dayMap = {
8
+ 'sunday': 'sunday',
9
+ 'sun': 'sunday',
10
+ 'su': 'sunday',
11
+ 'monday': 'monday',
12
+ 'mon': 'monday',
13
+ 'mo': 'monday',
14
+ 'tuesday': 'tuesday',
15
+ 'tue': 'tuesday',
16
+ 'tu': 'tuesday',
17
+ 'wednesday': 'wednesday',
18
+ 'wed': 'wednesday',
19
+ 'we': 'wednesday',
20
+ 'thursday': 'thursday',
21
+ 'thu': 'thursday',
22
+ 'th': 'thursday',
23
+ 'friday': 'friday',
24
+ 'fri': 'friday',
25
+ 'fr': 'friday',
26
+ 'saturday': 'saturday',
27
+ 'sat': 'saturday',
28
+ 'sa': 'saturday',
29
+ };
30
+ return dayMap[normalized] || normalized;
31
+ }
32
+ /**
33
+ * Helper function to convert day name to repeat_on format (MO, TU, WE, etc.)
34
+ */
35
+ function dayToRepeatOn(day) {
36
+ const normalized = normalizeDayName(day);
37
+ const repeatOnMap = {
38
+ 'sunday': 'SU',
39
+ 'monday': 'MO',
40
+ 'tuesday': 'TU',
41
+ 'wednesday': 'WE',
42
+ 'thursday': 'TH',
43
+ 'friday': 'FR',
44
+ 'saturday': 'SA',
45
+ };
46
+ return repeatOnMap[normalized] || normalized.toUpperCase();
47
+ }
48
+ /**
49
+ * Offerings API methods
50
+ */
51
+ export class OfferingsAPI {
52
+ constructor(client) {
53
+ this.client = client;
54
+ }
55
+ /**
56
+ * List offerings for the organization
57
+ */
58
+ async list(params) {
59
+ const query = {};
60
+ if (params?.eventId) {
61
+ query.eventId = params.eventId;
62
+ }
63
+ if (params?.providerId) {
64
+ query.providerId = params.providerId;
65
+ }
66
+ const response = await this.client.request('GET', '/api/v1/orgs/{orgId}/offerings', { query });
67
+ return response || [];
68
+ }
69
+ /**
70
+ * Get a single offering by ID
71
+ */
72
+ async get(offeringId) {
73
+ const response = await this.client.request('GET', `/api/v1/orgs/{orgId}/offerings/${offeringId}`);
74
+ return response.offering;
75
+ }
76
+ /**
77
+ * Update an existing offering
78
+ */
79
+ async update(offeringId, params) {
80
+ const body = {};
81
+ if (params.name !== undefined)
82
+ body.name = params.name;
83
+ if (params.description !== undefined)
84
+ body.description = params.description;
85
+ if (params.price_cents !== undefined)
86
+ body.price_cents = params.price_cents;
87
+ if (params.duration_minutes !== undefined)
88
+ body.duration_minutes = params.duration_minutes;
89
+ if (params.timezone !== undefined)
90
+ body.timezone = params.timezone;
91
+ if (params.is_all_day !== undefined)
92
+ body.is_all_day = params.is_all_day;
93
+ if (params.attendee_mode !== undefined)
94
+ body.attendee_mode = params.attendee_mode;
95
+ if (params.attendee_limit !== undefined)
96
+ body.attendee_limit = params.attendee_limit;
97
+ if (params.customer !== undefined)
98
+ body.customer = params.customer;
99
+ if (params.status !== undefined)
100
+ body.status = params.status;
101
+ if (params.type !== undefined)
102
+ body.type = params.type;
103
+ if (params.time_mode !== undefined)
104
+ body.time_mode = params.time_mode;
105
+ if (params.start_time !== undefined)
106
+ body.start_time = params.start_time;
107
+ if (params.end_time !== undefined)
108
+ body.end_time = params.end_time;
109
+ if (params.session_count !== undefined)
110
+ body.session_count = params.session_count;
111
+ if (params.recurrence_preset !== undefined)
112
+ body.recurrence_preset = params.recurrence_preset;
113
+ if (params.recurrence_interval_count !== undefined)
114
+ body.recurrence_interval_count = params.recurrence_interval_count;
115
+ if (params.recurrence_interval_unit !== undefined)
116
+ body.recurrence_interval_unit = params.recurrence_interval_unit;
117
+ if (params.recurrence_repeat_on !== undefined)
118
+ body.recurrence_repeat_on = params.recurrence_repeat_on;
119
+ if (params.recurrence_end_mode !== undefined)
120
+ body.recurrence_end_mode = params.recurrence_end_mode;
121
+ if (params.recurrence_end_date !== undefined)
122
+ body.recurrence_end_date = params.recurrence_end_date;
123
+ if (params.recurrence_end_count !== undefined)
124
+ body.recurrence_end_count = params.recurrence_end_count;
125
+ if (params.override_price_cents !== undefined)
126
+ body.override_price_cents = params.override_price_cents;
127
+ if (params.min_age !== undefined)
128
+ body.min_age = params.min_age;
129
+ if (params.max_age !== undefined)
130
+ body.max_age = params.max_age;
131
+ if (params.window_start_time !== undefined)
132
+ body.window_start_time = params.window_start_time;
133
+ if (params.window_end_time !== undefined)
134
+ body.window_end_time = params.window_end_time;
135
+ if (params.cadence_minutes !== undefined)
136
+ body.cadence_minutes = params.cadence_minutes;
137
+ if (params.slot_days !== undefined)
138
+ body.slot_days = params.slot_days;
139
+ if (params.auto_confirm !== undefined)
140
+ body.auto_confirm = params.auto_confirm;
141
+ if (params.providerIds !== undefined)
142
+ body.providerIds = params.providerIds;
143
+ if (params.hours !== undefined)
144
+ body.hours = params.hours;
145
+ if (params.weekly_hours !== undefined)
146
+ body.weekly_hours = params.weekly_hours;
147
+ if (params.monthly_recurrence !== undefined)
148
+ body.monthly_recurrence = params.monthly_recurrence;
149
+ const response = await this.client.request('PATCH', `/api/v1/orgs/{orgId}/offerings/${offeringId}`, { body });
150
+ return response.offering;
151
+ }
152
+ /**
153
+ * Delete an offering
154
+ */
155
+ async delete(offeringId) {
156
+ await this.client.request('DELETE', `/api/v1/orgs/{orgId}/offerings/${offeringId}`);
157
+ }
158
+ /**
159
+ * Create a new offering
160
+ */
161
+ async create(params) {
162
+ const body = {
163
+ name: params.name,
164
+ };
165
+ if (params.description !== undefined) {
166
+ body.description = params.description;
167
+ }
168
+ if (params.price_cents !== undefined) {
169
+ body.price_cents = params.price_cents;
170
+ }
171
+ if (params.duration_minutes !== undefined) {
172
+ body.duration_minutes = params.duration_minutes;
173
+ }
174
+ if (params.timezone) {
175
+ body.timezone = params.timezone;
176
+ }
177
+ if (params.is_all_day !== undefined) {
178
+ body.is_all_day = params.is_all_day;
179
+ }
180
+ if (params.attendee_mode) {
181
+ body.attendee_mode = params.attendee_mode;
182
+ }
183
+ if (params.attendee_limit !== undefined) {
184
+ body.attendee_limit = params.attendee_limit;
185
+ }
186
+ if (params.customer) {
187
+ body.customer = params.customer;
188
+ }
189
+ if (params.status) {
190
+ body.status = params.status;
191
+ }
192
+ if (params.type) {
193
+ body.type = params.type;
194
+ }
195
+ if (params.time_mode) {
196
+ body.time_mode = params.time_mode;
197
+ }
198
+ if (params.start_time) {
199
+ body.start_time = params.start_time;
200
+ }
201
+ if (params.end_time) {
202
+ body.end_time = params.end_time;
203
+ }
204
+ if (params.session_count !== undefined) {
205
+ body.session_count = params.session_count;
206
+ }
207
+ if (params.recurrence_preset !== undefined) {
208
+ body.recurrence_preset = params.recurrence_preset;
209
+ }
210
+ if (params.recurrence_interval_count !== undefined) {
211
+ body.recurrence_interval_count = params.recurrence_interval_count;
212
+ }
213
+ if (params.recurrence_interval_unit) {
214
+ body.recurrence_interval_unit = params.recurrence_interval_unit;
215
+ }
216
+ if (params.recurrence_repeat_on !== undefined) {
217
+ body.recurrence_repeat_on = params.recurrence_repeat_on;
218
+ }
219
+ if (params.recurrence_end_mode !== undefined) {
220
+ body.recurrence_end_mode = params.recurrence_end_mode;
221
+ }
222
+ if (params.recurrence_end_date) {
223
+ body.recurrence_end_date = params.recurrence_end_date;
224
+ }
225
+ if (params.recurrence_end_count !== undefined) {
226
+ body.recurrence_end_count = params.recurrence_end_count;
227
+ }
228
+ if (params.override_price_cents !== undefined) {
229
+ body.override_price_cents = params.override_price_cents;
230
+ }
231
+ if (params.min_age !== undefined) {
232
+ body.min_age = params.min_age;
233
+ }
234
+ if (params.max_age !== undefined) {
235
+ body.max_age = params.max_age;
236
+ }
237
+ if (params.window_start_time) {
238
+ body.window_start_time = params.window_start_time;
239
+ }
240
+ if (params.window_end_time) {
241
+ body.window_end_time = params.window_end_time;
242
+ }
243
+ if (params.cadence_minutes !== undefined) {
244
+ body.cadence_minutes = params.cadence_minutes;
245
+ }
246
+ if (params.slot_days) {
247
+ body.slot_days = params.slot_days;
248
+ }
249
+ if (params.providerIds && params.providerIds.length > 0) {
250
+ body.providerIds = params.providerIds;
251
+ }
252
+ if (params.hours !== undefined) {
253
+ body.hours = params.hours;
254
+ }
255
+ if (params.weekly_hours !== undefined) {
256
+ body.weekly_hours = params.weekly_hours;
257
+ }
258
+ if (params.monthly_recurrence !== undefined) {
259
+ body.monthly_recurrence = params.monthly_recurrence;
260
+ }
261
+ const response = await this.client.request('POST', '/api/v1/orgs/{orgId}/offerings', { body });
262
+ return response.offering;
263
+ }
264
+ /**
265
+ * Create a simple offering (basic 1:1 offering using provider availability schedules)
266
+ * This is the simplest way to create an offering - it uses provider availability
267
+ * instead of fixed times or recurrence patterns.
268
+ *
269
+ * @example
270
+ * ```typescript
271
+ * const offering = await client.offerings.createSimple({
272
+ * name: 'Therapy Session',
273
+ * duration_minutes: 60,
274
+ * price_cents: 15000,
275
+ * description: 'One-on-one therapy session',
276
+ * providerIds: [providerId]
277
+ * });
278
+ * ```
279
+ */
280
+ async createSimple(params) {
281
+ return this.create({
282
+ name: params.name,
283
+ duration_minutes: params.duration_minutes,
284
+ price_cents: params.price_cents,
285
+ description: params.description,
286
+ timezone: params.timezone,
287
+ attendee_mode: '1:1',
288
+ is_all_day: false,
289
+ providerIds: params.providerIds,
290
+ // No recurrence_preset = uses provider availability schedules
291
+ });
292
+ }
293
+ /**
294
+ * Create a weekly recurring offering with specific days and time slots
295
+ *
296
+ * @example
297
+ * ```typescript
298
+ * const offering = await client.offerings.createRecurringWeekly({
299
+ * name: 'Weekly Therapy',
300
+ * duration_minutes: 60,
301
+ * days: ['monday', 'wednesday', 'friday'],
302
+ * timeSlots: [{ start: '09:00', end: '17:00' }],
303
+ * price_cents: 15000,
304
+ * providerIds: [providerId]
305
+ * });
306
+ * ```
307
+ */
308
+ async createRecurringWeekly(params) {
309
+ // Normalize day names and build weekly_hours object
310
+ const weekly_hours = {
311
+ sunday: [],
312
+ monday: [],
313
+ tuesday: [],
314
+ wednesday: [],
315
+ thursday: [],
316
+ friday: [],
317
+ saturday: [],
318
+ };
319
+ // Map days to weekly_hours format
320
+ const normalizedDays = params.days.map(normalizeDayName);
321
+ normalizedDays.forEach((day) => {
322
+ if (weekly_hours[day] !== undefined) {
323
+ weekly_hours[day] = params.timeSlots;
324
+ }
325
+ });
326
+ // Build recurrence_repeat_on string (MO,WE,FR format)
327
+ const repeatOn = normalizedDays
328
+ .map(dayToRepeatOn)
329
+ .filter(Boolean)
330
+ .join(',');
331
+ return this.create({
332
+ name: params.name,
333
+ duration_minutes: params.duration_minutes,
334
+ price_cents: params.price_cents,
335
+ description: params.description,
336
+ timezone: params.timezone,
337
+ attendee_mode: '1:1',
338
+ is_all_day: false,
339
+ recurrence_preset: 'weekly',
340
+ recurrence_repeat_on: repeatOn,
341
+ weekly_hours,
342
+ providerIds: params.providerIds,
343
+ });
344
+ }
345
+ /**
346
+ * Create a daily recurring offering with time slots
347
+ *
348
+ * @example
349
+ * ```typescript
350
+ * const offering = await client.offerings.createRecurringDaily({
351
+ * name: 'Daily Consultation',
352
+ * duration_minutes: 30,
353
+ * timeSlots: [
354
+ * { start: '09:00', end: '12:00' },
355
+ * { start: '14:00', end: '17:00' }
356
+ * ],
357
+ * price_cents: 5000,
358
+ * providerIds: [providerId]
359
+ * });
360
+ * ```
361
+ */
362
+ async createRecurringDaily(params) {
363
+ return this.create({
364
+ name: params.name,
365
+ duration_minutes: params.duration_minutes,
366
+ price_cents: params.price_cents,
367
+ description: params.description,
368
+ timezone: params.timezone,
369
+ attendee_mode: '1:1',
370
+ is_all_day: false,
371
+ recurrence_preset: 'daily',
372
+ hours: params.timeSlots,
373
+ providerIds: params.providerIds,
374
+ });
375
+ }
376
+ /**
377
+ * Create an offering using the simplified endpoint
378
+ * This method calls the /simple endpoint which provides preset-based configuration
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * // Simple 1:1 offering
383
+ * const offering = await client.offerings.createFromSimple({
384
+ * name: 'Therapy Session',
385
+ * duration_minutes: 60,
386
+ * price_cents: 15000,
387
+ * preset: 'simple_1on1',
388
+ * provider_ids: [providerId]
389
+ * });
390
+ *
391
+ * // Weekly recurring
392
+ * const weeklyOffering = await client.offerings.createFromSimple({
393
+ * name: 'Weekly Therapy',
394
+ * duration_minutes: 60,
395
+ * preset: 'recurring_weekly',
396
+ * weekly_days: ['monday', 'wednesday'],
397
+ * weekly_time_slots: [{ start: '09:00', end: '17:00' }],
398
+ * price_cents: 15000,
399
+ * });
400
+ * ```
401
+ */
402
+ async createFromSimple(params) {
403
+ const body = {
404
+ name: params.name,
405
+ duration_minutes: params.duration_minutes,
406
+ };
407
+ if (params.description !== undefined) {
408
+ body.description = params.description;
409
+ }
410
+ if (params.price_cents !== undefined) {
411
+ body.price_cents = params.price_cents;
412
+ }
413
+ if (params.timezone) {
414
+ body.timezone = params.timezone;
415
+ }
416
+ if (params.provider_ids && params.provider_ids.length > 0) {
417
+ body.provider_ids = params.provider_ids;
418
+ }
419
+ if (params.preset) {
420
+ body.preset = params.preset;
421
+ }
422
+ if (params.weekly_days && params.weekly_days.length > 0) {
423
+ body.weekly_days = params.weekly_days;
424
+ }
425
+ if (params.weekly_time_slots && params.weekly_time_slots.length > 0) {
426
+ body.weekly_time_slots = params.weekly_time_slots;
427
+ }
428
+ if (params.daily_time_slots && params.daily_time_slots.length > 0) {
429
+ body.daily_time_slots = params.daily_time_slots;
430
+ }
431
+ if (params.attendee_limit !== undefined) {
432
+ body.attendee_limit = params.attendee_limit;
433
+ }
434
+ const response = await this.client.request('POST', '/api/v1/orgs/{orgId}/offerings/simple', { body });
435
+ return response.offering;
436
+ }
437
+ }
package/dist/orgs.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { AevumClient } from './client';
2
+ import type { Org, BookingSettings, UpdateBookingSettingsParams } from './types';
3
+ /**
4
+ * Organization API – org details for embedding, booking config, etc.
5
+ */
6
+ export declare class OrgsAPI {
7
+ private client;
8
+ constructor(client: AevumClient);
9
+ /**
10
+ * Get organization by ID (requires API key auth).
11
+ * Returns org details including slug for public booking URLs.
12
+ */
13
+ get(): Promise<Org>;
14
+ /**
15
+ * Get booking settings for the organization
16
+ * Returns booking configuration including safe period hours
17
+ */
18
+ getBookingSettings(): Promise<BookingSettings>;
19
+ /**
20
+ * Update booking settings for the organization
21
+ * Allows updating the safe period hours (minimum time before bookings can be made)
22
+ */
23
+ updateBookingSettings(params: UpdateBookingSettingsParams): Promise<BookingSettings>;
24
+ }
package/dist/orgs.js ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Organization API – org details for embedding, booking config, etc.
3
+ */
4
+ export class OrgsAPI {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get organization by ID (requires API key auth).
10
+ * Returns org details including slug for public booking URLs.
11
+ */
12
+ async get() {
13
+ const response = await this.client.request('GET', '/api/v1/orgs/{orgId}');
14
+ return response;
15
+ }
16
+ /**
17
+ * Get booking settings for the organization
18
+ * Returns booking configuration including safe period hours
19
+ */
20
+ async getBookingSettings() {
21
+ return this.client.request('GET', '/api/v1/orgs/{orgId}/settings/booking');
22
+ }
23
+ /**
24
+ * Update booking settings for the organization
25
+ * Allows updating the safe period hours (minimum time before bookings can be made)
26
+ */
27
+ async updateBookingSettings(params) {
28
+ return this.client.request('PATCH', '/api/v1/orgs/{orgId}/settings/booking', { body: params });
29
+ }
30
+ }
@@ -0,0 +1,33 @@
1
+ import type { AevumClient } from './client';
2
+ export interface PaymentIntentDetails {
3
+ paymentIntentId: string;
4
+ clientSecret: string | null;
5
+ amount: number;
6
+ status: string;
7
+ }
8
+ export interface UpdatePaymentIntentParams {
9
+ paymentIntentId: string;
10
+ tipAmountCents: number;
11
+ bookingId?: string;
12
+ }
13
+ export interface UpdatePaymentIntentResult {
14
+ success: boolean;
15
+ paymentIntentId: string;
16
+ amount: number;
17
+ clientSecret: string | null;
18
+ }
19
+ /**
20
+ * Payments API for managing payment intents
21
+ */
22
+ export declare class PaymentsAPI {
23
+ private readonly client;
24
+ constructor(client: AevumClient);
25
+ /**
26
+ * Get payment intent details including client secret
27
+ */
28
+ getIntent(paymentIntentId: string): Promise<PaymentIntentDetails>;
29
+ /**
30
+ * Update payment intent with tip amount
31
+ */
32
+ updateIntent(params: UpdatePaymentIntentParams): Promise<UpdatePaymentIntentResult>;
33
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Payments API for managing payment intents
3
+ */
4
+ export class PaymentsAPI {
5
+ constructor(client) {
6
+ this.client = client;
7
+ }
8
+ /**
9
+ * Get payment intent details including client secret
10
+ */
11
+ async getIntent(paymentIntentId) {
12
+ return this.client.request('GET', '/api/payments/intent', {
13
+ query: {
14
+ payment_intent_id: paymentIntentId,
15
+ },
16
+ });
17
+ }
18
+ /**
19
+ * Update payment intent with tip amount
20
+ */
21
+ async updateIntent(params) {
22
+ return this.client.request('POST', '/api/payments/update-intent', {
23
+ body: params,
24
+ });
25
+ }
26
+ }
@@ -0,0 +1,57 @@
1
+ import { AevumClient } from './client';
2
+ import type { Provider, CreateProviderParams, ListProvidersParams } from './types';
3
+ /**
4
+ * Providers API methods
5
+ */
6
+ export declare class ProvidersAPI {
7
+ private client;
8
+ constructor(client: AevumClient);
9
+ /**
10
+ * List providers for the organization
11
+ */
12
+ list(params?: ListProvidersParams): Promise<Provider[]>;
13
+ /**
14
+ * Get a single provider by ID
15
+ */
16
+ get(providerId: string): Promise<Provider>;
17
+ /**
18
+ * Create a new provider
19
+ */
20
+ create(params: CreateProviderParams): Promise<Provider>;
21
+ /**
22
+ * Update an existing provider
23
+ */
24
+ update(providerId: string, params: {
25
+ name?: string;
26
+ email?: string | null;
27
+ phone?: string | null;
28
+ userId?: string | null;
29
+ bio?: string | null;
30
+ minimum_advance_booking_minutes?: number | null;
31
+ }): Promise<Provider>;
32
+ /**
33
+ * Delete a provider
34
+ */
35
+ delete(providerId: string): Promise<void>;
36
+ /**
37
+ * Get Google Calendar connection status for a provider
38
+ */
39
+ getGoogleCalendarStatus(providerId: string): Promise<{
40
+ connected: boolean;
41
+ email?: string;
42
+ lastSync?: string;
43
+ }>;
44
+ /**
45
+ * Sync Google Calendar for a provider
46
+ */
47
+ syncGoogleCalendar(providerId: string): Promise<{
48
+ success: boolean;
49
+ syncedEvents?: number;
50
+ }>;
51
+ /**
52
+ * Disconnect Google Calendar for a provider
53
+ */
54
+ disconnectGoogleCalendar(providerId: string): Promise<{
55
+ success: boolean;
56
+ }>;
57
+ }