gman_client 0.0.10 → 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
- data/.gitignore +1 -0
- data/lib/gman/client.rb +2 -0
- data/lib/gman_client/api/customer_contracts.rb +20 -0
- data/lib/gman_client/api/health_check.rb +13 -0
- data/lib/gman_client/version.rb +1 -1
- data/lib/gman_client.rb +2 -0
- data/spec/lib/client/customer_contracts_spec.rb +98 -0
- data/spec/lib/client/health_check_spec.rb +52 -0
- data/spec/lib/client/orders_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -3
- metadata +9 -11
- data/pkg/gman_client-0.0.1.gem +0 -0
- data/pkg/gman_client-0.0.2.gem +0 -0
- data/pkg/gman_client-0.0.3.gem +0 -0
- data/pkg/gman_client-0.0.4.gem +0 -0
- data/pkg/gman_client-0.0.5.gem +0 -0
- data/pkg/gman_client-0.0.7.gem +0 -0
- data/pkg/gman_client-0.0.8.gem +0 -0
- data/pkg/gman_client-0.0.9.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aa6d21aa0d0f6fe345c586c397140edcf677c11
|
4
|
+
data.tar.gz: 84497c9c1c9b0bec166d29f1a40625c268b06318
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bec26eb20558386e4367b87a82a34dbfdd26cbab4f82c6d4f3e4a7dc475541ad102e0e598644b267209c5273340576f276d942e9eea9e474926a31830cb678e6
|
7
|
+
data.tar.gz: 800098bb6f74c540a2e484a6e1387d092c4e6f82fe51eeb9309a47c163bd22a0854ef6e5442ddf0b5fddac448b713e59994ccac92f058635b8f77089d4e3a682
|
data/.gitignore
CHANGED
data/lib/gman/client.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module GmanClient
|
2
|
+
module Api
|
3
|
+
module CustomerContracts
|
4
|
+
# Retrieves customer contracts
|
5
|
+
#
|
6
|
+
# @param [Hash] parameters to filter the orders
|
7
|
+
def customer_contracts(filter_params)
|
8
|
+
response = attempt(@retry_attempts) do
|
9
|
+
request
|
10
|
+
.api
|
11
|
+
.v1
|
12
|
+
.customer_contracts
|
13
|
+
.get(params: { q: filter_params })
|
14
|
+
end
|
15
|
+
|
16
|
+
response.map(&:to_h)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/gman_client/version.rb
CHANGED
data/lib/gman_client.rb
CHANGED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'webmock'
|
3
|
+
|
4
|
+
RSpec.describe Gman::Client do
|
5
|
+
include WebMock::API
|
6
|
+
|
7
|
+
let(:client) do
|
8
|
+
Gman::Client.new(
|
9
|
+
url: stubbed_url,
|
10
|
+
client_id: 'client_id',
|
11
|
+
client_secret: 'client_secret'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:customer_contracts_hash) do
|
16
|
+
[
|
17
|
+
{
|
18
|
+
contract_id: '50000000',
|
19
|
+
contract_type: 'Sale',
|
20
|
+
customer_id: '00010000',
|
21
|
+
location_id: '01'
|
22
|
+
},
|
23
|
+
{
|
24
|
+
contract_id: '50000100',
|
25
|
+
contract_type: 'Sale',
|
26
|
+
customer_id: '00010000',
|
27
|
+
location_id: '01'
|
28
|
+
}
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#customer_contracts' do
|
33
|
+
let(:described) { client.customer_contracts(params) }
|
34
|
+
let(:stubbed_url) { 'http://test.local' }
|
35
|
+
|
36
|
+
context 'when customer contracts are found' do
|
37
|
+
before do
|
38
|
+
stub_request(:post, "#{stubbed_url}/oauth/token")
|
39
|
+
.to_return(
|
40
|
+
body: { access_token: access_token }.to_json, status: 200
|
41
|
+
)
|
42
|
+
stub_request(
|
43
|
+
:get, "#{stubbed_url}/api/v1/customer_contracts.json?#{query_string}"
|
44
|
+
)
|
45
|
+
.to_return(body: customer_contracts_hash.to_json, status: 200)
|
46
|
+
end
|
47
|
+
let(:access_token) { SecureRandom.uuid }
|
48
|
+
let(:params) do
|
49
|
+
{
|
50
|
+
customer_id: '00010000'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
let(:query_string) do
|
54
|
+
params.map { |k, v| "q[#{k}]=#{v}" }.join('&')
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'response' do
|
58
|
+
subject { described }
|
59
|
+
|
60
|
+
it { is_expected.to be_kind_of(Array) }
|
61
|
+
its(:size) { is_expected.to eq 2 }
|
62
|
+
|
63
|
+
describe 'first match' do
|
64
|
+
subject { described[0] }
|
65
|
+
|
66
|
+
its([:contract_id]) do
|
67
|
+
is_expected.to eq customer_contracts_hash[0][:contract_id]
|
68
|
+
end
|
69
|
+
its([:contract_type]) do
|
70
|
+
is_expected.to eq customer_contracts_hash[0][:contract_type]
|
71
|
+
end
|
72
|
+
its([:customer_id]) do
|
73
|
+
is_expected.to eq customer_contracts_hash[0][:customer_id]
|
74
|
+
end
|
75
|
+
its([:location_id]) do
|
76
|
+
is_expected.to eq customer_contracts_hash[0][:location_id]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
describe 'second match' do
|
80
|
+
subject { described[1] }
|
81
|
+
|
82
|
+
its([:contract_id]) do
|
83
|
+
is_expected.to eq customer_contracts_hash[1][:contract_id]
|
84
|
+
end
|
85
|
+
its([:contract_type]) do
|
86
|
+
is_expected.to eq customer_contracts_hash[1][:contract_type]
|
87
|
+
end
|
88
|
+
its([:customer_id]) do
|
89
|
+
is_expected.to eq customer_contracts_hash[1][:customer_id]
|
90
|
+
end
|
91
|
+
its([:location_id]) do
|
92
|
+
is_expected.to eq customer_contracts_hash[1][:location_id]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'webmock'
|
3
|
+
|
4
|
+
RSpec.describe Gman::Client do
|
5
|
+
include WebMock::API
|
6
|
+
|
7
|
+
let(:client) do
|
8
|
+
Gman::Client.new(
|
9
|
+
url: stubbed_url,
|
10
|
+
client_id: 'client_id',
|
11
|
+
client_secret: 'client_secret'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#health_check' do
|
16
|
+
let(:described) { client.health_check }
|
17
|
+
let(:access_token) { SecureRandom.uuid }
|
18
|
+
let(:stubbed_url) { 'http://test.local' }
|
19
|
+
|
20
|
+
before do
|
21
|
+
stub_request(:post, "#{stubbed_url}/oauth/token")
|
22
|
+
.to_return(
|
23
|
+
body: { access_token: access_token }.to_json, status: 200
|
24
|
+
)
|
25
|
+
stub_request(
|
26
|
+
:get, "#{stubbed_url}/api/v1/health_check.json"
|
27
|
+
)
|
28
|
+
.to_return(body: health_check_hash.to_json, status: 200)
|
29
|
+
end
|
30
|
+
let(:access_token) { SecureRandom.uuid }
|
31
|
+
|
32
|
+
subject do
|
33
|
+
described
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when the health check is successful' do
|
37
|
+
let(:health_check_hash) { { health_check: 'Passed' } }
|
38
|
+
|
39
|
+
it 'should be true' do
|
40
|
+
expect(subject).to eq(true)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when the health check fails' do
|
45
|
+
let(:health_check_hash) { { health_check: 'Failed' } }
|
46
|
+
|
47
|
+
it 'should be false' do
|
48
|
+
expect(subject).to eq(false)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
require 'codeclimate-test-reporter'
|
2
|
-
CodeClimate::TestReporter.start
|
3
|
-
|
4
1
|
require 'rspec/its'
|
5
2
|
require 'spec_helper'
|
6
3
|
require 'gman_client'
|
7
4
|
require 'httparty'
|
8
5
|
require 'webmock'
|
6
|
+
require 'securerandom'
|
9
7
|
|
10
8
|
Dir[File.join(GmanClient.root, 'spec/support/**/*.rb')].each { |f| require f }
|
11
9
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gman_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MichaelAChrisco
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: vcr
|
@@ -171,19 +171,15 @@ files:
|
|
171
171
|
- gman_client.gemspec
|
172
172
|
- lib/gman/client.rb
|
173
173
|
- lib/gman_client.rb
|
174
|
+
- lib/gman_client/api/customer_contracts.rb
|
175
|
+
- lib/gman_client/api/health_check.rb
|
174
176
|
- lib/gman_client/api/orders.rb
|
175
177
|
- lib/gman_client/commodity_merchandising/contracts.rb
|
176
178
|
- lib/gman_client/inventory/items.rb
|
177
179
|
- lib/gman_client/utility.rb
|
178
180
|
- lib/gman_client/version.rb
|
179
|
-
-
|
180
|
-
-
|
181
|
-
- pkg/gman_client-0.0.3.gem
|
182
|
-
- pkg/gman_client-0.0.4.gem
|
183
|
-
- pkg/gman_client-0.0.5.gem
|
184
|
-
- pkg/gman_client-0.0.7.gem
|
185
|
-
- pkg/gman_client-0.0.8.gem
|
186
|
-
- pkg/gman_client-0.0.9.gem
|
181
|
+
- spec/lib/client/customer_contracts_spec.rb
|
182
|
+
- spec/lib/client/health_check_spec.rb
|
187
183
|
- spec/lib/client/order_spec.rb
|
188
184
|
- spec/lib/client/orders_spec.rb
|
189
185
|
- spec/lib/client_contracts_spec.rb
|
@@ -221,11 +217,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
217
|
version: '0'
|
222
218
|
requirements: []
|
223
219
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.
|
220
|
+
rubygems_version: 2.4.8
|
225
221
|
signing_key:
|
226
222
|
specification_version: 4
|
227
223
|
summary: Grossman API Client for Ruby
|
228
224
|
test_files:
|
225
|
+
- spec/lib/client/customer_contracts_spec.rb
|
226
|
+
- spec/lib/client/health_check_spec.rb
|
229
227
|
- spec/lib/client/order_spec.rb
|
230
228
|
- spec/lib/client/orders_spec.rb
|
231
229
|
- spec/lib/client_contracts_spec.rb
|
data/pkg/gman_client-0.0.1.gem
DELETED
Binary file
|
data/pkg/gman_client-0.0.2.gem
DELETED
Binary file
|
data/pkg/gman_client-0.0.3.gem
DELETED
Binary file
|
data/pkg/gman_client-0.0.4.gem
DELETED
Binary file
|
data/pkg/gman_client-0.0.5.gem
DELETED
Binary file
|
data/pkg/gman_client-0.0.7.gem
DELETED
Binary file
|
data/pkg/gman_client-0.0.8.gem
DELETED
Binary file
|
data/pkg/gman_client-0.0.9.gem
DELETED
Binary file
|