quicktravel_client 1.1.2 → 2.0.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.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +14 -2
  5. data/CHANGELOG.md +34 -3
  6. data/Gemfile +0 -3
  7. data/Rakefile +0 -6
  8. data/examples/login_example.rb +1 -1
  9. data/gemfiles/rails4.gemfile +9 -0
  10. data/lib/quick_travel.rb +2 -1
  11. data/lib/quick_travel/accommodation.rb +1 -15
  12. data/lib/quick_travel/adapter.rb +98 -67
  13. data/lib/quick_travel/{adapter_exception.rb → adapter_error.rb} +1 -1
  14. data/lib/quick_travel/address.rb +2 -7
  15. data/lib/quick_travel/adjustment.rb +0 -2
  16. data/lib/quick_travel/bed_configuration.rb +0 -1
  17. data/lib/quick_travel/bed_requirement.rb +0 -1
  18. data/lib/quick_travel/booking.rb +22 -46
  19. data/lib/quick_travel/cache.rb +8 -14
  20. data/lib/quick_travel/checkout.rb +1 -1
  21. data/lib/quick_travel/client.rb +2 -4
  22. data/lib/quick_travel/client_type.rb +2 -1
  23. data/lib/quick_travel/connection_error.rb +1 -1
  24. data/lib/quick_travel/constants.rb +0 -1
  25. data/lib/quick_travel/contact.rb +0 -1
  26. data/lib/quick_travel/country.rb +0 -3
  27. data/lib/quick_travel/document.rb +0 -2
  28. data/lib/quick_travel/document_group.rb +0 -2
  29. data/lib/quick_travel/location.rb +0 -2
  30. data/lib/quick_travel/party.rb +7 -12
  31. data/lib/quick_travel/passenger.rb +0 -1
  32. data/lib/quick_travel/passenger_price_break.rb +0 -2
  33. data/lib/quick_travel/passenger_type.rb +0 -2
  34. data/lib/quick_travel/payment.rb +0 -3
  35. data/lib/quick_travel/payment_type.rb +4 -13
  36. data/lib/quick_travel/price_changes.rb +3 -0
  37. data/lib/quick_travel/price_changes/booking_price_change.rb +30 -0
  38. data/lib/quick_travel/price_changes/price_change.rb +23 -0
  39. data/lib/quick_travel/{discounts/discount_tree.rb → price_changes/price_change_tree.rb} +12 -8
  40. data/lib/quick_travel/product.rb +15 -28
  41. data/lib/quick_travel/product_type.rb +4 -16
  42. data/lib/quick_travel/property.rb +4 -20
  43. data/lib/quick_travel/property_facility.rb +0 -1
  44. data/lib/quick_travel/property_type.rb +2 -14
  45. data/lib/quick_travel/region.rb +0 -9
  46. data/lib/quick_travel/reservation.rb +0 -21
  47. data/lib/quick_travel/resource.rb +7 -28
  48. data/lib/quick_travel/room_facility.rb +0 -1
  49. data/lib/quick_travel/route.rb +9 -25
  50. data/lib/quick_travel/route_stop.rb +0 -1
  51. data/lib/quick_travel/service.rb +2 -1
  52. data/lib/quick_travel/status.rb +23 -0
  53. data/lib/quick_travel/trip.rb +0 -1
  54. data/lib/quick_travel/vehicle.rb +2 -4
  55. data/lib/quick_travel/vehicle_type.rb +0 -3
  56. data/lib/quick_travel/version.rb +1 -1
  57. data/quicktravel_client.gemspec +4 -4
  58. data/spec/booking_spec.rb +24 -0
  59. data/spec/discounts_spec.rb +69 -69
  60. data/spec/passenger_type_spec.rb +30 -0
  61. data/spec/payment_type_spec.rb +10 -0
  62. data/spec/product_spec.rb +52 -21
  63. data/spec/product_type_spec.rb +19 -0
  64. data/spec/property_spec.rb +83 -0
  65. data/spec/region_spec.rb +1 -1
  66. data/spec/reservation_spec.rb +3 -2
  67. data/spec/resource_spec.rb +31 -7
  68. data/spec/route_spec.rb +118 -0
  69. data/spec/spec_helper.rb +18 -25
  70. data/spec/status_spec.rb +9 -0
  71. data/spec/support/cassettes/booking_create.yml +39 -33
  72. data/spec/support/cassettes/booking_documents.yml +36 -30
  73. data/spec/support/cassettes/booking_price_changes.yml +66 -0
  74. data/spec/support/cassettes/booking_show.yml +38 -32
  75. data/spec/support/cassettes/booking_update.yml +74 -62
  76. data/spec/support/cassettes/booking_with_documents.yml +88 -76
  77. data/spec/support/cassettes/booking_with_nested_attributes.yml +128 -110
  78. data/spec/support/cassettes/booking_with_price_changes.yml +86 -0
  79. data/spec/support/cassettes/countries.yml +140 -0
  80. data/spec/support/cassettes/country_all.yml +36 -30
  81. data/spec/support/cassettes/create_reservation_fail.yml +32 -27
  82. data/spec/support/cassettes/create_reservation_with_booking.yml +40 -34
  83. data/spec/support/cassettes/passenger_all.yml +36 -30
  84. data/spec/support/cassettes/payment_info.yml +61 -0
  85. data/spec/support/cassettes/product_date_range_bookability.yml +61 -59
  86. data/spec/support/cassettes/product_show.yml +42 -32
  87. data/spec/support/cassettes/product_show_as_agent.yml +63 -0
  88. data/spec/support/cassettes/product_type_all.yml +53 -0
  89. data/spec/support/cassettes/property.yml +66 -0
  90. data/spec/support/cassettes/region_show.yml +36 -30
  91. data/spec/support/cassettes/reservation_with_extra_picks.yml +137 -110
  92. data/spec/support/cassettes/resource_fare_bases.yml +47 -78
  93. data/spec/support/cassettes/resource_product_type.yml +63 -0
  94. data/spec/support/cassettes/resource_show.yml +37 -31
  95. data/spec/support/cassettes/resource_with_price.yml +63 -0
  96. data/spec/support/cassettes/route_all.yml +65 -0
  97. data/spec/support/cassettes/tenant_switcher.yml +109 -0
  98. data/spec/support/coverage_loader.rb +26 -0
  99. data/spec/tenant_spec.rb +28 -0
  100. metadata +106 -115
  101. data/bootstrap/boot.rb +0 -4
  102. data/lib/quick_travel/discounts.rb +0 -3
  103. data/lib/quick_travel/discounts/booking_discount.rb +0 -18
  104. data/lib/quick_travel/discounts/discount.rb +0 -21
  105. data/spec/support/cassettes/booking_create_legacy.yml +0 -50
  106. data/spec/support/cassettes/booking_discounts.yml +0 -53
  107. data/spec/support/cassettes/booking_with_discounts.yml +0 -72
  108. data/spec/support/cassettes/region_index.yml +0 -48
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: badf664a3d19487397626b95ca573f2feb995944
4
+ data.tar.gz: 11cd881dc671aa773918e21789acbc173ca8f7e6
5
+ SHA512:
6
+ metadata.gz: be1c4c52240989bcefa2c3a5b9155f9edf11f112fa73f52a9e23bcb15fe8e3d485961f3641865172253377898954f5bf0ea7f611190fe4badc6f80d5aaa1c51b
7
+ data.tar.gz: a49216933d018771fd9a8f885818d990179a7377c6b71eabf6d4be19b84c481fd6587b083addbc55fdc587c6854ecdfa5d2e5a61ab175f982b42ac523f230ad9
data/.gitignore CHANGED
@@ -23,3 +23,8 @@ tmp
23
23
  /tags
