ticketmeister 0.1.2

A lightweight and intuitive library for accessing ticket master api in rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
use api_request_utils_rs::{
    ParameterHashMap,
    serde_json::{
        Value,
        to_value
    }
};

use crate::{
    Unit,
    Market,
    SortingOrder,
    ClassificationName,
    Dma,
    Decision,
};

pub struct EventSearchQuery<'a>(pub(super) ParameterHashMap<'a>);
pub struct AttractionSearchQuery<'a>(pub(super) ParameterHashMap<'a>);
pub struct ClassificationSearchQuery<'a>(pub(super) ParameterHashMap<'a>);
pub struct VenueSearchQuery<'a>(pub(super) ParameterHashMap<'a>);

impl<'a> VenueSearchQuery<'a> {
    pub fn new() -> Self {
        let hashmap = ParameterHashMap::new();
        Self(hashmap)
    }
    /// Filter entities by its id
    pub fn with_id(mut self, id: &'a str) -> Self {
        self.0.insert("id", Value::from(id));
        self
    }

    /// Keyword to search on	
    pub fn with_keyword(mut self, keyword: &'a str) -> Self {
        self.0.insert("keyword", Value::from(keyword));
        self
    }

    /// Radius of the area in which we want to search for events.
    pub fn with_radius(mut self, radius: u16) -> Self {
        self.0.insert("radius", Value::from(radius));
        self
    }

    /// Unit of the radius
    pub fn with_unit(mut self, unit: Unit) -> Self {
        self.0.insert("unit", to_value(unit).unwrap());
        self
    }

    /// The locale in ISO code format. Multiple comma-separated values can be provided. When omitting the country part of the code (e.g. only 'en' or 'fr') then the first matching locale is used. When using a '*' it matches all locales. '*' can only be used at the end (e.g. 'en-us,en,*')
    pub fn with_locale(mut self, locale: &'a str) -> Self {
        self.0.insert("locale", Value::from(locale));
        self
    }

    pub fn with_country_code(mut self, country_code: &'a str) -> Self {
        self.0.insert("countryCode", Value::from(country_code));
        self
    }

    pub fn with_state_code(mut self, state_code: &'a str) -> Self {
        self.0.insert("stateCode", Value::from(state_code));
        self
    }
     /// Page size of the response 
     pub fn with_size(mut self, size: u16) -> Self {
        self.0.insert("size", Value::from(size));
        self
    }  

    /// Page number
    pub fn with_page(mut self, page: u16) -> Self {
        self.0.insert("page", Value::from(page));
        self
    }
    /// Sorting order of the search result.
    pub fn with_sort(mut self, sort: SortingOrder) -> Self {
        self.0.insert("sort", to_value(sort).unwrap());
        self
    }

    pub fn with_geo_point(mut self, geo_point: &'a str) -> Self {
        self.0.insert("geoPoint", Value::from(geo_point));
        self
    }

    /// Popularity boost by country, default is us.
    pub fn with_preferred_country_is_usa(mut self, result : bool) -> Self {
        let string = if result {
            "usa"
        }
        else {
            "ca"
        };

        self.0.insert("preferredCountry", Value::from(string));
        self
    }

    /// yes, to include spell check suggestions in the response.
    pub fn with_include_spellcheck(mut self, include_spellcheck: Decision) -> Self {
        self.0.insert("includeSpellcheck", to_value(include_spellcheck).unwrap());
        self
    }

    /// Filter entities based on domains they are available on
    pub fn with_domain(mut self, domain: &'a [&'a str]) -> Self {
        self.0.insert("domain", Value::from(domain));
        self
    }
}

impl<'a> ClassificationSearchQuery<'a> {
    pub fn new() -> Self {
        let hashmap = ParameterHashMap::new();
        Self(hashmap)
    }

    /// Filter entities by its id
    pub fn with_id(mut self, id: &'a str) -> Self {
        self.0.insert("id", Value::from(id));
        self
    }

    /// Keyword to search on	
    pub fn with_keyword(mut self, keyword: &'a str) -> Self {
        self.0.insert("keyword", Value::from(keyword));
        self
    }    
    /// The locale in ISO code format. Multiple comma-separated values can be provided. When omitting the country part of the code (e.g. only 'en' or 'fr') then the first matching locale is used. When using a '*' it matches all locales. '*' can only be used at the end (e.g. 'en-us,en,*')
     pub fn with_locale(mut self, locale: &'a str) -> Self {
        self.0.insert("locale", Value::from(locale));
        self
    }

