newgistics 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -1
- data/lib/newgistics.rb +4 -0
- data/lib/newgistics/manifest.rb +29 -0
- data/lib/newgistics/manifest_item.rb +10 -0
- data/lib/newgistics/requests/post_manifest.rb +90 -0
- data/lib/newgistics/response_handlers/post_manifest.rb +23 -0
- data/lib/newgistics/version.rb +1 -1
- metadata +6 -3
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e4beb6b736d1470b531b46cac3356b06405e5bd
|
4
|
+
data.tar.gz: c6743453796386f18b6a7f1b35472e67f491190f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6991c8ec582649313e5c5575a2644d16ea4df560208cbaec6b01218513fea8273b79c22032af7fc85156c96eba0ae98b188776f6d6e87fbebeea0a9746d2ef7e
|
7
|
+
data.tar.gz: 472593db28710abbafceb6bd491f38de105919eedd6e27c05586e0bce7618a775d9f9dc9cd13abb12f042bfc7ed86c08509f49d86732649cfdaca4807125ab2f
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ This Ruby gem allows you to interact with the Newgistics Fulfillment API.
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem 'newgistics'
|
14
|
+
gem 'newgistics'
|
15
15
|
```
|
16
16
|
|
17
17
|
And then execute:
|
@@ -168,6 +168,20 @@ Newgistics::Inventory.
|
|
168
168
|
You can use the `where` method to specify the parameters for the Search. Parameter keys will be automatically camelized when sent to
|
169
169
|
Newgistics, for a full list of the available parameters refer to the Newgistics API documentation.
|
170
170
|
|
171
|
+
### Manifests
|
172
|
+
|
173
|
+
#### Creating a new Manifest in Newgistics
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
manifest = Newgistics::Manifest.new(manifest_attributes)
|
177
|
+
manifest.save
|
178
|
+
```
|
179
|
+
|
180
|
+
`manifest_attributes` is a `Hash` containing all the attributes for the manifest, the attributes should map one-to-one to the Newgistics API spec.
|
181
|
+
|
182
|
+
`manifest.save` will return `true` if the manifest is placed successfully and `false` otherwise, any errors or warnings generated when creating the manifest are available under `manifest.errors` and `manifest.warnings` respectively
|
183
|
+
|
184
|
+
|
171
185
|
## Development
|
172
186
|
|
173
187
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/newgistics.rb
CHANGED
@@ -25,6 +25,7 @@ require "newgistics/requests/cancel_shipment"
|
|
25
25
|
require "newgistics/requests/post_shipment"
|
26
26
|
require "newgistics/requests/post_inbound_return"
|
27
27
|
require "newgistics/requests/search"
|
28
|
+
require "newgistics/requests/post_manifest"
|
28
29
|
require "newgistics/requests/update_shipment_contents"
|
29
30
|
require "newgistics/response_handlers/cancel_shipment"
|
30
31
|
require "newgistics/response_handlers/post_shipment"
|
@@ -32,6 +33,9 @@ require "newgistics/response_handlers/post_inbound_return"
|
|
32
33
|
require "newgistics/response_handlers/post_errors"
|
33
34
|
require "newgistics/response_handlers/search"
|
34
35
|
require "newgistics/response_handlers/update_shipment_contents"
|
36
|
+
require "newgistics/response_handlers/post_manifest"
|
37
|
+
require "newgistics/manifest_item"
|
38
|
+
require "newgistics/manifest"
|
35
39
|
require "newgistics/fee"
|
36
40
|
require "newgistics/shipment"
|
37
41
|
require "newgistics/version"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Newgistics
|
2
|
+
class Manifest
|
3
|
+
include Virtus.model
|
4
|
+
|
5
|
+
attribute :id, String
|
6
|
+
attribute :manifest_po, String
|
7
|
+
attribute :manifest_name, String
|
8
|
+
attribute :warehouse_id, String
|
9
|
+
attribute :status, String
|
10
|
+
attribute :ship_date, Date
|
11
|
+
attribute :shipped_via, String
|
12
|
+
attribute :tracking_no, String
|
13
|
+
attribute :created_date, Timestamp
|
14
|
+
attribute :estimated_arrival_date, Date
|
15
|
+
attribute :pallet_count, Integer
|
16
|
+
attribute :carton_count, Integer
|
17
|
+
attribute :weight, Float
|
18
|
+
attribute :notes, String
|
19
|
+
attribute :contents, Array[ManifestItem], default: []
|
20
|
+
|
21
|
+
attribute :errors, Array[String], default: []
|
22
|
+
attribute :warnings, Array[String], default: []
|
23
|
+
|
24
|
+
def save
|
25
|
+
Requests::PostManifest.new(self).perform
|
26
|
+
errors.empty?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Newgistics
|
2
|
+
module Requests
|
3
|
+
class PostManifest
|
4
|
+
attr_reader :manifest, :response_handler
|
5
|
+
|
6
|
+
def initialize(manifest, response_handler: nil)
|
7
|
+
@manifest = manifest
|
8
|
+
@response_handler = response_handler || default_response_handler
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
'/post_manifests.aspx'
|
13
|
+
end
|
14
|
+
|
15
|
+
def body
|
16
|
+
xml_builder.to_xml
|
17
|
+
end
|
18
|
+
|
19
|
+
def perform
|
20
|
+
Newgistics.api.post(self, response_handler)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def api_key
|
26
|
+
Newgistics.configuration.api_key
|
27
|
+
end
|
28
|
+
|
29
|
+
def xml_builder
|
30
|
+
Nokogiri::XML::Builder.new do |xml|
|
31
|
+
manifests_xml(xml)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def manifests_xml(xml)
|
36
|
+
xml.manifests(apiKey: api_key) do
|
37
|
+
manifest_xml(xml)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def manifest_xml(xml)
|
42
|
+
xml.manifest do
|
43
|
+
manifest_slip_xml(xml)
|
44
|
+
contents_xml(xml)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def manifest_slip_xml(xml)
|
49
|
+
xml.manifest_slip do
|
50
|
+
xml.manifest_po manifest.manifest_po
|
51
|
+
xml.manifest_name manifest.manifest_name
|
52
|
+
xml.warehouse_id manifest.warehouse_id
|
53
|
+
xml.status manifest.status
|
54
|
+
xml.tracking_no manifest.tracking_no
|
55
|
+
xml.pallet_count manifest.pallet_count
|
56
|
+
xml.carton_count manifest.carton_count
|
57
|
+
xml.weight manifest.weight
|
58
|
+
xml.notes manifest.notes
|
59
|
+
|
60
|
+
date_xml(xml, :ship_date)
|
61
|
+
date_xml(xml, :estimated_arrival_date)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def date_xml(xml, attribute)
|
66
|
+
date = manifest.send(attribute)
|
67
|
+
xml.send(attribute, date.strftime("%m/%d/%Y")) unless date.nil?
|
68
|
+
end
|
69
|
+
|
70
|
+
def contents_xml(xml)
|
71
|
+
xml.contents do
|
72
|
+
manifest.contents.each { |item| item_xml(item, xml) }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def item_xml(item, xml)
|
77
|
+
xml.item do
|
78
|
+
xml.sku item.sku
|
79
|
+
xml.description item.description
|
80
|
+
xml.original_qty item.original_qty
|
81
|
+
xml.received_qty item.received_qty
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def default_response_handler
|
86
|
+
ResponseHandlers::PostManifest.new(manifest)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Newgistics
|
2
|
+
module ResponseHandlers
|
3
|
+
class PostManifest
|
4
|
+
attr_reader :manifest
|
5
|
+
|
6
|
+
def initialize(manifest)
|
7
|
+
@manifest = manifest
|
8
|
+
end
|
9
|
+
|
10
|
+
def handle(response)
|
11
|
+
PostErrors.new(manifest).handle(response)
|
12
|
+
handle_successful_response(response) if manifest.errors.empty?
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def handle_successful_response(response)
|
18
|
+
xml = Nokogiri::XML(response.body)
|
19
|
+
manifest.id = xml.at_css('manifest')['id']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/newgistics/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newgistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Martinez
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: virtus
|
@@ -193,7 +193,6 @@ files:
|
|
193
193
|
- ".rspec"
|
194
194
|
- ".ruby-version"
|
195
195
|
- ".simplecov"
|
196
|
-
- ".travis.yml"
|
197
196
|
- CODE_OF_CONDUCT.md
|
198
197
|
- Gemfile
|
199
198
|
- LICENSE.txt
|
@@ -211,17 +210,21 @@ files:
|
|
211
210
|
- lib/newgistics/inbound_return.rb
|
212
211
|
- lib/newgistics/inventory.rb
|
213
212
|
- lib/newgistics/item.rb
|
213
|
+
- lib/newgistics/manifest.rb
|
214
|
+
- lib/newgistics/manifest_item.rb
|
214
215
|
- lib/newgistics/order.rb
|
215
216
|
- lib/newgistics/product.rb
|
216
217
|
- lib/newgistics/query.rb
|
217
218
|
- lib/newgistics/requests/cancel_shipment.rb
|
218
219
|
- lib/newgistics/requests/post_inbound_return.rb
|
220
|
+
- lib/newgistics/requests/post_manifest.rb
|
219
221
|
- lib/newgistics/requests/post_shipment.rb
|
220
222
|
- lib/newgistics/requests/search.rb
|
221
223
|
- lib/newgistics/requests/update_shipment_contents.rb
|
222
224
|
- lib/newgistics/response_handlers/cancel_shipment.rb
|
223
225
|
- lib/newgistics/response_handlers/post_errors.rb
|
224
226
|
- lib/newgistics/response_handlers/post_inbound_return.rb
|
227
|
+
- lib/newgistics/response_handlers/post_manifest.rb
|
225
228
|
- lib/newgistics/response_handlers/post_shipment.rb
|
226
229
|
- lib/newgistics/response_handlers/search.rb
|
227
230
|
- lib/newgistics/response_handlers/update_shipment_contents.rb
|