24
24
  /.tags
25
25
  /TAGS
26
+
27
+ # Gems
28
+ /vendor/ruby
29
+ .bundle
30
+
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-1.9.3-p551
1
+ 2.2.4
data/.travis.yml CHANGED
@@ -1,12 +1,24 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9
4
- script: "bundle && bundle exec rake coverage"
4
+ - 2.2
5
+ - 2.3.0
6
+ script: bundle && bundle exec rake spec
5
7
  gemfile:
6
8
  - gemfiles/rails2.gemfile
9
+ - gemfiles/rails4.gemfile
7
10
  matrix:
8
11
  exclude:
12
+ - rvm: 1.9
13
+ gemfile: gemfiles/rails4.gemfile
14
+ - rvm: 2.2
15
+ gemfile: gemfiles/rails2.gemfile
16
+ - rvm: 2.3.0
17
+ gemfile: gemfiles/rails2.gemfile
9
18
  notifications:
10
19
  email:
11
20
  - support@travellink.com.au
12
- flowdock: e69dcafad1fea15c6b8c76e9ced965af
21
+ flowdock:
22
+ secure: tIc3OVnTl83tGjhjzBSPk7AMRHVta4zAdacBDWOVA3s/YpDoa1wCMaq7xfG7GlEgHtPscvucSKbxoLocBd5d54jQVx3X9q9OrQ91D6h6tbTOK8ZTh1vTdSfMkIoxNjnVJ9KyZYJ3zy44DzfzgmcgqesshqSrXAgcpSvxkEcjAz8=
23
+ sudo: false
24
+ cache: bundler
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+ This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
2
5
 
