zanders 1.4.10 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zanders.rb +1 -0
- data/lib/zanders/address.rb +1 -1
- data/lib/zanders/catalog.rb +56 -0
- data/lib/zanders/inventory.rb +14 -27
- data/lib/zanders/order.rb +2 -4
- data/lib/zanders/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87b6fba3d86fa736bca99aa0c64cddc262c1b8c0
|
4
|
+
data.tar.gz: 108b978150d49336b6c697e8b108270a2c4db8a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963c1d800361f0e04a18b22535ab3d153772813224772e2b5af3ab7a19f60602b69280fccac2f24ba5a3802ddd10217a623fba0e458fe2594266738f85b85043
|
7
|
+
data.tar.gz: 65f26302cd660430a46064e4b1ecf7d3f16f8bca393ea3f66761bf6373c725ba64595b9740730fc6b133d26ea6e8b089c18ee1e5cc042471be813f337d759317
|
data/lib/zanders.rb
CHANGED
data/lib/zanders/address.rb
CHANGED
@@ -36,7 +36,7 @@ module Zanders
|
|
36
36
|
response = response.body[:use_ship_to_response][:return][:item]
|
37
37
|
|
38
38
|
# Successful call return_code is 0
|
39
|
-
if response.first[:value] == "0"
|
39
|
+
if response.first[:value] == "0"
|
40
40
|
ship_to_number = Hash.new
|
41
41
|
|
42
42
|
# Let's dig to get to data we actually need. Yay, digging...
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Zanders
|
2
|
+
class Catalog < Base
|
3
|
+
|
4
|
+
CATALOG_FILENAME = "zandersinv.csv"
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
requires!(options, :username, :password)
|
8
|
+
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.all(chunk_size = 15, options = {}, &block)
|
13
|
+
requires!(options, :username, :password)
|
14
|
+
new(options).all(chunk_size, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def all(chunk_size, &block)
|
18
|
+
connect(@options) do |ftp|
|
19
|
+
begin
|
20
|
+
csv_tempfile = Tempfile.new
|
21
|
+
|
22
|
+
ftp.chdir(Zanders.config.ftp_directory)
|
23
|
+
ftp.getbinaryfile(CATALOG_FILENAME, csv_tempfile.path)
|
24
|
+
|
25
|
+
SmarterCSV.process(csv_tempfile, {
|
26
|
+
:chunk_size => chunk_size,
|
27
|
+
:convert_values_to_numeric => false,
|
28
|
+
:key_mapping => {
|
29
|
+
:available => :quantity,
|
30
|
+
:desc1 => :short_description,
|
31
|
+
:itemnumber => :item_identifier,
|
32
|
+
:manufacturer => :brand,
|
33
|
+
:mfgpnumber => :mfg_number,
|
34
|
+
:mapprice => :map_price,
|
35
|
+
:price1 => :price
|
36
|
+
}
|
37
|
+
}) do |chunk|
|
38
|
+
chunk.each do |item|
|
39
|
+
item[:name] = item[:short_description]
|
40
|
+
item[:long_description] = "#{item[:short_description]} #{item[:desc2]}"
|
41
|
+
|
42
|
+
item.except!(:desc2, :qty1, :qty2, :qty3, :price2, :price3)
|
43
|
+
end
|
44
|
+
|
45
|
+
yield(chunk)
|
46
|
+
end
|
47
|
+
|
48
|
+
csv_tempfile.unlink
|
49
|
+
ensure
|
50
|
+
ftp.close
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
data/lib/zanders/inventory.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Zanders
|
2
2
|
class Inventory < Base
|
3
3
|
|
4
|
-
INVENTORY_FILENAME = "
|
5
|
-
QUANTITY_FILENAME = "liveinv.csv"
|
4
|
+
INVENTORY_FILENAME = "liveinv.csv"
|
6
5
|
|
7
6
|
def initialize(options = {})
|
8
7
|
requires!(options, :username, :password)
|
@@ -15,31 +14,7 @@ module Zanders
|
|
15
14
|
new(options).all(chunk_size, &block)
|
16
15
|
end
|
17
16
|
|
18
|
-
def self.quantities(chunk_size = 15, options = {}, &block)
|
19
|
-
requires!(options, :username, :password)
|
20
|
-
new(options).quantities(chunk_size, &block)
|
21
|
-
end
|
22
|
-
|
23
17
|
def all(chunk_size, &block)
|
24
|
-
connect(@options) do |ftp|
|
25
|
-
begin
|
26
|
-
csv_tempfile = Tempfile.new
|
27
|
-
|
28
|
-
ftp.chdir(Zanders.config.ftp_directory)
|
29
|
-
ftp.getbinaryfile(INVENTORY_FILENAME, csv_tempfile.path)
|
30
|
-
|
31
|
-
SmarterCSV.process(csv_tempfile, { :chunk_size => chunk_size, :convert_values_to_numeric => false }) do |chunk|
|
32
|
-
yield(chunk)
|
33
|
-
end
|
34
|
-
|
35
|
-
csv_tempfile.unlink
|
36
|
-
ensure
|
37
|
-
ftp.close
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def quantities(chunk_size, &block)
|
43
18
|
connect(@options) do |ftp|
|
44
19
|
begin
|
45
20
|
csv_tempfile = Tempfile.new
|
@@ -47,7 +22,19 @@ module Zanders
|
|
47
22
|
ftp.chdir(Zanders.config.ftp_directory)
|
48
23
|
ftp.getbinaryfile(QUANTITY_FILENAME, csv_tempfile.path)
|
49
24
|
|
50
|
-
SmarterCSV.process(csv_tempfile, {
|
25
|
+
SmarterCSV.process(csv_tempfile, {
|
26
|
+
:chunk_size => chunk_size,
|
27
|
+
:convert_values_to_numeric => false,
|
28
|
+
:key_mapping => {
|
29
|
+
:available => :quantity,
|
30
|
+
:itemnumber => :item_identifier,
|
31
|
+
:price1 => :price
|
32
|
+
}
|
33
|
+
}) do |chunk|
|
34
|
+
chunk.each do |item|
|
35
|
+
item.except!(:qty1, :qty2, :qty3, :price2, :price3)
|
36
|
+
end
|
37
|
+
|
51
38
|
yield(chunk)
|
52
39
|
end
|
53
40
|
|
data/lib/zanders/order.rb
CHANGED
@@ -53,11 +53,9 @@ module Zanders
|
|
53
53
|
])
|
54
54
|
end
|
55
55
|
|
56
|
-
shipping_code = (@options[:account] == :default ? 'UM' : 'UG')
|
57
|
-
|
58
56
|
shipping_information.push(*[
|
59
57
|
{ key: 'shipDate', value: Time.now.strftime("%Y-%m-%d") },
|
60
|
-
{ key: 'shipViaCode', value:
|
58
|
+
{ key: 'shipViaCode', value: 'UG' },
|
61
59
|
{ key: 'purchaseOrderNumber', value: purchase_order_number }
|
62
60
|
])
|
63
61
|
|
@@ -69,7 +67,7 @@ module Zanders
|
|
69
67
|
if ship_to_number[:success]
|
70
68
|
shipping_information.push({key: 'shipToNo', value: ship_to_number[:ship_to_number] })
|
71
69
|
else
|
72
|
-
return { success: false, error_code: ship_to_number[:error_code], error_message:
|
70
|
+
return { success: false, error_code: ship_to_number[:error_code], error_message: response.last[:value] }
|
73
71
|
end
|
74
72
|
else
|
75
73
|
shipping_information.push(*[
|
data/lib/zanders/version.rb
CHANGED
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:
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Knight
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/zanders.rb
|
116
116
|
- lib/zanders/address.rb
|
117
117
|
- lib/zanders/base.rb
|
118
|
+
- lib/zanders/catalog.rb
|
118
119
|
- lib/zanders/inventory.rb
|
119
120
|
- lib/zanders/item.rb
|
120
121
|
- lib/zanders/order.rb
|