sports_south 2.0.3 → 2.0.4
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/base.rb +1 -2
- data/lib/sports_south/brand.rb +13 -3
- data/lib/sports_south/catalog.rb +21 -15
- data/lib/sports_south/category.rb +12 -2
- data/lib/sports_south/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34ff8eafee6d8b855e8d46a14297dfaa086ab27f
|
4
|
+
data.tar.gz: b7abf90f19cc28af2916df3a345fde61534ea122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c152cb8465053591736a65d37f5a8e9dde43536bba758c91b704df3525595b6f4752f7ccd82987c0e450592508962a557181d5da7d017b26442448fa02060e30
|
7
|
+
data.tar.gz: 8a09d81975ece026091695cd0bd64299c8d21162eebec928985af22e1ea436d72a2a9f6be474f4683f434d6a871df297c31c0195fc83e0fb3d91f51a5e5e01ce
|
data/lib/sports_south/base.rb
CHANGED
@@ -57,11 +57,10 @@ module SportsSouth
|
|
57
57
|
end
|
58
58
|
def get_http_and_request(*args); self.class.get_http_and_request(*args); end
|
59
59
|
|
60
|
-
def
|
60
|
+
def not_authenticated?(xml_doc)
|
61
61
|
msg = content_for(xml_doc, 'ERROR')
|
62
62
|
(msg =~ /Authentication Failed/i) || (msg =~ /NOT AUTHENTICATED/i)
|
63
63
|
end
|
64
|
-
def not_authenticated?(*args); self.class.not_authenticated?(*args); end
|
65
64
|
|
66
65
|
# HACK: We have to fix the malformed XML response SS is currently returning.
|
67
66
|
def self.sanitize_response(response)
|
data/lib/sports_south/brand.rb
CHANGED
@@ -3,11 +3,21 @@ module SportsSouth
|
|
3
3
|
|
4
4
|
API_URL = 'http://webservices.theshootingwarehouse.com/smart/inventory.asmx'
|
5
5
|
|
6
|
+
def initialize(options = {})
|
7
|
+
requires!(options, :username, :password)
|
8
|
+
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
6
12
|
def self.all(options = {})
|
7
13
|
requires!(options, :username, :password)
|
8
14
|
|
15
|
+
new(options).all
|
16
|
+
end
|
17
|
+
|
18
|
+
def all
|
9
19
|
http, request = get_http_and_request(API_URL, '/BrandUpdate')
|
10
|
-
request.set_form_data(form_params(options))
|
20
|
+
request.set_form_data(form_params(@options))
|
11
21
|
|
12
22
|
response = http.request(request)
|
13
23
|
xml_doc = Nokogiri::XML(sanitize_response(response))
|
@@ -19,9 +29,9 @@ module SportsSouth
|
|
19
29
|
|
20
30
|
protected
|
21
31
|
|
22
|
-
def
|
32
|
+
def map_hash(node)
|
23
33
|
{
|
24
|
-
|
34
|
+
brand_id: content_for(node, 'BRDNO'),
|
25
35
|
name: content_for(node, 'BRDNM'),
|
26
36
|
url: content_for(node, 'BRDURL'),
|
27
37
|
item_count: content_for(node, 'ITCOUNT')
|
data/lib/sports_south/catalog.rb
CHANGED
@@ -25,7 +25,9 @@ module SportsSouth
|
|
25
25
|
def initialize(options = {})
|
26
26
|
requires!(options, :username, :password)
|
27
27
|
|
28
|
-
@options
|
28
|
+
@options = options
|
29
|
+
@categories = SportsSouth::Category.all(options)
|
30
|
+
@brands = SportsSouth::Brand.all(options)
|
29
31
|
end
|
30
32
|
|
31
33
|
def self.all(chunk_size = 15, options = {}, &block)
|
@@ -60,7 +62,7 @@ module SportsSouth
|
|
60
62
|
|
61
63
|
chunker.reset!
|
62
64
|
else
|
63
|
-
chunker.add(
|
65
|
+
chunker.add(map_hash(item))
|
64
66
|
end
|
65
67
|
|
66
68
|
if chunker.chunk.count > 0
|
@@ -72,23 +74,27 @@ module SportsSouth
|
|
72
74
|
protected
|
73
75
|
|
74
76
|
def map_hash(node)
|
77
|
+
category = @categories.find { |category| category[:category_id] == content_for(node, 'CATID') }
|
78
|
+
brand = @brands.find { |brand| brand[:brand_id] == content_for(node, 'ITBRDNO') }
|
79
|
+
|
75
80
|
{
|
76
|
-
upc:
|
77
|
-
item_identifier:
|
78
|
-
quantity:
|
79
|
-
price:
|
80
|
-
short_description:
|
81
|
-
long_description:
|
82
|
-
category:
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
81
|
+
upc: content_for(node, 'ITUPC'),
|
82
|
+
item_identifier: content_for(node, 'ITEMNO'),
|
83
|
+
quantity: content_for(node, 'QTYOH').to_i,
|
84
|
+
price: content_for(node, 'CPRC'),
|
85
|
+
short_description: content_for(node, 'SHDESC'),
|
86
|
+
long_description: content_for(node, 'IDESC'),
|
87
|
+
category: category[:department_description],
|
88
|
+
sub_category: category[:description],
|
89
|
+
product_type: ITEM_TYPES[content_for(node, 'ITYPE')],
|
90
|
+
mfg_number: content_for(node, 'IMFGNO'),
|
91
|
+
weight: content_for(node, 'WTPBX'),
|
92
|
+
map_price: content_for(node, 'MFPRC'),
|
93
|
+
brand: brand[:name],
|
88
94
|
features: {
|
89
95
|
length: content_for(node, 'LENGTH'),
|
90
96
|
height: content_for(node, 'HEIGHT'),
|
91
|
-
width:
|
97
|
+
width: content_for(node, 'WIDTH')
|
92
98
|
}
|
93
99
|
}
|
94
100
|
end
|
@@ -3,11 +3,21 @@ module SportsSouth
|
|
3
3
|
|
4
4
|
API_URL = 'http://webservices.theshootingwarehouse.com/smart/inventory.asmx'
|
5
5
|
|
6
|
+
def initialize(options = {})
|
7
|
+
requires!(options, :username, :password)
|
8
|
+
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
6
12
|
def self.all(options = {})
|
7
13
|
requires!(options, :username, :password)
|
8
14
|
|
15
|
+
new(options).all
|
16
|
+
end
|
17
|
+
|
18
|
+
def all
|
9
19
|
http, request = get_http_and_request(API_URL, '/CategoryUpdate')
|
10
|
-
request.set_form_data(form_params(options))
|
20
|
+
request.set_form_data(form_params(@options))
|
11
21
|
|
12
22
|
response = http.request(request)
|
13
23
|
xml_doc = Nokogiri::XML(sanitize_response(response))
|
@@ -19,7 +29,7 @@ module SportsSouth
|
|
19
29
|
|
20
30
|
protected
|
21
31
|
|
22
|
-
def
|
32
|
+
def map_hash(node)
|
23
33
|
{
|
24
34
|
category_id: content_for(node, 'CATID'),
|
25
35
|
description: content_for(node, 'CATDES'),
|
data/lib/sports_south/version.rb
CHANGED