3
- ## [Unreleased]
4
- ###
5
- - [DC-2147] Update resources api for CCC
6
+ ## [2.0.0] - 2016-04-08
7
+ ### Added
8
+ - This changelog
9
+ - Support for new ProductType API
10
+
11
+ ### Changed
12
+ - Discount API renamed Price Change API
13
+ - Multiple internal refactorings and cleanups
14
+ - Changes Price Quotes API to support non segment based products
15
+
16
+ ## [1.1.1] - 2015-06-22
17
+ ### Fixed
18
+ - Fixed issue with Checkout API
19
+
20
+ ## [1.1.0] - 2015-06-19
21
+ ### Added
22
+ - Checkout API
23
+
24
+ ## [1.0.2] - 2015-06-01
25
+ ### Fixed
26
+ - Fixed issue with payment type code format
27
+
28
+ ### Added
29
+ - Code attribute to passenger type
30
+
31
+ ## [1.0.1] - 2015-03-04
32
+ ### Fixed
33
+ - Fixed conflict between active_support and facets underscore method
34
+
35
+ ## [1.0.0] - 2015-03-03
36
+ - Initial public release
data/Gemfile CHANGED
@@ -1,5 +1,2 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
-
4
- # TODO: Give money extensions proper versioning and release it
5
- gem 'money_extensions', github: 'sealink/money_extensions', branch: 'master'
data/Rakefile CHANGED
@@ -10,9 +10,3 @@ RSpec::Core::RakeTask.new do |t|
10
10
  t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
11
11
  # Put spec opts in a file named .rspec in root
12
12
  end
13
-
14
- desc "Generate SimpleCov test coverage and open in your browser"
15
- task :coverage do
16
- ENV['COVERAGE'] = 'true'
17
- Rake::Task['spec'].invoke
18
- end
@@ -14,7 +14,7 @@ password = gets.chomp
14
14
  puts "Ok #{login}, just a tick..."
15
15
  result = begin
16
16
  QuickTravel::Party.login(login: login, password: password)
17
- rescue QuickTravel::AdapterException
17
+ rescue QuickTravel::AdapterError
18
18
  nil
19
19
  end
20
20
 
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+ gemspec :path => '../'
3
+
4
+ group :development, :test do
5
+ gem 'activesupport', '~> 4.2'
6
+ gem 'activerecord', '~> 4.2'
7
+ gem 'actionpack', '~> 4.2'
8
+ end
9
+
data/lib/quick_travel.rb CHANGED
@@ -8,8 +8,9 @@ module QuickTravel
8
8
  require 'quick_travel/cache'
9
9
  require 'quick_travel/config'
10
10
  require 'quick_travel/adapter'
11
- require 'quick_travel/adapter_exception'
11
+ require 'quick_travel/adapter_error'
12
12
  require 'quick_travel/connection_error'
13
+ require 'quick_travel/status'
13
14
 
14
15
  # Don't include this guy: pull the pieces into the classes that use it, or ref
15
16
  require 'quick_travel/constants'
@@ -4,21 +4,7 @@ require 'quick_travel/room_facility'
4
4
 
5
5
  module QuickTravel
6
6
  class Accommodation < Adapter
