quicktravel_client 4.4.0 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/quick_travel/adapter.rb +5 -0
- data/lib/quick_travel/config.rb +1 -1
- data/lib/quick_travel/resource.rb +5 -0
- data/lib/quick_travel/version.rb +1 -1
- data/spec/adapter_spec.rb +24 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/coverage_loader.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0325799c230cd8fe94a4f7454f8ff7ccb5fddb27ab18a67b9f3096d72aada02
|
4
|
+
data.tar.gz: 427ad145f755aa347c5ceb6d1c558b9e47392d1e61f48daeac074b933d7ded30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 744fc85a1f7bf032a494eb394c1573f06c0a1094608da175f7fc20c053babf78a8950bf038ff0b6dff97a0926f70492b96db2481083aa9055590f9fd8bdd33ac
|
7
|
+
data.tar.gz: 42f9a4aefc2150631c807a96bfaad03b8a0b6ff9c1427980435bd5a35818dadb84929b715199c47c2f02093be211b5f1565ef9957087129f5feed7398768bbae
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +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
|
+
## Unreleased
|
7
|
+
|
8
|
+
|
9
|
+
## 4.5.0
|
10
|
+
- [TT-9346] Support injection of additional headers in requests to quicktravel
|
11
|
+
- [TT-9331] Cache resources to reduce unnecessary API requests
|
12
|
+
|
6
13
|
## 4.4.0
|
7
14
|
- [TT-8615] Update to build with github actions / ruby 3.0 / rails 6.1
|
8
15
|
|
data/lib/quick_travel/adapter.rb
CHANGED
@@ -216,6 +216,7 @@ module QuickTravel
|
|
216
216
|
http_params[:headers]['Content-length'] = '0' if http_params[:body].blank?
|
217
217
|
http_params[:headers]['x-api-key'] = QuickTravel.config.access_key
|
218
218
|
http_params[:headers]['user-agent'] = 'quicktravel_client/' + QuickTravel::VERSION;
|
219
|
+
http_params[:headers].merge!(extra_headers) if extra_headers
|
219
220
|
|
220
221
|
expect = http_params.delete(:expect)
|
221
222
|
|
@@ -254,6 +255,10 @@ module QuickTravel
|
|
254
255
|
response
|
255
256
|
end
|
256
257
|
|
258
|
+
def self.extra_headers
|
259
|
+
QuickTravel.config.extra_headers
|
260
|
+
end
|
261
|
+
|
257
262
|
# Do standard validations on response
|
258
263
|
#
|
259
264
|
# Firstly, check if a valid HTTP code was returned
|
data/lib/quick_travel/config.rb
CHANGED
@@ -11,6 +11,11 @@ module QuickTravel
|
|
11
11
|
Resource.find_all!('/api/resources.json', parent_resource_id: @id)
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.find(id, opts = {})
|
15
|
+
opts = { cache_key: "resource:#{id}", cache_options: { expires_in: 1.hour } }.merge(opts)
|
16
|
+
super(id, opts)
|
17
|
+
end
|
18
|
+
|
14
19
|
def self.all_with_price(opts)
|
15
20
|
cache_key = GenerateCacheKey.new(name, opts).call
|
16
21
|
find_all!("/api/resources/index_with_price.json", opts.merge(cache_key: cache_key))
|
data/lib/quick_travel/version.rb
CHANGED
data/spec/adapter_spec.rb
CHANGED
@@ -83,4 +83,28 @@ describe QuickTravel::Adapter do
|
|
83
83
|
specify { expect(api).to have_received(:call_and_validate).twice }
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
context 'extra headers defined' do
|
88
|
+
let(:url) { 'http://test.quicktravel.com.au' }
|
89
|
+
let(:query) { {} }
|
90
|
+
let(:change_config) { }
|
91
|
+
let(:useragent) { 'rspec' }
|
92
|
+
|
93
|
+
before do
|
94
|
+
change_config
|
95
|
+
QuickTravel::Adapter.post_and_validate(url, query)
|
96
|
+
end
|
97
|
+
|
98
|
+
let(:expected_params) { a_hash_including(headers: a_hash_including('user-agent' => useragent)) }
|
99
|
+
|
100
|
+
specify { expect(QuickTravel::Api).to have_received(:post).with(url, expected_params) }
|
101
|
+
|
102
|
+
context 'and the config is changed' do
|
103
|
+
let(:useragent) { 'newspec' }
|
104
|
+
let(:change_config) {
|
105
|
+
QuickTravel.config.extra_headers = { 'user-agent' => 'newspec' }
|
106
|
+
}
|
107
|
+
specify { expect(QuickTravel::Api).to have_received(:post).with(url, expected_params) }
|
108
|
+
end
|
109
|
+
end
|
86
110
|
end
|
data/spec/spec_helper.rb
CHANGED
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: 4.
|
4
|
+
version: 4.5.0
|
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: 2021-
|
13
|
+
date: 2021-05-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|