ngp_van 0.1.4 → 0.2.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +11 -0
- data/lib/ngp_van/client.rb +9 -0
- data/lib/ngp_van/connection.rb +4 -4
- data/lib/ngp_van/version.rb +2 -2
- data/spec/ngp_van/client_spec.rb +34 -0
- metadata +4 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49541631c032128c94d612b0934327512578a7f49e0ed7d0c143ffdcd4a9db71
|
4
|
+
data.tar.gz: 4965a5ac2d4fee4079a605870904745f6a6249fc6d6d4a44a484bc2bb8e33fe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03ab10c4f055ce52c29e9e463a55a52e3fcf6e1ec55fdf52d25b08affd9a7d17e78922df2d783638635c2faedf19d41c9b6f841fbdc72922d39c3fa6ab3a151a
|
7
|
+
data.tar.gz: a64f5bb442fb98d4be32de10a892fc69536a1e096683e288bde9b61403ba092f69ef31415115b982faa29d5d4dd98729a52d49e0743c50d8b6adf1c31719e13d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -60,6 +60,17 @@ Options can also be set on the configuration object:
|
|
60
60
|
# => "de286a1a-f2e7-421a-91b8-f8cc8201558f|1"
|
61
61
|
```
|
62
62
|
|
63
|
+
In a multi-threaded environment you may want to use multiple configurations simultaneously.
|
64
|
+
In that case, pass an appropriately setup configuration class to the client object.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
configuration = NgpVan::Configuration.new
|
68
|
+
configuration.api_key = 'de286a1a-f2e7-421a-91b8-f8cc8201558f|1'
|
69
|
+
client = NgpVan::Client.new(configuration)
|
70
|
+
client.district_fields
|
71
|
+
|
72
|
+
```
|
73
|
+
|
63
74
|
## Making requests
|
64
75
|
|
65
76
|
API Methods can be called as module methods or as instance methods on the client.
|
data/lib/ngp_van/client.rb
CHANGED
@@ -20,6 +20,15 @@ require 'ngp_van/client/users'
|
|
20
20
|
|
21
21
|
module NgpVan
|
22
22
|
class Client
|
23
|
+
|
24
|
+
def initialize(configuration = nil)
|
25
|
+
@config = configuration
|
26
|
+
end
|
27
|
+
|
28
|
+
def config
|
29
|
+
@config || NgpVan.configuration
|
30
|
+
end
|
31
|
+
|
23
32
|
include NgpVan::Connection
|
24
33
|
include NgpVan::Request
|
25
34
|
include NgpVan::Response
|
data/lib/ngp_van/connection.rb
CHANGED
@@ -10,17 +10,17 @@ module NgpVan
|
|
10
10
|
# rubocop:disable Metrics/MethodLength
|
11
11
|
def connection
|
12
12
|
options = {
|
13
|
-
url:
|
13
|
+
url: config.api_endpoint,
|
14
14
|
headers: {
|
15
15
|
'Accept' => 'application/json; charset=utf-8',
|
16
|
-
'User-Agent' =>
|
16
|
+
'User-Agent' => config.user_agent
|
17
17
|
}
|
18
18
|
}
|
19
19
|
|
20
20
|
Faraday::Connection.new(options) do |connection|
|
21
21
|
connection.basic_auth(
|
22
|
-
|
23
|
-
|
22
|
+
config.application_name,
|
23
|
+
config.api_key
|
24
24
|
)
|
25
25
|
|
26
26
|
connection.request(:json)
|
data/lib/ngp_van/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module NgpVan
|
6
|
+
RSpec.describe Client do
|
7
|
+
describe 'initialization' do
|
8
|
+
describe 'with a specified configuration' do
|
9
|
+
let(:config) { NgpVan::Configuration.new }
|
10
|
+
|
11
|
+
subject { NgpVan::Client.new(config) }
|
12
|
+
|
13
|
+
it 'should accept and store as config' do
|
14
|
+
expect(subject.config).to eq(config)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'without a specified config' do
|
19
|
+
it 'should get the default' do
|
20
|
+
expect(subject.config).to eq(NgpVan.configuration)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'usage' do
|
26
|
+
it 'should be possible to build a config and use it per client' do
|
27
|
+
configuration = NgpVan::Configuration.new
|
28
|
+
configuration.user_agent = 'test agent'
|
29
|
+
client = NgpVan::Client.new(configuration)
|
30
|
+
expect(client.config.user_agent).to eq('test agent')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ngp_van
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Styles
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
uZ9aI1c3Tt/pkw9HxXwDo1m/+BQOZkAhEZu6LQQgBPAX8hlUyDw54SoJtfnFp0FI
|
37
37
|
Hje6PutFGypAA8f9kmLl8X2Eu74D8PI9ywc=
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2018-
|
39
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: faraday
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- spec/ngp_van/client/signups_spec.rb
|
125
125
|
- spec/ngp_van/client/survey_questions_spec.rb
|
126
126
|
- spec/ngp_van/client/users_spec.rb
|
127
|
+
- spec/ngp_van/client_spec.rb
|
127
128
|
- spec/ngp_van/configuration_spec.rb
|
128
129
|
- spec/ngp_van/request_spec.rb
|
129
130
|
- spec/ngp_van_spec.rb
|
@@ -195,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
196
|
version: '0'
|
196
197
|
requirements: []
|
197
198
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.7.
|
199
|
+
rubygems_version: 2.7.6
|
199
200
|
signing_key:
|
200
201
|
specification_version: 4
|
201
202
|
summary: Ruby wrapper for the NGP VAN API
|
metadata.gz.sig
CHANGED
Binary file
|