gman_client 0.2.1 → 0.3.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/lib/gman/client.rb +1 -0
- data/lib/gman_client/api/customer_contracts.rb +1 -5
- data/lib/gman_client/api/pick_up_orders.rb +16 -0
- data/lib/gman_client/utility.rb +8 -0
- data/lib/gman_client/version.rb +1 -1
- data/lib/gman_client.rb +1 -0
- data/spec/lib/client/orders_spec.rb +2 -2
- data/spec/lib/client/pick_up_orders_spec.rb +104 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/shared_contexts.rb +10 -0
- data/spec/support/vcr.rb +0 -9
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cea6b098f8e201f18a6621a1b3bee3ccb28296a4
|
4
|
+
data.tar.gz: 1236b436d46d5bdc9135a80337502c73acbd6cab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a6258aa3633d713e506d0b86cde2da540f4b669f2a2a52871a81ceceb911918dca6444069c2654c1ce0303295e081561b310cff52b2979f777ec8c04c34bcf3
|
7
|
+
data.tar.gz: bd883a95564481acd6de1ebf074596b161bb39a169fe0ce835144d1e1e5a2419f2deeac3c5a33791bc07e7505fe4c88ac47f1f74df6d94b179c369285f17fb95
|
data/lib/gman/client.rb
CHANGED
@@ -2,6 +2,7 @@ module Gman
|
|
2
2
|
class Client
|
3
3
|
include GmanClient::Api::CustomerContracts
|
4
4
|
include GmanClient::Api::Orders
|
5
|
+
include GmanClient::Api::PickUpOrders
|
5
6
|
include GmanClient::Api::HealthCheck
|
6
7
|
include GmanClient::CommodityMerchandising::Contracts
|
7
8
|
include GmanClient::Utility
|
@@ -6,11 +6,7 @@ module GmanClient
|
|
6
6
|
# @param [Hash] parameters to filter the orders
|
7
7
|
def customer_contracts(filter_params)
|
8
8
|
response = attempt(@retry_attempts) do
|
9
|
-
|
10
|
-
.api
|
11
|
-
.v1
|
12
|
-
.customer_contracts
|
13
|
-
.get(params: { q: filter_params })
|
9
|
+
get(:customer_contracts, q: filter_params)
|
14
10
|
end
|
15
11
|
|
16
12
|
response.map(&:to_h)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GmanClient
|
2
|
+
module Api
|
3
|
+
module PickUpOrders
|
4
|
+
# Retrieves pick up orders
|
5
|
+
#
|
6
|
+
# @param [Hash] parameters to filter the pick up orders
|
7
|
+
def pick_up_orders(filter_params)
|
8
|
+
response = attempt(@retry_attempts) do
|
9
|
+
get(:pick_up_orders, q: filter_params)
|
10
|
+
end
|
11
|
+
|
12
|
+
response.map(&:to_h)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/gman_client/utility.rb
CHANGED
data/lib/gman_client/version.rb
CHANGED
data/lib/gman_client.rb
CHANGED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Gman::Client do
|
4
|
+
before(:all) { VCR.turn_off! }
|
5
|
+
after(:all) { VCR.turn_on! }
|
6
|
+
|
7
|
+
let(:access_token) { SecureRandom.uuid }
|
8
|
+
let(:stubbed_url) { 'http://test.local' }
|
9
|
+
|
10
|
+
include_context 'new grossman client' do
|
11
|
+
let(:url) { stubbed_url }
|
12
|
+
let(:client_id) { SecureRandom.uuid }
|
13
|
+
let(:client_secret) { SecureRandom.uuid }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#pick_up_orders' do
|
17
|
+
subject do
|
18
|
+
client.pick_up_orders(params)
|
19
|
+
end
|
20
|
+
|
21
|
+
before do
|
22
|
+
stub_request(:post, "#{stubbed_url}/oauth/token")
|
23
|
+
.to_return(
|
24
|
+
body: { access_token: access_token }.to_json, status: 200
|
25
|
+
)
|
26
|
+
|
27
|
+
stub_request(
|
28
|
+
:get, "#{stubbed_url}/api/v1/pick_up_orders.json?#{query_string}"
|
29
|
+
)
|
30
|
+
.to_return(body: pick_up_orders_hash.to_json, status: 200)
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:query_string) do
|
34
|
+
params.map { |k, v| "q[#{k}]=#{v}" }.join('&')
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when there are results' do
|
38
|
+
let(:params) do
|
39
|
+
{
|
40
|
+
contract_commodity_id_eq: 1010
|
41
|
+
}
|
42
|
+
end
|
43
|
+
let(:pick_up_orders_hash) do
|
44
|
+
[
|
45
|
+
{
|
46
|
+
contract_id: '10000100',
|
47
|
+
contract_location_id: 1,
|
48
|
+
commodity_id: 1070,
|
49
|
+
item_id: '1234',
|
50
|
+
load_number: 1,
|
51
|
+
origin: 'HTV',
|
52
|
+
origin_state: 'CA',
|
53
|
+
origin_weight_certificate: 0,
|
54
|
+
origin_tare_weight: 0,
|
55
|
+
origin_gross_weight: 0,
|
56
|
+
origin_net_weight: 0,
|
57
|
+
pickup_type: 'Contract',
|
58
|
+
purchase_customer_id: '00000100',
|
59
|
+
release_prefix: 'TEST',
|
60
|
+
release_load_number: 1,
|
61
|
+
release_number: 'TEST 0001',
|
62
|
+
ship_date: '2016-12-28',
|
63
|
+
status: 'Used'
|
64
|
+
},
|
65
|
+
{
|
66
|
+
contract_id: '10000100',
|
67
|
+
contract_location_id: 1,
|
68
|
+
commodity_id: 1070,
|
69
|
+
item_id: '1234',
|
70
|
+
load_number: 2,
|
71
|
+
origin: 'HTV',
|
72
|
+
origin_state: 'CA',
|
73
|
+
origin_weight_certificate: 0,
|
74
|
+
origin_tare_weight: 0,
|
75
|
+
origin_gross_weight: 0,
|
76
|
+
origin_net_weight: 0,
|
77
|
+
pickup_type: 'Contract',
|
78
|
+
purchase_customer_id: '00000100',
|
79
|
+
release_prefix: 'TEST',
|
80
|
+
release_load_number: 2,
|
81
|
+
release_number: 'TEST 0002',
|
82
|
+
ship_date: '2016-12-28',
|
83
|
+
status: 'Open'
|
84
|
+
}
|
85
|
+
]
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should respond with a collection of hashs' do
|
89
|
+
expect(subject).to all be_kind_of(Hash)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should contain the pick up orders' do
|
93
|
+
expect(subject).to eq(pick_up_orders_hash)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'when there are no results' do
|
98
|
+
let(:params) { {} }
|
99
|
+
let(:pick_up_orders_hash) { [] }
|
100
|
+
|
101
|
+
it { is_expected.to be_empty }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/vcr.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'vcr'
|
2
2
|
|
3
|
-
real_requests = ENV['VCR_ALLOW_ACTUAL_REQUESTS']
|
4
|
-
|
5
3
|
VCR.configure do |c|
|
6
|
-
c.allow_http_connections_when_no_cassette = true if real_requests
|
7
4
|
c.cassette_library_dir = 'spec/vcr_cassettes'
|
8
5
|
c.configure_rspec_metadata!
|
9
6
|
c.default_cassette_options = { record: :new_episodes }
|
@@ -17,9 +14,3 @@ VCR.configure do |c|
|
|
17
14
|
c.hook_into :webmock
|
18
15
|
c.ignore_hosts 'codeclimate.com'
|
19
16
|
end
|
20
|
-
|
21
|
-
RSpec.configure do |config|
|
22
|
-
config.before(:each) do
|
23
|
-
VCR.eject_cassette
|
24
|
-
end if real_requests
|
25
|
-
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.
|
4
|
+
version: 0.3.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:
|
12
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: vcr
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/gman_client/api/customer_contracts.rb
|
176
176
|
- lib/gman_client/api/health_check.rb
|
177
177
|
- lib/gman_client/api/orders.rb
|
178
|
+
- lib/gman_client/api/pick_up_orders.rb
|
178
179
|
- lib/gman_client/commodity_merchandising/contracts.rb
|
179
180
|
- lib/gman_client/inventory/items.rb
|
180
181
|
- lib/gman_client/utility.rb
|
@@ -183,6 +184,7 @@ files:
|
|
183
184
|
- spec/lib/client/health_check_spec.rb
|
184
185
|
- spec/lib/client/order_spec.rb
|
185
186
|
- spec/lib/client/orders_spec.rb
|
187
|
+
- spec/lib/client/pick_up_orders_spec.rb
|
186
188
|
- spec/lib/client_contracts_spec.rb
|
187
189
|
- spec/lib/driver_commission_history_response_spec.rb
|
188
190
|
- spec/lib/driver_response_spec.rb
|
@@ -227,6 +229,7 @@ test_files:
|
|
227
229
|
- spec/lib/client/health_check_spec.rb
|
228
230
|
- spec/lib/client/order_spec.rb
|
229
231
|
- spec/lib/client/orders_spec.rb
|
232
|
+
- spec/lib/client/pick_up_orders_spec.rb
|
230
233
|
- spec/lib/client_contracts_spec.rb
|
231
234
|
- spec/lib/driver_commission_history_response_spec.rb
|
232
235
|
- spec/lib/driver_response_spec.rb
|