    /// Page size of the response 
    pub fn with_size(mut self, size: u16) -> Self {
        self.0.insert("size", Value::from(size));
        self
    }  

    /// Page number
    pub fn with_page(mut self, page: u16) -> Self {
        self.0.insert("page", Value::from(page));
        self
    }

    /// Sorting order of the search result.
    pub fn with_sort(mut self, sort: SortingOrder) -> Self {
        self.0.insert("sort", to_value(sort).unwrap());
        self
    }

    
    /// Popularity boost by country, default is us.
    pub fn with_preferred_country_is_usa(mut self, result : bool) -> Self {
        let string = if result {
            "usa"
        }
        else {
            "ca"
        };

        self.0.insert("preferredCountry", Value::from(string));
        self
    }

    /// yes, to include spell check suggestions in the response.
    pub fn with_include_spellcheck(mut self, include_spellcheck: Decision) -> Self {
        self.0.insert("includeSpellcheck", to_value(include_spellcheck).unwrap());
        self
    }

    /// Filter entities based on domains they are available on
    pub fn with_domain(mut self, domain: &'a [&'a str]) -> Self {
        self.0.insert("domain", Value::from(domain));
        self
    }
}

impl<'a> AttractionSearchQuery<'a> {
    pub fn new() -> Self {
        let hashmap = ParameterHashMap::new();
        Self(hashmap)
    }

    
    /// Filter entities by its id
    pub fn with_id(mut self, id: &'a str) -> Self {
        self.0.insert("id", Value::from(id));
        self
    }

    /// Keyword to search on	
    pub fn with_keyword(mut self, keyword: &'a str) -> Self {
        self.0.insert("keyword", Value::from(keyword));
        self
    }

    /// The locale in ISO code format. Multiple comma-separated values can be provided. When omitting the country part of the code (e.g. only 'en' or 'fr') then the first matching locale is used. When using a '*' it matches all locales. '*' can only be used at the end (e.g. 'en-us,en,*')
    pub fn with_locale(mut self, locale: &'a str) -> Self {
        self.0.insert("locale", Value::from(locale));
        self
    }

    /// Page size of the response 
    pub fn with_size(mut self, size: u16) -> Self {
        self.0.insert("size", Value::from(size));
        self
    }  

    /// Page number
    pub fn with_page(mut self, page: u16) -> Self {
        self.0.insert("page", Value::from(page));
        self
    }

    /// Sorting order of the search result.
    pub fn with_sort(mut self, sort: SortingOrder) -> Self {
        self.0.insert("sort", to_value(sort).unwrap());
        self
    }

    /// Filter attractions by classification name
    pub fn with_classification_name(mut self, classification_name: ClassificationName) -> Self {
        self.0.insert("classificationName", to_value(classification_name).unwrap());
        self
    }

    /// Filter attractions by classification id
    pub fn with_classification_id(mut self, classification_id: &'a[&'a str]) -> Self {
        self.0.insert("classificationId", Value::from(classification_id));
        self
    }

    /// Filter by classification that are family-friendly
    pub fn with_include_family(mut self, include_family: Decision) -> Self {
        self.0.insert("includeFamily", to_value(include_family).unwrap());
        self
    }
    
    /// Filter attractions by segmentId   
    pub fn with_segment_id(mut self, segment: &'a str) -> Self {
        self.0.insert("segmentId", Value::from(segment));
        self
    } 

    /// Filter attractions by genreId
    pub fn with_genre_id(mut self, genre_id: &'a [&'a str]) -> Self {
        self.0.insert("genreId", Value::from(genre_id));
        self
    }

    /// Filter attractions by subGenreId
    pub fn with_sub_genre_id(mut self, sub_genre_id: &'a [&'a str]) -> Self {
        self.0.insert("subGenreId", Value::from(sub_genre_id));
        self
    }

    /// 	Filter attractions by typeId
    pub fn with_type_id(mut self, type_id: &'a [&'a str]) -> Self {
        self.0.insert("typeId", Value::from(type_id));
        self
    }

    ///Filter attractions by subTypeId
    pub fn with_sub_type_id(mut self, sub_type_id: &'a [&'a str]) -> Self {
        self.0.insert("subTypeId", Value::from(sub_type_id));
        self
    }

    /// Popularity boost by country, default is us.
    pub fn with_preferred_country_is_usa(mut self, result : bool) -> Self {
        let string = if result {
            "usa"
        }
        else {
            "ca"
        };

        self.0.insert("preferredCountry", Value::from(string));
        self
    }
}

