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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 89bbfb0b8419f723b3961add32b0ab0dc1b6c70a
4
- data.tar.gz: 0a8cbe3047e4e1331423f66d7b7b95513419c91e
2
+ SHA256:
3
+ metadata.gz: df053041bc7fa3f9b61433fb91979122fcd5f2b7ed797f71308aaa5f68508c4a
4
+ data.tar.gz: 283e7c5de0300ae2de368bd143c0fe7b13c68427740165a4d4a49d907aaaffb1
5
5
  SHA512:
6
- metadata.gz: 74ed395a7d1f728a9f4d0c2f65d8ecc4ce552b4f266e86fff6a15034945a2c4b81a822b81b6d4f3bbb2465005228d8fa00bbc56c581c2a1bdcd01836aba92c93
7
- data.tar.gz: 66a084e8ef02b7acb4211a27c38baf098cdbd44cc3dcca31e765aa82f9dbf9966cd56807daf9ca279ea62c6a540f47d16a3219e87d8a3e8e671cd9111bf2c48e
6
+ metadata.gz: 86546d32d2de9a8ffc80a55fe80eedf3c57fdfa4483c3d024ac4d9a4670b3abe15a776d167eb2928768d460b25a0ae944649dfbe8f23a756a01ab4c9bf6fd174
7
+ data.tar.gz: 43725d92fcb0ec3b78b442136d62b3acece58435bfc2fcb07941989e370bb285019cabd5e2dc5e1d73fa0c931b1437de76d8a9f9c64995675f1a73097c399f75
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.3.6
@@ -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
- @ftp_host ||= "ftp2.gzanders.com"
46
- @ftp_directory ||= "Inventory/AmmoReady"
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
@@ -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
 
@@ -48,9 +48,19 @@ module Zanders
48
48
 
49
49
  items.each do |item|
50
50
  order_items.push(item: [
51
- { key: 'itemNumber', value: item[:item_number], attributes!: { key: {'xsi:type' => 'xsd:string'}, value: {'xsi:type' => 'xsd:string'} }},
52
- { key: 'quantity', value: item[:quantity] , attributes!: { key: {'xsi:type' => 'xsd:string'}, value: {'xsi:type' => 'xsd:string'} }},
53
- { key: 'allowBackOrder', value: false, attributes!: { key: { 'xsi:type' => 'xsd:string' }, value: {'xsi:type' => 'xsd:boolean'} }}
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', value: address[:name] },
78
- { key: 'shipToAddress1', value: address[:address1] },
79
- { key: 'shipToAddress2', value: address[:address2] },
80
- { key: 'shipToCity', value: address[:city] },
81
- { key: 'shipToState', value: address[:state] },
82
- { key: 'shipToZip', value: address[:zip] }
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: {"xsi:type" => "xsd:string"},
111
- value: {"enc:itemType" => "ns2:Map[#{order_items.count}]", "enc:arraySize" => order_items.count.to_s, "xsi:type" => "enc:Array"}
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
- response = soap_client(ORDER_API_URL).call(:create_order, message: order)
116
- response = response.body[:create_order_response][:return][:item]
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 response.first[:value] == "0"
119
- { success: true, order_number: response.last[:value] }
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
- { success: false, error_code: response.first[:value], error_message: response.last[:value] }
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 = Hash.new
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]
@@ -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(namespaces)
25
+ namespaces(NAMESPACES)
26
26
  namespace_identifier(:ns1)
27
27
  strip_namespaces true
28
28
  ssl_verify_mode :none
@@ -1,3 +1,3 @@
1
1
  module Zanders
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '3.0.1'.freeze
3
3
  end
@@ -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 = ["David Knight"]
10
- spec.email = ["viacoffee@gmail.com"]
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.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - David Knight
7
+ - AmmoReady.com
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-17 00:00:00.000000000 Z
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
- - viacoffee@gmail.com
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: '0'
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.6.12
175
+ rubygems_version: 2.7.7
176
176
  signing_key:
177
177
  specification_version: 4
178
178
  summary: Ruby library for Zanders