bootic_client 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/bootic_client/client.rb +2 -1
- data/lib/bootic_client/version.rb +1 -1
- data/lib/bootic_client.rb +6 -1
- data/spec/client_spec.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03f3eb030bbf24bfb6139b46682376a00520cff4
|
4
|
+
data.tar.gz: 480c44fe0b9e62387028d5d0d2061ee5350664e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29a90003594b260e0dbc0a0ddcdaa2758ab9f54a87fd467698bc7a658efaa836ebeb5a3182f24c83e659016c753c669970a5178ca5224e528a6ed801b402b3aa
|
7
|
+
data.tar.gz: ea07a9a75c125f616945985be788b5b246e53c4df9e4b288a2e70d41445c501a1df943f79071f7d6c31a34652e5a3d743b5d3a9653c54d3d9157f312fee3e1d8
|
data/README.md
CHANGED
@@ -28,11 +28,14 @@ You first must create an OAuth2 Application in your Bootic dashboard. Then confi
|
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
BooticClient.configure do |c|
|
31
|
+
# these are required for OAuth2 strategies
|
31
32
|
c.client_id = ENV['BOOTIC_CLIENT_ID']
|
32
33
|
c.client_secret = ENV['BOOTIC_CLIENT_SECRET']
|
34
|
+
# these are optional
|
33
35
|
c.logger = Logger.new(STDOUT)
|
34
36
|
c.logging = true
|
35
37
|
c.cache_store = Rails.cache
|
38
|
+
c.user_agent = "My App v1"
|
36
39
|
end
|
37
40
|
```
|
38
41
|
|
data/lib/bootic_client/client.rb
CHANGED
@@ -18,6 +18,7 @@ module BooticClient
|
|
18
18
|
@options = {
|
19
19
|
logging: false,
|
20
20
|
faraday_adapter: [:net_http_persistent],
|
21
|
+
user_agent: USER_AGENT
|
21
22
|
}.merge(options.dup)
|
22
23
|
|
23
24
|
@options[:cache_store] = @options[:cache_store] || Faraday::HttpCache::MemoryStore.new
|
@@ -76,7 +77,7 @@ module BooticClient
|
|
76
77
|
|
77
78
|
def request_headers
|
78
79
|
{
|
79
|
-
'User-Agent' =>
|
80
|
+
'User-Agent' => options[:user_agent],
|
80
81
|
'Accept' => JSON_MIME,
|
81
82
|
'Content-Type' => JSON_MIME
|
82
83
|
}
|
data/lib/bootic_client.rb
CHANGED
@@ -13,7 +13,7 @@ module BooticClient
|
|
13
13
|
|
14
14
|
class << self
|
15
15
|
attr_accessor :logging
|
16
|
-
attr_reader :client_id, :client_secret, :cache_store
|
16
|
+
attr_reader :client_id, :client_secret, :cache_store, :user_agent
|
17
17
|
|
18
18
|
def strategies
|
19
19
|
@strategies ||= {}
|
@@ -24,10 +24,15 @@ module BooticClient
|
|
24
24
|
opts[:logging] = logging
|
25
25
|
opts[:logger] = logger if logging
|
26
26
|
opts[:cache_store] = cache_store if cache_store
|
27
|
+
opts[:user_agent] = user_agent if user_agent
|
27
28
|
require "bootic_client/strategies/#{strategy_name}"
|
28
29
|
strategies.fetch(strategy_name.to_sym).new self, opts, &on_new_token
|
29
30
|
end
|
30
31
|
|
32
|
+
def user_agent=(v)
|
33
|
+
set_non_nil :user_agent, v
|
34
|
+
end
|
35
|
+
|
31
36
|
def client_id=(v)
|
32
37
|
set_non_nil :client_id, v
|
33
38
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -110,6 +110,27 @@ describe BooticClient::Client do
|
|
110
110
|
|
111
111
|
end
|
112
112
|
|
113
|
+
context 'User-Agent' do
|
114
|
+
it 'sends it' do
|
115
|
+
req = stub_request(:get, root_url)
|
116
|
+
.with(headers: {'User-Agent' => described_class::USER_AGENT})
|
117
|
+
.to_return(status: 200, body: JSON.dump(root_data), headers: response_headers)
|
118
|
+
|
119
|
+
client.get(root_url, {}, request_headers)
|
120
|
+
expect(req).to have_been_requested
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'can be configured' do
|
124
|
+
client = described_class.new(user_agent: 'foobar')
|
125
|
+
req = stub_request(:get, root_url)
|
126
|
+
.with(headers: {'User-Agent' => 'foobar'})
|
127
|
+
.to_return(status: 200, body: JSON.dump(root_data), headers: response_headers)
|
128
|
+
|
129
|
+
client.get(root_url, {}, request_headers)
|
130
|
+
expect(req).to have_been_requested
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
113
134
|
context 'errors' do
|
114
135
|
describe '500 Server error' do
|
115
136
|
before do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootic_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ismael Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|