impl<'a> EventSearchQuery<'a> {
    pub fn new() -> Self {
        let hashmap = ParameterHashMap::new();
        Self(hashmap)
    }

    /// Filter entities by its id
    pub fn with_id(mut self, id: &'a str) -> Self {
        self.0.insert("id", Value::from(id));
        self
    }

    /// Keyword to search on	
    pub fn with_keyword(mut self, keyword: &'a str) -> Self {
        self.0.insert("keyword", Value::from(keyword));
        self
    }

    /// Filter by attraction id
    pub fn with_attraction_id(mut self, attraction_id: &'a str) -> Self {
        self.0.insert("attractionId", Value::from(attraction_id));
        self
    }

    /// Filter by venue id
    pub fn with_venue_id(mut self, venue_id: &'a str) -> Self {
        self.0.insert("venueId", Value::from(venue_id));
        self
    }

    /// Filter by postal code / zipcode
    pub fn with_postal_code(mut self, postal_code: &'a str) -> Self {
        self.0.insert("postalCode", Value::from(postal_code));
        self
    }

    /// Radius of the area in which we want to search for events.
    pub fn with_radius(mut self, radius: u16) -> Self {
        self.0.insert("radius", Value::from(radius));
        self
    }

    /// Unit of the radius
    pub fn with_unit(mut self, unit: Unit) -> Self {
        self.0.insert("unit", to_value(unit).unwrap());
        self
    }

    /// The locale in ISO code format. Multiple comma-separated values can be provided. When omitting the country part of the code (e.g. only 'en' or 'fr') then the first matching locale is used. When using a '*' it matches all locales. '*' can only be used at the end (e.g. 'en-us,en,*')
    pub fn with_locale(mut self, locale: &'a str) -> Self {
        self.0.insert("locale", Value::from(locale));
        self
    }

    /// Filter by market id
    pub fn with_market(mut self, market: Market) -> Self {
        self.0.insert("marketId", to_value(market).unwrap());
        self
    }

    /// Filter with a start date after this date
    pub fn with_start_date_time(mut self, start_date_time: &'a str) -> Self {
        self.0.insert("startDateTime", Value::from(start_date_time));
        self
    }

    /// Filter with a start date before this date
    pub fn with_end_date_time(mut self, end_date_time: &'a str) -> Self {
        self.0.insert("endDateTime", Value::from(end_date_time));
        self
    }

      /// yes, to include with date to be announce (TBA)
      pub fn with_include_tba(mut self, include_tba: Decision) -> Self {
        self.0.insert("includeTBA", to_value(include_tba).unwrap());
        self
    }

    /// yes, to include with a date to be defined (TBD)
    pub fn with_include_tbd(mut self, include_tbd: Decision) -> Self {
        self.0.insert("includeTBD", to_value(include_tbd).unwrap());
        self
    }

    /// Page size of the response 
    pub fn with_size(mut self, size: u16) -> Self {
        self.0.insert("size", Value::from(size));
        self
    }  

    /// Page number
    pub fn with_page(mut self, page: u16) -> Self {
        self.0.insert("page", Value::from(page));
        self
    }
    /// Sorting order of the search result.
    pub fn with_sort(mut self, sort: SortingOrder) -> Self {
        self.0.insert("sort", to_value(sort).unwrap());
        self
    }

    pub fn with_onsale_start_date_time(mut self, onsale_start_date_time: &'a str) -> Self {
        self.0.insert("onsaleStartDateTime", Value::from(onsale_start_date_time));
        self
    }

    pub fn with_onsale_end_date_time(mut self, onsale_end_date_time: &'a str) -> Self {
        self.0.insert("onsaleEndDateTime", Value::from(onsale_end_date_time));
        self
    }

