@jphil/bookwhen-client 0.4.2 → 0.5.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.
- package/README.md +67 -300
- package/dist/index.d.ts +350 -0
- package/dist/index.js +236 -0
- package/dist/index.js.map +1 -1
- package/package.json +20 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
+
declare interface AttachmentAttributes {
|
|
5
|
+
title: string;
|
|
6
|
+
file_url: string;
|
|
7
|
+
file_size_bytes: string;
|
|
8
|
+
file_size_text: string;
|
|
9
|
+
file_name: string;
|
|
10
|
+
file_type: string;
|
|
11
|
+
content_type: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare type AttachmentFilters = {
|
|
15
|
+
[K in keyof AttachmentFiltersMap]?: AttachmentFiltersMap[K];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
declare interface AttachmentFiltersMap {
|
|
19
|
+
title?: string;
|
|
20
|
+
file_name?: string;
|
|
21
|
+
file_type?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare interface AttachmentResponse extends JsonApiResponse_4<BookwhenAttachment> {
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare class AttachmentService implements IAttachmentService {
|
|
28
|
+
private axiosInstance;
|
|
29
|
+
constructor(axiosInstance: AxiosInstance);
|
|
30
|
+
getById(params: z.infer<typeof GetAttachmentByIdParamsSchema>): Promise<AttachmentResponse>;
|
|
31
|
+
getMultiple(params?: GetMultipleAttachmentsParams): Promise<AttachmentsResponse>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare interface AttachmentsResponse extends JsonApiResponse_4<BookwhenAttachment[]> {
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare interface BookwhenAttachment {
|
|
38
|
+
id: string;
|
|
39
|
+
type: string;
|
|
40
|
+
attributes: AttachmentAttributes;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare interface BookwhenClassPass {
|
|
44
|
+
id: string;
|
|
45
|
+
type: string;
|
|
46
|
+
attributes: ClassPassAttributes;
|
|
47
|
+
}
|
|
48
|
+
|
|
4
49
|
/**
|
|
5
50
|
* Client for the Bookwhen API.
|
|
6
51
|
*
|
|
@@ -9,6 +54,10 @@ import { z } from 'zod';
|
|
|
9
54
|
declare class BookwhenClient {
|
|
10
55
|
private axiosInstance;
|
|
11
56
|
private eventService?;
|
|
57
|
+
private ticketService?;
|
|
58
|
+
private locationService?;
|
|
59
|
+
private attachmentService?;
|
|
60
|
+
private classPassService?;
|
|
12
61
|
private readonly isBrowser;
|
|
13
62
|
/**
|
|
14
63
|
* Creates a new instance of the BookwhenClient class.
|
|
@@ -26,6 +75,10 @@ declare class BookwhenClient {
|
|
|
26
75
|
* @returns The EventService instance.
|
|
27
76
|
*/
|
|
28
77
|
get events(): EventService;
|
|
78
|
+
get tickets(): TicketService;
|
|
79
|
+
get locations(): LocationService;
|
|
80
|
+
get attachments(): AttachmentService;
|
|
81
|
+
get classPasses(): ClassPassService;
|
|
29
82
|
}
|
|
30
83
|
|
|
31
84
|
declare interface BookwhenClientOptions {
|
|
@@ -53,6 +106,54 @@ declare interface BookwhenEvent {
|
|
|
53
106
|
attributes: EventAttributes;
|
|
54
107
|
}
|
|
55
108
|
|
|
109
|
+
declare interface BookwhenLocation {
|
|
110
|
+
id: string;
|
|
111
|
+
type: string;
|
|
112
|
+
attributes: LocationAttributes;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare interface BookwhenTicket {
|
|
116
|
+
id: string;
|
|
117
|
+
type: string;
|
|
118
|
+
attributes: TicketAttributes;
|
|
119
|
+
relationships?: TicketRelationships;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare interface ClassPassAttributes {
|
|
123
|
+
title: string;
|
|
124
|
+
details: string;
|
|
125
|
+
usage_allowance: number;
|
|
126
|
+
usage_type: 'personal' | 'any' | string;
|
|
127
|
+
number_available: number | null;
|
|
128
|
+
use_restricted_for_days: number | null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare interface ClassPassesResponse extends JsonApiResponse_5<BookwhenClassPass[]> {
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export declare type ClassPassFilters = {
|
|
135
|
+
[K in keyof ClassPassFiltersMap]?: ClassPassFiltersMap[K];
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
declare interface ClassPassFiltersMap {
|
|
139
|
+
title?: string;
|
|
140
|
+
detail?: string;
|
|
141
|
+
usage_type?: 'personal' | 'any';
|
|
142
|
+
cost?: string;
|
|
143
|
+
usage_allowance?: string;
|
|
144
|
+
use_restricted_for_days?: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare interface ClassPassResponse extends JsonApiResponse_5<BookwhenClassPass> {
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
declare class ClassPassService implements IClassPassService {
|
|
151
|
+
private axiosInstance;
|
|
152
|
+
constructor(axiosInstance: AxiosInstance);
|
|
153
|
+
getById(params: z.infer<typeof GetClassPassByIdParamsSchema>): Promise<ClassPassResponse>;
|
|
154
|
+
getMultiple(params?: GetMultipleClassPassesParams): Promise<ClassPassesResponse>;
|
|
155
|
+
}
|
|
156
|
+
|
|
56
157
|
/**
|
|
57
158
|
* Creates an instance of Axios with the provided API key.
|
|
58
159
|
* @param apiKey - The API key used for authentication.
|
|
@@ -143,6 +244,30 @@ export declare interface Filters {
|
|
|
143
244
|
[key: string]: string | string[] | boolean;
|
|
144
245
|
}
|
|
145
246
|
|
|
247
|
+
export declare interface GetAttachmentByIdParams {
|
|
248
|
+
attachmentId: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
declare const GetAttachmentByIdParamsSchema: z.ZodObject<{
|
|
252
|
+
attachmentId: z.ZodString;
|
|
253
|
+
}, "strip", z.ZodTypeAny, {
|
|
254
|
+
attachmentId: string;
|
|
255
|
+
}, {
|
|
256
|
+
attachmentId: string;
|
|
257
|
+
}>;
|
|
258
|
+
|
|
259
|
+
export declare interface GetClassPassByIdParams {
|
|
260
|
+
classPassId: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
declare const GetClassPassByIdParamsSchema: z.ZodObject<{
|
|
264
|
+
classPassId: z.ZodString;
|
|
265
|
+
}, "strip", z.ZodTypeAny, {
|
|
266
|
+
classPassId: string;
|
|
267
|
+
}, {
|
|
268
|
+
classPassId: string;
|
|
269
|
+
}>;
|
|
270
|
+
|
|
146
271
|
/**
|
|
147
272
|
* Parameters for querying a single event from the Bookwhen API, including optional include parameter.
|
|
148
273
|
* @param eventId The unique identifier of the event.
|
|
@@ -164,6 +289,26 @@ declare const GetEventByIdParamsSchema: z.ZodObject<{
|
|
|
164
289
|
includes?: ("location" | "attachments" | "tickets" | "tickets.events" | "tickets.class_passes")[] | undefined;
|
|
165
290
|
}>;
|
|
166
291
|
|
|
292
|
+
export declare interface GetLocationByIdParams {
|
|
293
|
+
locationId: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
declare const GetLocationByIdParamsSchema: z.ZodObject<{
|
|
297
|
+
locationId: z.ZodString;
|
|
298
|
+
}, "strip", z.ZodTypeAny, {
|
|
299
|
+
locationId: string;
|
|
300
|
+
}, {
|
|
301
|
+
locationId: string;
|
|
302
|
+
}>;
|
|
303
|
+
|
|
304
|
+
export declare interface GetMultipleAttachmentsParams {
|
|
305
|
+
filters?: AttachmentFilters;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export declare interface GetMultipleClassPassesParams {
|
|
309
|
+
filters?: ClassPassFilters;
|
|
310
|
+
}
|
|
311
|
+
|
|
167
312
|
/**
|
|
168
313
|
* Represents the parameters for getting multiple events.
|
|
169
314
|
* @param filter The filter parameters to apply to the query.
|
|
@@ -174,11 +319,46 @@ export declare interface GetMultipleEventsParams {
|
|
|
174
319
|
includes?: EventResource[];
|
|
175
320
|
}
|
|
176
321
|
|
|
322
|
+
export declare interface GetMultipleLocationsParams {
|
|
323
|
+
filters?: LocationFilters;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export declare interface GetMultipleTicketsParams {
|
|
327
|
+
eventId: string;
|
|
328
|
+
includes?: TicketResource[];
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export declare interface GetTicketByIdParams {
|
|
332
|
+
ticketId: string;
|
|
333
|
+
includes?: TicketResource[];
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
declare const GetTicketByIdParamsSchema: z.ZodObject<{
|
|
337
|
+
ticketId: z.ZodString;
|
|
338
|
+
includes: z.ZodOptional<z.ZodArray<z.ZodEnum<["class_passes", "events", "events.location", "events.tickets", "events.attachments"]>, "many">>;
|
|
339
|
+
}, "strip", z.ZodTypeAny, {
|
|
340
|
+
ticketId: string;
|
|
341
|
+
includes?: ("class_passes" | "events" | "events.location" | "events.tickets" | "events.attachments")[] | undefined;
|
|
342
|
+
}, {
|
|
343
|
+
ticketId: string;
|
|
344
|
+
includes?: ("class_passes" | "events" | "events.location" | "events.tickets" | "events.attachments")[] | undefined;
|
|
345
|
+
}>;
|
|
346
|
+
|
|
177
347
|
export declare interface HttpStatus {
|
|
178
348
|
code: number;
|
|
179
349
|
message: string;
|
|
180
350
|
}
|
|
181
351
|
|
|
352
|
+
export declare interface IAttachmentService {
|
|
353
|
+
getById(params: GetAttachmentByIdParams): Promise<AttachmentResponse>;
|
|
354
|
+
getMultiple(params?: GetMultipleAttachmentsParams): Promise<AttachmentsResponse>;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export declare interface IClassPassService {
|
|
358
|
+
getById(params: GetClassPassByIdParams): Promise<ClassPassResponse>;
|
|
359
|
+
getMultiple(params?: GetMultipleClassPassesParams): Promise<ClassPassesResponse>;
|
|
360
|
+
}
|
|
361
|
+
|
|
182
362
|
/**
|
|
183
363
|
* Interface for services handling events via the Bookwhen API V2.
|
|
184
364
|
*/
|
|
@@ -198,6 +378,16 @@ export declare interface IEventService {
|
|
|
198
378
|
getMultiple?(params?: GetMultipleEventsParams): Promise<EventsResponse>;
|
|
199
379
|
}
|
|
200
380
|
|
|
381
|
+
export declare interface ILocationService {
|
|
382
|
+
getById(params: GetLocationByIdParams): Promise<LocationResponse>;
|
|
383
|
+
getMultiple(params?: GetMultipleLocationsParams): Promise<LocationsResponse>;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export declare interface ITicketService {
|
|
387
|
+
getById(params: GetTicketByIdParams): Promise<TicketResponse>;
|
|
388
|
+
getMultiple(params: GetMultipleTicketsParams): Promise<TicketsResponse>;
|
|
389
|
+
}
|
|
390
|
+
|
|
201
391
|
declare interface JsonApiResponse<T> {
|
|
202
392
|
data: T;
|
|
203
393
|
included?: any[];
|
|
@@ -217,6 +407,113 @@ declare interface JsonApiResponse<T> {
|
|
|
217
407
|
};
|
|
218
408
|
}
|
|
219
409
|
|
|
410
|
+
declare interface JsonApiResponse_2<T> {
|
|
411
|
+
data: T;
|
|
412
|
+
included?: any[];
|
|
413
|
+
links?: {
|
|
414
|
+
self?: string;
|
|
415
|
+
first?: string;
|
|
416
|
+
last?: string;
|
|
417
|
+
prev?: string;
|
|
418
|
+
next?: string;
|
|
419
|
+
};
|
|
420
|
+
meta?: {
|
|
421
|
+
page?: {
|
|
422
|
+
current?: number;
|
|
423
|
+
total?: number;
|
|
424
|
+
size?: number;
|
|
425
|
+
};
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
declare interface JsonApiResponse_3<T> {
|
|
430
|
+
data: T;
|
|
431
|
+
included?: any[];
|
|
432
|
+
links?: {
|
|
433
|
+
self?: string;
|
|
434
|
+
first?: string;
|
|
435
|
+
last?: string;
|
|
436
|
+
prev?: string;
|
|
437
|
+
next?: string;
|
|
438
|
+
};
|
|
439
|
+
meta?: {
|
|
440
|
+
page?: {
|
|
441
|
+
current?: number;
|
|
442
|
+
total?: number;
|
|
443
|
+
size?: number;
|
|
444
|
+
};
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
declare interface JsonApiResponse_4<T> {
|
|
449
|
+
data: T;
|
|
450
|
+
included?: any[];
|
|
451
|
+
links?: {
|
|
452
|
+
self?: string;
|
|
453
|
+
first?: string;
|
|
454
|
+
last?: string;
|
|
455
|
+
prev?: string;
|
|
456
|
+
next?: string;
|
|
457
|
+
};
|
|
458
|
+
meta?: {
|
|
459
|
+
page?: {
|
|
460
|
+
current?: number;
|
|
461
|
+
total?: number;
|
|
462
|
+
size?: number;
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
declare interface JsonApiResponse_5<T> {
|
|
468
|
+
data: T;
|
|
469
|
+
included?: any[];
|
|
470
|
+
links?: {
|
|
471
|
+
self?: string;
|
|
472
|
+
first?: string;
|
|
473
|
+
last?: string;
|
|
474
|
+
prev?: string;
|
|
475
|
+
next?: string;
|
|
476
|
+
};
|
|
477
|
+
meta?: {
|
|
478
|
+
page?: {
|
|
479
|
+
current?: number;
|
|
480
|
+
total?: number;
|
|
481
|
+
size?: number;
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
declare interface LocationAttributes {
|
|
487
|
+
address_text: string;
|
|
488
|
+
additional_info: string;
|
|
489
|
+
latitude: number;
|
|
490
|
+
longitude: number;
|
|
491
|
+
zoom: number;
|
|
492
|
+
map_url: string;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export declare type LocationFilters = {
|
|
496
|
+
[K in keyof LocationFiltersMap]?: LocationFiltersMap[K];
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
declare interface LocationFiltersMap {
|
|
500
|
+
address_text?: string;
|
|
501
|
+
additional_info?: string;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
declare interface LocationResponse extends JsonApiResponse_3<BookwhenLocation> {
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
declare class LocationService implements ILocationService {
|
|
508
|
+
private axiosInstance;
|
|
509
|
+
constructor(axiosInstance: AxiosInstance);
|
|
510
|
+
getById(params: z.infer<typeof GetLocationByIdParamsSchema>): Promise<LocationResponse>;
|
|
511
|
+
getMultiple(params?: GetMultipleLocationsParams): Promise<LocationsResponse>;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
declare interface LocationsResponse extends JsonApiResponse_3<BookwhenLocation[]> {
|
|
515
|
+
}
|
|
516
|
+
|
|
220
517
|
/**
|
|
221
518
|
* Generic JSON:API relationship resolver utility
|
|
222
519
|
*
|
|
@@ -249,4 +546,57 @@ export declare type Resource = string;
|
|
|
249
546
|
|
|
250
547
|
export declare type Resources = Resource[];
|
|
251
548
|
|
|
549
|
+
declare interface TicketAttributes {
|
|
550
|
+
title: string;
|
|
551
|
+
details: string;
|
|
552
|
+
number_issued: number | null;
|
|
553
|
+
number_taken: number;
|
|
554
|
+
course_ticket: boolean;
|
|
555
|
+
group_ticket: boolean;
|
|
556
|
+
group_min: number | null;
|
|
557
|
+
group_max: number | null;
|
|
558
|
+
available: boolean;
|
|
559
|
+
available_from: string | null;
|
|
560
|
+
available_to: string | null;
|
|
561
|
+
cost: TicketCost;
|
|
562
|
+
built_basket_iframe_url: string;
|
|
563
|
+
built_basket_url: string;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
declare interface TicketCost {
|
|
567
|
+
currency_code: string;
|
|
568
|
+
net: number;
|
|
569
|
+
tax: number;
|
|
570
|
+
face_value_net?: number;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
declare interface TicketRelationshipData {
|
|
574
|
+
id: string;
|
|
575
|
+
type: string;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
declare interface TicketRelationships {
|
|
579
|
+
events?: {
|
|
580
|
+
data: TicketRelationshipData[];
|
|
581
|
+
};
|
|
582
|
+
class_passes?: {
|
|
583
|
+
data: TicketRelationshipData[];
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export declare type TicketResource = 'class_passes' | 'events' | 'events.location' | 'events.tickets' | 'events.attachments';
|
|
588
|
+
|
|
589
|
+
declare interface TicketResponse extends JsonApiResponse_2<BookwhenTicket> {
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
declare class TicketService implements ITicketService {
|
|
593
|
+
private axiosInstance;
|
|
594
|
+
constructor(axiosInstance: AxiosInstance);
|
|
595
|
+
getById(params: z.infer<typeof GetTicketByIdParamsSchema>): Promise<TicketResponse>;
|
|
596
|
+
getMultiple(params: GetMultipleTicketsParams): Promise<TicketsResponse>;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
declare interface TicketsResponse extends JsonApiResponse_2<BookwhenTicket[]> {
|
|
600
|
+
}
|
|
601
|
+
|
|
252
602
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -6498,6 +6498,214 @@ class EventService {
|
|
|
6498
6498
|
}
|
|
6499
6499
|
}
|
|
6500
6500
|
}
|
|
6501
|
+
const TicketResourceSchema = z.enum([
|
|
6502
|
+
"class_passes",
|
|
6503
|
+
"events",
|
|
6504
|
+
"events.location",
|
|
6505
|
+
"events.tickets",
|
|
6506
|
+
"events.attachments"
|
|
6507
|
+
]);
|
|
6508
|
+
const GetTicketByIdParamsSchema = z.object({
|
|
6509
|
+
ticketId: z.string().min(1, "Invalid ticket ID"),
|
|
6510
|
+
includes: TicketResourceSchema.array().optional()
|
|
6511
|
+
});
|
|
6512
|
+
const GetMultipleTicketsParamsSchema = z.object({
|
|
6513
|
+
eventId: z.string().min(1, "Invalid event ID"),
|
|
6514
|
+
includes: TicketResourceSchema.array().optional()
|
|
6515
|
+
});
|
|
6516
|
+
class TicketService {
|
|
6517
|
+
constructor(axiosInstance) {
|
|
6518
|
+
__publicField(this, "axiosInstance");
|
|
6519
|
+
this.axiosInstance = axiosInstance;
|
|
6520
|
+
}
|
|
6521
|
+
async getById(params) {
|
|
6522
|
+
try {
|
|
6523
|
+
const validParams = GetTicketByIdParamsSchema.parse(params);
|
|
6524
|
+
const query = new BookwhenRequest(`/tickets/${validParams.ticketId}`);
|
|
6525
|
+
if (validParams.includes) {
|
|
6526
|
+
query.addIncludes(validParams.includes);
|
|
6527
|
+
}
|
|
6528
|
+
const response = await this.axiosInstance.get(`${query}`);
|
|
6529
|
+
return response.data;
|
|
6530
|
+
} catch (error) {
|
|
6531
|
+
if (error instanceof z.ZodError) {
|
|
6532
|
+
const errorMessages = error.errors.map((e) => e.message).join(", ");
|
|
6533
|
+
throw new Error(
|
|
6534
|
+
`tickets.getById: Schema Validation failed: ${errorMessages}`
|
|
6535
|
+
);
|
|
6536
|
+
}
|
|
6537
|
+
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES, {
|
|
6538
|
+
404: {
|
|
6539
|
+
code: 404,
|
|
6540
|
+
message: "Ticket not found. Please check the ticket ID and try again."
|
|
6541
|
+
}
|
|
6542
|
+
});
|
|
6543
|
+
}
|
|
6544
|
+
}
|
|
6545
|
+
async getMultiple(params) {
|
|
6546
|
+
try {
|
|
6547
|
+
const validParams = GetMultipleTicketsParamsSchema.parse(params);
|
|
6548
|
+
const queryParts = [`event=${encodeURIComponent(validParams.eventId)}`];
|
|
6549
|
+
if (validParams.includes?.length) {
|
|
6550
|
+
queryParts.push(`include=${validParams.includes.join(",")}`);
|
|
6551
|
+
}
|
|
6552
|
+
const response = await this.axiosInstance.get(
|
|
6553
|
+
`/tickets?${queryParts.join("&")}`
|
|
6554
|
+
);
|
|
6555
|
+
return response.data;
|
|
6556
|
+
} catch (error) {
|
|
6557
|
+
if (error instanceof z.ZodError) {
|
|
6558
|
+
const errorMessages = error.errors.map((e) => e.message).join(", ");
|
|
6559
|
+
throw new Error(
|
|
6560
|
+
`tickets.getMultiple: Schema Validation failed: ${errorMessages}`
|
|
6561
|
+
);
|
|
6562
|
+
}
|
|
6563
|
+
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES);
|
|
6564
|
+
}
|
|
6565
|
+
}
|
|
6566
|
+
}
|
|
6567
|
+
const GetLocationByIdParamsSchema = z.object({
|
|
6568
|
+
locationId: z.string().min(1, "Invalid location ID")
|
|
6569
|
+
});
|
|
6570
|
+
class LocationService {
|
|
6571
|
+
constructor(axiosInstance) {
|
|
6572
|
+
__publicField(this, "axiosInstance");
|
|
6573
|
+
this.axiosInstance = axiosInstance;
|
|
6574
|
+
}
|
|
6575
|
+
async getById(params) {
|
|
6576
|
+
try {
|
|
6577
|
+
const validParams = GetLocationByIdParamsSchema.parse(params);
|
|
6578
|
+
const query = new BookwhenRequest(`/locations/${validParams.locationId}`);
|
|
6579
|
+
const response = await this.axiosInstance.get(
|
|
6580
|
+
`${query}`
|
|
6581
|
+
);
|
|
6582
|
+
return response.data;
|
|
6583
|
+
} catch (error) {
|
|
6584
|
+
if (error instanceof z.ZodError) {
|
|
6585
|
+
const errorMessages = error.errors.map((e) => e.message).join(", ");
|
|
6586
|
+
throw new Error(
|
|
6587
|
+
`locations.getById: Schema Validation failed: ${errorMessages}`
|
|
6588
|
+
);
|
|
6589
|
+
}
|
|
6590
|
+
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES, {
|
|
6591
|
+
404: {
|
|
6592
|
+
code: 404,
|
|
6593
|
+
message: "Location not found. Please check the location ID and try again."
|
|
6594
|
+
}
|
|
6595
|
+
});
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6598
|
+
async getMultiple(params = {}) {
|
|
6599
|
+
try {
|
|
6600
|
+
const query = new BookwhenRequest("/locations");
|
|
6601
|
+
if (params.filters) {
|
|
6602
|
+
query.addFilters(params.filters);
|
|
6603
|
+
}
|
|
6604
|
+
const response = await this.axiosInstance.get(
|
|
6605
|
+
`${query}`
|
|
6606
|
+
);
|
|
6607
|
+
return response.data;
|
|
6608
|
+
} catch (error) {
|
|
6609
|
+
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES);
|
|
6610
|
+
}
|
|
6611
|
+
}
|
|
6612
|
+
}
|
|
6613
|
+
const GetAttachmentByIdParamsSchema = z.object({
|
|
6614
|
+
attachmentId: z.string().min(1, "Invalid attachment ID")
|
|
6615
|
+
});
|
|
6616
|
+
class AttachmentService {
|
|
6617
|
+
constructor(axiosInstance) {
|
|
6618
|
+
__publicField(this, "axiosInstance");
|
|
6619
|
+
this.axiosInstance = axiosInstance;
|
|
6620
|
+
}
|
|
6621
|
+
async getById(params) {
|
|
6622
|
+
try {
|
|
6623
|
+
const validParams = GetAttachmentByIdParamsSchema.parse(params);
|
|
6624
|
+
const query = new BookwhenRequest(
|
|
6625
|
+
`/attachments/${validParams.attachmentId}`
|
|
6626
|
+
);
|
|
6627
|
+
const response = await this.axiosInstance.get(
|
|
6628
|
+
`${query}`
|
|
6629
|
+
);
|
|
6630
|
+
return response.data;
|
|
6631
|
+
} catch (error) {
|
|
6632
|
+
if (error instanceof z.ZodError) {
|
|
6633
|
+
const errorMessages = error.errors.map((e) => e.message).join(", ");
|
|
6634
|
+
throw new Error(
|
|
6635
|
+
`attachments.getById: Schema Validation failed: ${errorMessages}`
|
|
6636
|
+
);
|
|
6637
|
+
}
|
|
6638
|
+
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES, {
|
|
6639
|
+
404: {
|
|
6640
|
+
code: 404,
|
|
6641
|
+
message: "Attachment not found. Please check the attachment ID and try again."
|
|
6642
|
+
}
|
|
6643
|
+
});
|
|
6644
|
+
}
|
|
6645
|
+
}
|
|
6646
|
+
async getMultiple(params = {}) {
|
|
6647
|
+
try {
|
|
6648
|
+
const query = new BookwhenRequest("/attachments");
|
|
6649
|
+
if (params.filters) {
|
|
6650
|
+
query.addFilters(params.filters);
|
|
6651
|
+
}
|
|
6652
|
+
const response = await this.axiosInstance.get(
|
|
6653
|
+
`${query}`
|
|
6654
|
+
);
|
|
6655
|
+
return response.data;
|
|
6656
|
+
} catch (error) {
|
|
6657
|
+
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES);
|
|
6658
|
+
}
|
|
6659
|
+
}
|
|
6660
|
+
}
|
|
6661
|
+
const GetClassPassByIdParamsSchema = z.object({
|
|
6662
|
+
classPassId: z.string().min(1, "Invalid class pass ID")
|
|
6663
|
+
});
|
|
6664
|
+
class ClassPassService {
|
|
6665
|
+
constructor(axiosInstance) {
|
|
6666
|
+
__publicField(this, "axiosInstance");
|
|
6667
|
+
this.axiosInstance = axiosInstance;
|
|
6668
|
+
}
|
|
6669
|
+
async getById(params) {
|
|
6670
|
+
try {
|
|
6671
|
+
const validParams = GetClassPassByIdParamsSchema.parse(params);
|
|
6672
|
+
const query = new BookwhenRequest(
|
|
6673
|
+
`/class_passes/${validParams.classPassId}`
|
|
6674
|
+
);
|
|
6675
|
+
const response = await this.axiosInstance.get(
|
|
6676
|
+
`${query}`
|
|
6677
|
+
);
|
|
6678
|
+
return response.data;
|
|
6679
|
+
} catch (error) {
|
|
6680
|
+
if (error instanceof z.ZodError) {
|
|
6681
|
+
const errorMessages = error.errors.map((e) => e.message).join(", ");
|
|
6682
|
+
throw new Error(
|
|
6683
|
+
`classPasses.getById: Schema Validation failed: ${errorMessages}`
|
|
6684
|
+
);
|
|
6685
|
+
}
|
|
6686
|
+
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES, {
|
|
6687
|
+
404: {
|
|
6688
|
+
code: 404,
|
|
6689
|
+
message: "Class pass not found. Please check the class pass ID and try again."
|
|
6690
|
+
}
|
|
6691
|
+
});
|
|
6692
|
+
}
|
|
6693
|
+
}
|
|
6694
|
+
async getMultiple(params = {}) {
|
|
6695
|
+
try {
|
|
6696
|
+
const query = new BookwhenRequest("/class_passes");
|
|
6697
|
+
if (params.filters) {
|
|
6698
|
+
query.addFilters(params.filters);
|
|
6699
|
+
}
|
|
6700
|
+
const response = await this.axiosInstance.get(
|
|
6701
|
+
`${query}`
|
|
6702
|
+
);
|
|
6703
|
+
return response.data;
|
|
6704
|
+
} catch (error) {
|
|
6705
|
+
handleServiceHTTPErrors(error, SERVICE_HTTP_STATUS_CODES);
|
|
6706
|
+
}
|
|
6707
|
+
}
|
|
6708
|
+
}
|
|
6501
6709
|
class BookwhenClient {
|
|
6502
6710
|
/**
|
|
6503
6711
|
* Creates a new instance of the BookwhenClient class.
|
|
@@ -6506,6 +6714,10 @@ class BookwhenClient {
|
|
|
6506
6714
|
*/
|
|
6507
6715
|
constructor(axiosInstance) {
|
|
6508
6716
|
__publicField(this, "eventService");
|
|
6717
|
+
__publicField(this, "ticketService");
|
|
6718
|
+
__publicField(this, "locationService");
|
|
6719
|
+
__publicField(this, "attachmentService");
|
|
6720
|
+
__publicField(this, "classPassService");
|
|
6509
6721
|
__publicField(this, "isBrowser");
|
|
6510
6722
|
this.axiosInstance = axiosInstance;
|
|
6511
6723
|
this.isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
@@ -6528,6 +6740,30 @@ class BookwhenClient {
|
|
|
6528
6740
|
}
|
|
6529
6741
|
return this.eventService;
|
|
6530
6742
|
}
|
|
6743
|
+
get tickets() {
|
|
6744
|
+
if (!this.ticketService) {
|
|
6745
|
+
this.ticketService = new TicketService(this.axiosInstance);
|
|
6746
|
+
}
|
|
6747
|
+
return this.ticketService;
|
|
6748
|
+
}
|
|
6749
|
+
get locations() {
|
|
6750
|
+
if (!this.locationService) {
|
|
6751
|
+
this.locationService = new LocationService(this.axiosInstance);
|
|
6752
|
+
}
|
|
6753
|
+
return this.locationService;
|
|
6754
|
+
}
|
|
6755
|
+
get attachments() {
|
|
6756
|
+
if (!this.attachmentService) {
|
|
6757
|
+
this.attachmentService = new AttachmentService(this.axiosInstance);
|
|
6758
|
+
}
|
|
6759
|
+
return this.attachmentService;
|
|
6760
|
+
}
|
|
6761
|
+
get classPasses() {
|
|
6762
|
+
if (!this.classPassService) {
|
|
6763
|
+
this.classPassService = new ClassPassService(this.axiosInstance);
|
|
6764
|
+
}
|
|
6765
|
+
return this.classPassService;
|
|
6766
|
+
}
|
|
6531
6767
|
}
|
|
6532
6768
|
function createBookwhenClient(options) {
|
|
6533
6769
|
const {
|