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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c44b103b3e33f46ee4bbc5edeb75122db504a7a2de724d3f8f09f057a8082c10
4
- data.tar.gz: a0b067fff874a08a078dfcec38f71d68b4c82a7cdc93f58229b1949a14b222f2
3
+ metadata.gz: '08a9d9d70ebb966ca94dc5b5da0038346c22444d301ab2591fa874c91ae65676'
4
+ data.tar.gz: 518f4ec38d0cae6ba00e2aac542e58333ee8ed01bb282de2808cb2b67e9a6761
5
5
  SHA512:
6
- metadata.gz: 446a6cb21d2a614050ced6642724a214f5d14e91fb0938e20dedf4a1288c9ea2003b85d14dbfeb5ef996f5b7c429cb740841a6247d8a3f0ce4bfa68cd1c28d02
7
- data.tar.gz: 2685b0fe62ea0c1cd67fc85de9809ec818a6277e3341e6bd02e050b42d424d3c3fd6d329b1e205836c36fb9822ceebfc0d9b559221468ccb7dfbbc3f54922e32
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
@@ -4,46 +4,34 @@ module Liteapi
4
4
  module Analytics
5
5
  # Retrieve weekly analytics
6
6
  #
7
- # Fetches weekly analytics data for a date range.
8
- #
9
- # @param from [String] Start date (YYYY-MM-DD)
10
- # @param to [String] End date (YYYY-MM-DD)
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
- # Fetches a detailed analytics report including revenue and sales data.
19
- #
20
- # @param from [String] Start date (YYYY-MM-DD)
21
- # @param to [String] End date (YYYY-MM-DD)
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
- # Fetches market-level analytics data.
30
- #
31
- # @param from [String] Start date (YYYY-MM-DD)
32
- # @param to [String] End date (YYYY-MM-DD)
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
- # Fetches data on most booked hotels during a date range.
41
- #
42
- # @param from [String] Start date (YYYY-MM-DD)
43
- # @param to [String] End date (YYYY-MM-DD)
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
@@ -4,68 +4,53 @@ module Liteapi
4
4
  module Booking
5
5
  # Pre-book a rate to confirm availability and pricing
6
6
  #
