gman_client 0.0.9 → 0.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0b2012b4f4a924167b18271efdb13e092788ce7
4
- data.tar.gz: 1a3f2f3281bb916cfd1b0a17f96362f197ee1c0c
3
+ metadata.gz: 7c1961bbbdfb8456af992da97bdc4c62be5c55f6
4
+ data.tar.gz: 698d78209642e4be8dce4959929b033f196fff3f
5
5
  SHA512:
6
- metadata.gz: 45e41fc768e6a7af96b33839ad40a736395ffeea7197eb1312ccc0a891b72a831cedba12ce20e0eac73600ad796115f51beaf856a6f26def7b6fc94ae6ef1e9c
7
- data.tar.gz: 4ec31c7001b660759fd40faeee19346fa46475f987f9da1343d459c8c1ab548259a4413199d4775c0aa824a67cf0780ec0ab2485dd5fbd08db24d64edfe1117f
6
+ metadata.gz: da90786bdb30d56ebc16cc169931ef4fbe2eec28df962f92833db7e9b47d4f4fee772b42d1d5a39f4d62896825b016a177d821ba45fdff201bcf49dec8cb28b3
7
+ data.tar.gz: fbca6812bef81e0265f6fa84f8de67b82244e8c55a07d12032b0ccd915b7adddebfcfba4801fb120d4ca4c3cdc8c160caba0715de008aacd965d43bc8ba310fc
@@ -16,6 +16,21 @@ module GmanClient
16
16
 
17
17
  response.to_h
18
18
  end
19
+
20
+ # Retrieves a number of orders
21
+ #
22
+ # @param [Hash] parameters to filter the orders
23
+ def orders(filter_params)
24
+ response = attempt(@retry_attempts) do
25
+ request
26
+ .api
27
+ .v1
28
+ .orders
29
+ .get(params: filter_params)
30
+ end
31
+
32
+ response.map(&:to_h)
33
+ end
19
34
  end
20
35
  end
21
36
  end
@@ -1,3 +1,3 @@
1
1
  module GmanClient
2
- VERSION = '0.0.9'.freeze
2
+ VERSION = '0.0.10'.freeze
3
3
  end
Binary file
@@ -11,20 +11,19 @@ RSpec.describe Gman::Client do
11
11
  client_secret: 'client_secret'
12
12
  )
13
13
  end
14
-
15
14
  let(:orders_hash) do