    pub fn with_city(mut self, city: &'a [&'a str]) -> Self {
        self.0.insert("city", Value::from(city));
        self
    }

    pub fn with_country_code(mut self, country_code: &'a str) -> Self {
        self.0.insert("countryCode", Value::from(country_code));
        self
    }

    pub fn with_state_code(mut self, state_code: &'a str) -> Self {
        self.0.insert("stateCode", Value::from(state_code));
        self
    }

    /// Filter attractions by classification name
    pub fn with_classification_name(mut self, classification_name: ClassificationName) -> Self {
        self.0.insert("classificationName", to_value(classification_name).unwrap());
        self
    }

    /// Filter attractions by classification id
    pub fn with_classification_id(mut self, classification_id: &'a[&'a str]) -> Self {
        self.0.insert("classificationId", Value::from(classification_id));
        self
    }

    pub fn with_local_start_date_time(mut self, local_start_date_time: &'a [&'a str]) -> Self {
        self.0.insert("localStartDateTime", Value::from(local_start_date_time));
        self
    }

    pub fn with_local_start_end_date_time(mut self, local_start_end_date_time: &'a [&'a str]) -> Self {
        self.0.insert("localStartEndDateTime", Value::from(local_start_end_date_time));
        self
    }

    pub fn with_start_end_date_time(mut self, start_end_date_time: &'a [&'a str]) -> Self {
        self.0.insert("startEndDateTime", Value::from(start_end_date_time));
        self
    }

    pub fn with_public_visibility_start_date_time(mut self, public_visibility_start_date_time: &'a str) -> Self {
        self.0.insert("publicVisibilityStartDateTime", Value::from(public_visibility_start_date_time));
        self
    }

    pub fn with_pre_sale_date_time(mut self, pre_sale_date_time: &'a [&'a str]) -> Self {
        self.0.insert("preSaleDateTime", Value::from(pre_sale_date_time));
        self
    }

    pub fn with_onsale_on_start_date(mut self, onsale_on_start_date: &'a str) -> Self {
        self.0.insert("onsaleOnStartDate", Value::from(onsale_on_start_date));
        self
    }

    pub fn with_dma(mut self, dma: Dma) -> Self {
        self.0.insert("dmaId", to_value(dma).unwrap());
        self
    }

    pub fn with_onsale_on_after_start_date(mut self, onsale_on_after_start_date: &'a str) -> Self {
        self.0.insert("onsaleOnAfterStartDate", Value::from(onsale_on_after_start_date));
        self
    }

    pub fn with_collection_id(mut self, collection_id: &'a [&'a str]) -> Self {
        self.0.insert("collectionId", Value::from(collection_id));
        self
    }

    pub fn with_segment_id(mut self, segment_id: &'a [&'a str]) -> Self {
        self.0.insert("segmentId", Value::from(segment_id));
        self
    }

    pub fn with_segment_name(mut self, segment_name: &'a [&'a str]) -> Self {
        self.0.insert("segmentName", Value::from(segment_name));
        self
    }

    /// Filter by classification that are family-friendly
    pub fn with_include_family(mut self, include_family: Decision) -> Self {
        self.0.insert("includeFamily", to_value(include_family).unwrap());
        self
    }

    pub fn with_promoter_id(mut self, promoter_id: &'a str) -> Self {
        self.0.insert("promoterId", Value::from(promoter_id));
        self
    }

    /// Filter attractions by genreId
    pub fn with_genre_id(mut self, genre_id: &'a [&'a str]) -> Self {
        self.0.insert("genreId", Value::from(genre_id));
        self
    }

    /// Filter attractions by subGenreId
    pub fn with_sub_genre_id(mut self, sub_genre_id: &'a [&'a str]) -> Self {
        self.0.insert("subGenreId", Value::from(sub_genre_id));
        self
    }

    /// 	Filter attractions by typeId
    pub fn with_type_id(mut self, type_id: &'a [&'a str]) -> Self {
        self.0.insert("typeId", Value::from(type_id));
        self
    }

    ///Filter attractions by subTypeId
    pub fn with_sub_type_id(mut self, sub_type_id: &'a [&'a str]) -> Self {
        self.0.insert("subTypeId", Value::from(sub_type_id));
        self
    }

    pub fn with_geo_point(mut self, geo_point: &'a str) -> Self {
        self.0.insert("geoPoint", Value::from(geo_point));
        self
    }

    /// Popularity boost by country, default is us.
    pub fn with_preferred_country_is_usa(mut self, result : bool) -> Self {
        let string = if result {
            "usa"
        }
        else {
            "ca"
        };

        self.0.insert("preferredCountry", Value::from(string));
        self
    }

    /// yes, to include spell check suggestions in the response.
    pub fn with_include_spellcheck(mut self, include_spellcheck: Decision) -> Self {
        self.0.insert("includeSpellcheck", to_value(include_spellcheck).unwrap());
        self
    }

    /// Filter entities based on domains they are available on
    pub fn with_domain(mut self, domain: &'a [&'a str]) -> Self {
        self.0.insert("domain", Value::from(domain));
        self
    }
}