zanders 3.0.0 → 3.0.1
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 +5 -5
- data/.ruby-version +1 -1
- data/lib/zanders.rb +4 -2
- data/lib/zanders/catalog.rb +3 -3
- data/lib/zanders/order.rb +43 -18
- data/lib/zanders/soap_client.rb +9 -9
- data/lib/zanders/version.rb +1 -1
- data/zanders.gemspec +4 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: df053041bc7fa3f9b61433fb91979122fcd5f2b7ed797f71308aaa5f68508c4a
|
4
|
+
data.tar.gz: 283e7c5de0300ae2de368bd143c0fe7b13c68427740165a4d4a49d907aaaffb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86546d32d2de9a8ffc80a55fe80eedf3c57fdfa4483c3d024ac4d9a4670b3abe15a776d167eb2928768d460b25a0ae944649dfbe8f23a756a01ab4c9bf6fd174
|
7
|
+
data.tar.gz: 43725d92fcb0ec3b78b442136d62b3acece58435bfc2fcb07941989e370bb285019cabd5e2dc5e1d73fa0c931b1437de76d8a9f9c64995675f1a73097c399f75
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.6
|
data/lib/zanders.rb
CHANGED
@@ -35,6 +35,7 @@ module Zanders
|
|
35
35
|
|
36
36
|
class Configuration
|
37
37
|
attr_accessor :debug_mode
|
38
|
+
attr_accessor :file_encoding
|
38
39
|
attr_accessor :ftp_host
|
39
40
|
attr_accessor :ftp_directory
|
40
41
|
|
@@ -42,8 +43,9 @@ module Zanders
|
|
42
43
|
|
43
44
|
def initialize
|
44
45
|
@debug_mode ||= false
|
45
|
-
@
|
46
|
-
@
|
46
|
+
@file_encoding ||= 'Windows-1252'
|
47
|
+
@ftp_host ||= 'ftp2.gzanders.com'
|
48
|
+
@ftp_directory ||= 'Inventory/AmmoReady'
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
data/lib/zanders/catalog.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Zanders
|
2
2
|
class Catalog < Base
|
3
3
|
|
4
|
-
CATALOG_FILENAME = 'zandersinv.xml'
|
5
|
-
ITEM_NODE_NAME = 'ZandersDataOut'
|
4
|
+
CATALOG_FILENAME = 'zandersinv.xml'.freeze
|
5
|
+
ITEM_NODE_NAME = 'ZandersDataOut'.freeze
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
8
|
requires!(options, :username, :password)
|
@@ -17,7 +17,7 @@ module Zanders
|
|
17
17
|
def all(&block)
|
18
18
|
tempfile = get_file(CATALOG_FILENAME)
|
19
19
|
|
20
|
-
Nokogiri::XML::Reader.from_io(tempfile).each do |node|
|
20
|
+
Nokogiri::XML::Reader.from_io(tempfile, nil, Zanders.config.file_encoding).each do |node|
|
21
21
|
next unless node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT
|
22
22
|
next unless node.name == ITEM_NODE_NAME
|
23
23
|
|
data/lib/zanders/order.rb
CHANGED
@@ -48,9 +48,19 @@ module Zanders
|
|
48
48
|
|
49
49
|
items.each do |item|
|
50
50
|
order_items.push(item: [
|
51
|
-
{
|
52
|
-
|
53
|
-
|
51
|
+
{
|
52
|
+
key: 'itemNumber',
|
53
|
+
value: item[:item_number],
|
54
|
+
attributes!: { key: { 'xsi:type' => 'xsd:string' }, value: { 'xsi:type' => 'xsd:string' } }
|
55
|
+
}, {
|
56
|
+
key: 'quantity',
|
57
|
+
value: item[:quantity],
|
58
|
+
attributes!: { key: { 'xsi:type' => 'xsd:string' }, value: { 'xsi:type' => 'xsd:string' } }
|
59
|
+
}, {
|
60
|
+
key: 'allowBackOrder',
|
61
|
+
value: false,
|
62
|
+
attributes!: { key: { 'xsi:type' => 'xsd:string' }, value: { 'xsi:type' => 'xsd:boolean' } }
|
63
|
+
}
|
54
64
|
])
|
55
65
|
end
|
56
66
|
|
@@ -74,12 +84,12 @@ module Zanders
|
|
74
84
|
end
|
75
85
|
else
|
76
86
|
shipping_information.push(*[
|
77
|
-
{ key: 'shipToName',
|
78
|
-
{ key: 'shipToAddress1',
|
79
|
-
{ key: 'shipToAddress2',
|
80
|
-
{ key: 'shipToCity',
|
81
|
-
{ key: 'shipToState',
|
82
|
-
{ key: 'shipToZip',
|
87
|
+
{ key: 'shipToName', value: address[:name] },
|
88
|
+
{ key: 'shipToAddress1', value: address[:address1] },
|
89
|
+
{ key: 'shipToAddress2', value: address[:address2] },
|
90
|
+
{ key: 'shipToCity', value: address[:city] },
|
91
|
+
{ key: 'shipToState', value: address[:state] },
|
92
|
+
{ key: 'shipToZip', value: address[:zip] }
|
83
93
|
])
|
84
94
|
end
|
85
95
|
|
@@ -107,18 +117,33 @@ module Zanders
|
|
107
117
|
key: 'items',
|
108
118
|
value: order_items,
|
109
119
|
attributes!: {
|
110
|
-
key: {
|
111
|
-
|
120
|
+
key: {
|
121
|
+
"xsi:type" => "xsd:string"
|
122
|
+
},
|
123
|
+
value: {
|
124
|
+
"enc:itemType" => "ns2:Map[#{order_items.count}]",
|
125
|
+
"enc:arraySize" => order_items.count.to_s,
|
126
|
+
"xsi:type" => "enc:Array"
|
127
|
+
}
|
112
128
|
}
|
113
129
|
})
|
114
130
|
|
115
|
-
|
116
|
-
|
131
|
+
soap_response = soap_client(ORDER_API_URL).call(:create_order, message: order)
|
132
|
+
hash = soap_response.body[:create_order_response][:return][:item]
|
117
133
|
|
118
|
-
if
|
119
|
-
{
|
134
|
+
if hash.first[:value] == "0"
|
135
|
+
{
|
136
|
+
success: true,
|
137
|
+
order_number: hash.find { |h| h[:key] == 'orderNumber' }&.dig(:value),
|
138
|
+
removed_items: hash.find { |h| h[:key] == 'removedItems' }&.dig(:value, :item),
|
139
|
+
raw_xml: soap_response.to_xml
|
140
|
+
}
|
120
141
|
else
|
121
|
-
{
|
142
|
+
{
|
143
|
+
success: false,
|
144
|
+
error_code: hash.first[:value],
|
145
|
+
error_message: hash.last[:value]
|
146
|
+
}
|
122
147
|
end
|
123
148
|
end
|
124
149
|
|
@@ -182,9 +207,9 @@ module Zanders
|
|
182
207
|
response = response.body[:get_tracking_info_response][:return][:item]
|
183
208
|
|
184
209
|
if response.first[:value] == "0"
|
185
|
-
info =
|
210
|
+
info = { shipments: [] }
|
211
|
+
|
186
212
|
info[:number_of_shipments] = response.find { |i| i[:key] == "numberOfShipments" }[:value].to_i
|
187
|
-
info[:shipments] = Array.new
|
188
213
|
|
189
214
|
if info[:number_of_shipments] > 0
|
190
215
|
tracking_numbers = response.find { |i| i[:key] == "trackingNumbers" }[:value]
|
data/lib/zanders/soap_client.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module Zanders
|
2
2
|
class SoapClient < Base
|
3
3
|
|
4
|
+
NAMESPACES = {
|
5
|
+
"xmlns:env" => "http://www.w3.org/2003/05/soap-envelope",
|
6
|
+
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
|
7
|
+
"xmlns:xsl" => "http://www.w3.org/2001/XMLSchema-Instance",
|
8
|
+
"xmlns:ns2" => "http://xml.apache.org/xml-soap",
|
9
|
+
"xmlns:enc" => "http://www.w3.org/2003/05/soap-encoding"
|
10
|
+
}
|
11
|
+
|
4
12
|
##
|
5
13
|
# == Item Service
|
6
14
|
#
|
@@ -12,17 +20,9 @@ module Zanders
|
|
12
20
|
protected
|
13
21
|
|
14
22
|
def soap_client(api_url)
|
15
|
-
namespaces = {
|
16
|
-
"xmlns:env" => "http://www.w3.org/2003/05/soap-envelope",
|
17
|
-
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
|
18
|
-
"xmlns:xsl" => "http://www.w3.org/2001/XMLSchema-Instance",
|
19
|
-
"xmlns:ns2" => "http://xml.apache.org/xml-soap",
|
20
|
-
"xmlns:enc" => "http://www.w3.org/2003/05/soap-encoding"
|
21
|
-
}
|
22
|
-
|
23
23
|
@soap_client ||= Savon.client do
|
24
24
|
wsdl(api_url)
|
25
|
-
namespaces(
|
25
|
+
namespaces(NAMESPACES)
|
26
26
|
namespace_identifier(:ns1)
|
27
27
|
strip_namespaces true
|
28
28
|
ssl_verify_mode :none
|
data/lib/zanders/version.rb
CHANGED
data/zanders.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'zanders/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "zanders"
|
8
8
|
spec.version = Zanders::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["AmmoReady.com"]
|
10
|
+
spec.email = ["admin@ammoready.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Ruby library for Zanders}
|
13
13
|
spec.description = %q{}
|
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
+
spec.required_ruby_version = '~> 2.3'
|
25
|
+
|
24
26
|
spec.add_dependency "nokogiri", "~> 1.6"
|
25
27
|
spec.add_dependency "savon", "~> 2.11.1"
|
26
28
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zanders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- AmmoReady.com
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -124,7 +124,7 @@ dependencies:
|
|
124
124
|
version: '3.4'
|
125
125
|
description: ''
|
126
126
|
email:
|
127
|
-
-
|
127
|
+
- admin@ammoready.com
|
128
128
|
executables: []
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
@@ -162,9 +162,9 @@ require_paths:
|
|
162
162
|
- lib
|
163
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
164
164
|
requirements:
|
165
|
-
- - "
|
165
|
+
- - "~>"
|
166
166
|
- !ruby/object:Gem::Version
|
167
|
-
version: '
|
167
|
+
version: '2.3'
|
168
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
170
|
- - ">="
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.7.7
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: Ruby library for Zanders
|