quicktravel_client 3.6.1 → 3.7.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 +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +4 -2
- data/CHANGELOG.md +12 -3
- data/README.md +1 -1
- data/lib/quick_travel.rb +2 -0
- data/lib/quick_travel/adapter.rb +8 -58
- data/lib/quick_travel/address.rb +4 -2
- data/lib/quick_travel/adjustment.rb +3 -2
- data/lib/quick_travel/background_check.rb +4 -2
- data/lib/quick_travel/bed_configuration.rb +3 -2
- data/lib/quick_travel/bed_requirement.rb +3 -2
- data/lib/quick_travel/booking.rb +10 -1
- data/lib/quick_travel/checkout.rb +1 -1
- data/lib/quick_travel/client.rb +3 -2
- data/lib/quick_travel/contact.rb +4 -1
- data/lib/quick_travel/init_from_hash.rb +54 -1
- data/lib/quick_travel/passenger.rb +7 -2
- data/lib/quick_travel/passenger_price_break.rb +3 -2
- data/lib/quick_travel/passenger_split.rb +5 -0
- data/lib/quick_travel/property.rb +2 -1
- data/lib/quick_travel/property_facility.rb +3 -2
- data/lib/quick_travel/reservation.rb +4 -0
- data/lib/quick_travel/resource.rb +11 -2
- data/lib/quick_travel/resource_category.rb +5 -1
- data/lib/quick_travel/resource_group.rb +9 -0
- data/lib/quick_travel/room_facility.rb +3 -2
- data/lib/quick_travel/route_stop.rb +11 -2
- data/lib/quick_travel/service.rb +3 -2
- data/lib/quick_travel/version.rb +1 -1
- data/quicktravel_client.gemspec +2 -1
- data/spec/adapter_spec.rb +2 -2
- data/spec/booking_spec.rb +14 -6
- data/spec/checkout_spec.rb +182 -0
- data/spec/product_spec.rb +5 -5
- data/spec/region_spec.rb +2 -2
- data/spec/reservation_spec.rb +2 -6
- data/spec/support/cassettes/accommodation_reserve.yml +109 -51
- data/spec/support/cassettes/basic_product_scheduled_trips.yml +19 -33
- data/spec/support/cassettes/basic_product_scheduled_trips_multi_sector.yml +19 -27
- data/spec/support/cassettes/basic_product_scheduled_trips_unbookable.yml +9 -11
- data/spec/support/cassettes/booking_activate.yml +25 -28
- data/spec/support/cassettes/booking_cancel.yml +25 -28
- data/spec/support/cassettes/booking_create.yml +14 -15
- data/spec/support/cassettes/booking_create_accommodation.yml +62 -0
- data/spec/support/cassettes/booking_documents.yml +9 -11
- data/spec/support/cassettes/booking_non_existant.yml +8 -10
- data/spec/support/cassettes/booking_price_changes.yml +19 -17
- data/spec/support/cassettes/booking_show.yml +13 -14
- data/spec/support/cassettes/booking_update.yml +25 -27
- data/spec/support/cassettes/booking_with_documents.yml +35 -36
- data/spec/support/cassettes/booking_with_nested_attributes.yml +61 -61
- data/spec/support/cassettes/booking_with_price_changes.yml +27 -26
- data/spec/support/cassettes/checkout_client_token.yml +11 -13
- data/spec/support/cassettes/countries.yml +15 -93
- data/spec/support/cassettes/country_all.yml +15 -93
- data/spec/support/cassettes/create_reservation_fail.yml +8 -10
- data/spec/support/cassettes/create_reservation_with_booking.yml +15 -16
- data/spec/support/cassettes/locations.yml +12 -14
- data/spec/support/cassettes/opal_modern_pay_failed_booking.yml +62 -0
- data/spec/support/cassettes/opal_modern_pay_failed_create.yml +59 -0
- data/spec/support/cassettes/opal_modern_pay_failed_update.yml +57 -0
- data/spec/support/cassettes/opal_modern_pay_successful_booking.yml +62 -0
- data/spec/support/cassettes/opal_modern_pay_successful_response.yml +59 -0
- data/spec/support/cassettes/opal_modern_pay_successful_update_response.yml +59 -0
- data/spec/support/cassettes/opal_pay.yml +59 -0
- data/spec/support/cassettes/opal_pay_booking.yml +62 -0
- data/spec/support/cassettes/passenger_all.yml +11 -13
- data/spec/support/cassettes/payment_info.yml +9 -11
- data/spec/support/cassettes/price_quote.yml +17 -21
- data/spec/support/cassettes/product_date_range_bookability.yml +32 -48
- data/spec/support/cassettes/product_show.yml +13 -17
- data/spec/support/cassettes/product_show_as_agent.yml +14 -22
- data/spec/support/cassettes/product_type_all.yml +16 -14
- data/spec/support/cassettes/product_type_resource_categories.yml +9 -11
- data/spec/support/cassettes/product_type_resource_categories_tickets.yml +12 -14
- data/spec/support/cassettes/product_type_routes.yml +14 -16
- data/spec/support/cassettes/property.yml +16 -18
- data/spec/support/cassettes/property_types.yml +12 -14
- data/spec/support/cassettes/region_show.yml +11 -13
- data/spec/support/cassettes/reservation_resource.yml +62 -0
- data/spec/support/cassettes/reservation_with_extra_picks.yml +54 -60
- data/spec/support/cassettes/resource_category_all.yml +12 -14
- data/spec/support/cassettes/resource_category_all_for_product_type_8.yml +11 -13
- data/spec/support/cassettes/resource_fare_bases.yml +18 -23
- data/spec/support/cassettes/resource_show.yml +15 -17
- data/spec/support/cassettes/resource_with_price.yml +16 -18
- data/spec/support/cassettes/settings_basic.yml +9 -11
- data/spec/support/cassettes/tenant_switcher.yml +31 -27
- data/spec/support/cassettes/wrong_url.yml +25 -46
- data/spec/support/coverage_loader.rb +1 -1
- metadata +43 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b60bf00c1c2d71210f2d1f462986abba8859b7acd216b13d68c8d4ad2c475e9d
|
4
|
+
data.tar.gz: 79cb1bad6bdd5a2178577824c1196ff9e5728beda74e5474bac7f9e53e63c053
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205130ad17115f1f0491351af5b76242a8b67a1f384912708fa4ebad3211d428e83284c41aa8c024d82b1004371415848d47a7fd44bd86fcd375952c5eb68737
|
7
|
+
data.tar.gz: b0cca6ec2c7b5dd695112ba71d112f7593c8bc174070c380aade2d3ddd5aed23b9a44eec3796c207b65ef3d87c6f6bd2f02ced5c3248e58a505907ddfcb2c1f4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,12 +3,21 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
|
5
5
|
|
6
|
-
## [
|
6
|
+
## [3.7.0]
|
7
|
+
### Added
|
8
|
+
- [DC-1437] Add relationship accesssor methods
|
9
|
+
- [TT-3337] Add booking.delete_reservations method
|
10
|
+
- [TT-3780] Add tests for Opal payments
|
11
|
+
- [TT-3780] Add tests for Opal payment using create / update workflow
|
7
12
|
|
8
|
-
|
9
|
-
###
|
13
|
+
### Fixed
|
10
14
|
- [TT-3304] Handle no response in booking update API
|
11
15
|
|
16
|
+
### Changed
|
17
|
+
- [TT-3333] URL encode data sent to booking reference lookup
|
18
|
+
- [TT-3783] Remove deprecated FixNum
|
19
|
+
- [TT-3812] Update cassettes
|
20
|
+
|
12
21
|
## [3.6.0]
|
13
22
|
###
|
14
23
|
- [ROT-114] Add drop off details
|
data/README.md
CHANGED
@@ -27,4 +27,4 @@ bundle exec puma -Ilib -p7000
|
|
27
27
|
|
28
28
|
In QuickTravel Client:
|
29
29
|
rm spec/support/cassettes/ -rf
|
30
|
-
QT_KEYS=a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2,
|
30
|
+
QT_KEYS=a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2,1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a bundle exec rspec
|
data/lib/quick_travel.rb
CHANGED
@@ -36,6 +36,7 @@ module QuickTravel
|
|
36
36
|
require 'quick_travel/party'
|
37
37
|
require 'quick_travel/passenger'
|
38
38
|
require 'quick_travel/passenger_type'
|
39
|
+
require 'quick_travel/passenger_split'
|
39
40
|
require 'quick_travel/payment'
|
40
41
|
require 'quick_travel/background_check'
|
41
42
|
require 'quick_travel/payment_type'
|
@@ -49,6 +50,7 @@ module QuickTravel
|
|
49
50
|
require 'quick_travel/reservation'
|
50
51
|
require 'quick_travel/resource'
|
51
52
|
require 'quick_travel/resource_category'
|
53
|
+
require 'quick_travel/resource_group'
|
52
54
|
require 'quick_travel/room_facility'
|
53
55
|
require 'quick_travel/route_stop'
|
54
56
|
require 'quick_travel/service'
|
data/lib/quick_travel/adapter.rb
CHANGED
@@ -25,27 +25,6 @@ module QuickTravel
|
|
25
25
|
# ]
|
26
26
|
class_attribute :object_key # Key of sub-objects (i.e. convert under a key)
|
27
27
|
|
28
|
-
def initialize(hash = {})
|
29
|
-
return nil if hash.blank?
|
30
|
-
define_readers(hash.keys)
|
31
|
-
super(Parser.new(hash).parsed_attributes)
|
32
|
-
end
|
33
|
-
|
34
|
-
def define_readers(keys)
|
35
|
-
keys.each do |key|
|
36
|
-
next if respond_to?(key)
|
37
|
-
define_singleton_method(key) { instance_variable_get("@#{key}") }
|
38
|
-
if key.to_s.ends_with? '_cents'
|
39
|
-
name = key.to_s.gsub(/_in_cents$/, '')
|
40
|
-
define_singleton_method(name) {
|
41
|
-
cents = instance_variable_get("@#{key}")
|
42
|
-
return nil unless cents
|
43
|
-
Money.new(cents)
|
44
|
-
}
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
28
|
def self.has_many(relation_name, options = {})
|
50
29
|
define_method relation_name do
|
51
30
|
instance_variable_get("@#{relation_name}") || instance_variable_set(
|
@@ -105,6 +84,14 @@ module QuickTravel
|
|
105
84
|
instance_values
|
106
85
|
end
|
107
86
|
|
87
|
+
def to_s
|
88
|
+
if defined? @to_s
|
89
|
+
@to_s
|
90
|
+
else
|
91
|
+
super
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
108
95
|
protected
|
109
96
|
|
110
97
|
def self.check_id!(id)
|
@@ -223,43 +210,6 @@ module QuickTravel
|
|
223
210
|
end
|
224
211
|
end
|
225
212
|
|
226
|
-
class Parser
|
227
|
-
def initialize(attributes)
|
228
|
-
@attributes = attributes
|
229
|
-
end
|
230
|
-
|
231
|
-
def attributes
|
232
|
-
@attributes ||= {}
|
233
|
-
end
|
234
|
-
|
235
|
-
def parsed_attributes
|
236
|
-
@parsed_attributes ||= parse_attributes
|
237
|
-
end
|
238
|
-
|
239
|
-
private
|
240
|
-
|
241
|
-
def parse_attributes
|
242
|
-
attributes.map.with_object({}) do |(attribute, value), hash|
|
243
|
-
hash[attribute] = parse(attribute, value)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
def parse(attribute, value)
|
248
|
-
return nil if value.nil?
|
249
|
-
return convert(value, :to_date) if attribute.to_s.ends_with?('_date')
|
250
|
-
return convert(value, :to_date) if attribute.to_s.ends_with?('_on')
|
251
|
-
# to_datetime as it converts to app time zone, to_time converts to system time zone
|
252
|
-
return convert(value, :to_datetime) if attribute.to_s.ends_with?('_time')
|
253
|
-
return convert(value, :to_datetime) if attribute.to_s.ends_with?('_at')
|
254
|
-
value
|
255
|
-
end
|
256
|
-
|
257
|
-
def convert(value, conversion_method)
|
258
|
-
convertable_value = value.is_a?(Hash) ? value['_value'] : value
|
259
|
-
convertable_value.send(conversion_method)
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
213
|
class Api
|
264
214
|
include HTTParty
|
265
215
|
|
data/lib/quick_travel/address.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
require 'quick_travel/
|
1
|
+
require 'quick_travel/init_from_hash'
|
2
2
|
|
3
3
|
module QuickTravel
|
4
|
-
class BackgroundCheck
|
4
|
+
class BackgroundCheck
|
5
|
+
include QuickTravel::InitFromHash
|
6
|
+
|
5
7
|
def self.check(options = {})
|
6
8
|
get_and_validate('/background_check/check.json', options)
|
7
9
|
end
|
data/lib/quick_travel/booking.rb
CHANGED
@@ -4,6 +4,7 @@ require 'quick_travel/vehicle'
|
|
4
4
|
require 'quick_travel/payment'
|
5
5
|
require 'quick_travel/payment_type'
|
6
6
|
require 'quick_travel/price_changes'
|
7
|
+
require 'uri'
|
7
8
|
|
8
9
|
module QuickTravel
|
9
10
|
class Booking < Adapter
|
@@ -12,7 +13,7 @@ module QuickTravel
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def self.find_by_reference(reference)
|
15
|
-
find_all!("#{api_base}/reference/#{reference}.json").first
|
16
|
+
find_all!("#{api_base}/reference/#{URI.escape(reference)}.json").first
|
16
17
|
end
|
17
18
|
|
18
19
|
def documents(regenerate = false)
|
@@ -156,6 +157,10 @@ module QuickTravel
|
|
156
157
|
reserve(:packages, options)
|
157
158
|
end
|
158
159
|
|
160
|
+
def delete_reservations
|
161
|
+
delete_and_validate("#{api_base}/#{@id}/reservations")
|
162
|
+
end
|
163
|
+
|
159
164
|
# Delete a reservation
|
160
165
|
#
|
161
166
|
# Returns current booking object after deleting the reservation
|
@@ -184,6 +189,10 @@ module QuickTravel
|
|
184
189
|
vehicles.detect { |v| v.id.to_i == vid.to_i }
|
185
190
|
end
|
186
191
|
|
192
|
+
def passengers
|
193
|
+
@passenger_objects ||= @passengers_attributes.map{ |p| Passenger.new(p) }
|
194
|
+
end
|
195
|
+
|
187
196
|
def passenger_types_counts
|
188
197
|
passengers.each_with_object(Hash.new(0)) do |passenger, hash|
|
189
198
|
hash[passenger.passenger_type_id] += 1
|
@@ -46,7 +46,7 @@ module QuickTravel
|
|
46
46
|
# TODO Move to an external builder?
|
47
47
|
def self.attributes_for
|
48
48
|
attrs = yield
|
49
|
-
attrs[:completed] =
|
49
|
+
attrs[:completed] = attrs['progress'] == 'completed' || attrs['successful']
|
50
50
|
attrs[:successful] = attrs[:completed]
|
51
51
|
attrs
|
52
52
|
rescue AdapterError => e
|
data/lib/quick_travel/client.rb
CHANGED
data/lib/quick_travel/contact.rb
CHANGED
@@ -3,7 +3,8 @@ module QuickTravel
|
|
3
3
|
def initialize(hash = {})
|
4
4
|
return nil if hash.blank?
|
5
5
|
|
6
|
-
hash.
|
6
|
+
define_readers(hash.keys)
|
7
|
+
Parser.new(hash).parsed_attributes.each do |attr, val|
|
7
8
|
# set datamember of the object using hash key and value
|
8
9
|
if respond_to?("#{attr}=")
|
9
10
|
send("#{attr}=", val)
|
@@ -12,5 +13,57 @@ module QuickTravel
|
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
16
|
+
|
17
|
+
def define_readers(keys)
|
18
|
+
keys.each do |key|
|
19
|
+
next if respond_to?(key)
|
20
|
+
define_singleton_method(key) { instance_variable_get("@#{key}") }
|
21
|
+
if key.to_s.ends_with? '_cents'
|
22
|
+
name = key.to_s.gsub(/_in_cents$/, '')
|
23
|
+
define_singleton_method(name) {
|
24
|
+
cents = instance_variable_get("@#{key}")
|
25
|
+
return nil unless cents
|
26
|
+
Money.new(cents)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Parser
|
34
|
+
def initialize(attributes)
|
35
|
+
@attributes = attributes
|
36
|
+
end
|
37
|
+
|
38
|
+
def attributes
|
39
|
+
@attributes ||= {}
|
40
|
+
end
|
41
|
+
|
42
|
+
def parsed_attributes
|
43
|
+
@parsed_attributes ||= parse_attributes
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def parse_attributes
|
49
|
+
attributes.map.with_object({}) do |(attribute, value), hash|
|
50
|
+
hash[attribute] = parse(attribute, value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def parse(attribute, value)
|
55
|
+
return nil if value.nil?
|
56
|
+
return convert(value, :to_date) if attribute.to_s.ends_with?('_date')
|
57
|
+
return convert(value, :to_date) if attribute.to_s.ends_with?('_on')
|
58
|
+
# to_datetime as it converts to app time zone, to_time converts to system time zone
|
59
|
+
return convert(value, :to_datetime) if attribute.to_s.ends_with?('_time')
|
60
|
+
return convert(value, :to_datetime) if attribute.to_s.ends_with?('_at')
|
61
|
+
value
|
62
|
+
end
|
63
|
+
|
64
|
+
def convert(value, conversion_method)
|
65
|
+
convertable_value = value.is_a?(Hash) ? value['_value'] : value
|
66
|
+
convertable_value.try(conversion_method) || convertable_value
|
67
|
+
end
|
15
68
|
end
|
16
69
|
end
|
@@ -1,6 +1,11 @@
|
|
1
|
-
require 'quick_travel/
|
1
|
+
require 'quick_travel/init_from_hash'
|
2
2
|
|
3
3
|
module QuickTravel
|
4
|
-
class Passenger
|
4
|
+
class Passenger
|
5
|
+
include QuickTravel::InitFromHash
|
6
|
+
|
7
|
+
def passenger_type
|
8
|
+
QuickTravel::PassengerType.find(@passenger_type_id)
|
9
|
+
end
|
5
10
|
end
|
6
11
|
end
|
@@ -3,6 +3,7 @@ require 'quick_travel/property_facility'
|
|
3
3
|
|
4
4
|
module QuickTravel
|
5
5
|
class Property < Adapter
|
6
|
+
self.api_base = '/api/properties'
|
6
7
|
attr_reader :error
|
7
8
|
|
8
9
|
def accommodations=(hash_array)
|
@@ -23,7 +24,7 @@ module QuickTravel
|
|
23
24
|
|
24
25
|
def self.load_with_pricing(id, options)
|
25
26
|
# Find property 'standard' way -- finds price for whole duration
|
26
|
-
fail ArgumentError.new('Must Specify valid property id') if id.blank? || id.
|
27
|
+
fail ArgumentError.new('Must Specify valid property id') if id.blank? || !id.is_a?(Integer)
|
27
28
|
property = find_all!("/api/properties/#{id}.json", options).first
|
28
29
|
first_travel_date = options.fetch(:product).fetch(:first_travel_date)
|
29
30
|
property.accommodations.each do |accommodation|
|
@@ -30,6 +30,10 @@ module QuickTravel
|
|
30
30
|
end_time.to_time.on(last_travel_date) if end_time
|
31
31
|
end
|
32
32
|
|
33
|
+
def passenger_splits
|
34
|
+
@_passenger_splits ||= @passenger_splits.map{ |split| PassengerSplit.new(split) }
|
35
|
+
end
|
36
|
+
|
33
37
|
def passengers_count_string(booking)
|
34
38
|
passengers_count(booking).join(', ')
|
35
39
|
end
|
@@ -5,10 +5,10 @@ require 'quick_travel/product_type'
|
|
5
5
|
|
6
6
|
module QuickTravel
|
7
7
|
class Resource < Adapter
|
8
|
-
self.api_base = '/resources'
|
8
|
+
self.api_base = '/api/resources'
|
9
9
|
|
10
10
|
def sub_resources
|
11
|
-
Resource.find_all!('/resources.json', parent_resource_id: @id)
|
11
|
+
Resource.find_all!('/api/resources.json', parent_resource_id: @id)
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.all_with_price(opts)
|
@@ -20,6 +20,15 @@ module QuickTravel
|
|
20
20
|
QuickTravel::ProductType.find(product_type_id)
|
21
21
|
end
|
22
22
|
|
23
|
+
def locations
|
24
|
+
location_ids.map{ |id| Location.find(id) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def category
|
28
|
+
return nil if @category.nil?
|
29
|
+
@_category ||= QuickTravel::ResourceCategory.new(@category)
|
30
|
+
end
|
31
|
+
|
23
32
|
def bed_requirements
|
24
33
|
@_bed_requirements ||= Array.wrap(@bed_requirements).map do |bed_requirement|
|
25
34
|
BedRequirement.new(bed_requirement)
|