7
- # TODO: find a dynamic way to provide getter/setters for all data members instead of writing all of them.
8
-
9
- attr_accessor :book_before_level, :book_before_units, :bookable_individually, :bookable_online, :booking_notes, :code, :created_at
10
- attr_accessor :days_before_inventory_expires, :default_capacity, :deposit_id, :disclaimer_id, :expiry_level, :expiry_units, :fare_basis_pointer_id
11
- attr_accessor :frequent_traveller_points_multiplier, :guardian_minimum_age, :id, :inline_cost_in_cents, :inline_price_in_cents, :inline_pricing
12
- attr_accessor :inventory_type, :active, :location_id, :masterpoint_resource_id, :maximum_occupancy, :maximum_passengers, :maximum_passengers_online
13
- attr_accessor :maximum_weight, :minimum_age, :minimum_passengers, :name, :no_expiry, :non_commissionable, :on_request_after_inventory_expiration
14
- attr_accessor :overriding_passenger_ticket_format_id, :overriding_reservation_ticket_format_id, :overriding_vehicle_ticket_format_id
15
- attr_accessor :product_type_id, :property_id, :property_type_id, :reason_required, :report_changes, :required_number_of_vehicles
16
- attr_accessor :resource_category_id, :restrict_to_client_types, :star_rating, :type, :unlimited_uses, :updated_at, :uses, :vendor_id
17
- attr_accessor :availability, :minimum_bookable_duration, :description,
18
- :minimum_price, :nightly_price
19
- attr_accessor :on_request
20
- attr_accessor :error
21
-
7
+ attr_reader :error
22
8
  attr_reader :bed_configurations, :room_facilities
23
9
 
24
10
  MAX_DAYS = 8
@@ -3,17 +3,14 @@ require 'pp'
3
3
  require 'json'
4
4
  require 'active_support/core_ext'
5
5
  require 'money'
6
- require 'money_extensions/money_field'
7
6
 
8
7
  require 'quick_travel/config'
9
- require 'quick_travel/adapter_exception'
8
+ require 'quick_travel/adapter_error'
10
9
  require 'quick_travel/init_from_hash'
11
10
 
12
11
  module QuickTravel
13
12
  class Adapter
14
- include HTTParty
15
13
  include QuickTravel::InitFromHash
16
- include MoneyField
17
14
 
18
15
  class_attribute :api_base, :lookup
19
16
 
@@ -28,10 +25,25 @@ module QuickTravel
28
25
 
29
26
  def initialize(hash = {})
30
27
  return nil if hash.blank?
28
+ define_readers(hash.keys)
31
29
  super(Parser.new(hash).parsed_attributes)
32
30
  end
33
31
 
32
+ def define_readers(keys)
33
+ keys.each do |key|
34
+ next if respond_to?(key)
35
+ define_singleton_method(key) { instance_variable_get("@#{key}") }
36
+ if key.to_s.ends_with? '_cents'
37
+ name = key.to_s.gsub(/_in_cents$/, '')
38
+ define_singleton_method(name) {
39
+ Money.new(instance_variable_get("@#{key}"))
40
+ }
41
+ end
42
+ end
43
+ end
44
+
34
45
  def self.find(id, opts = {})
46
+ check_id!(id)
35
47
  if lookup
36
48
  all.detect { |o| o.id == id.to_i }
37
49
  else
@@ -41,9 +53,7 @@ module QuickTravel
41
53
 
42
54
  def self.all(opts = {})
43
55
  if lookup
44
- QuickTravel::Cache.cache("#{name}.all") {
45
- find_all!("#{api_base}.json", opts)
46
- }
56
+ find_all!("#{api_base}.json", opts.merge(cache: "#{name}.all-attrs"))
47
57
  else
48
58
  find_all!("#{api_base}.json", opts)
49
59
  end
@@ -54,6 +64,7 @@ module QuickTravel
54
64
  end
55
65
 
56
66
  def self.update(id, options = {})
67
+ check_id!(id)
57
68
  put_and_validate("#{api_base}/#{id}.json", options)
58
69
  end
59
70
 
@@ -72,18 +83,28 @@ module QuickTravel
72
83
 
73
84
  protected
74
85
 
75
- # Find first
76
- def self.generic_first(request_path, opts = {})
77
- find_all!(request_path, opts).first
86
+ def self.check_id!(id)
87
+ Integer(id)
88
+ rescue ArgumentError, # if invalid string
89
+ TypeError # if nil
90
+ fail ArgumentError, 'id must be an integer'
78
91
  end
