@jphil/bookwhen-client 0.4.2 → 0.6.0

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 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.
@@ -128,12 +229,24 @@ declare class EventService implements IEventService {
128
229
  */
129
230
  getById(params: z.infer<typeof GetEventByIdParamsSchema>): Promise<EventResponse>;
130
231
  /**
131
- * Retrieves multiple events based on filtering and pagination parameters.
232
+ * Retrieves a single page of events based on filtering and pagination parameters.
233
+ * The Bookwhen API returns up to 20 events per page by default.
132
234
  *
133
235
  * @param {GetMultipleEventsParams} params - Optional parameters for filtering and pagination.
134
236
  * @return {Promise<EventsResponse>} A Promise that resolves to the full JSON:API response object.
135
237
  */
136
238
  getMultiple(params?: GetMultipleEventsParams): Promise<EventsResponse>;
239
+ /**
240
+ * Retrieves all events matching the given filters, automatically following
241
+ * pagination links to fetch every page of results.
242
+ *
243
+ * The returned response contains the combined `data` and deduplicated
244
+ * `included` arrays from all pages.
245
+ *
246
+ * @param {GetMultipleEventsParams} params - Optional parameters for filtering.
247
+ * @return {Promise<EventsResponse>} A Promise that resolves to the combined JSON:API response.
248
+ */
249
+ getAll(params?: GetMultipleEventsParams): Promise<EventsResponse>;
137
250
  }
138
251
 
