zanders 0.1.5
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 +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +1 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/zanders/address.rb +88 -0
- data/lib/zanders/base.rb +43 -0
- data/lib/zanders/inventory.rb +54 -0
- data/lib/zanders/item.rb +105 -0
- data/lib/zanders/order.rb +160 -0
- data/lib/zanders/soap_client.rb +39 -0
- data/lib/zanders/version.rb +3 -0
- data/lib/zanders.rb +47 -0
- data/zanders.gemspec +32 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 320b713912cf45d9193b127a38bfb51e5b5b91d6
|
4
|
+
data.tar.gz: 7736dcf3ffab83a65309c16cea0df56e8235bb5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3203095d5298e9e5ca76c00bcde33e576e5a549fe6e492844eda133d731bd0b7de5571fc65355b9794f2024b8a824aac45f397b4acbb75469d1b67c23eeaa334
|
7
|
+
data.tar.gz: 419adab7698aa2915f0703be0baef0efbded9b282c44fa0bc9f03d8e95edf8e094799b61c46ee4e85a9d9355a68a453778f5542756a2f8044c3157943b7b5efd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
zanders
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 David Knight
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Zanders
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "zanders"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
module Zanders
|
2
|
+
class Address < SoapClient
|
3
|
+
|
4
|
+
attr_reader :username
|
5
|
+
attr_reader :password
|
6
|
+
|
7
|
+
# Public: Initializes a new Address with username
|
8
|
+
# and password
|
9
|
+
#
|
10
|
+
# username - A String username
|
11
|
+
# password - A String password
|
12
|
+
#
|
13
|
+
# Returns a new Address service interface
|
14
|
+
def initialize(options = {})
|
15
|
+
requires!(options, :username, :password)
|
16
|
+
|
17
|
+
@username = options[:username]
|
18
|
+
@password = options[:password]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.ship_to_number(address, options = {})
|
22
|
+
new(options).ship_to_number(address)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Public: Get a shipToNumber for the address
|
26
|
+
# provided in `address`
|
27
|
+
#
|
28
|
+
# address - Hash of the address
|
29
|
+
#
|
30
|
+
# Returns Hash containing the ship to number, or an error
|
31
|
+
# code if the call failed
|
32
|
+
def ship_to_number(address)
|
33
|
+
request_data = build_request_data(address)
|
34
|
+
|
35
|
+
response = soap_client(ADDRESS_API_URL).call(:use_ship_to, message: request_data)
|
36
|
+
response = response.body[:use_ship_to_response][:return][:item]
|
37
|
+
|
38
|
+
# Successful call return_code is 0
|
39
|
+
if response.first[:value] == "0"
|
40
|
+
ship_to_number = Hash.new
|
41
|
+
|
42
|
+
# Let's dig to get to data we actually need. Yay, digging...
|
43
|
+
parts = ship_to_number[:ship_to_number] = response.last[:value].first[1]
|
44
|
+
|
45
|
+
# We only need the ship_to_number out of the data received
|
46
|
+
ship_to_number[:ship_to_number] = parts.find { |i| i[:key] == "ShipToNo" }[:value]
|
47
|
+
|
48
|
+
ship_to_number[:success] = true
|
49
|
+
|
50
|
+
ship_to_number
|
51
|
+
else
|
52
|
+
{ success: false, error_code: response.first[:value] }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
# Private: Combines request data with the username,
|
59
|
+
# password, and type-cast assignments
|
60
|
+
#
|
61
|
+
# hash - Hash of request data
|
62
|
+
#
|
63
|
+
# Returns merged Hash
|
64
|
+
def build_request_data(hash)
|
65
|
+
{
|
66
|
+
:attributes! => {
|
67
|
+
addressinfo: { "xsi:type" => "ns2:Map" },
|
68
|
+
},
|
69
|
+
username: @username,
|
70
|
+
password: @password,
|
71
|
+
addressinfo: {
|
72
|
+
item: [
|
73
|
+
{ key: 'name', value: hash[:name] },
|
74
|
+
{ key: 'address1', value: hash[:address1] },
|
75
|
+
{ key: 'address2', value: hash[:address2] },
|
76
|
+
{ key: 'city', value: hash[:city] },
|
77
|
+
{ key: 'state', value: hash[:state] },
|
78
|
+
{ key: 'zip', value: hash[:zip] },
|
79
|
+
{ key: 'fflno', value: hash[:fflno] },
|
80
|
+
{ key: 'fflexp', value: hash[:fflexp] }
|
81
|
+
]
|
82
|
+
},
|
83
|
+
testing: true
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
data/lib/zanders/base.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Zanders
|
2
|
+
class Base
|
3
|
+
|
4
|
+
def self.connect(options = {})
|
5
|
+
requires!(options, :username, :password)
|
6
|
+
|
7
|
+
Net::FTP.open(Zanders.config.ftp_host, options[:username], options[:password]) do |ftp|
|
8
|
+
ftp.passive = true
|
9
|
+
yield ftp
|
10
|
+
end
|
11
|
+
rescue Net::FTPPermError
|
12
|
+
raise Zanders::NotAuthenticated
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
# Wrapper to `self.requires!` that can be used as an instance method.
|
18
|
+
def requires!(*args)
|
19
|
+
self.class.requires!(*args)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.requires!(hash, *params)
|
23
|
+
params.each do |param|
|
24
|
+
if param.is_a?(Array)
|
25
|
+
raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first)
|
26
|
+
|
27
|
+
valid_options = param[1..-1]
|
28
|
+
raise ArgumentError.new("Parameter: #{param.first} must be one of: #{valid_options.join(', ')}") unless valid_options.include?(hash[param.first])
|
29
|
+
else
|
30
|
+
raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Instance methods become class methods through inheritance
|
36
|
+
def connect(options)
|
37
|
+
self.class.connect(options) do |ftp|
|
38
|
+
yield ftp
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Zanders
|
2
|
+
class Inventory < Base
|
3
|
+
|
4
|
+
INVENTORY_FILENAME = "zandersinv.csv"
|
5
|
+
QUANTITY_FILENAME = "liveinv.csv"
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
requires!(options, :username, :password)
|
9
|
+
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.all(chunk_size = 15, options = {}, &block)
|
14
|
+
requires!(options, :username, :password)
|
15
|
+
new(options).all(chunk_size, &block)
|
16
|
+
end
|
17
|
+
|
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
|
+
def all(chunk_size, &block)
|
24
|
+
connect(@options) do |ftp|
|
25
|
+
csv_tempfile = Tempfile.new
|
26
|
+
|
27
|
+
ftp.chdir(Zanders.config.ftp_directory)
|
28
|
+
ftp.getbinaryfile(INVENTORY_FILENAME, csv_tempfile.path)
|
29
|
+
|
30
|
+
SmarterCSV.process(csv_tempfile, { :chunk_size => chunk_size, :convert_values_to_numeric => false }) do |chunk|
|
31
|
+
yield(chunk)
|
32
|
+
end
|
33
|
+
|
34
|
+
csv_tempfile.unlink
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def quantities(chunk_size, &block)
|
39
|
+
connect(@options) do |ftp|
|
40
|
+
csv_tempfile = Tempfile.new
|
41
|
+
|
42
|
+
ftp.chdir(Zanders.config.ftp_directory)
|
43
|
+
ftp.getbinaryfile(QUANTITY_FILENAME, csv_tempfile.path)
|
44
|
+
|
45
|
+
SmarterCSV.process(csv_tempfile, { :chunk_size => chunk_size, :convert_values_to_numeric => false }) do |chunk|
|
46
|
+
yield(chunk)
|
47
|
+
end
|
48
|
+
|
49
|
+
csv_tempfile.unlink
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
data/lib/zanders/item.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
module Zanders
|
2
|
+
class Item < SoapClient
|
3
|
+
|
4
|
+
attr_reader :username
|
5
|
+
attr_reader :password
|
6
|
+
|
7
|
+
# Public: Initialize a new Item interface with
|
8
|
+
# username and password
|
9
|
+
#
|
10
|
+
# options - Hash of username and password
|
11
|
+
#
|
12
|
+
# Returns a new Item service interface
|
13
|
+
def initialize(options = {})
|
14
|
+
requires!(options, :username, :password)
|
15
|
+
|
16
|
+
@username = options[:username]
|
17
|
+
@password = options[:password]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Public: Get item info by item number
|
21
|
+
#
|
22
|
+
# item_number - Integer of the item number
|
23
|
+
#
|
24
|
+
# Returns Hash containing item info, or an error code if
|
25
|
+
# the call failed
|
26
|
+
def get_info(item_number)
|
27
|
+
request_data = build_request_data({ itemnumber: item_number })
|
28
|
+
|
29
|
+
response = soap_client(ITEM_API_URL).call(:get_item_info, message: request_data)
|
30
|
+
response = response.body[:get_item_info_response][:return][:item]
|
31
|
+
|
32
|
+
# Successful call return_code is 0
|
33
|
+
if response.first[:value] == "0"
|
34
|
+
info = Hash.new
|
35
|
+
|
36
|
+
# Let's toss the data we need into a ruby-ish hash
|
37
|
+
response.each do |info_part|
|
38
|
+
case info_part[:key]
|
39
|
+
when "itemNumber"
|
40
|
+
info[:item_number] = info_part[:value]
|
41
|
+
when "itemDescription"
|
42
|
+
info[:description] = info_part[:value]
|
43
|
+
when "itemPrice"
|
44
|
+
info[:price] = info_part[:value]
|
45
|
+
when "itemWeight"
|
46
|
+
info[:weight] = info_part[:value]
|
47
|
+
when "numberAvailable"
|
48
|
+
info[:quantity] = info_part[:value]
|
49
|
+
else
|
50
|
+
next
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
info[:success] = true
|
55
|
+
|
56
|
+
info
|
57
|
+
else
|
58
|
+
{ success: false, error_code: response.first[:value] }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Public: Get item quantity by item number
|
63
|
+
#
|
64
|
+
# item_number - Integer of the item number
|
65
|
+
#
|
66
|
+
# Returns Hash containing item quantity, or an error code
|
67
|
+
# if the call failed
|
68
|
+
def get_quantity(item_number)
|
69
|
+
request_data = build_request_data({ itemnumber: item_number })
|
70
|
+
|
71
|
+
response = soap_client(ITEM_API_URL).call(:get_item_inventory, message: request_data)
|
72
|
+
response = response.body[:get_item_inventory_response][:return][:item]
|
73
|
+
|
74
|
+
# Successful call return_code is 0
|
75
|
+
if response.first[:value] == "0"
|
76
|
+
quantity = Hash.new
|
77
|
+
|
78
|
+
# We only need the quantity out of the data received
|
79
|
+
quantity[:quantity] = response.find { |i| i[:key] == "numberAvailable" }[:value]
|
80
|
+
|
81
|
+
quantity[:success] = true
|
82
|
+
|
83
|
+
quantity
|
84
|
+
else
|
85
|
+
{ success: false, error_code: response.first[:value] }
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
# Private: Combines request data with the username and password
|
92
|
+
#
|
93
|
+
# hash - Hash of request data
|
94
|
+
#
|
95
|
+
# Returns merged Hash
|
96
|
+
def build_request_data(hash)
|
97
|
+
{
|
98
|
+
username: @username,
|
99
|
+
password: @password,
|
100
|
+
testing: true
|
101
|
+
}.merge(hash)
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
module Zanders
|
2
|
+
class Order < SoapClient
|
3
|
+
|
4
|
+
##
|
5
|
+
# == Order Service
|
6
|
+
#
|
7
|
+
# Return Codes
|
8
|
+
# 0: Success
|
9
|
+
# 1: Username and/or Password were incorrect
|
10
|
+
# 2: There was a problem creating the order
|
11
|
+
# 5: Cannot create order with no items
|
12
|
+
# 9: Order not created because all items not available and not to be back ordered
|
13
|
+
# 10: Ship date cannot be before today
|
14
|
+
# 11: Ship date cannoy be more than 30days in the future
|
15
|
+
# 21: The order number is NOT connected to your customer number
|
16
|
+
# 31: Can NOT add item with quantity of less than 1
|
17
|
+
# 41: The item number requested is NOT connected to this order
|
18
|
+
|
19
|
+
attr_reader :username, :password, :options
|
20
|
+
|
21
|
+
# Public: Initialize a new Order
|
22
|
+
#
|
23
|
+
# options - Hash of username, password, and address information
|
24
|
+
#
|
25
|
+
# Returns an Order service interface
|
26
|
+
def initialize(options = {})
|
27
|
+
requires!(options, :username, :password)
|
28
|
+
|
29
|
+
@username = options[:username]
|
30
|
+
@password = options[:password]
|
31
|
+
|
32
|
+
@options = options
|
33
|
+
end
|
34
|
+
|
35
|
+
# Public: Create a new order
|
36
|
+
#
|
37
|
+
# items - Array of hashes containing item_number and quantity
|
38
|
+
#
|
39
|
+
# Returns an order_number
|
40
|
+
def create_order(items, address)
|
41
|
+
order = build_order_data
|
42
|
+
order_items = Array.new
|
43
|
+
|
44
|
+
items.each do |item|
|
45
|
+
order_items.push(item: [
|
46
|
+
{ key: 'itemNumber', value: item[:item_number] },
|
47
|
+
{ key: 'quantity', value: item[:quantity] },
|
48
|
+
{ key: 'allowBackOrder', value: false }
|
49
|
+
])
|
50
|
+
end
|
51
|
+
|
52
|
+
ship_to_number = Zanders::Address.ship_to_number(address, @options)
|
53
|
+
|
54
|
+
if ship_to_number[:success]
|
55
|
+
shipping_information = [
|
56
|
+
{ key: 'shipToNo', value: ship_to_number[:ship_to_number] },
|
57
|
+
{ key: 'shipDate', value: Time.now.strftime("%Y-%m-%d") },
|
58
|
+
# TODO-david
|
59
|
+
{ key: 'ShipViaCode', value: 'UG' },
|
60
|
+
# TODO-david
|
61
|
+
{ key: 'purchaseOrderNumber', value: '4567' }
|
62
|
+
]
|
63
|
+
|
64
|
+
# NOTE-david
|
65
|
+
# order(ns2 map)
|
66
|
+
# item
|
67
|
+
# key
|
68
|
+
# value(ns2map)
|
69
|
+
# item - order item
|
70
|
+
# item - order item
|
71
|
+
# item
|
72
|
+
# "
|
73
|
+
#
|
74
|
+
order[:order] = Hash.new
|
75
|
+
order[:order][:item] = shipping_information
|
76
|
+
|
77
|
+
order_items = {item: order_items, attributes!: { item: { "xsi:type" => "ns2:Map"} }}
|
78
|
+
|
79
|
+
order[:order][:item].push({
|
80
|
+
key: 'items',
|
81
|
+
value: order_items
|
82
|
+
})
|
83
|
+
|
84
|
+
response = soap_client(ORDER_API_URL).call(:create_order, message: order)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Public: Get order info
|
89
|
+
#
|
90
|
+
# order_number - The String order number
|
91
|
+
#
|
92
|
+
# Returns Hash containing order information, or an error
|
93
|
+
# code if the call failed
|
94
|
+
def get_order(order_number)
|
95
|
+
order = build_order_data.merge({ ordernumber: order_number })
|
96
|
+
|
97
|
+
response = soap_client(ORDER_API_URL).call(:get_order_info, message: order)
|
98
|
+
response = response.body[:get_order_info_response][:return][:item]
|
99
|
+
|
100
|
+
# Successful call return_code is 0
|
101
|
+
if response.first[:value] == "0"
|
102
|
+
info = Hash.new
|
103
|
+
|
104
|
+
# Just use the order number we already have
|
105
|
+
info[:order_number] = order_number
|
106
|
+
|
107
|
+
# Transform the response into a ruby-ish hash
|
108
|
+
response.each do |part|
|
109
|
+
case part[:key]
|
110
|
+
when "purchaseOrderNumber"
|
111
|
+
info[:purchase_order_number] = part[:value]
|
112
|
+
when "orderDate"
|
113
|
+
info[:order_date] = part[:value]
|
114
|
+
when "orderEnteredDate"
|
115
|
+
info[:ordered_entered_date] = part[:value]
|
116
|
+
when "orderShipDate"
|
117
|
+
info[:order_ship_date] = part[:value]
|
118
|
+
when "subtotal"
|
119
|
+
info[:subtotal] = part[:value]
|
120
|
+
when "freight"
|
121
|
+
info[:freight] = part[:value]
|
122
|
+
when "miscFee"
|
123
|
+
info[:misc_fee] = part[:value]
|
124
|
+
when "selectionCode"
|
125
|
+
info[:selection_code] = part[:value]
|
126
|
+
when "datePicked"
|
127
|
+
info[:date_picked] = part[:value]
|
128
|
+
when "grandTotal"
|
129
|
+
info[:grand_total] = part[:value]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
info[:success] = true
|
134
|
+
|
135
|
+
info
|
136
|
+
else
|
137
|
+
{ success: false, error_code: response.first[:value] }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
# Private: Builds request data
|
144
|
+
#
|
145
|
+
# Returns Hash of username, password, and cast assignments
|
146
|
+
def build_order_data
|
147
|
+
hash = {
|
148
|
+
:attributes! => {
|
149
|
+
order: { "xsi:type" => "ns2:Map" }
|
150
|
+
},
|
151
|
+
username: @username,
|
152
|
+
password: @password,
|
153
|
+
testing: true
|
154
|
+
}
|
155
|
+
|
156
|
+
hash
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Zanders
|
2
|
+
class SoapClient < Base
|
3
|
+
|
4
|
+
##
|
5
|
+
# == Item Service
|
6
|
+
#
|
7
|
+
# Return Codes
|
8
|
+
# 0: Success
|
9
|
+
# 1: Username and/or Password were incorrect
|
10
|
+
# 2: There was a problem retrieving information on the item(s)
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
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
|
+
@soap_client ||= Savon.client do
|
24
|
+
wsdl(api_url)
|
25
|
+
namespaces(namespaces)
|
26
|
+
namespace_identifier(:ns1)
|
27
|
+
strip_namespaces true
|
28
|
+
ssl_verify_mode :none
|
29
|
+
|
30
|
+
if DEBUG
|
31
|
+
log(true)
|
32
|
+
log_level(:debug)
|
33
|
+
pretty_print_xml(true)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
data/lib/zanders.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require "zanders/version"
|
2
|
+
|
3
|
+
require 'net/ftp'
|
4
|
+
require 'savon'
|
5
|
+
# TODO-david
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
require 'zanders/base'
|
9
|
+
require 'zanders/soap_client'
|
10
|
+
|
11
|
+
require 'zanders/address'
|
12
|
+
require 'zanders/order'
|
13
|
+
require 'zanders/item'
|
14
|
+
require 'zanders/inventory'
|
15
|
+
|
16
|
+
module Zanders
|
17
|
+
|
18
|
+
DEBUG = true
|
19
|
+
|
20
|
+
ADDRESS_API_URL = 'https://shop2.gzanders.com/webservice/shiptoaddresses?wsdl'
|
21
|
+
ORDER_API_URL = 'https://shop2.gzanders.com/webservice/orders?wsdl'
|
22
|
+
ITEM_API_URL = 'https://shop2.gzanders.com/webservice/items?wsdl'
|
23
|
+
|
24
|
+
class NotAuthenticated < StandardError; end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
attr_accessor :config
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.config
|
31
|
+
@config ||= Configuration.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.configure
|
35
|
+
yield(config)
|
36
|
+
end
|
37
|
+
|
38
|
+
class Configuration
|
39
|
+
attr_accessor :ftp_host
|
40
|
+
attr_accessor :ftp_directory
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
@ftp_host ||= "ftp.gzanders.com"
|
44
|
+
@ftp_directory ||= "Inventory/AmmoReady"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/zanders.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'zanders/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "zanders"
|
8
|
+
spec.version = Zanders::VERSION
|
9
|
+
spec.authors = ["David Knight"]
|
10
|
+
spec.email = ["viacoffee@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby library for Zanders}
|
13
|
+
spec.description = %q{}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "nokogiri", "~> 1.6"
|
25
|
+
spec.add_dependency "savon", "~> 2.11.1"
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "smarter_csv", "~> 1.1.4"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zanders
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Knight
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: savon
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.11.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.11.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: smarter_csv
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.1.4
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.1.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description: ''
|
98
|
+
email:
|
99
|
+
- viacoffee@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".ruby-gemset"
|
107
|
+
- ".ruby-version"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- lib/zanders.rb
|
116
|
+
- lib/zanders/address.rb
|
117
|
+
- lib/zanders/base.rb
|
118
|
+
- lib/zanders/inventory.rb
|
119
|
+
- lib/zanders/item.rb
|
120
|
+
- lib/zanders/order.rb
|
121
|
+
- lib/zanders/soap_client.rb
|
122
|
+
- lib/zanders/version.rb
|
123
|
+
- zanders.gemspec
|
124
|
+
homepage: ''
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.5.1
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Ruby library for Zanders
|
148
|
+
test_files: []
|