79
92
 
80
93
  def self.find_all!(request_path, opts = {})
81
- response = get_and_validate(request_path, opts, return_response_object: true)
94
+ response = if opts.key? :cache
95
+ QuickTravel::Cache.cache(opts[:cache], opts[:cache_options]) {
96
+ get_and_validate(request_path, opts.except(:cache, :cache_options))
97
+ }
98
+ else
99
+ get_and_validate(request_path, opts, return_response_object: true)
100
+ end
101
+ full_response = response.respond_to? :parsed_response
102
+ parsed_response = full_response ? response.parsed_response : response
82
103
 
83
- deserializer = Deserializer.new(response.parsed_response)
104
+ deserializer = Deserializer.new(parsed_response)
84
105
  objects = Array.wrap(deserializer.extract_under_root(self))
85
106
 
86
- if response.headers['pagination'].present?
107
+ if full_response && response.headers['pagination'].present?
87
108
  pagination_headers = ::JSON.parse(response.headers['pagination'])
88
109
  WillPaginate::Collection.create(pagination_headers['current_page'], pagination_headers['per_page'], pagination_headers['total_entries']) do |pager|
89
110
  pager.replace(objects)
@@ -112,18 +133,16 @@ module QuickTravel
112
133
  self.class.extract(collection_data, klass, opts)
113
134
  end
114
135
 
115
- def self.extract(objects, klass, opts = {})
116
- objects = Array.wrap(objects)
117
- objects.map! { |item| item[opts[:object_key_name]] } if opts[:object_key_name]
118
- objects.map! { |item| klass.new(item) }
119
-
120
- # if opts[:page] && opts[:per_page]
121
- # objects = WillPaginate::Collection.create(opts[:page], opts[:per_page], opts).replace(objects)
122
- objects
136
+ def self.extract(raw_objects, klass, opts = {})
137
+ objects = Array.wrap(raw_objects)
138
+ if opts[:object_key_name]
139
+ objects = objects.map { |item| item[opts[:object_key_name]] }
140
+ end
141
+ objects.map { |item| klass.new(item) }
123
142
  end
124
143
  end
125
144
 
126
- # The above generic_first find_all and the above find
145
+ # The above find_all and the above find
127
146
  # all suck
128
147
  #
129
148
  # We should make it standard behaviour that objects
@@ -171,10 +190,58 @@ module QuickTravel
171
190
  call_and_validate(:delete, path, query, opts)
172
191
  end
173
192
 
193
+ def self.call_and_validate(http_method, path, query = {}, opts = {})
194
+ Api.call_and_validate(http_method, path, query, opts)
195
+ end
196
+
197
+ def self.base_uri(uri = nil)
198
+ Api.base_uri uri
199
+ end
200
+ end
201
+
202
+ class Parser
203
+ def initialize(attributes)
204
+ @attributes = attributes
205
+ end
206
+
207
+ def attributes
208
+ @attributes ||= {}
209
+ end
210
+
211
+ def parsed_attributes
212
+ @parsed_attributes ||= parse_attributes
213
+ end
214
+
215
+ private
216
+
217
+ def parse_attributes
218
+ attributes.map.with_object({}) do |(attribute, value), hash|
219
+ hash[attribute] = parse(attribute, value)
220
+ end
221
+ end
222
+
223
+ def parse(attribute, value)
224
+ return nil if value.nil?
225
+ return convert(value, :to_date) if attribute.to_s.ends_with?('_date')
226
+ return convert(value, :to_date) if attribute.to_s.ends_with?('_on')
227
+ # to_datetime as it converts to app time zone, to_time converts to system time zone
228
+ return convert(value, :to_datetime) if attribute.to_s.ends_with?('_time')
229
+ return convert(value, :to_datetime) if attribute.to_s.ends_with?('_at')
230
+ value
231
+ end
232
+
233
+ def convert(value, conversion_method)
234
+ convertable_value = value.is_a?(Hash) ? value['_value'] : value
235
+ convertable_value.send(conversion_method)
236
+ end
237
+ end
238
+
239
+ class Api
240
+ include HTTParty
241
+
174
242
  def self.call_and_validate(http_method, path, query = {}, opts = {})