139
252
  declare interface EventsResponse extends JsonApiResponse<BookwhenEvent[]> {
@@ -143,6 +256,30 @@ export declare interface Filters {
143
256
  [key: string]: string | string[] | boolean;
144
257
  }
145
258
 
259
+ export declare interface GetAttachmentByIdParams {
260
+ attachmentId: string;
261
+ }
262
+
263
+ declare const GetAttachmentByIdParamsSchema: z.ZodObject<{
264
+ attachmentId: z.ZodString;
265
+ }, "strip", z.ZodTypeAny, {
266
+ attachmentId: string;
267
+ }, {
268
+ attachmentId: string;
269
+ }>;
270
+
271
+ export declare interface GetClassPassByIdParams {
272
+ classPassId: string;
273
+ }
274
+
275
+ declare const GetClassPassByIdParamsSchema: z.ZodObject<{
276
+ classPassId: z.ZodString;
277
+ }, "strip", z.ZodTypeAny, {
278
+ classPassId: string;
279
+ }, {
280
+ classPassId: string;
281
+ }>;
282
+
146
283
  /**
147
284
  * Parameters for querying a single event from the Bookwhen API, including optional include parameter.
148
285
  * @param eventId The unique identifier of the event.
@@ -164,6 +301,26 @@ declare const GetEventByIdParamsSchema: z.ZodObject<{
164
301
  includes?: ("location" | "attachments" | "tickets" | "tickets.events" | "tickets.class_passes")[] | undefined;
165
302
  }>;
166
303
 
304
+ export declare interface GetLocationByIdParams {
305
+ locationId: string;
306
+ }
307
+
308
+ declare const GetLocationByIdParamsSchema: z.ZodObject<{
309
+ locationId: z.ZodString;
310
+ }, "strip", z.ZodTypeAny, {
311
+ locationId: string;
312
+ }, {
313
+ locationId: string;
314
+ }>;
315
+
316
+ export declare interface GetMultipleAttachmentsParams {
317
+ filters?: AttachmentFilters;
318
+ }
319
+
320
+ export declare interface GetMultipleClassPassesParams {
321
+ filters?: ClassPassFilters;
322
+ }
323
+
167
324
  /**
168
325
  * Represents the parameters for getting multiple events.
169
326
  * @param filter The filter parameters to apply to the query.
@@ -174,11 +331,46 @@ export declare interface GetMultipleEventsParams {
174
331
  includes?: EventResource[];
175
332
  }
176
333
 
334
+ export declare interface GetMultipleLocationsParams {
335
+ filters?: LocationFilters;
336
+ }
337
+
338
+ export declare interface GetMultipleTicketsParams {
339
+ eventId: string;
340
+ includes?: TicketResource[];
341
+ }
342
+
343
+ export declare interface GetTicketByIdParams {
344
+ ticketId: string;
345
+ includes?: TicketResource[];
346
+ }
347
+
348
+ declare const GetTicketByIdParamsSchema: z.ZodObject<{
349
+ ticketId: z.ZodString;
350
+ includes: z.ZodOptional<z.ZodArray<z.ZodEnum<["class_passes", "events", "events.location", "events.tickets", "events.attachments"]>, "many">>;
351
+ }, "strip", z.ZodTypeAny, {
352
+ ticketId: string;
353
+ includes?: ("class_passes" | "events" | "events.location" | "events.tickets" | "events.attachments")[] | undefined;
354
+ }, {
355
+ ticketId: string;
356
+ includes?: ("class_passes" | "events" | "events.location" | "events.tickets" | "events.attachments")[] | undefined;
357
+ }>;
358
+
177
359
  export declare interface HttpStatus {
178
360
  code: number;
179
361
  message: string;
180
362
  }
181
363
 
364
+ export declare interface IAttachmentService {
365
+ getById(params: GetAttachmentByIdParams): Promise<AttachmentResponse>;
366
+ getMultiple(params?: GetMultipleAttachmentsParams): Promise<AttachmentsResponse>;
367
+ }
368
+
369
+ export declare interface IClassPassService {
370
+ getById(params: GetClassPassByIdParams): Promise<ClassPassResponse>;
371
+ getMultiple(params?: GetMultipleClassPassesParams): Promise<ClassPassesResponse>;
372
+ }
373
+
182
374
  /**
183
375
  * Interface for services handling events via the Bookwhen API V2.
184
376
  */
@@ -191,11 +383,28 @@ export declare interface IEventService {
191
383
  */
192
384
  getById(params: GetEventByIdParams): Promise<EventResponse>;
193
385
  /**
194
- * Retrieves multiple events based on specified parameters.
386
+ * Retrieves a single page of events based on specified parameters.
195
387
  * @param params Optional parameters to filter and control the list of returned events, according to what the Bookwhen API supports.
196
388
  * @returns A Promise that resolves to the full JSON:API response object.
197
389
  */
198
390
  getMultiple?(params?: GetMultipleEventsParams): Promise<EventsResponse>;
391
+ /**
392
+ * Retrieves all events matching the given filters, automatically following
393
+ * pagination links to fetch every page of results.
394
+ * @param params Optional parameters to filter the returned events.
395
+ * @returns A Promise that resolves to the combined JSON:API response with all pages merged.
396
+ */
397
+ getAll?(params?: GetMultipleEventsParams): Promise<EventsResponse>;
398
+ }
399
+
400
+ export declare interface ILocationService {
401
+ getById(params: GetLocationByIdParams): Promise<LocationResponse>;
402
+ getMultiple(params?: GetMultipleLocationsParams): Promise<LocationsResponse>;
403
+ }
404
+
405
+ export declare interface ITicketService {
406
+ getById(params: GetTicketByIdParams): Promise<TicketResponse>;
407
+ getMultiple(params: GetMultipleTicketsParams): Promise<TicketsResponse>;
199
408
  }
200
409
 
201
410
  declare interface JsonApiResponse<T> {
@@ -217,6 +426,113 @@ declare interface JsonApiResponse<T> {
217
426
  };
218
427
  }
219
428
 
429
+ declare interface JsonApiResponse_2<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_3<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_4<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 JsonApiResponse_5<T> {
487
+ data: T;
488
+ included?: any[];
489
+ links?: {
490
+ self?: string;
491
+ first?: string;
492
+ last?: string;
493
+ prev?: string;
494
+ next?: string;
495
+ };
496
+ meta?: {
497
+ page?: {
498
+ current?: number;
499
+ total?: number;
500
+ size?: number;
501
+ };
502
+ };
503
+ }
504
+
505
+ declare interface LocationAttributes {
506
+ address_text: string;
507
+ additional_info: string;
508
+ latitude: number;
509
+ longitude: number;
510
+ zoom: number;
511
+ map_url: string;
512
+ }
513
+
514
+ export declare type LocationFilters = {
515
+ [K in keyof LocationFiltersMap]?: LocationFiltersMap[K];
516
+ };
517
+
518
+ declare interface LocationFiltersMap {
519
+ address_text?: string;
520
+ additional_info?: string;
521
+ }
522
+
523
+ declare interface LocationResponse extends JsonApiResponse_3<BookwhenLocation> {
524
+ }
525
+
526
+ declare class LocationService implements ILocationService {
527
+ private axiosInstance;
528
+ constructor(axiosInstance: AxiosInstance);
529
+ getById(params: z.infer<typeof GetLocationByIdParamsSchema>): Promise<LocationResponse>;
530
+ getMultiple(params?: GetMultipleLocationsParams): Promise<LocationsResponse>;
531
+ }
532
+
533
+ declare interface LocationsResponse extends JsonApiResponse_3<BookwhenLocation[]> {
534
+ }
535
+
220
536
  /**
221
537
  * Generic JSON:API relationship resolver utility
222
538
  *
@@ -249,4 +565,57 @@ export declare type Resource = string;
249
565
 
250
566
  export declare type Resources = Resource[];
251
567
 
568
+ declare interface TicketAttributes {
569
+ title: string;
570
+ details: string;
571
+ number_issued: number | null;
572
+ number_taken: number;
573
+ course_ticket: boolean;
574
+ group_ticket: boolean;
575
+ group_min: number | null;
576
+ group_max: number | null;
577
+ available: boolean;
578
+ available_from: string | null;
579
+ available_to: string | null;
580
+ cost: TicketCost;
581
+ built_basket_iframe_url: string;
582
+ built_basket_url: string;
583
+ }
584
+
585
+ declare interface TicketCost {
586
+ currency_code: string;
587
+ net: number;
588
+ tax: number;
589
+ face_value_net?: number;
590
+ }
591
+
592
+ declare interface TicketRelationshipData {
593
+ id: string;
594
+ type: string;
595
+ }
596
+
597
+ declare interface TicketRelationships {
598
+ events?: {
599
+ data: TicketRelationshipData[];
600
+ };
601
+ class_passes?: {
602
+ data: TicketRelationshipData[];
603
+ };
604
+ }
605
+
606
+ export declare type TicketResource = 'class_passes' | 'events' | 'events.location' | 'events.tickets' | 'events.attachments';
607
+
608
+ declare interface TicketResponse extends JsonApiResponse_2<BookwhenTicket> {
609
+ }
610
+
611
+ declare class TicketService implements ITicketService {
612
+ private axiosInstance;
613
+ constructor(axiosInstance: AxiosInstance);
614
+ getById(params: z.infer<typeof GetTicketByIdParamsSchema>): Promise<TicketResponse>;
615
+ getMultiple(params: GetMultipleTicketsParams): Promise<TicketsResponse>;
616
+ }
617
+
618
+ declare interface TicketsResponse extends JsonApiResponse_2<BookwhenTicket[]> {
619
+ }
620
+
252
621
  export { }