newgistics 1.1.0 → 2.0.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/.codeclimate.yml +0 -7
- data/.rubocop.yml +14 -0
- data/lib/newgistics/customer.rb +1 -1
- data/lib/newgistics/fee.rb +1 -1
- data/lib/newgistics/inbound_return.rb +1 -2
- data/lib/newgistics/inventory.rb +5 -2
- data/lib/newgistics/item.rb +1 -1
- data/lib/newgistics/manifest.rb +22 -15
- data/lib/newgistics/manifest_item.rb +9 -2
- data/lib/newgistics/manifest_slip.rb +49 -0
- data/lib/newgistics/model.rb +14 -0
- data/lib/newgistics/order.rb +1 -1
- data/lib/newgistics/product.rb +5 -2
- data/lib/newgistics/query.rb +2 -5
- data/lib/newgistics/requests/cancel_shipment.rb +1 -1
- data/lib/newgistics/requests/post_manifest.rb +17 -15
- data/lib/newgistics/requests/search.rb +1 -1
- data/lib/newgistics/response_handlers/search.rb +4 -5
- data/lib/newgistics/return.rb +1 -2
- data/lib/newgistics/shipment.rb +1 -2
- data/lib/newgistics/shipment_cancellation.rb +1 -1
- data/lib/newgistics/shipment_update.rb +1 -1
- data/lib/newgistics/string_helper.rb +12 -4
- data/lib/newgistics/version.rb +1 -1
- data/lib/newgistics/warehouse.rb +1 -1
- data/lib/newgistics/xml_marshaller.rb +1 -6
- data/lib/newgistics.rb +2 -0
- 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: 71568ff5b6f4a81cfe913095bc14707e6e76867e
|
4
|
+
data.tar.gz: 003a16e6b4cbc982e1bf366db97590237c0f0448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45ff8b1f9cf39885b897d198bedd54a526ca81f960ef7ee4ebe7dbfab527c71f68dbbcee36510a2ba325dc3eeadb742a30db9b9c10c908cc0f263e1fa93a1ab4
|
7
|
+
data.tar.gz: 90c502e5be3d5458dc1687752c84085f46ece2a4f729535bbc6ef85386debae1b4707986729fff9a871424d800e422983739cfcccc77b5936308ed1bcccc91dd
|
data/.codeclimate.yml
CHANGED
data/.rubocop.yml
ADDED
data/lib/newgistics/customer.rb
CHANGED
data/lib/newgistics/fee.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Newgistics
|
2
2
|
class InboundReturn
|
3
|
-
include
|
3
|
+
include Newgistics::Model
|
4
4
|
|
5
5
|
attribute :id, String
|
6
6
|
attribute :shipment_id, String
|
@@ -15,7 +15,6 @@ module Newgistics
|
|
15
15
|
def self.where(conditions)
|
16
16
|
Query.build(
|
17
17
|
endpoint: '/inbound_returns.aspx',
|
18
|
-
element_selector: 'InboundReturns InboundReturn',
|
19
18
|
model_class: self
|
20
19
|
).where(conditions)
|
21
20
|
end
|
data/lib/newgistics/inventory.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Newgistics
|
2
2
|
class Inventory
|
3
|
-
include
|
3
|
+
include Newgistics::Model
|
4
4
|
|
5
5
|
attribute :manifest_id, String
|
6
6
|
attribute :manifest_po, String
|
@@ -14,9 +14,12 @@ module Newgistics
|
|
14
14
|
def self.where(conditions)
|
15
15
|
Query.build(
|
16
16
|
endpoint: '/inventory_details.aspx',
|
17
|
-
element_selector: 'inventories inventory',
|
18
17
|
model_class: self
|
19
18
|
).where(conditions)
|
20
19
|
end
|
20
|
+
|
21
|
+
def self.element_selector
|
22
|
+
'inventory'
|
23
|
+
end
|
21
24
|
end
|
22
25
|
end
|
data/lib/newgistics/item.rb
CHANGED
data/lib/newgistics/manifest.rb
CHANGED
@@ -1,29 +1,36 @@
|
|
1
1
|
module Newgistics
|
2
2
|
class Manifest
|
3
|
-
include
|
3
|
+
include Newgistics::Model
|
4
4
|
|
5
|
-
attribute :
|
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
|
5
|
+
attribute :manifest_slip, ManifestSlip
|
19
6
|
attribute :contents, Array[ManifestItem], default: []
|
20
7
|
|
21
8
|
attribute :errors, Array[String], default: []
|
22
9
|
attribute :warnings, Array[String], default: []
|
23
10
|
|
11
|
+
def id
|
12
|
+
manifest_slip&.manifest_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def id=(id)
|
16
|
+
self.manifest_slip ||= ManifestSlip.new
|
17
|
+
manifest_slip.manifest_id = id
|
18
|
+
end
|
19
|
+
|
24
20
|
def save
|
25
21
|
Requests::PostManifest.new(self).perform
|
26
22
|
errors.empty?
|
27
23
|
end
|
24
|
+
|
25
|
+
def self.where(conditions)
|
26
|
+
Query.build(
|
27
|
+
endpoint: '/manifests.aspx',
|
28
|
+
model_class: self
|
29
|
+
).where(conditions)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.element_selector
|
33
|
+
'manifest'
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
@@ -1,10 +1,17 @@
|
|
1
1
|
module Newgistics
|
2
2
|
class ManifestItem
|
3
|
-
include
|
3
|
+
include Newgistics::Model
|
4
4
|
|
5
|
-
attribute :
|
5
|
+
attribute :damaged_qty, Integer
|
6
6
|
attribute :description, String
|
7
7
|
attribute :original_qty, Integer
|
8
8
|
attribute :received_qty, Integer
|
9
|
+
attribute :sku, String
|
10
|
+
attribute :upc, String
|
11
|
+
attribute :variance, Integer
|
12
|
+
|
13
|
+
def self.element_selector
|
14
|
+
"item"
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Newgistics
|
2
|
+
class ManifestSlip
|
3
|
+
include Newgistics::Model
|
4
|
+
|
5
|
+
attribute :actual_arrival_date, Timestamp
|
6
|
+
attribute :actual_received_date, Timestamp
|
7
|
+
attribute :carton_count, Integer
|
8
|
+
attribute :created_date, Timestamp
|
9
|
+
attribute :estimated_arrival_date, Date
|
10
|
+
attribute :manifest_id, String
|
11
|
+
attribute :manifest_name, String
|
12
|
+
attribute :manifest_po, String
|
13
|
+
attribute :notes, String
|
14
|
+
attribute :pallet_count, Integer
|
15
|
+
attribute :ship_date, Timestamp
|
16
|
+
attribute :shipped_via, String
|
17
|
+
attribute :status, String
|
18
|
+
attribute :total_weight, Float
|
19
|
+
attribute :tracking_no, String
|
20
|
+
attribute :warehouse_id, String
|
21
|
+
attribute :weight, Float
|
22
|
+
|
23
|
+
alias_method :no_pallets, :pallet_count
|
24
|
+
alias_method :no_pallets=, :pallet_count=
|
25
|
+
alias_method :no_cartons, :carton_count
|
26
|
+
alias_method :no_cartons=, :carton_count=
|
27
|
+
alias_method :shipped_date, :ship_date
|
28
|
+
alias_method :shipped_date=, :ship_date=
|
29
|
+
alias_method :total_weight, :weight
|
30
|
+
alias_method :total_weight=, :weight=
|
31
|
+
|
32
|
+
def estimated_arrival_date=(date)
|
33
|
+
date = parse_date(date) if should_parse_date?(date)
|
34
|
+
super(date)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def should_parse_date?(date)
|
40
|
+
date.is_a?(String) && date =~ %r{[01]\d/[0123]\d/\d{4}}
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse_date(date)
|
44
|
+
Date.strptime(date, '%m/%d/%Y')
|
45
|
+
rescue ArgumentError
|
46
|
+
date
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/newgistics/order.rb
CHANGED
data/lib/newgistics/product.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Newgistics
|
2
2
|
class Product
|
3
|
-
include
|
3
|
+
include Newgistics::Model
|
4
4
|
|
5
5
|
attribute :id, String
|
6
6
|
attribute :sku, String
|
@@ -22,9 +22,12 @@ module Newgistics
|
|
22
22
|
def self.where(conditions)
|
23
23
|
Query.build(
|
24
24
|
endpoint: '/inventory.aspx',
|
25
|
-
element_selector: 'products product',
|
26
25
|
model_class: self
|
27
26
|
).where(conditions)
|
28
27
|
end
|
28
|
+
|
29
|
+
def self.element_selector
|
30
|
+
'product'
|
31
|
+
end
|
29
32
|
end
|
30
33
|
end
|
data/lib/newgistics/query.rb
CHANGED
@@ -10,12 +10,9 @@ module Newgistics
|
|
10
10
|
@conditions = {}
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.build(endpoint:,
|
13
|
+
def self.build(endpoint:, model_class:)
|
14
14
|
request = Requests::Search.new(endpoint)
|
15
|
-
response_handler = ResponseHandlers::Search.new(
|
16
|
-
element_selector: element_selector,
|
17
|
-
model_class: model_class
|
18
|
-
)
|
15
|
+
response_handler = ResponseHandlers::Search.new(model_class: model_class)
|
19
16
|
|
20
17
|
new(request, response_handler)
|
21
18
|
end
|
@@ -46,25 +46,27 @@ module Newgistics
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def manifest_slip_xml(xml)
|
49
|
-
|
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
|
49
|
+
manifest_slip = manifest.manifest_slip || ManifestSlip.new
|
59
50
|
|
60
|
-
|
61
|
-
|
51
|
+
xml.manifest_slip do
|
52
|
+
xml.manifest_po manifest_slip.manifest_po
|
53
|
+
xml.manifest_name manifest_slip.manifest_name
|
54
|
+
xml.warehouse_id manifest_slip.warehouse_id
|
55
|
+
xml.status manifest_slip.status
|
56
|
+
xml.tracking_no manifest_slip.tracking_no
|
57
|
+
xml.pallet_count manifest_slip.pallet_count
|
58
|
+
xml.carton_count manifest_slip.carton_count
|
59
|
+
xml.weight manifest_slip.weight
|
60
|
+
xml.notes manifest_slip.notes
|
61
|
+
xml.ship_date format_date(manifest_slip.ship_date)
|
62
|
+
xml.estimated_arrival_date format_date(
|
63
|
+
manifest_slip.estimated_arrival_date
|
64
|
+
)
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
65
|
-
def
|
66
|
-
date
|
67
|
-
xml.send(attribute, date.strftime("%m/%d/%Y")) unless date.nil?
|
68
|
+
def format_date(date)
|
69
|
+
date.strftime("%m/%d/%Y") if date.respond_to?(:strftime)
|
68
70
|
end
|
69
71
|
|
70
72
|
def contents_xml(xml)
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module Newgistics
|
2
2
|
module ResponseHandlers
|
3
3
|
class Search
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :model_class
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@element_selector = element_selector
|
6
|
+
def initialize(model_class:)
|
8
7
|
@model_class = model_class
|
9
8
|
end
|
10
9
|
|
@@ -34,7 +33,7 @@ module Newgistics
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def build_models(xml)
|
37
|
-
xml.css(element_selector).map do |model_xml|
|
36
|
+
xml.css(model_class.element_selector).map do |model_xml|
|
38
37
|
build_model(model_xml)
|
39
38
|
end
|
40
39
|
end
|
@@ -50,7 +49,7 @@ module Newgistics
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def raise_error(message)
|
53
|
-
raise QueryError
|
52
|
+
raise QueryError, message
|
54
53
|
end
|
55
54
|
end
|
56
55
|
end
|
data/lib/newgistics/return.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Newgistics
|
2
2
|
class Return
|
3
|
-
include
|
3
|
+
include Newgistics::Model
|
4
4
|
|
5
5
|
attribute :warehouse_id, String
|
6
6
|
attribute :shipment_id, String
|
@@ -32,7 +32,6 @@ module Newgistics
|
|
32
32
|
def self.where(conditions)
|
33
33
|
Query.build(
|
34
34
|
endpoint: '/returns.aspx',
|
35
|
-
element_selector: 'Returns Return',
|
36
35
|
model_class: self
|
37
36
|
).where(conditions)
|
38
37
|
end
|
data/lib/newgistics/shipment.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Newgistics
|
2
2
|
class Shipment
|
3
|
-
include
|
3
|
+
include Newgistics::Model
|
4
4
|
|
5
5
|
attribute :id, String
|
6
6
|
attribute :client_name, String
|
@@ -71,7 +71,6 @@ module Newgistics
|
|
71
71
|
def self.where(conditions)
|
72
72
|
Query.build(
|
73
73
|
endpoint: '/shipments.aspx',
|
74
|
-
element_selector: 'Shipments Shipment',
|
75
74
|
model_class: self
|
76
75
|
).where(conditions)
|
77
76
|
end
|
@@ -1,13 +1,21 @@
|
|
1
1
|
module Newgistics
|
2
2
|
class StringHelper
|
3
|
+
CAMEL_CASED_STRING_REGEX = /([a-z])([A-Z])/
|
4
|
+
UNDERSCORED_STRING_REGEX = /([A-Za-z\d]+)(_|\z)/
|
5
|
+
CAPITALIZED_STRING_REGEX = /\A[A-Z]/
|
6
|
+
|
3
7
|
def self.camelize(string, upcase_first: true)
|
4
|
-
|
5
|
-
|
6
|
-
|
8
|
+
string.dup.to_s.tap do |s|
|
9
|
+
s.gsub!(UNDERSCORED_STRING_REGEX) { $1.capitalize! || $1 }
|
10
|
+
s.gsub!(CAPITALIZED_STRING_REGEX) { $&.downcase! } unless upcase_first
|
11
|
+
end
|
7
12
|
end
|
8
13
|
|
9
14
|
def self.underscore(string)
|
10
|
-
string.to_s.
|
15
|
+
string.dup.to_s.tap do |s|
|
16
|
+
s.gsub!(CAMEL_CASED_STRING_REGEX) { "#{$1}_#{$2}" }
|
17
|
+
s.downcase!
|
18
|
+
end
|
11
19
|
end
|
12
20
|
end
|
13
21
|
end
|
data/lib/newgistics/version.rb
CHANGED
data/lib/newgistics/warehouse.rb
CHANGED
@@ -37,8 +37,7 @@ module Newgistics
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def build_list(item_class, element)
|
40
|
-
|
41
|
-
element.css(item_selector).map do |child|
|
40
|
+
element.css(item_class.element_selector).map do |child|
|
42
41
|
build_object(item_class, child)
|
43
42
|
end
|
44
43
|
end
|
@@ -49,10 +48,6 @@ module Newgistics
|
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
|
-
def get_list_item_selector(item_class)
|
53
|
-
item_class.to_s.split('::').last
|
54
|
-
end
|
55
|
-
|
56
51
|
def assign_simple_attribute(object, element)
|
57
52
|
attribute = attribute_name(element)
|
58
53
|
assign_attribute(object, attribute, element.text)
|
data/lib/newgistics.rb
CHANGED
@@ -8,6 +8,7 @@ require "newgistics/default_logger"
|
|
8
8
|
require "newgistics/configuration"
|
9
9
|
require "newgistics/time_zone"
|
10
10
|
require "newgistics/timestamp"
|
11
|
+
require "newgistics/model"
|
11
12
|
require "newgistics/customer"
|
12
13
|
require "newgistics/item"
|
13
14
|
require "newgistics/order"
|
@@ -35,6 +36,7 @@ require "newgistics/response_handlers/search"
|
|
35
36
|
require "newgistics/response_handlers/update_shipment_contents"
|
36
37
|
require "newgistics/response_handlers/post_manifest"
|
37
38
|
require "newgistics/manifest_item"
|
39
|
+
require "newgistics/manifest_slip"
|
38
40
|
require "newgistics/manifest"
|
39
41
|
require "newgistics/fee"
|
40
42
|
require "newgistics/shipment"
|
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:
|
4
|
+
version: 2.0.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-09-
|
12
|
+
date: 2018-09-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: virtus
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- ".env.sample"
|
192
192
|
- ".gitignore"
|
193
193
|
- ".rspec"
|
194
|
+
- ".rubocop.yml"
|
194
195
|
- ".ruby-version"
|
195
196
|
- ".simplecov"
|
196
197
|
- CODE_OF_CONDUCT.md
|
@@ -212,6 +213,8 @@ files:
|
|
212
213
|
- lib/newgistics/item.rb
|
213
214
|
- lib/newgistics/manifest.rb
|
214
215
|
- lib/newgistics/manifest_item.rb
|
216
|
+
- lib/newgistics/manifest_slip.rb
|
217
|
+
- lib/newgistics/model.rb
|
215
218
|
- lib/newgistics/order.rb
|
216
219
|
- lib/newgistics/product.rb
|
217
220
|
- lib/newgistics/query.rb
|