175
243
  http_params = opts.clone
176
244
  return_response_object = http_params.delete(:return_response_object)
177
- klass = self
178
245
 
179
246
  # Set default token
180
247
  http_params[:query] ||= query
@@ -193,7 +260,7 @@ module QuickTravel
193
260
  http_params[:follow_redirects] = false
194
261
 
195
262
  begin
196
- response = klass.send(http_method, path, http_params)
263
+ response = self.send(http_method, path, http_params)
197
264
  rescue Errno::ECONNREFUSED
198
265
  raise ConnectionError.new('Connection refused')
199
266
  rescue SocketError
@@ -203,7 +270,7 @@ module QuickTravel
203
270
  end
204
271
 
205
272
  if expect && expect == :json && !response.is_a?(Hash)
206
- fail AdapterException, <<-FAIL
273
+ fail AdapterError, <<-FAIL
207
274
  Request expected to be json but failed. Debug information below:
208
275
  http_method: #{http_method.inspect}
209
276
  path: #{path.inspect}
@@ -213,7 +280,7 @@ module QuickTravel
213
280
  FAIL
214
281
  end
215
282
 
216
- klass.validate!(response)
283
+ validate!(response)
217
284
 
218
285
  if return_response_object
219
286
  response
@@ -228,14 +295,14 @@ module QuickTravel
228
295
  # Secondly, check for presence of "error" key in returned hash
229
296
  def self.validate!(response)
230
297
  case response.code
231
- when 300..399 # redirects
232
- fail ConnectionError.new('We were redirected. QT YML configuration appears to be incorrect. Verify your URL and API.')
233
- when 400..599 # client and server errors
234
- fail AdapterException.new(response)
298
+ when 300..399 # redirects
299
+ fail ConnectionError.new('We were redirected. QT YML configuration appears to be incorrect. Verify your URL and API.')
300
+ when 400..599 # client and server errors
301
+ fail AdapterError.new(response)
235
302
  end
236
303
 
237
304
  if response_contains_error?(response)
238
- fail AdapterException, response
305
+ fail AdapterError, response
239
306
  end
240
307
  end
241
308
 
@@ -244,40 +311,4 @@ module QuickTravel
244
311
  parsed_response.is_a?(Hash) && parsed_response.key?('error')
245
312
  end
246
313
  end
247
-
248
- class Parser
249
- def initialize(attributes)
250
- @attributes = attributes
251
- end
252
-
253
- def attributes
254
- @attributes ||= {}
255
- end
256
-
257
- def parsed_attributes
258
- @parsed_attributes ||= parse_attributes
259
- end
260
-
261
- private
262
-
263
- def parse_attributes
264
- attributes.map.with_object({}) do |(attribute, value), hash|
265
- hash[attribute] = parse(attribute, value)
266
- end
267
- end
268
-
269
- def parse(attribute, value)
270
- return nil if value.nil?
271
- return convert(value, :to_date) if attribute.to_s.ends_with?('_date')
272
- # to_datetime as it converts to app time zone, to_time converts to system time zone
273
- return convert(value, :to_datetime) if attribute.to_s.ends_with?('_time')
274
- return convert(value, :to_datetime) if attribute.to_s.ends_with?('_at')
275
- value
276
- end
277
-
278
- def convert(value, conversion_method)
279
- convertable_value = value.is_a?(Hash) ? value['_value'] : value
280
- convertable_value.send(conversion_method)
281
- end
282
- end
283
314
  end
@@ -1,5 +1,5 @@
1
1
  module QuickTravel
2
- class AdapterException < Exception
2
+ class AdapterError < StandardError
3
3
  attr_reader :response
4
4
 
5
5
  def initialize(response)
@@ -3,13 +3,8 @@ require 'geokit'
3
3
 
4
4
  module QuickTravel
5
5
  class Address < Adapter
6
- attr_accessor :address_line1, :address_line2, :city, :country_id, :id, :post_code, :state, :country_name
7
-
8
- def initialize(hash)
9
- super(hash)
10
- if @country_id == AUSTRALIA_COUNTRY_ID
11
- @country_name = 'Australia'
12
- end
6
+ def country_name
7
+ QuickTravel::Country.find(@country_id).name
13
8
  end
14
9
 
15
10
  def geocode