7
- # Confirms if the room and rates are still available. Returns a prebook_id
8
- # needed for the final booking.
9
- #
10
- # @param offer_id [String] The offer/rate ID from full_rates
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
- # Confirms the booking with guest and payment information.
19
- #
20
- # @param prebook_id [String] The prebook ID from prebook response
21
- # @param guest [Hash] Guest information (first_name, last_name, email)
22
- # @param payment [Hash] Payment information (card holder name, number, expiry, cvc)
23
- # @param client_reference [String, nil] Your reference for this booking
24
- # @return [Hash] Booking confirmation with booking_id
25
- def book(prebook_id:, guest:, payment:, client_reference: nil)
26
- body = {
27
- prebookId: prebook_id,
28
- guestInfo: {
29
- guestFirstName: guest[:first_name],
30
- guestLastName: guest[:last_name],
31
- guestEmail: guest[:email]
32
- },
33
- paymentMethod: {
34
- holderName: payment[:holder_name],
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
- # @param client_reference [String] Your reference to search for
49
- # @return [Array] List of bookings
50
- def bookings(client_reference:)
51
- book_get('bookings', clientReference: client_reference)
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
- # @param booking_id [String] The booking ID
57
- # @return [Hash] Booking details
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
- # Cancellation success depends on the cancellation policy.
65
- # Non-refundable bookings or those past the cancellation date cannot be cancelled.
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
@@ -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
@@ -4,59 +4,40 @@ module Liteapi
4
4
  module Guests
5
5
  # Get loyalty program status
6
6
  #
7
- # Returns current loyalty program settings including status and cashback rates.
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
- # Creates a new loyalty program with specified settings.
17
- #
18
- # @param status [String] Program status ('enabled' or 'disabled')
19
- # @param cashback_rate [Float] Cashback rate (e.g., 0.03 = 3%)
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
- # Updates existing loyalty program settings.
31
- #
32
- # @param status [String] Program status ('enabled' or 'disabled')
33
- # @param cashback_rate [Float] Cashback rate (e.g., 0.03 = 3%)
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
- # Retrieves detailed information about a guest including personal data,
45
- # loyalty points, and booking history.
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
- # Retrieves all bookings for a specific guest with loyalty points
56
- # and cashback information.
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
- # guest_nationality: 'US',
26
- # currency: 'USD'
15
+ # currency: 'USD',
16
+ # guest_nationality: 'US'
27
17
  # )
28
- def full_rates(hotel_ids:, checkin:, checkout:, occupancies:, guest_nationality:, currency:,
29
- guest_id: nil)
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
- # guest_nationality: 'US',
62
- # currency: 'USD'
32
+ # currency: 'USD',
33
+ # guest_nationality: 'US'
63
34
  # )
64
- def min_rates(hotel_ids:, checkin:, checkout:, occupancies:, guest_nationality:, currency:)
65
- body = {
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
@@ -9,20 +9,21 @@ module Liteapi
9
9
 
10
10
  # Returns list of cities for a country
11
11
  #
12
- # @param country_code [String] ISO-2 country code (e.g., 'SG', 'US')
13
- def cities(country_code:)
14
- get('data/cities', countryCode: country_code)
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
- # @param query [String] Search text (e.g., 'Rome', 'Manhattan')
20
- # @param type [String, nil] Filter by place type (e.g., 'hotel')
21
- # @param language [String] Language for results (default: 'en')
22
- def places(query:, type: nil, language: 'en')
23
- params = { textQuery: query, language: language }
24
- params[:type] = type if type
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
- # @param country_code [String] ISO-2 country code (required)
56
- # @param city_name [String, nil] Filter by city name
57
- # @param latitude [Float, nil] Latitude for geo search
58
- # @param longitude [Float, nil] Longitude for geo search
59
- # @param radius [Integer, nil] Search radius in km (for geo search)
60
- # @param language [String] Language for results (default: 'en')
61
- def hotels(country_code:, city_name: nil, latitude: nil, longitude: nil, radius: nil, language: 'en')
62
- params = { countryCode: country_code, language: language }
63
- params[:cityName] = city_name if city_name
64
- params[:latitude] = latitude if latitude
65
- params[:longitude] = longitude if longitude
66
- params[:radius] = radius if radius
67
- get('data/hotels', params)
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
- # @param hotel_id [String] Hotel identifier
73
- # @param language [String, nil] Language for results
74
- def hotel(hotel_id, language: nil)
75
- params = { hotelId: hotel_id }
76
- params[:language] = language if language
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
- # @param hotel_id [String] Hotel identifier
83
- # @param limit [Integer, nil] Maximum reviews to return (max 1000)
84
- # @param sentiment [Boolean] Include sentiment analysis
85
- def hotel_reviews(hotel_id:, limit: nil, sentiment: false)
86
- params = { hotelId: hotel_id }
87
- params[:limit] = limit if limit
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Liteapi
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -4,97 +4,53 @@ module Liteapi
4
4
  module Vouchers
5
5
  # List all vouchers
6
6
  #
7
- # Retrieves all available vouchers including codes, discounts, and validity.
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
- # Retrieves details for a specific voucher.
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
- # Creates a new voucher with specified settings.
27
- #
28
- # @param voucher_code [String] Unique voucher code
29
- # @param discount_type [String] Type of discount ('percentage' or 'fixed')
30
- # @param discount_value [Float] Discount value
31
- # @param minimum_spend [Float] Minimum spend to apply voucher
32
- # @param maximum_discount_amount [Float] Maximum discount amount
33
- # @param currency [String] Currency code
34
- # @param validity_start [String] Start date (YYYY-MM-DD)
35
- # @param validity_end [String] End date (YYYY-MM-DD)
36
- # @param usages_limit [Integer] Maximum redemptions
37
- # @param status [String] Voucher status ('active' or 'inactive')
38
- # @return [Hash] Created voucher confirmation
39
- def create_voucher(voucher_code:, discount_type:, discount_value:, minimum_spend:,
40
- maximum_discount_amount:, currency:, validity_start:, validity_end:,
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
- # Updates an existing voucher's settings.
59
- #
60
- # @param voucher_id [String, Integer] Voucher identifier
61
- # @param voucher_code [String] Unique voucher code
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
- # Activates or deactivates a voucher.
92
- #
93
- # @param voucher_id [String, Integer] Voucher identifier
94
- # @param status [String] New status ('active' or 'inactive')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liteapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Bradburne