quicktravel_client 2.3.0 → 2.3.1
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 +11 -7
- data/lib/quick_travel/adapter.rb +33 -1
- data/lib/quick_travel/version.rb +1 -1
- data/spec/adapter_spec.rb +38 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5dcbf38f81c9b909173948030ab544edf2b10a6
|
4
|
+
data.tar.gz: fde0ede3e1331d355c4ee42db771e2c9f0e2e8ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac7e14d70db0fe8944f44f07dbdd37f5bb8825dce307b38856e1f893734956a792c692876c770014ae0f6ad347c9bdd7cbacc48a430061113c75435ec0292052
|
7
|
+
data.tar.gz: 0b4ca73328cea2f66a10f89cd005403443ebbd39f15f3385180d37f68d77548fd0fa82a7b042931dc8e81b464ba5b7c380c1b8abbeeaadf27a202208139f8d17
|
data/CHANGELOG.md
CHANGED
@@ -3,9 +3,13 @@ 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
|
+
## [2.3.1]
|
7
|
+
### Fixed
|
8
|
+
- Omits empty array parameters
|
9
|
+
|
6
10
|
## [2.3.0]
|
7
11
|
### Changed
|
8
|
-
|
12
|
+
- Change cache expiries
|
9
13
|
- Adds support for passing dates to Resource#all_with_price
|
10
14
|
|
11
15
|
### Fixed
|
@@ -14,21 +18,21 @@ This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
|
|
14
18
|
|
15
19
|
## [2.2.2]
|
16
20
|
### Changed
|
17
|
-
|
18
|
-
|
21
|
+
- Deprecates Booking#calculate_price_quote
|
22
|
+
- Fix when money is nil from QT
|
19
23
|
|
20
24
|
## [2.2.1] - 2016-04-18
|
21
25
|
### Fixed
|
22
|
-
|
26
|
+
- Adds missing require for PriceQuote adapter
|
23
27
|
|
24
28
|
## [2.2.0] - 2016-04-18
|
25
29
|
### Added
|
26
|
-
|
30
|
+
- PriceQuote adapter
|
27
31
|
|
28
32
|
## [2.1.0] - 2016-04-13
|
29
33
|
### Added
|
30
|
-
|
31
|
-
|
34
|
+
- Resource categories
|
35
|
+
- Products
|
32
36
|
|
33
37
|
## [2.0.0] - 2016-04-08
|
34
38
|
### Added
|
data/lib/quick_travel/adapter.rb
CHANGED
@@ -3,6 +3,8 @@ require 'pp'
|
|
3
3
|
require 'json'
|
4
4
|
require 'active_support/core_ext'
|
5
5
|
require 'money'
|
6
|
+
require 'facets/hash/recurse'
|
7
|
+
require 'facets/hash/delete_values'
|
6
8
|
|
7
9
|
require 'quick_travel/config'
|
8
10
|
require 'quick_travel/adapter_error'
|
@@ -247,7 +249,7 @@ module QuickTravel
|
|
247
249
|
return_response_object = http_params.delete(:return_response_object)
|
248
250
|
|
249
251
|
# Set default token
|
250
|
-
http_params[:query]
|
252
|
+
http_params[:query] ||= FilterQuery.new(query).call
|
251
253
|
http_params[:headers] ||= {}
|
252
254
|
http_params[:headers]['Content-length'] = '0' if http_params[:body].blank?
|
253
255
|
expect = http_params.delete(:expect)
|
@@ -313,5 +315,35 @@ module QuickTravel
|
|
313
315
|
parsed_response = response.parsed_response
|
314
316
|
parsed_response.is_a?(Hash) && parsed_response.key?('error')
|
315
317
|
end
|
318
|
+
|
319
|
+
# HTTParty v0.14.0 introduced this change:
|
320
|
+
#
|
321
|
+
# * [allow empty array to be used as param](https://github.com/jnunemaker/httparty/pull/477)
|
322
|
+
#
|
323
|
+
# Unfortunately, when submitting an empty array as a parameter,
|
324
|
+
# Rack interprets it as an array containing an empty string:
|
325
|
+
#
|
326
|
+
# Rack::Utils.parse_nested_query('array[]=') #=> {"array"=>[""]}
|
327
|
+
#
|
328
|
+
# The workaround is to avoid sending empty arrays to Rack based web applications
|
329
|
+
class FilterQuery
|
330
|
+
def initialize(query)
|
331
|
+
@query = query
|
332
|
+
end
|
333
|
+
|
334
|
+
def call
|
335
|
+
return @query unless @query.is_a? Hash
|
336
|
+
without_empty_arrays
|
337
|
+
end
|
338
|
+
|
339
|
+
private
|
340
|
+
|
341
|
+
def without_empty_arrays
|
342
|
+
@query.recurse { |hash|
|
343
|
+
hash.delete_values([])
|
344
|
+
hash
|
345
|
+
}
|
346
|
+
end
|
347
|
+
end
|
316
348
|
end
|
317
349
|
end
|
data/lib/quick_travel/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'quick_travel/adapter'
|
3
|
+
|
4
|
+
describe QuickTravel::Adapter do
|
5
|
+
let(:response) { double code: 200, parsed_response: parsed_response }
|
6
|
+
let(:parsed_response) { { test: true } }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow(QuickTravel::Api).to receive(:post).and_return(response)
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when the query contains empty arrays' do
|
13
|
+
let(:url) { 'http://test.quicktravel.com.au' }
|
14
|
+
let(:query) {
|
15
|
+
{
|
16
|
+
test: true,
|
17
|
+
empty_array: [],
|
18
|
+
sub_hash: { id: 42, values: [] }
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
before do
|
23
|
+
QuickTravel::Adapter.post_and_validate(url, query)
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:expected_body) {
|
27
|
+
{
|
28
|
+
test: true,
|
29
|
+
sub_hash: { id: 42 },
|
30
|
+
access_key: an_instance_of(String)
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
let(:expected_params) { a_hash_including body: expected_body }
|
35
|
+
|
36
|
+
specify { expect(QuickTravel::Api).to have_received(:post).with(url, expected_params) }
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quicktravel_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-08-
|
13
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -355,6 +355,7 @@ files:
|
|
355
355
|
- lib/quick_travel/version.rb
|
356
356
|
- lib/quicktravel_client.rb
|
357
357
|
- quicktravel_client.gemspec
|
358
|
+
- spec/adapter_spec.rb
|
358
359
|
- spec/booking_spec.rb
|
359
360
|
- spec/country_spec.rb
|
360
361
|
- spec/credit_card_spec.rb
|
@@ -436,6 +437,7 @@ signing_key:
|
|
436
437
|
specification_version: 4
|
437
438
|
summary: Booking process using QuickTravel API
|
438
439
|
test_files:
|
440
|
+
- spec/adapter_spec.rb
|
439
441
|
- spec/booking_spec.rb
|
440
442
|
- spec/country_spec.rb
|
441
443
|
- spec/credit_card_spec.rb
|