snap-api 0.1.4 → 0.1.5
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/History.md +6 -0
- data/lib/snap/api/errors/order_stage_error.rb +8 -0
- data/lib/snap/api/shipment_status.rb +1 -1
- data/lib/snap/api/shipments.rb +5 -2
- data/lib/snap/client.rb +15 -1
- data/lib/snap/version.rb +1 -1
- data/lib/snap.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4c7f2ab6265d52e1c9e48ca60783fb125559aa900188864a3c0553a00274977
|
4
|
+
data.tar.gz: c6825d01e780dc708f0344175bcf675fb2fb2564fe3517fd59230e559b97d1ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61cc3d73640512a749b649248ceb090d050abe0628fb832c219359d014c4473c057ca4c650c19b909679c4584c6dfeb2e5973e5778bdfc40660b2a2e9b78bac8
|
7
|
+
data.tar.gz: 442ab51322849cc78a28d7fec934cd652d79a606e89bd8c1f41d0ce4bb110591dbcb6eb98a70e9b86548501e45f63f0549fe0bb5b4979930184394223f91fb84
|
data/History.md
CHANGED
@@ -7,7 +7,7 @@ module Snap
|
|
7
7
|
|
8
8
|
def self.update(options)
|
9
9
|
shipment_status = Snap::ShipmentStatus.new(options)
|
10
|
-
client.put("/shipmentstatus/#{shipment_status.ShipmentId}", body: shipment_status)
|
10
|
+
client.put("/shipmentstatus/#{shipment_status.ShipmentId}", body: shipment_status.to_json)
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.model
|
data/lib/snap/api/shipments.rb
CHANGED
@@ -15,12 +15,15 @@ module Snap
|
|
15
15
|
|
16
16
|
def self.create(options)
|
17
17
|
shipment = Snap::Shipment.new(options)
|
18
|
-
client.post('/shipments', body: shipment)
|
18
|
+
client.post('/shipments', body: shipment.to_json)
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.update(options)
|
22
22
|
shipment = Snap::Shipment.new(options)
|
23
|
-
client.put(
|
23
|
+
client.put(
|
24
|
+
"/shipments/#{shipment.ShipmentId}",
|
25
|
+
body: shipment.to_json
|
26
|
+
)
|
24
27
|
end
|
25
28
|
|
26
29
|
def self.model
|
data/lib/snap/client.rb
CHANGED
@@ -6,6 +6,7 @@ module Snap
|
|
6
6
|
def client
|
7
7
|
base_uri Snap.config.endpoint
|
8
8
|
basic_auth(Snap.config.username, Snap.config.password)
|
9
|
+
headers('Content-Type' => 'application/json')
|
9
10
|
self
|
10
11
|
end
|
11
12
|
|
@@ -34,7 +35,20 @@ module Snap
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def wrap_response
|
37
|
-
|
38
|
+
httparty_response = yield
|
39
|
+
snoop_for_errors(httparty_response)
|
40
|
+
Snap::Response.new(httparty_response, model)
|
41
|
+
end
|
42
|
+
|
43
|
+
def snoop_for_errors(httparty_response)
|
44
|
+
case httparty_response.parsed_response.class
|
45
|
+
# Snap can return response bodies in many different formats. How we look
|
46
|
+
# for and what errors can occur are dependent on that type. For example
|
47
|
+
# 500's mostly return raw html as a string. Pages with lists are an
|
48
|
+
# Array. Resource endpoints are typically Hash.
|
49
|
+
when Hash
|
50
|
+
raise Api::OrderStageError, httparty_response if httparty_response.parsed_response.value? 'ORDER_STAGE'
|
51
|
+
end
|
38
52
|
end
|
39
53
|
end
|
40
54
|
end
|
data/lib/snap/version.rb
CHANGED
data/lib/snap.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snap-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Hood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- bin/setup
|
200
200
|
- config/initializers/snap.rb
|
201
201
|
- lib/snap.rb
|
202
|
+
- lib/snap/api/errors/order_stage_error.rb
|
202
203
|
- lib/snap/api/outbound.rb
|
203
204
|
- lib/snap/api/shipment_status.rb
|
204
205
|
- lib/snap/api/shipments.rb
|