liteapi 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +6 -0
- data/lib/liteapi/analytics.rb +16 -28
- data/lib/liteapi/booking.rb +29 -44
- data/lib/liteapi/client.rb +31 -0
- data/lib/liteapi/guests.rb +14 -33
- data/lib/liteapi/rates.rb +8 -46
- data/lib/liteapi/static_data.rb +40 -37
- data/lib/liteapi/version.rb +1 -1
- data/lib/liteapi/vouchers.rb +27 -71
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08a9d9d70ebb966ca94dc5b5da0038346c22444d301ab2591fa874c91ae65676'
|
|
4
|
+
data.tar.gz: 518f4ec38d0cae6ba00e2aac542e58333ee8ed01bb282de2808cb2b67e9a6761
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 657351d9a1174cde8e6425236c0e0cca813f3c4784adcffc68ee97e80f5306824ba47f035fb32cde698f38d299993834e7d3995a341862ffc1a8766244a7876f
|
|
7
|
+
data.tar.gz: 781c345554af02201d60f6db7bd93a7d371690b976e7312eb217d56f2c4c0962e49a101342daef67cea1f5695b5d7d02f93f3cee47320430b220bf2e1e6b9705
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2025-01-12
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **Dynamic parameters**: All methods now accept arbitrary keyword arguments that are automatically converted from Ruby `snake_case` to API `camelCase`. This allows using new API parameters without SDK updates.
|
|
8
|
+
- Nested hashes and arrays are recursively transformed for POST/PUT request bodies.
|
|
9
|
+
- Array parameters in GET requests are joined with commas for query strings.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Properly handle nested structures like `occupancies` in rates requests.
|
|
14
|
+
|
|
3
15
|
## [0.1.0] - 2025-01-12
|
|
4
16
|
|
|
5
17
|
### Added
|
data/README.md
CHANGED
|
@@ -90,6 +90,12 @@ client = Liteapi::Client.new(api_key: 'your_api_key')
|
|
|
90
90
|
| `open_timeout` | `10` | Connection timeout in seconds |
|
|
91
91
|
| `max_retries` | `3` | Retries on 429/5xx errors |
|
|
92
92
|
|
|
93
|
+
### API Documentation
|
|
94
|
+
|
|
95
|
+
For the full list of available parameters for each endpoint, see the official API documentation at **[docs.liteapi.travel](https://docs.liteapi.travel)**.
|
|
96
|
+
|
|
97
|
+
This SDK uses Ruby-style `snake_case` parameter names which are automatically converted to the API's `camelCase` format. For example, `country_code` becomes `countryCode`.
|
|
98
|
+
|
|
93
99
|
---
|
|
94
100
|
|
|
95
101
|
# Static Data
|
data/lib/liteapi/analytics.rb
CHANGED
|
@@ -4,46 +4,34 @@ module Liteapi
|
|
|
4
4
|
module Analytics
|
|
5
5
|
# Retrieve weekly analytics
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# @return [Hash] Weekly analytics data
|
|
12
|
-
def weekly_analytics(from:, to:)
|
|
13
|
-
dashboard_post('analytics/weekly', { from: from, to: to })
|
|
7
|
+
# @example
|
|
8
|
+
# client.weekly_analytics(from: '2025-01-01', to: '2025-01-07')
|
|
9
|
+
def weekly_analytics(**params)
|
|
10
|
+
dashboard_post('analytics/weekly', prepare_body_params(params))
|
|
14
11
|
end
|
|
15
12
|
|
|
16
13
|
# Retrieve detailed analytics report
|
|
17
14
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# @return [Hash] Detailed analytics report
|
|
23
|
-
def analytics_report(from:, to:)
|
|
24
|
-
dashboard_post('analytics/report', { from: from, to: to })
|
|
15
|
+
# @example
|
|
16
|
+
# client.analytics_report(from: '2025-01-01', to: '2025-01-31')
|
|
17
|
+
def analytics_report(**params)
|
|
18
|
+
dashboard_post('analytics/report', prepare_body_params(params))
|
|
25
19
|
end
|
|
26
20
|
|
|
27
21
|
# Retrieve market analytics
|
|
28
22
|
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# @return [Hash] Market analytics data
|
|
34
|
-
def market_analytics(from:, to:)
|
|
35
|
-
dashboard_post('analytics/market', { from: from, to: to })
|
|
23
|
+
# @example
|
|
24
|
+
# client.market_analytics(from: '2025-01-01', to: '2025-01-31')
|
|
25
|
+
def market_analytics(**params)
|
|
26
|
+
dashboard_post('analytics/market', prepare_body_params(params))
|
|
36
27
|
end
|
|
37
28
|
|
|
38
29
|
# Retrieve most booked hotels
|
|
39
30
|
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# @return [Array] List of most booked hotels
|
|
45
|
-
def most_booked_hotels(from:, to:)
|
|
46
|
-
dashboard_post('analytics/top-hotels', { from: from, to: to })
|
|
31
|
+
# @example
|
|
32
|
+
# client.most_booked_hotels(from: '2025-01-01', to: '2025-01-31')
|
|
33
|
+
def most_booked_hotels(**params)
|
|
34
|
+
dashboard_post('analytics/top-hotels', prepare_body_params(params))
|
|
47
35
|
end
|
|
48
36
|
end
|
|
49
37
|
end
|
data/lib/liteapi/booking.rb
CHANGED
|
@@ -4,68 +4,53 @@ module Liteapi
|
|
|
4
4
|
module Booking
|
|
5
5
|
# Pre-book a rate to confirm availability and pricing
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# @return [Hash] Prebook confirmation with prebook_id
|
|
12
|
-
def prebook(offer_id:)
|
|
13
|
-
book_post('rates/prebook', { offerId: offer_id })
|
|
7
|
+
# @example
|
|
8
|
+
# client.prebook(offer_id: 'offer_abc123')
|
|
9
|
+
def prebook(**params)
|
|
10
|
+
book_post('rates/prebook', prepare_body_params(params))
|
|
14
11
|
end
|
|
15
12
|
|
|
16
13
|
# Complete a booking
|
|
17
14
|
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
# @
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
paymentMethodId: payment[:payment_method_id] || 'creditCard',
|
|
36
|
-
cardNumber: payment[:card_number],
|
|
37
|
-
expireDate: payment[:expire_date],
|
|
38
|
-
cvc: payment[:cvc]
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
body[:clientReference] = client_reference if client_reference
|
|
42
|
-
|
|
43
|
-
book_post('rates/book', body)
|
|
15
|
+
# @example
|
|
16
|
+
# client.book(
|
|
17
|
+
# prebook_id: 'prebook_123',
|
|
18
|
+
# guest_info: {
|
|
19
|
+
# guest_first_name: 'John',
|
|
20
|
+
# guest_last_name: 'Doe',
|
|
21
|
+
# guest_email: 'john@example.com'
|
|
22
|
+
# },
|
|
23
|
+
# payment_method: {
|
|
24
|
+
# holder_name: 'John Doe',
|
|
25
|
+
# card_number: '4111111111111111',
|
|
26
|
+
# expire_date: '12/25',
|
|
27
|
+
# cvc: '123'
|
|
28
|
+
# }
|
|
29
|
+
# )
|
|
30
|
+
def book(**params)
|
|
31
|
+
book_post('rates/book', prepare_body_params(params))
|
|
44
32
|
end
|
|
45
33
|
|
|
46
34
|
# List bookings by client reference
|
|
47
35
|
#
|
|
48
|
-
# @
|
|
49
|
-
#
|
|
50
|
-
def bookings(
|
|
51
|
-
book_get('bookings',
|
|
36
|
+
# @example
|
|
37
|
+
# client.bookings(client_reference: 'my-booking-123')
|
|
38
|
+
def bookings(**params)
|
|
39
|
+
book_get('bookings', prepare_query_params(params))
|
|
52
40
|
end
|
|
53
41
|
|
|
54
42
|
# Retrieve a specific booking
|
|
55
43
|
#
|
|
56
|
-
# @
|
|
57
|
-
#
|
|
44
|
+
# @example
|
|
45
|
+
# client.booking('booking_abc123')
|
|
58
46
|
def booking(booking_id)
|
|
59
47
|
book_get("bookings/#{booking_id}")
|
|
60
48
|
end
|
|
61
49
|
|
|
62
50
|
# Cancel a booking
|
|
63
51
|
#
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
# @param booking_id [String] The booking ID to cancel
|
|
68
|
-
# @return [Hash] Cancellation confirmation
|
|
52
|
+
# @example
|
|
53
|
+
# client.cancel_booking('booking_abc123')
|
|
69
54
|
def cancel_booking(booking_id)
|
|
70
55
|
book_put("bookings/#{booking_id}")
|
|
71
56
|
end
|
data/lib/liteapi/client.rb
CHANGED
|
@@ -96,5 +96,36 @@ module Liteapi
|
|
|
96
96
|
def dashboard_post(path, body = {})
|
|
97
97
|
dashboard_connection.post(path, body)
|
|
98
98
|
end
|
|
99
|
+
|
|
100
|
+
# Convert Ruby snake_case key to API camelCase
|
|
101
|
+
def camelize_key(key)
|
|
102
|
+
key.to_s.gsub(/_([a-z])/) { ::Regexp.last_match(1).upcase }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Recursively convert keys from snake_case to camelCase
|
|
106
|
+
def deep_camelize_keys(obj)
|
|
107
|
+
case obj
|
|
108
|
+
when Hash
|
|
109
|
+
obj.each_with_object({}) do |(key, value), result|
|
|
110
|
+
result[camelize_key(key)] = deep_camelize_keys(value)
|
|
111
|
+
end
|
|
112
|
+
when Array
|
|
113
|
+
obj.map { |item| deep_camelize_keys(item) }
|
|
114
|
+
else
|
|
115
|
+
obj
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Prepare query params for GET requests (joins arrays with commas)
|
|
120
|
+
def prepare_query_params(params)
|
|
121
|
+
deep_camelize_keys(params.compact).transform_values do |v|
|
|
122
|
+
v.is_a?(Array) ? v.join(',') : v
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Prepare body params for POST/PUT requests (keeps arrays as arrays)
|
|
127
|
+
def prepare_body_params(params)
|
|
128
|
+
deep_camelize_keys(params.compact)
|
|
129
|
+
end
|
|
99
130
|
end
|
|
100
131
|
end
|
data/lib/liteapi/guests.rb
CHANGED
|
@@ -4,59 +4,40 @@ module Liteapi
|
|
|
4
4
|
module Guests
|
|
5
5
|
# Get loyalty program status
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
# @return [Hash] Loyalty program details
|
|
7
|
+
# @example
|
|
8
|
+
# client.loyalty
|
|
10
9
|
def loyalty
|
|
11
10
|
get('guests/loyalty')
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
# Enable loyalty program
|
|
15
14
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# @return [Hash] Loyalty program details
|
|
21
|
-
def enable_loyalty(status:, cashback_rate:)
|
|
22
|
-
post('guests/loyalty', {
|
|
23
|
-
status: status,
|
|
24
|
-
cashbackRate: cashback_rate
|
|
25
|
-
})
|
|
15
|
+
# @example
|
|
16
|
+
# client.enable_loyalty(status: 'enabled', cashback_rate: 0.03)
|
|
17
|
+
def enable_loyalty(**params)
|
|
18
|
+
post('guests/loyalty', prepare_body_params(params))
|
|
26
19
|
end
|
|
27
20
|
|
|
28
21
|
# Update loyalty program
|
|
29
22
|
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# @return [Hash] Updated loyalty program details
|
|
35
|
-
def update_loyalty(status:, cashback_rate:)
|
|
36
|
-
put('guests/loyalty', {
|
|
37
|
-
status: status,
|
|
38
|
-
cashbackRate: cashback_rate
|
|
39
|
-
})
|
|
23
|
+
# @example
|
|
24
|
+
# client.update_loyalty(status: 'enabled', cashback_rate: 0.05)
|
|
25
|
+
def update_loyalty(**params)
|
|
26
|
+
put('guests/loyalty', prepare_body_params(params))
|
|
40
27
|
end
|
|
41
28
|
|
|
42
29
|
# Get guest details
|
|
43
30
|
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
# @param guest_id [String, Integer] Guest identifier
|
|
48
|
-
# @return [Hash] Guest details
|
|
31
|
+
# @example
|
|
32
|
+
# client.guest(123)
|
|
49
33
|
def guest(guest_id)
|
|
50
34
|
get("guests/#{guest_id}")
|
|
51
35
|
end
|
|
52
36
|
|
|
53
37
|
# Get guest bookings
|
|
54
38
|
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
# @param guest_id [String, Integer] Guest identifier
|
|
59
|
-
# @return [Array] List of guest bookings
|
|
39
|
+
# @example
|
|
40
|
+
# client.guest_bookings(123)
|
|
60
41
|
def guest_bookings(guest_id)
|
|
61
42
|
get("guests/#{guest_id}/bookings")
|
|
62
43
|
end
|
data/lib/liteapi/rates.rb
CHANGED
|
@@ -5,16 +5,6 @@ module Liteapi
|
|
|
5
5
|
# Search for full rates and availability for hotels
|
|
6
6
|
#
|
|
7
7
|
# Returns all available rooms with rates, cancellation policies for a list of hotel IDs.
|
|
8
|
-
# Includes loyalty rewards if guest_id is provided.
|
|
9
|
-
#
|
|
10
|
-
# @param hotel_ids [Array<String>] List of hotel IDs to search
|
|
11
|
-
# @param checkin [String] Check-in date (YYYY-MM-DD)
|
|
12
|
-
# @param checkout [String] Check-out date (YYYY-MM-DD)
|
|
13
|
-
# @param occupancies [Array<Hash>] Room occupancies, each with :rooms, :adults, :children (ages array)
|
|
14
|
-
# @param guest_nationality [String] Guest nationality (ISO-2)
|
|
15
|
-
# @param currency [String] Currency code
|
|
16
|
-
# @param guest_id [String, nil] Guest ID for loyalty pricing
|
|
17
|
-
# @return [Hash] Rates and availability data
|
|
18
8
|
#
|
|
19
9
|
# @example
|
|
20
10
|
# client.full_rates(
|
|
@@ -22,56 +12,28 @@ module Liteapi
|
|
|
22
12
|
# checkin: '2025-03-01',
|
|
23
13
|
# checkout: '2025-03-03',
|
|
24
14
|
# occupancies: [{ rooms: 1, adults: 2, children: [5, 10] }],
|
|
25
|
-
#
|
|
26
|
-
#
|
|
15
|
+
# currency: 'USD',
|
|
16
|
+
# guest_nationality: 'US'
|
|
27
17
|
# )
|
|
28
|
-
def full_rates(
|
|
29
|
-
|
|
30
|
-
body = {
|
|
31
|
-
hotelIds: hotel_ids,
|
|
32
|
-
checkin: checkin,
|
|
33
|
-
checkout: checkout,
|
|
34
|
-
occupancies: occupancies,
|
|
35
|
-
guestNationality: guest_nationality,
|
|
36
|
-
currency: currency
|
|
37
|
-
}
|
|
38
|
-
body[:guestId] = guest_id if guest_id
|
|
39
|
-
|
|
40
|
-
post('hotels/rates', body)
|
|
18
|
+
def full_rates(**params)
|
|
19
|
+
post('hotels/rates', prepare_body_params(params))
|
|
41
20
|
end
|
|
42
21
|
|
|
43
22
|
# Search for minimum rates for hotels
|
|
44
23
|
#
|
|
45
24
|
# Returns only the minimum rate per hotel for quick comparisons.
|
|
46
25
|
#
|
|
47
|
-
# @param hotel_ids [Array<String>] List of hotel IDs to search
|
|
48
|
-
# @param checkin [String] Check-in date (YYYY-MM-DD)
|
|
49
|
-
# @param checkout [String] Check-out date (YYYY-MM-DD)
|
|
50
|
-
# @param occupancies [Array<Hash>] Room occupancies, each with :rooms, :adults, :children (ages array)
|
|
51
|
-
# @param guest_nationality [String] Guest nationality (ISO-2)
|
|
52
|
-
# @param currency [String] Currency code
|
|
53
|
-
# @return [Hash] Minimum rates data
|
|
54
|
-
#
|
|
55
26
|
# @example
|
|
56
27
|
# client.min_rates(
|
|
57
28
|
# hotel_ids: ['lp1234'],
|
|
58
29
|
# checkin: '2025-03-01',
|
|
59
30
|
# checkout: '2025-03-03',
|
|
60
31
|
# occupancies: [{ rooms: 1, adults: 2 }],
|
|
61
|
-
#
|
|
62
|
-
#
|
|
32
|
+
# currency: 'USD',
|
|
33
|
+
# guest_nationality: 'US'
|
|
63
34
|
# )
|
|
64
|
-
def min_rates(
|
|
65
|
-
|
|
66
|
-
hotelIds: hotel_ids,
|
|
67
|
-
checkin: checkin,
|
|
68
|
-
checkout: checkout,
|
|
69
|
-
occupancies: occupancies,
|
|
70
|
-
guestNationality: guest_nationality,
|
|
71
|
-
currency: currency
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
post('hotels/min-rates', body)
|
|
35
|
+
def min_rates(**params)
|
|
36
|
+
post('hotels/min-rates', prepare_body_params(params))
|
|
75
37
|
end
|
|
76
38
|
end
|
|
77
39
|
end
|
data/lib/liteapi/static_data.rb
CHANGED
|
@@ -9,20 +9,21 @@ module Liteapi
|
|
|
9
9
|
|
|
10
10
|
# Returns list of cities for a country
|
|
11
11
|
#
|
|
12
|
-
# @
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
# @example
|
|
13
|
+
# client.cities(country_code: 'IT')
|
|
14
|
+
def cities(**params)
|
|
15
|
+
get('data/cities', prepare_query_params(params))
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
# Search for places and areas
|
|
18
19
|
#
|
|
19
|
-
# @
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
def places(query:,
|
|
23
|
-
params =
|
|
24
|
-
params[:
|
|
25
|
-
get('data/places', params)
|
|
20
|
+
# @example
|
|
21
|
+
# client.places(query: 'Rome')
|
|
22
|
+
# client.places(query: 'Rome', type: 'hotel', language: 'it')
|
|
23
|
+
def places(query:, **params)
|
|
24
|
+
params[:text_query] = query
|
|
25
|
+
params[:language] ||= 'en'
|
|
26
|
+
get('data/places', prepare_query_params(params))
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
# Returns all available currency codes
|
|
@@ -52,41 +53,43 @@ module Liteapi
|
|
|
52
53
|
|
|
53
54
|
# Search for hotels
|
|
54
55
|
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
# @
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
# Supports multiple search approaches: by city, coordinates, place ID, or hotel IDs.
|
|
57
|
+
# All parameters are passed through to the API with snake_case converted to camelCase.
|
|
58
|
+
#
|
|
59
|
+
# @example Search by country and city
|
|
60
|
+
# client.hotels(country_code: 'IT', city_name: 'Rome')
|
|
61
|
+
#
|
|
62
|
+
# @example Search by hotel IDs
|
|
63
|
+
# client.hotels(hotel_ids: ['lp1234', 'lp5678'])
|
|
64
|
+
#
|
|
65
|
+
# @example AI-powered search
|
|
66
|
+
# client.hotels(ai_search: 'luxury beach resort with pool')
|
|
67
|
+
#
|
|
68
|
+
# @example Search by place ID
|
|
69
|
+
# client.hotels(place_id: 'place_abc123')
|
|
70
|
+
def hotels(**params)
|
|
71
|
+
params[:language] ||= 'en'
|
|
72
|
+
get('data/hotels', prepare_query_params(params))
|
|
68
73
|
end
|
|
69
74
|
|
|
70
75
|
# Get detailed hotel information
|
|
71
76
|
#
|
|
72
|
-
# @
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
params[:
|
|
77
|
-
get('data/hotel', params)
|
|
77
|
+
# @example
|
|
78
|
+
# client.hotel('lp1897')
|
|
79
|
+
# client.hotel('lp1897', language: 'fr')
|
|
80
|
+
def hotel(hotel_id, **params)
|
|
81
|
+
params[:hotel_id] = hotel_id
|
|
82
|
+
get('data/hotel', prepare_query_params(params))
|
|
78
83
|
end
|
|
79
84
|
|
|
80
85
|
# Get hotel reviews with optional sentiment analysis
|
|
81
86
|
#
|
|
82
|
-
# @
|
|
83
|
-
#
|
|
84
|
-
#
|
|
85
|
-
def hotel_reviews(hotel_id:,
|
|
86
|
-
params =
|
|
87
|
-
params
|
|
88
|
-
params[:getSentiment] = sentiment if sentiment
|
|
89
|
-
get('data/reviews', params)
|
|
87
|
+
# @example
|
|
88
|
+
# client.hotel_reviews(hotel_id: 'lp1897')
|
|
89
|
+
# client.hotel_reviews(hotel_id: 'lp1897', limit: 100, get_sentiment: true)
|
|
90
|
+
def hotel_reviews(hotel_id:, **params)
|
|
91
|
+
params[:hotel_id] = hotel_id
|
|
92
|
+
get('data/reviews', prepare_query_params(params))
|
|
90
93
|
end
|
|
91
94
|
end
|
|
92
95
|
end
|
data/lib/liteapi/version.rb
CHANGED
data/lib/liteapi/vouchers.rb
CHANGED
|
@@ -4,97 +4,53 @@ module Liteapi
|
|
|
4
4
|
module Vouchers
|
|
5
5
|
# List all vouchers
|
|
6
6
|
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
# @return [Array] List of voucher objects
|
|
7
|
+
# @example
|
|
8
|
+
# client.vouchers
|
|
10
9
|
def vouchers
|
|
11
10
|
get('vouchers')
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
# Get voucher details
|
|
15
14
|
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
# @param voucher_id [String, Integer] Voucher identifier
|
|
19
|
-
# @return [Hash] Voucher details
|
|
15
|
+
# @example
|
|
16
|
+
# client.voucher(42)
|
|
20
17
|
def voucher(voucher_id)
|
|
21
18
|
get("vouchers/#{voucher_id}")
|
|
22
19
|
end
|
|
23
20
|
|
|
24
21
|
# Create a voucher
|
|
25
22
|
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
def create_voucher(
|
|
40
|
-
|
|
41
|
-
usages_limit:, status:)
|
|
42
|
-
post('vouchers', {
|
|
43
|
-
voucher_code: voucher_code,
|
|
44
|
-
discount_type: discount_type,
|
|
45
|
-
discount_value: discount_value,
|
|
46
|
-
minimum_spend: minimum_spend,
|
|
47
|
-
maximum_discount_amount: maximum_discount_amount,
|
|
48
|
-
currency: currency,
|
|
49
|
-
validity_start: validity_start,
|
|
50
|
-
validity_end: validity_end,
|
|
51
|
-
usages_limit: usages_limit,
|
|
52
|
-
status: status
|
|
53
|
-
})
|
|
23
|
+
# @example
|
|
24
|
+
# client.create_voucher(
|
|
25
|
+
# voucher_code: 'SUMMER20',
|
|
26
|
+
# discount_type: 'percentage',
|
|
27
|
+
# discount_value: 20,
|
|
28
|
+
# minimum_spend: 100,
|
|
29
|
+
# maximum_discount_amount: 50,
|
|
30
|
+
# currency: 'USD',
|
|
31
|
+
# validity_start: '2025-06-01',
|
|
32
|
+
# validity_end: '2025-08-31',
|
|
33
|
+
# usages_limit: 100,
|
|
34
|
+
# status: 'active'
|
|
35
|
+
# )
|
|
36
|
+
def create_voucher(**params)
|
|
37
|
+
post('vouchers', prepare_body_params(params))
|
|
54
38
|
end
|
|
55
39
|
|
|
56
40
|
# Update a voucher
|
|
57
41
|
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# @param discount_type [String] Type of discount
|
|
63
|
-
# @param discount_value [Float] Discount value
|
|
64
|
-
# @param minimum_spend [Float] Minimum spend
|
|
65
|
-
# @param maximum_discount_amount [Float] Maximum discount
|
|
66
|
-
# @param currency [String] Currency code
|
|
67
|
-
# @param validity_start [String] Start date (YYYY-MM-DD)
|
|
68
|
-
# @param validity_end [String] End date (YYYY-MM-DD)
|
|
69
|
-
# @param usages_limit [Integer] Maximum redemptions
|
|
70
|
-
# @param status [String] Voucher status
|
|
71
|
-
# @return [Hash] Update confirmation
|
|
72
|
-
def update_voucher(voucher_id, voucher_code:, discount_type:, discount_value:, minimum_spend:,
|
|
73
|
-
maximum_discount_amount:, currency:, validity_start:, validity_end:,
|
|
74
|
-
usages_limit:, status:)
|
|
75
|
-
put("vouchers/#{voucher_id}", {
|
|
76
|
-
voucher_code: voucher_code,
|
|
77
|
-
discount_type: discount_type,
|
|
78
|
-
discount_value: discount_value,
|
|
79
|
-
minimum_spend: minimum_spend,
|
|
80
|
-
maximum_discount_amount: maximum_discount_amount,
|
|
81
|
-
currency: currency,
|
|
82
|
-
validity_start: validity_start,
|
|
83
|
-
validity_end: validity_end,
|
|
84
|
-
usages_limit: usages_limit,
|
|
85
|
-
status: status
|
|
86
|
-
})
|
|
42
|
+
# @example
|
|
43
|
+
# client.update_voucher(42, voucher_code: 'SUMMER25', discount_value: 25, ...)
|
|
44
|
+
def update_voucher(voucher_id, **params)
|
|
45
|
+
put("vouchers/#{voucher_id}", prepare_body_params(params))
|
|
87
46
|
end
|
|
88
47
|
|
|
89
48
|
# Update voucher status
|
|
90
49
|
#
|
|
91
|
-
#
|
|
92
|
-
#
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
# @return [Hash] Update confirmation
|
|
96
|
-
def update_voucher_status(voucher_id, status:)
|
|
97
|
-
put("vouchers/#{voucher_id}/status", { status: status })
|
|
50
|
+
# @example
|
|
51
|
+
# client.update_voucher_status(42, status: 'inactive')
|
|
52
|
+
def update_voucher_status(voucher_id, **params)
|
|
53
|
+
put("vouchers/#{voucher_id}/status", prepare_body_params(params))
|
|
98
54
|
end
|
|
99
55
|
end
|
|
100
56
|
end
|