16
15
  [
17
16
  {
18
- order_number: 000001,
19
- order_key: 001,
17
+ order_number: 100_001,
18
+ order_key: 101,
20
19
  quantity_shipped: 5.0,
21
20
  ship_date: '2000-01-01',
22
21
  warehouse_id: 1,
23
22
  uuid: '949085E3-6FC3-4240-BC86-2940D543DB35'
24
23
  },
25
24
  {
26
- order_number: 000002,
27
- order_key: 002,
25
+ order_number: 100_002,
26
+ order_key: 102,
28
27
  quantity_shipped: 5.0,
29
28
  ship_date: '2000-01-01',
30
29
  warehouse_id: 1,
@@ -0,0 +1,110 @@
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
+ let(:orders_hash) do
15
+ [
16
+ {
17
+ order_number: 100_001,
18
+ order_key: 100,
19
+ quantity_shipped: 5.0,
20
+ ship_date: '2000-01-01',
21
+ warehouse_id: 1,
22
+ uuid: '949085E3-6FC3-4240-BC86-2940D543DB35'
23
+ },
24
+ {
25
+ order_number: 100_002,
26
+ order_key: 100,
27
+ quantity_shipped: 5.0,
28
+ ship_date: '2000-01-01',
29
+ warehouse_id: 1,
30
+ uuid: '1AE4C0FD-B1B3-4381-ACF2-62025A6F0D8C'
31
+ }
32
+ ]
33
+ end
34
+
35
+ describe '#orders' do
36
+ let(:described) { client.orders(params) }
37
+ let(:access_token) { SecureRandom.uuid }
38
+ let(:order_hash) { orders_hash.sample }
39
+ let(:stubbed_url) { 'http://test.local' }
40
+ let(:params) { {} }
41
+
42
+ subject do
43
+ described
44
+ end
45
+
46
+ context 'when the authorization fails' do
47
+ before do
48
+ stub_request(:post, "#{stubbed_url}/oauth/token")
49
+ .to_return(response)
50
+ end
51
+
52
+ let(:response) do
53
+ {
54
+ body: {
55
+ error: 'invalid_client',
56
+ error_description: '...'
57
+ }.to_json,
58
+ status: 401
59
+ }
60
+ end
61
+
62
+ it 'should raise RestClient::Unauthorized' do
63
+ expect { subject }.to raise_error(RestClient::Unauthorized)
64
+ end
65
+ end
66
+
67
+ context 'when an order is found' do
68
+ before do
69
+ stub_request(:post, "#{stubbed_url}/oauth/token")
70
+ .to_return(
71
+ body: { access_token: access_token }.to_json, status: 200
72
+ )
73
+
74
+ query_string = params.map { |k, v| "#{k}=#{v}" }.join('&')
75
+ stub_request(
76
+ :get, "#{stubbed_url}/api/v1/orders.json?#{query_string}"
77
+ )
78
+ .to_return(body: [order_hash].to_json, status: 200)
79
+ end
80
+ let(:access_token) { SecureRandom.uuid }
81
+ let(:params) do
82
+ {
83
+ warehouse_id_eq: order_hash[:warehouse_id],
84
+ order_number_eq: order_hash[:order_number]
85
+ }
86
+ end
87
+
88
+ it 'should respond with a Hash' do
89
+ expect(subject).to be_kind_of(Array)
90
+ end
91
+
92
+ describe 'response' do
93
+ its(:size) { is_expected.to eq 1 }
94
+
95
+ describe 'first match' do
96
+ subject { described[0] }
97
+
98
+ its([:order_number]) { is_expected.to eq order_hash[:order_number] }
99
+ its([:order_key]) { is_expected.to eq order_hash[:order_key] }
100
+ its([:quantity_shipped]) do
101
+ is_expected.to eq order_hash[:quantity_shipped]
102
+ end
103
+ its([:ship_date]) { is_expected.to eq order_hash[:ship_date] }
104
+ its([:warehouse_id]) { is_expected.to eq order_hash[:warehouse_id] }
105
+ its([:uuid]) { is_expected.to eq order_hash[:uuid] }
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
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.9
4
+ version: 0.0.10
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-08-17 00:00:00.000000000 Z
12
+ date: 2016-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: vcr
@@ -183,8 +183,10 @@ files:
183
183
  - pkg/gman_client-0.0.5.gem
184
184
  - pkg/gman_client-0.0.7.gem
185
185
  - pkg/gman_client-0.0.8.gem
186
+ - pkg/gman_client-0.0.9.gem
187
+ - spec/lib/client/order_spec.rb
188
+ - spec/lib/client/orders_spec.rb
186
189
  - spec/lib/client_contracts_spec.rb
187
- - spec/lib/client_orders_spec.rb
188
190
  - spec/lib/driver_commission_history_response_spec.rb
189
191
  - spec/lib/driver_response_spec.rb
190
192
  - spec/lib/inventory_item_response_spec.rb
@@ -219,13 +221,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
221
  version: '0'
220
222
  requirements: []
221
223
  rubyforge_project:
222
- rubygems_version: 2.4.8
224
+ rubygems_version: 2.6.4
223
225
  signing_key:
224
226
  specification_version: 4
225
227
  summary: Grossman API Client for Ruby
226
228
  test_files:
229
+ - spec/lib/client/order_spec.rb
230
+ - spec/lib/client/orders_spec.rb
227
231
  - spec/lib/client_contracts_spec.rb
228
- - spec/lib/client_orders_spec.rb
229
232
  - spec/lib/driver_commission_history_response_spec.rb
230
233
  - spec/lib/driver_response_spec.rb
231
234
  - spec/lib/inventory_item_response_spec.rb