liteapi 0.1.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.
data/README.md ADDED
@@ -0,0 +1,938 @@
1
+ # LiteAPI Ruby SDK
2
+
3
+ Ruby SDK for [LiteAPI](https://liteapi.travel) travel services.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Configuration](#configuration)
9
+ - [Static Data](#static-data)
10
+ - [List of Countries](#list-of-countries)
11
+ - [List of Cities](#list-of-cities)
12
+ - [List of Hotels](#list-of-hotels)
13
+ - [Hotel Details](#hotel-details)
14
+ - [Hotel Reviews](#hotel-reviews)
15
+ - [Search Places](#search-places)
16
+ - [List of Currencies](#list-of-currencies)
17
+ - [IATA Codes](#iata-codes)
18
+ - [Hotel Facilities](#hotel-facilities)
19
+ - [Hotel Types](#hotel-types)
20
+ - [Hotel Chains](#hotel-chains)
21
+ - [Booking Flow](#booking-flow)
22
+ - [Search Rates](#search-rates)
23
+ - [Full Rates](#full-rates)
24
+ - [Minimum Rates](#minimum-rates)
25
+ - [Book](#book)
26
+ - [Prebook](#prebook)
27
+ - [Book](#book-1)
28
+ - [Booking Management](#booking-management)
29
+ - [Booking List](#booking-list)
30
+ - [Booking Details](#booking-details)
31
+ - [Cancel Booking](#cancel-booking)
32
+ - [Guests & Loyalty](#guests--loyalty)
33
+ - [Loyalty Program](#loyalty-program)
34
+ - [Enable Loyalty](#enable-loyalty)
35
+ - [Update Loyalty](#update-loyalty)
36
+ - [Guest Details](#guest-details)
37
+ - [Guest Bookings](#guest-bookings)
38
+ - [Vouchers](#vouchers)
39
+ - [List Vouchers](#list-vouchers)
40
+ - [Voucher Details](#voucher-details)
41
+ - [Create Voucher](#create-voucher)
42
+ - [Update Voucher](#update-voucher)
43
+ - [Update Voucher Status](#update-voucher-status)
44
+ - [Analytics](#analytics)
45
+ - [Weekly Analytics](#weekly-analytics)
46
+ - [Analytics Report](#analytics-report)
47
+ - [Market Analytics](#market-analytics)
48
+ - [Most Booked Hotels](#most-booked-hotels)
49
+ - [Error Handling](#error-handling)
50
+
51
+ ## Installation
52
+
53
+ Add to your Gemfile:
54
+
55
+ ```ruby
56
+ gem 'liteapi'
57
+ ```
58
+
59
+ Then run:
60
+
61
+ ```sh
62
+ bundle install
63
+ ```
64
+
65
+ ## Configuration
66
+
67
+ ```ruby
68
+ require 'liteapi'
69
+
70
+ # Global configuration
71
+ Liteapi.configure do |config|
72
+ config.api_key = ENV['LITEAPI_API_KEY']
73
+ end
74
+
75
+ client = Liteapi::Client.new
76
+
77
+ # Or pass API key directly
78
+ client = Liteapi::Client.new(api_key: 'your_api_key')
79
+ ```
80
+
81
+ ### Configuration Options
82
+
83
+ | Option | Default | Description |
84
+ |--------|---------|-------------|
85
+ | `api_key` | `ENV['LITEAPI_API_KEY']` | Your LiteAPI key |
86
+ | `base_url` | `https://api.liteapi.travel/v3.0` | API base URL |
87
+ | `book_base_url` | `https://book.liteapi.travel/v3.0` | Booking API base URL |
88
+ | `dashboard_base_url` | `https://da.liteapi.travel` | Analytics API base URL |
89
+ | `timeout` | `30` | Request timeout in seconds |
90
+ | `open_timeout` | `10` | Connection timeout in seconds |
91
+ | `max_retries` | `3` | Retries on 429/5xx errors |
92
+
93
+ ---
94
+
95
+ # Static Data
96
+
97
+ ## List of Countries
98
+
99
+ Returns the list of countries available along with their ISO-2 codes.
100
+
101
+ ```ruby
102
+ result = client.countries
103
+ ```
104
+
105
+ **Parameters:** None
106
+
107
+ **Returns:** Array of country objects
108
+
109
+ | Field | Type | Description |
110
+ |-------|------|-------------|
111
+ | `code` | String | Country code in ISO-2 format |
112
+ | `name` | String | Name of the country |
113
+
114
+ ---
115
+
116
+ ## List of Cities
117
+
118
+ Returns a list of city names from a specific country.
119
+
120
+ ```ruby
121
+ result = client.cities(country_code: 'IT')
122
+ ```
123
+
124
+ **Parameters:**
125
+
126
+ | Name | Type | Description | Required |
127
+ |------|------|-------------|----------|
128
+ | `country_code` | String | Country code in ISO-2 format (e.g., 'US', 'IT') | Yes |
129
+
130
+ **Returns:** Array of city objects
131
+
132
+ | Field | Type | Description |
133
+ |-------|------|-------------|
134
+ | `city` | String | Name of the city |
135
+
136
+ ---
137
+
138
+ ## List of Hotels
139
+
140
+ Returns a list of hotels based on search criteria.
141
+
142
+ ```ruby
143
+ result = client.hotels(country_code: 'IT', city_name: 'Rome')
144
+ ```
145
+
146
+ **Parameters:**
147
+
148
+ | Name | Type | Description | Required |
149
+ |------|------|-------------|----------|
150
+ | `country_code` | String | Country code in ISO-2 format | Yes |
151
+ | `city_name` | String | City name to filter by | No |
152
+ | `latitude` | Float | Latitude for geo search | No |
153
+ | `longitude` | Float | Longitude for geo search | No |
154
+ | `radius` | Integer | Search radius in km | No |
155
+ | `language` | String | Language code (default: 'en') | No |
156
+
157
+ **Returns:** Array of hotel objects
158
+
159
+ | Field | Type | Description |
160
+ |-------|------|-------------|
161
+ | `id` | String | Unique hotel identifier |
162
+ | `name` | String | Hotel name |
163
+ | `hotelDescription` | String | Hotel description |
164
+ | `country` | String | Country code |
165
+ | `city` | String | City name |
166
+ | `latitude` | Float | Latitude coordinate |
167
+ | `longitude` | Float | Longitude coordinate |
168
+ | `address` | String | Hotel address |
169
+ | `zip` | String | Postal code |
170
+ | `stars` | Integer | Star rating |
171
+ | `main_photo` | String | URL of main photo |
172
+
173
+ ---
174
+
175
+ ## Hotel Details
176
+
177
+ Returns all static content details for a specific hotel.
178
+
179
+ ```ruby
180
+ result = client.hotel('lp1897')
181
+ result = client.hotel('lp1897', language: 'fr')
182
+ ```
183
+
184
+ **Parameters:**
185
+
186
+ | Name | Type | Description | Required |
187
+ |------|------|-------------|----------|
188
+ | `hotel_id` | String | Unique hotel identifier | Yes |
189
+ | `language` | String | Language code for response | No |
190
+
191
+ **Returns:** Hotel object with full details
192
+
193
+ | Field | Type | Description |
194
+ |-------|------|-------------|
195
+ | `id` | String | Hotel identifier |
196
+ | `name` | String | Hotel name |
197
+ | `hotelDescription` | String | Full description |
198
+ | `checkinCheckoutTimes` | Hash | Check-in/out times |
199
+ | `hotelImages` | Array | Array of image objects |
200
+ | `currency` | String | Currency code |
201
+ | `country` | String | Country code |
202
+ | `city` | String | City name |
203
+ | `starRating` | Integer | Star rating |
204
+ | `location` | Hash | Latitude/longitude |
205
+ | `address` | String | Full address |
206
+ | `hotelFacilities` | Array | List of facilities |
207
+
208
+ ---
209
+
210
+ ## Hotel Reviews
211
+
212
+ Returns reviews for a specific hotel with optional sentiment analysis.
213
+
214
+ ```ruby
215
+ result = client.hotel_reviews(hotel_id: 'lp1897', limit: 100, sentiment: true)
216
+ ```
217
+
218
+ **Parameters:**
219
+
220
+ | Name | Type | Description | Required |
221
+ |------|------|-------------|----------|
222
+ | `hotel_id` | String | Unique hotel identifier | Yes |
223
+ | `limit` | Integer | Max reviews to return (max 1000) | No |
224
+ | `sentiment` | Boolean | Include sentiment analysis | No |
225
+
226
+ **Returns:** Array of review objects
227
+
228
+ | Field | Type | Description |
229
+ |-------|------|-------------|
230
+ | `rating` | Integer | Review rating |
231
+ | `text` | String | Review text |
232
+ | `sentimentAnalysis` | Hash | Sentiment data (if requested) |
233
+
234
+ ---
235
+
236
+ ## Search Places
237
+
238
+ Search for places and areas by query text.
239
+
240
+ ```ruby
241
+ result = client.places(query: 'Manhattan')
242
+ result = client.places(query: 'Rome', type: 'hotel', language: 'it')
243
+ ```
244
+
245
+ **Parameters:**
246
+
247
+ | Name | Type | Description | Required |
248
+ |------|------|-------------|----------|
249
+ | `query` | String | Search query (e.g., 'Manhattan') | Yes |
250
+ | `type` | String | Filter by type (e.g., 'hotel') | No |
251
+ | `language` | String | Language code (default: 'en') | No |
252
+
253
+ **Returns:** Array of place objects
254
+
255
+ ---
256
+
257
+ ## List of Currencies
258
+
259
+ Returns all available currency codes.
260
+
261
+ ```ruby
262
+ result = client.currencies
263
+ ```
264
+
265
+ **Parameters:** None
266
+
267
+ **Returns:** Array of currency objects
268
+
269
+ | Field | Type | Description |
270
+ |-------|------|-------------|
271
+ | `code` | String | Currency code |
272
+ | `currency` | String | Currency name |
273
+ | `countries` | Array | Countries using this currency |
274
+
275
+ ---
276
+
277
+ ## IATA Codes
278
+
279
+ Returns IATA codes for all available airports.
280
+
281
+ ```ruby
282
+ result = client.iata_codes
283
+ ```
284
+
285
+ **Parameters:** None
286
+
287
+ **Returns:** Array of IATA objects
288
+
289
+ | Field | Type | Description |
290
+ |-------|------|-------------|
291
+ | `code` | String | IATA code |
292
+ | `name` | String | Airport name |
293
+ | `latitude` | Float | Latitude |
294
+ | `longitude` | Float | Longitude |
295
+ | `countryCode` | String | Country code |
296
+
297
+ ---
298
+
299
+ ## Hotel Facilities
300
+
301
+ Returns the list of available hotel facilities.
302
+
303
+ ```ruby
304
+ result = client.hotel_facilities
305
+ ```
306
+
307
+ **Parameters:** None
308
+
309
+ **Returns:** Array of facility objects
310
+
311
+ ---
312
+
313
+ ## Hotel Types
314
+
315
+ Returns the list of available hotel types.
316
+
317
+ ```ruby
318
+ result = client.hotel_types
319
+ ```
320
+
321
+ **Parameters:** None
322
+
323
+ **Returns:** Array of hotel type objects
324
+
325
+ ---
326
+
327
+ ## Hotel Chains
328
+
329
+ Returns the list of available hotel chains.
330
+
331
+ ```ruby
332
+ result = client.hotel_chains
333
+ ```
334
+
335
+ **Parameters:** None
336
+
337
+ **Returns:** Array of hotel chain objects
338
+
339
+ ---
340
+
341
+ # Booking Flow
342
+
343
+ The booking flow consists of: **Search** → **Prebook** → **Book** → **Manage**
344
+
345
+ ## Search Rates
346
+
347
+ ### Full Rates
348
+
349
+ Returns all available rooms with rates and cancellation policies.
350
+
351
+ ```ruby
352
+ result = client.full_rates(
353
+ hotel_ids: ['lp3803c', 'lp1f982', 'lp19b70'],
354
+ checkin: '2025-03-15',
355
+ checkout: '2025-03-16',
356
+ occupancies: [
357
+ { rooms: 1, adults: 2, children: [2, 3] }
358
+ ],
359
+ currency: 'USD',
360
+ guest_nationality: 'US',
361
+ guest_id: 'guest_123' # optional, for loyalty pricing
362
+ )
363
+ ```
364
+
365
+ **Parameters:**
366
+
367
+ | Name | Type | Description | Required |
368
+ |------|------|-------------|----------|
369
+ | `hotel_ids` | Array | List of hotel IDs to search | Yes |
370
+ | `checkin` | String | Check-in date (YYYY-MM-DD) | Yes |
371
+ | `checkout` | String | Check-out date (YYYY-MM-DD) | Yes |
372
+ | `occupancies` | Array | Room occupancies (see below) | Yes |
373
+ | `currency` | String | Currency code (e.g., 'USD') | Yes |
374
+ | `guest_nationality` | String | Guest nationality ISO-2 code | Yes |
375
+ | `guest_id` | String | Guest ID for loyalty pricing | No |
376
+
377
+ **Occupancy object:**
378
+
379
+ | Field | Type | Description |
380
+ |-------|------|-------------|
381
+ | `rooms` | Integer | Number of rooms |
382
+ | `adults` | Integer | Number of adults |
383
+ | `children` | Array | Ages of children |
384
+
385
+ **Returns:** Hash with hotel rates
386
+
387
+ | Field | Type | Description |
388
+ |-------|------|-------------|
389
+ | `offerId` | String | Offer ID for prebook |
390
+ | `roomTypeId` | String | Room type identifier |
391
+ | `supplier` | String | Supplier name |
392
+ | `rates` | Array | Rate details with pricing |
393
+
394
+ ---
395
+
396
+ ### Minimum Rates
397
+
398
+ Returns only minimum rates per hotel for quick comparison.
399
+
400
+ ```ruby
401
+ result = client.min_rates(
402
+ hotel_ids: ['lp3803c', 'lp1f982'],
403
+ checkin: '2025-03-15',
404
+ checkout: '2025-03-16',
405
+ occupancies: [{ rooms: 1, adults: 2 }],
406
+ currency: 'USD',
407
+ guest_nationality: 'US'
408
+ )
409
+ ```
410
+
411
+ **Parameters:** Same as `full_rates` (except `guest_id`)
412
+
413
+ **Returns:** Array of minimum rate objects
414
+
415
+ | Field | Type | Description |
416
+ |-------|------|-------------|
417
+ | `hotelId` | String | Hotel identifier |
418
+ | `minRate` | Float | Minimum rate |
419
+
420
+ ---
421
+
422
+ ## Book
423
+
424
+ ### Prebook
425
+
426
+ Confirms room availability and pricing before booking.
427
+
428
+ ```ruby
429
+ result = client.prebook(offer_id: 'offer_abc123')
430
+ ```
431
+
432
+ **Parameters:**
433
+
434
+ | Name | Type | Description | Required |
435
+ |------|------|-------------|----------|
436
+ | `offer_id` | String | Offer ID from full_rates response | Yes |
437
+
438
+ **Returns:** Prebook confirmation
439
+
440
+ | Field | Type | Description |
441
+ |-------|------|-------------|
442
+ | `prebookId` | String | Prebook ID for booking |
443
+ | `hotelId` | String | Hotel identifier |
444
+ | `currency` | String | Currency code |
445
+ | `price` | Float | Total price |
446
+ | `priceDifferencePercent` | Float | Price change percentage |
447
+ | `cancellationChanged` | Boolean | If cancellation policy changed |
448
+ | `roomTypes` | Array | Room and rate details |
449
+
450
+ ---
451
+
452
+ ### Book
453
+
454
+ Completes the booking with guest and payment information.
455
+
456
+ ```ruby
457
+ result = client.book(
458
+ prebook_id: 'prebook_xyz789',
459
+ guest: {
460
+ first_name: 'John',
461
+ last_name: 'Doe',
462
+ email: 'john.doe@example.com'
463
+ },
464
+ payment: {
465
+ holder_name: 'John Doe',
466
+ card_number: '4111111111111111',
467
+ expire_date: '12/25',
468
+ cvc: '123'
469
+ },
470
+ client_reference: 'my-booking-123' # optional
471
+ )
472
+ ```
473
+
474
+ **Parameters:**
475
+
476
+ | Name | Type | Description | Required |
477
+ |------|------|-------------|----------|
478
+ | `prebook_id` | String | Prebook ID from prebook response | Yes |
479
+ | `guest` | Hash | Guest information (see below) | Yes |
480
+ | `payment` | Hash | Payment information (see below) | Yes |
481
+ | `client_reference` | String | Your reference for the booking | No |
482
+
483
+ **Guest object:**
484
+
485
+ | Field | Type | Description |
486
+ |-------|------|-------------|
487
+ | `first_name` | String | Guest first name |
488
+ | `last_name` | String | Guest last name |
489
+ | `email` | String | Guest email |
490
+
491
+ **Payment object:**
492
+
493
+ | Field | Type | Description |
494
+ |-------|------|-------------|
495
+ | `holder_name` | String | Cardholder name |
496
+ | `card_number` | String | Credit card number |
497
+ | `expire_date` | String | Expiry date (MM/YY) |
498
+ | `cvc` | String | CVC code |
499
+
500
+ **Returns:** Booking confirmation
501
+
502
+ | Field | Type | Description |
503
+ |-------|------|-------------|
504
+ | `bookingId` | String | Unique booking ID |
505
+ | `clientReference` | String | Your reference |
506
+ | `status` | String | Booking status |
507
+ | `hotelConfirmationCode` | String | Hotel confirmation code |
508
+ | `checkin` | String | Check-in date |
509
+ | `checkout` | String | Check-out date |
510
+ | `hotel` | Hash | Hotel details |
511
+ | `bookedRooms` | Array | Booked room details |
512
+ | `guestInfo` | Hash | Guest information |
513
+ | `price` | Float | Total price |
514
+ | `currency` | String | Currency code |
515
+ | `cancellationPolicies` | Hash | Cancellation policy details |
516
+
517
+ ---
518
+
519
+ ## Booking Management
520
+
521
+ ### Booking List
522
+
523
+ Returns bookings by client reference.
524
+
525
+ ```ruby
526
+ result = client.bookings(client_reference: 'my-booking-123')
527
+ ```
528
+
529
+ **Parameters:**
530
+
531
+ | Name | Type | Description | Required |
532
+ |------|------|-------------|----------|
533
+ | `client_reference` | String | Your booking reference | Yes |
534
+
535
+ **Returns:** Array of booking objects
536
+
537
+ | Field | Type | Description |
538
+ |-------|------|-------------|
539
+ | `bookingId` | String | Booking ID |
540
+
541
+ ---
542
+
543
+ ### Booking Details
544
+
545
+ Returns details for a specific booking.
546
+
547
+ ```ruby
548
+ result = client.booking('booking_abc123')
549
+ ```
550
+
551
+ **Parameters:**
552
+
553
+ | Name | Type | Description | Required |
554
+ |------|------|-------------|----------|
555
+ | `booking_id` | String | Booking ID | Yes |
556
+
557
+ **Returns:** Full booking object (same as book response)
558
+
559
+ ---
560
+
561
+ ### Cancel Booking
562
+
563
+ Cancels an existing booking (subject to cancellation policy).
564
+
565
+ ```ruby
566
+ result = client.cancel_booking('booking_abc123')
567
+ ```
568
+
569
+ **Parameters:**
570
+
571
+ | Name | Type | Description | Required |
572
+ |------|------|-------------|----------|
573
+ | `booking_id` | String | Booking ID to cancel | Yes |
574
+
575
+ **Returns:** Cancellation result
576
+
577
+ | Field | Type | Description |
578
+ |-------|------|-------------|
579
+ | `bookingId` | String | Booking ID |
580
+ | `status` | String | New status ('cancelled') |
581
+ | `cancellation_fee` | Float | Cancellation fee charged |
582
+ | `refund_amount` | Float | Amount refunded |
583
+ | `currency` | String | Currency code |
584
+
585
+ ---
586
+
587
+ # Guests & Loyalty
588
+
589
+ ## Loyalty Program
590
+
591
+ Returns current loyalty program settings.
592
+
593
+ ```ruby
594
+ result = client.loyalty
595
+ ```
596
+
597
+ **Parameters:** None
598
+
599
+ **Returns:** Loyalty program object
600
+
601
+ | Field | Type | Description |
602
+ |-------|------|-------------|
603
+ | `status` | String | Program status ('enabled' or 'disabled') |
604
+ | `cashbackRate` | Float | Cashback rate (e.g., 0.03 = 3%) |
605
+
606
+ ---
607
+
608
+ ## Enable Loyalty
609
+
610
+ Creates a new loyalty program.
611
+
612
+ ```ruby
613
+ result = client.enable_loyalty(status: 'enabled', cashback_rate: 0.03)
614
+ ```
615
+
616
+ **Parameters:**
617
+
618
+ | Name | Type | Description | Required |
619
+ |------|------|-------------|----------|
620
+ | `status` | String | Program status ('enabled' or 'disabled') | Yes |
621
+ | `cashback_rate` | Float | Cashback rate (e.g., 0.03 = 3%) | Yes |
622
+
623
+ **Returns:** Loyalty program object
624
+
625
+ ---
626
+
627
+ ## Update Loyalty
628
+
629
+ Updates existing loyalty program settings.
630
+
631
+ ```ruby
632
+ result = client.update_loyalty(status: 'enabled', cashback_rate: 0.05)
633
+ ```
634
+
635
+ **Parameters:** Same as `enable_loyalty`
636
+
637
+ **Returns:** Updated loyalty program object
638
+
639
+ ---
640
+
641
+ ## Guest Details
642
+
643
+ Retrieves detailed information about a guest.
644
+
645
+ ```ruby
646
+ result = client.guest(123)
647
+ ```
648
+
649
+ **Parameters:**
650
+
651
+ | Name | Type | Description | Required |
652
+ |------|------|-------------|----------|
653
+ | `guest_id` | String/Integer | Guest identifier | Yes |
654
+
655
+ **Returns:** Guest object
656
+
657
+ | Field | Type | Description |
658
+ |-------|------|-------------|
659
+ | `id` | Integer | Guest identifier |
660
+ | `firstName` | String | First name |
661
+ | `lastName` | String | Last name |
662
+ | `email` | String | Email address |
663
+ | `loyaltyPoints` | Integer | Accumulated points |
664
+
665
+ ---
666
+
667
+ ## Guest Bookings
668
+
669
+ Retrieves all bookings for a guest with loyalty information.
670
+
671
+ ```ruby
672
+ result = client.guest_bookings(123)
673
+ ```
674
+
675
+ **Parameters:**
676
+
677
+ | Name | Type | Description | Required |
678
+ |------|------|-------------|----------|
679
+ | `guest_id` | String/Integer | Guest identifier | Yes |
680
+
681
+ **Returns:** Array of booking objects with loyalty data
682
+
683
+ | Field | Type | Description |
684
+ |-------|------|-------------|
685
+ | `bookingId` | String | Booking identifier |
686
+ | `loyaltyPoints` | Integer | Points earned |
687
+ | `cashbackApplied` | Float | Cashback amount |
688
+
689
+ ---
690
+
691
+ # Vouchers
692
+
693
+ ## List Vouchers
694
+
695
+ Retrieves all available vouchers.
696
+
697
+ ```ruby
698
+ result = client.vouchers
699
+ ```
700
+
701
+ **Parameters:** None
702
+
703
+ **Returns:** Array of voucher objects
704
+
705
+ | Field | Type | Description |
706
+ |-------|------|-------------|
707
+ | `id` | Integer | Voucher identifier |
708
+ | `voucher_code` | String | Voucher code |
709
+ | `discount_type` | String | 'percentage' or 'fixed' |
710
+ | `discount_value` | Float | Discount amount |
711
+ | `status` | String | 'active' or 'inactive' |
712
+
713
+ ---
714
+
715
+ ## Voucher Details
716
+
717
+ Retrieves details for a specific voucher.
718
+
719
+ ```ruby
720
+ result = client.voucher(42)
721
+ ```
722
+
723
+ **Parameters:**
724
+
725
+ | Name | Type | Description | Required |
726
+ |------|------|-------------|----------|
727
+ | `voucher_id` | String/Integer | Voucher identifier | Yes |
728
+
729
+ **Returns:** Voucher object with full details
730
+
731
+ ---
732
+
733
+ ## Create Voucher
734
+
735
+ Creates a new voucher.
736
+
737
+ ```ruby
738
+ result = client.create_voucher(
739
+ voucher_code: 'SUMMER20',
740
+ discount_type: 'percentage',
741
+ discount_value: 20,
742
+ minimum_spend: 100,
743
+ maximum_discount_amount: 50,
744
+ currency: 'USD',
745
+ validity_start: '2025-06-01',
746
+ validity_end: '2025-08-31',
747
+ usages_limit: 100,
748
+ status: 'active'
749
+ )
750
+ ```
751
+
752
+ **Parameters:**
753
+
754
+ | Name | Type | Description | Required |
755
+ |------|------|-------------|----------|
756
+ | `voucher_code` | String | Unique voucher code | Yes |
757
+ | `discount_type` | String | 'percentage' or 'fixed' | Yes |
758
+ | `discount_value` | Float | Discount value | Yes |
759
+ | `minimum_spend` | Float | Minimum spend to apply | Yes |
760
+ | `maximum_discount_amount` | Float | Maximum discount | Yes |
761
+ | `currency` | String | Currency code | Yes |
762
+ | `validity_start` | String | Start date (YYYY-MM-DD) | Yes |
763
+ | `validity_end` | String | End date (YYYY-MM-DD) | Yes |
764
+ | `usages_limit` | Integer | Maximum redemptions | Yes |
765
+ | `status` | String | 'active' or 'inactive' | Yes |
766
+
767
+ **Returns:** Creation confirmation
768
+
769
+ ---
770
+
771
+ ## Update Voucher
772
+
773
+ Updates an existing voucher.
774
+
775
+ ```ruby
776
+ result = client.update_voucher(42,
777
+ voucher_code: 'SUMMER25',
778
+ discount_type: 'percentage',
779
+ discount_value: 25,
780
+ # ... all other parameters required
781
+ )
782
+ ```
783
+
784
+ **Parameters:** `voucher_id` plus all parameters from `create_voucher`
785
+
786
+ **Returns:** Update confirmation
787
+
788
+ ---
789
+
790
+ ## Update Voucher Status
791
+
792
+ Activates or deactivates a voucher.
793
+
794
+ ```ruby
795
+ result = client.update_voucher_status(42, status: 'inactive')
796
+ ```
797
+
798
+ **Parameters:**
799
+
800
+ | Name | Type | Description | Required |
801
+ |------|------|-------------|----------|
802
+ | `voucher_id` | String/Integer | Voucher identifier | Yes |
803
+ | `status` | String | 'active' or 'inactive' | Yes |
804
+
805
+ **Returns:** Status update confirmation
806
+
807
+ ---
808
+
809
+ # Analytics
810
+
811
+ ## Weekly Analytics
812
+
813
+ Fetches weekly analytics data for a date range.
814
+
815
+ ```ruby
816
+ result = client.weekly_analytics(from: '2025-01-01', to: '2025-01-07')
817
+ ```
818
+
819
+ **Parameters:**
820
+
821
+ | Name | Type | Description | Required |
822
+ |------|------|-------------|----------|
823
+ | `from` | String | Start date (YYYY-MM-DD) | Yes |
824
+ | `to` | String | End date (YYYY-MM-DD) | Yes |
825
+
826
+ **Returns:** Weekly analytics object
827
+
828
+ | Field | Type | Description |
829
+ |-------|------|-------------|
830
+ | `totalBookings` | Integer | Total bookings |
831
+ | `totalRevenue` | Float | Total revenue |
832
+
833
+ ---
834
+
835
+ ## Analytics Report
836
+
837
+ Fetches a detailed analytics report.
838
+
839
+ ```ruby
840
+ result = client.analytics_report(from: '2025-01-01', to: '2025-01-31')
841
+ ```
842
+
843
+ **Parameters:** Same as `weekly_analytics`
844
+
845
+ **Returns:** Detailed report object
846
+
847
+ | Field | Type | Description |
848
+ |-------|------|-------------|
849
+ | `totalRevenue` | Float | Total revenue |
850
+ | `salesRevenue` | Float | Sales revenue |
851
+
852
+ ---
853
+
854
+ ## Market Analytics
855
+
856
+ Fetches market-level analytics data.
857
+
858
+ ```ruby
859
+ result = client.market_analytics(from: '2025-01-01', to: '2025-01-31')
860
+ ```
861
+
862
+ **Parameters:** Same as `weekly_analytics`
863
+
864
+ **Returns:** Market analytics object
865
+
866
+ | Field | Type | Description |
867
+ |-------|------|-------------|
868
+ | `markets` | Array | Market breakdown by country |
869
+
870
+ ---
871
+
872
+ ## Most Booked Hotels
873
+
874
+ Fetches data on most booked hotels.
875
+
876
+ ```ruby
877
+ result = client.most_booked_hotels(from: '2025-01-01', to: '2025-01-31')
878
+ ```
879
+
880
+ **Parameters:** Same as `weekly_analytics`
881
+
882
+ **Returns:** Array of hotel objects
883
+
884
+ | Field | Type | Description |
885
+ |-------|------|-------------|
886
+ | `hotelId` | String | Hotel identifier |
887
+ | `bookings` | Integer | Number of bookings |
888
+
889
+ ---
890
+
891
+ # Error Handling
892
+
893
+ The SDK raises specific exceptions for different error types:
894
+
895
+ ```ruby
896
+ begin
897
+ client.hotel('invalid_id')
898
+ rescue Liteapi::AuthenticationError => e
899
+ # 401 - Invalid API key
900
+ puts "Auth error: #{e.message}"
901
+ puts "Status: #{e.status}"
902
+ rescue Liteapi::NotFoundError => e
903
+ # 404 - Resource not found
904
+ puts "Not found: #{e.message}"
905
+ rescue Liteapi::ValidationError => e
906
+ # 422 - Invalid request parameters
907
+ puts "Validation error: #{e.message}"
908
+ rescue Liteapi::RateLimitError => e
909
+ # 429 - Too many requests
910
+ puts "Rate limited: #{e.message}"
911
+ rescue Liteapi::ServerError => e
912
+ # 5xx - Server error
913
+ puts "Server error: #{e.message}"
914
+ rescue Liteapi::APIError => e
915
+ # Other API errors
916
+ puts "API error (#{e.status}): #{e.message}"
917
+ puts "Response: #{e.response}"
918
+ end
919
+ ```
920
+
921
+ All API errors include:
922
+ - `message` - Error description
923
+ - `status` - HTTP status code
924
+ - `code` - API error code
925
+ - `response` - Full error response
926
+
927
+ ---
928
+
929
+ ## Development
930
+
931
+ ```sh
932
+ bundle install
933
+ bundle exec rake test
934
+ ```
935
+
936
+ ## License
937
+
938
+ MIT License. See [LICENSE.txt](LICENSE.txt).