sports_south 2.1.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sports_south.rb +0 -1
- data/lib/sports_south/base.rb +1 -1
- data/lib/sports_south/catalog.rb +4 -15
- data/lib/sports_south/inventory.rb +12 -54
- data/lib/sports_south/invoice.rb +9 -8
- data/lib/sports_south/order.rb +6 -5
- data/lib/sports_south/rotator.rb +0 -1
- data/lib/sports_south/version.rb +1 -1
- data/sports_south.gemspec +1 -0
- metadata +17 -4
- data/lib/sports_south/chunker.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd770d8c140f2571c87ce1f3fae13571c1259e63
|
4
|
+
data.tar.gz: cc5837ea9f109de82636f7b056a186d851df0139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0551d34300ec47e40f9acb8c51c8580943f517036b5bbb00cf4f3af12c737caf6cfb44ce634055367e2de312803af288a06468713b6526be5abd8d6e6bceeb73
|
7
|
+
data.tar.gz: cb2d3a70347fdca2a5d2a7c0e25d196f062ade020d4ec9092b3736e8948997e6cb00b64bc90a03a7e01d8048ca6ec7946c274aa475307b389a8ad792c8e4f3e3
|
data/lib/sports_south.rb
CHANGED
data/lib/sports_south/base.rb
CHANGED
@@ -5,7 +5,7 @@ module SportsSouth
|
|
5
5
|
class Base
|
6
6
|
|
7
7
|
TIMEOUT = 960 # seconds
|
8
|
-
USER_AGENT = "sports_south rubygems.org/gems/sports_south v(#{SportsSouth::VERSION})"
|
8
|
+
USER_AGENT = "sports_south rubygems.org/gems/sports_south v(#{SportsSouth::VERSION})".freeze
|
9
9
|
CONTENT_TYPE = 'application/x-www-form-urlencoded'.freeze
|
10
10
|
|
11
11
|
protected
|
data/lib/sports_south/catalog.rb
CHANGED
@@ -35,7 +35,7 @@ module SportsSouth
|
|
35
35
|
@brands = SportsSouth::Brand.all(options)
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.all(
|
38
|
+
def self.all(options = {}, &block)
|
39
39
|
requires!(options, :username, :password)
|
40
40
|
|
41
41
|
if options[:last_updated]
|
@@ -46,7 +46,7 @@ module SportsSouth
|
|
46
46
|
|
47
47
|
options[:last_item] ||= '-1'
|
48
48
|
|
49
|
-
new(options).all
|
49
|
+
new(options).all &block
|
50
50
|
end
|
51
51
|
|
52
52
|
def self.get_description(item_number, options = {})
|
@@ -55,8 +55,7 @@ module SportsSouth
|
|
55
55
|
new(options, :username, :password)
|
56
56
|
end
|
57
57
|
|
58
|
-
def all(
|
59
|
-
chunker = SportsSouth::Chunker.new(chunk_size)
|
58
|
+
def all(&block)
|
60
59
|
http, request = get_http_and_request(API_URL, '/DailyItemUpdate')
|
61
60
|
|
62
61
|
request.set_form_data(form_params(@options).merge({
|
@@ -68,17 +67,7 @@ module SportsSouth
|
|
68
67
|
xml_doc = Nokogiri::XML(sanitize_response(response))
|
69
68
|
|
70
69
|
xml_doc.css('Table').map do |item|
|
71
|
-
|
72
|
-
yield(chunker.chunk)
|
73
|
-
|
74
|
-
chunker.reset!
|
75
|
-
else
|
76
|
-
chunker.add(map_hash(item, !@options[:full_product].nil?))
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
if chunker.chunk.count > 0
|
81
|
-
yield(chunker.chunk)
|
70
|
+
yield(map_hash(item, !@options[:full_product].nil?))
|
82
71
|
end
|
83
72
|
end
|
84
73
|
|
@@ -12,13 +12,13 @@ module SportsSouth
|
|
12
12
|
def self.get_quantity_file(options = {})
|
13
13
|
requires!(options, :username, :password)
|
14
14
|
|
15
|
-
options[:last_updated]
|
16
|
-
options[:last_item]
|
15
|
+
options[:last_updated] = '1990-09-25T14:15:47-04:00'
|
16
|
+
options[:last_item] = '-1'
|
17
17
|
|
18
18
|
new(options).get_quantity_file
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.all(
|
21
|
+
def self.all(options = {}, &block)
|
22
22
|
requires!(options, :username, :password)
|
23
23
|
|
24
24
|
if options[:last_updated].present?
|
@@ -29,7 +29,7 @@ module SportsSouth
|
|
29
29
|
|
30
30
|
options[:last_item] ||= '-1'
|
31
31
|
|
32
|
-
new(options).all(
|
32
|
+
new(options).all(&block)
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.get(item_identifier, options = {})
|
@@ -37,8 +37,7 @@ module SportsSouth
|
|
37
37
|
new(options).get(item_identifier)
|
38
38
|
end
|
39
39
|
|
40
|
-
def all(
|
41
|
-
chunker = SportsSouth::Chunker.new(chunk_size)
|
40
|
+
def all(&block)
|
42
41
|
http, request = get_http_and_request(API_URL, '/IncrementalOnhandUpdate')
|
43
42
|
|
44
43
|
request.set_form_data(form_params = form_params(@options).merge({
|
@@ -46,21 +45,11 @@ module SportsSouth
|
|
46
45
|
LastItem: @options[:last_item].to_s
|
47
46
|
}))
|
48
47
|
|
49
|
-
response
|
50
|
-
xml_doc
|
48
|
+
response = http.request(request)
|
49
|
+
xml_doc = Nokogiri::XML(sanitize_response(response))
|
51
50
|
|
52
51
|
xml_doc.css('Onhand').map do |item|
|
53
|
-
|
54
|
-
yield(chunker.chunk)
|
55
|
-
|
56
|
-
chunker.reset!
|
57
|
-
else
|
58
|
-
chunker.add(self.map_hash(item))
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
if chunker.chunk.count > 0
|
63
|
-
yield(chunker.chunk)
|
52
|
+
yield(self.map_hash(item))
|
64
53
|
end
|
65
54
|
end
|
66
55
|
|
@@ -73,19 +62,18 @@ module SportsSouth
|
|
73
62
|
LastItem: @options[:last_item].to_s
|
74
63
|
}))
|
75
64
|
|
76
|
-
response
|
77
|
-
xml_doc
|
65
|
+
response = http.request(request)
|
66
|
+
xml_doc = Nokogiri::XML(sanitize_response(response))
|
78
67
|
|
79
68
|
xml_doc.css('Onhand').map do |item|
|
80
69
|
tempfile.puts("#{content_for(item, 'I')},#{content_for(item, 'Q')}")
|
81
70
|
end
|
82
71
|
|
83
72
|
tempfile.close
|
84
|
-
|
85
73
|
tempfile.path
|
86
74
|
end
|
87
75
|
|
88
|
-
def self.quantity(
|
76
|
+
def self.quantity(options = {}, &block)
|
89
77
|
requires!(options, :username, :password)
|
90
78
|
|
91
79
|
if options[:last_updated].present?
|
@@ -96,37 +84,7 @@ module SportsSouth
|
|
96
84
|
|
97
85
|
options[:last_item] ||= '-1'
|
98
86
|
|
99
|
-
new(options).all(
|
100
|
-
end
|
101
|
-
|
102
|
-
def quantity(chunk_size, &block)
|
103
|
-
chunker = SportsSouth::Chunker.new(chunk_size)
|
104
|
-
http, request = get_http_and_request(API_URL, '/IncrementalOnhandUpdate')
|
105
|
-
|
106
|
-
request.set_form_data(form_params = form_params(@options).merge({
|
107
|
-
SinceDateTime: @options[:last_updated],
|
108
|
-
LastItem: @options[:last_item].to_s
|
109
|
-
}))
|
110
|
-
|
111
|
-
response = http.request(request)
|
112
|
-
xml_doc = Nokogiri::XML(sanitize_response(response))
|
113
|
-
|
114
|
-
xml_doc.css('Onhand').map do |item|
|
115
|
-
if chunker.is_full?
|
116
|
-
yield(chunker.chunk)
|
117
|
-
|
118
|
-
chunker.reset!
|
119
|
-
else
|
120
|
-
chunker.add({
|
121
|
-
item_identifier: content_for(node, 'I'),
|
122
|
-
quantity: content_for(node, 'Q').to_i
|
123
|
-
})
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
if chunker.chunk.count > 0
|
128
|
-
yield(chunker.chunk)
|
129
|
-
end
|
87
|
+
new(options).all(&block)
|
130
88
|
end
|
131
89
|
|
132
90
|
def get(item_identifier)
|
data/lib/sports_south/invoice.rb
CHANGED
@@ -35,17 +35,18 @@ module SportsSouth
|
|
35
35
|
@response_body = body
|
36
36
|
|
37
37
|
@tracking = {
|
38
|
-
invoice_number:
|
38
|
+
invoice_number: content_for(xml_doc, 'INVNO'),
|
39
39
|
customer_number: content_for(xml_doc, 'CUSNO'),
|
40
|
-
po_number:
|
41
|
-
ship_date:
|
40
|
+
po_number: content_for(xml_doc, 'PONBR'),
|
41
|
+
ship_date: content_for(xml_doc, 'SHPDTE'),
|
42
42
|
tracking_number: content_for(xml_doc, 'TRACKNO'),
|
43
|
-
package_weight:
|
44
|
-
cod_amount:
|
45
|
-
hazmat:
|
46
|
-
ship_amount:
|
47
|
-
ship_service:
|
43
|
+
package_weight: content_for(xml_doc, 'PKGWT'),
|
44
|
+
cod_amount: content_for(xml_doc, 'CODAMT'),
|
45
|
+
hazmat: content_for(xml_doc, 'HAZMAT'),
|
46
|
+
ship_amount: content_for(xml_doc, 'SHPAMT'),
|
47
|
+
ship_service: content_for(xml_doc, 'SERVICE'),
|
48
48
|
}
|
49
49
|
end
|
50
|
+
|
50
51
|
end
|
51
52
|
end
|
data/lib/sports_south/order.rb
CHANGED
@@ -4,11 +4,12 @@ module SportsSouth
|
|
4
4
|
API_URL = 'http://webservices.theshootingwarehouse.com/smart/orders.asmx'
|
5
5
|
|
6
6
|
SHIP_VIA = {
|
7
|
-
ground:
|
8
|
-
next_day:
|
9
|
-
two_day:
|
7
|
+
ground: '',
|
8
|
+
next_day: 'N',
|
9
|
+
two_day: '2',
|
10
10
|
three_day: '3',
|
11
|
-
saturday:
|
11
|
+
saturday: 'S',
|
12
|
+
premium_ground: 'G',
|
12
13
|
}
|
13
14
|
|
14
15
|
# D=Placed, E=Error placing Order, R=Placed-Verifying, W=Open
|
@@ -42,8 +43,8 @@ module SportsSouth
|
|
42
43
|
|
43
44
|
requires!(header[:shipping], :name, :address_one, :city, :state, :zip, :phone)
|
44
45
|
header[:shipping][:attn] = '' unless header[:shipping].has_key?(:attn)
|
45
|
-
header[:shipping][:via] = SHIP_VIA[:ground] unless header[:shipping].has_key?(:ship_via)
|
46
46
|
header[:shipping][:address_two] = '' unless header[:shipping].has_key?(:address_two)
|
47
|
+
header[:shipping][:via] = (header[:shipping].has_key?(:ship_via) ? SHIP_VIA[header[:shipping][:ship_via]] : SHIP_VIA[:ground])
|
47
48
|
|
48
49
|
http, request = get_http_and_request(API_URL, '/AddHeader')
|
49
50
|
|
data/lib/sports_south/rotator.rb
CHANGED
data/lib/sports_south/version.rb
CHANGED
data/sports_south.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "nokogiri", "~> 1.6"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.12"
|
26
|
+
spec.add_development_dependency "activesupport", "~> 5"
|
26
27
|
spec.add_development_dependency "net-http-spy", "~> 0.2"
|
27
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
29
|
spec.add_development_dependency "rspec", "~> 3.3"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sports_south
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dale Campbell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: net-http-spy
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,7 +131,6 @@ files:
|
|
117
131
|
- lib/sports_south/brand.rb
|
118
132
|
- lib/sports_south/catalog.rb
|
119
133
|
- lib/sports_south/category.rb
|
120
|
-
- lib/sports_south/chunker.rb
|
121
134
|
- lib/sports_south/ffl.rb
|
122
135
|
- lib/sports_south/image.rb
|
123
136
|
- lib/sports_south/inventory.rb
|
@@ -147,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
160
|
version: '0'
|
148
161
|
requirements: []
|
149
162
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.6.12
|
151
164
|
signing_key:
|
152
165
|
specification_version: 4
|
153
166
|
summary: Sports South API Ruby library.
|
data/lib/sports_south/chunker.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module SportsSouth
|
2
|
-
class Chunker
|
3
|
-
|
4
|
-
attr_accessor :chunk, :total_count, :current_count, :size
|
5
|
-
|
6
|
-
def initialize(size, total_count = nil)
|
7
|
-
@size = size
|
8
|
-
@chunk = Array.new
|
9
|
-
@current_count = 0
|
10
|
-
@total_count = total_count
|
11
|
-
end
|
12
|
-
|
13
|
-
def add(row)
|
14
|
-
self.reset! if is_full?
|
15
|
-
|
16
|
-
@chunk.push(row)
|
17
|
-
|
18
|
-
@current_count += 1
|
19
|
-
end
|
20
|
-
|
21
|
-
def reset!
|
22
|
-
@chunk.clear
|
23
|
-
end
|
24
|
-
|
25
|
-
def is_full?
|
26
|
-
@chunk.count == @size
|
27
|
-
end
|
28
|
-
|
29
|
-
def is_complete?
|
30
|
-
@total_count == @current_count
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|