sports_south 0.15.0 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a79344ff1ad7199740dfb64fdf7b4bcf926b6221
4
- data.tar.gz: 82f7781c63d7ce9e7a7deb4f1a4b225a0928eb4c
3
+ metadata.gz: 9e9ce1ac3fe3b6153a108f6cdf06a9d775a1ed5d
4
+ data.tar.gz: c1733e62462b1ce5c578c20a67cdbf0f6c8529ac
5
5
  SHA512:
6
- metadata.gz: f87efe260a07df9fd5febede463f29b5b3f5f2874afc83512f7aa193ad888c02562c01ae5fc2bc69bc243ce88169053b13b9f18df4e7515be89847596765fb6d
7
- data.tar.gz: 39ea202d9c745616f2a0b94dc0d615c11f4d2dd4da6e7e15d390cb055ba69118c98362cf4d1c826e70924c6ec047b7491eb6dcffff5ff5c35333df340b531d0c
6
+ metadata.gz: 71ff858afb5298a31484104fdd19c16ce993871accc302a077d9da794e9e14dafa2377b6aec2db278f9b0706db38f7f2c3209a6e197abe1333486aac81c6e810
7
+ data.tar.gz: 947dbd5e095c4609922fec14ba98a902ccb8cdbdcb1b4131f4015ede8146a671355f804b4d7b4ea5b608780bbd618302c04117796a5be6a5ee96539a9326a3ef
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ script/*
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.3.1
@@ -4,6 +4,7 @@ module SportsSouth
4
4
 
5
5
  TIMEOUT = 960 # seconds
6
6
  USER_AGENT = "sports_south rubygems.org/gems/sports_south v(#{SportsSouth::VERSION})"
7
+ CONTENT_TYPE = 'application/x-www-form-urlencoded'.freeze
7
8
 
8
9
  protected
9
10
 
@@ -44,7 +45,8 @@ module SportsSouth
44
45
  http = Net::HTTP.new(uri.host, uri.port)
45
46
  http.read_timeout = TIMEOUT
46
47
  request = Net::HTTP::Post.new(uri.request_uri)
47
- request["User-Agent"] = USER_AGENT
48
+ request['User-Agent'] = USER_AGENT
49
+ request['Content-Type'] = CONTENT_TYPE
48
50
 
49
51
  return http, request
50
52
  end
@@ -7,26 +7,25 @@ module SportsSouth
7
7
  requires!(options, :username, :password, :source, :customer_number)
8
8
 
9
9
  http, request = get_http_and_request(API_URL, '/BrandUpdate')
10
-
11
10
  request.set_form_data(form_params(options))
11
+
12
12
  response = http.request(request)
13
- body = sanitize_response(response)
14
- xml_doc = Nokogiri::XML(body)
13
+ xml_doc = Nokogiri::XML(sanitize_response(response))
15
14
 
16
15
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
17
16
 
18
- brands = []
17
+ xml_doc.css('Table').map { |brand| map_hash(brand) }
18
+ end
19
19
 
20
- xml_doc.css('Table').each do |brand|
21
- brands << {
22
- id: content_for(brand, 'BRDNO'),
23
- name: content_for(brand, 'BRDNM'),
24
- url: content_for(brand, 'BRDURL'),
25
- item_count: content_for(brand, 'ITCOUNT'),
26
- }
27
- end
20
+ protected
28
21
 
29
- brands
22
+ def self.map_hash(node)
23
+ {
24
+ id: content_for(node, 'BRDNO'),
25
+ name: content_for(node, 'BRDNM'),
26
+ url: content_for(node, 'BRDURL'),
27
+ item_count: content_for(node, 'ITCOUNT')
28
+ }
30
29
  end
31
30
 
32
31
  end
@@ -1,52 +1,51 @@
1
1
  module SportsSouth
2
2
  class Category < Base
3
+
3
4
  API_URL = 'http://webservices.theshootingwarehouse.com/smart/inventory.asmx'
4
5
 
5
6
  def self.all(options = {})
6
7
  requires!(options, :username, :password, :source, :customer_number)
7
8
 
8
9
  http, request = get_http_and_request(API_URL, '/CategoryUpdate')
9
-
10
10
  request.set_form_data(form_params(options))
11
11
 
12
12
  response = http.request(request)
13
- body = sanitize_response(response)
14
- xml_doc = Nokogiri::XML(body)
13
+ xml_doc = Nokogiri::XML(sanitize_response(response))
15
14
 
16
15
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
17
16
 
18
- categories = []
19
-
20
- xml_doc.css('Table').each do |category|
21
- categories << {
22
- category_id: content_for(category, 'CATID'),
23
- description: content_for(category, 'CATDES'),
24
- department_id: content_for(category, 'DEPID'),
25
- department_description: content_for(category, 'DEP'),
26
- attribute_1: content_for(category, 'ATTR1'),
27
- attribute_2: content_for(category, 'ATTR2'),
28
- attribute_3: content_for(category, 'ATTR3'),
29
- attribute_4: content_for(category, 'ATTR4'),
30
- attribute_5: content_for(category, 'ATTR5'),
31
- attribute_6: content_for(category, 'ATTR6'),
32
- attribute_7: content_for(category, 'ATTR7'),
33
- attribute_8: content_for(category, 'ATTR8'),
34
- attribute_9: content_for(category, 'ATTR9'),
35
- attribute_10: content_for(category, 'ATTR0'),
36
- attribute_11: content_for(category, 'ATTR11'),
37
- attribute_12: content_for(category, 'ATTR12'),
38
- attribute_13: content_for(category, 'ATTR13'),
39
- attribute_14: content_for(category, 'ATTR14'),
40
- attribute_15: content_for(category, 'ATTR15'),
41
- attribute_16: content_for(category, 'ATTR16'),
42
- attribute_17: content_for(category, 'ATTR17'),
43
- attribute_18: content_for(category, 'ATTR18'),
44
- attribute_19: content_for(category, 'ATTR19'),
45
- attribute_20: content_for(category, 'ATTR20'),
46
- }
47
- end
48
-
49
- categories
17
+ xml_doc.css('Table').map { |category| map_hash(category) }
18
+ end
19
+
20
+ protected
21
+
22
+ def self.map_hash(node)
23
+ {
24
+ category_id: content_for(node, 'CATID'),
25
+ description: content_for(node, 'CATDES'),
26
+ department_id: content_for(node, 'DEPID'),
27
+ department_description: content_for(node, 'DEP'),
28
+ attribute_1: content_for(node, 'ATTR1'),
29
+ attribute_2: content_for(node, 'ATTR2'),
30
+ attribute_3: content_for(node, 'ATTR3'),
31
+ attribute_4: content_for(node, 'ATTR4'),
32
+ attribute_5: content_for(node, 'ATTR5'),
33
+ attribute_6: content_for(node, 'ATTR6'),
34
+ attribute_7: content_for(node, 'ATTR7'),
35
+ attribute_8: content_for(node, 'ATTR8'),
36
+ attribute_9: content_for(node, 'ATTR9'),
37
+ attribute_10: content_for(node, 'ATTR0'),
38
+ attribute_11: content_for(node, 'ATTR11'),
39
+ attribute_12: content_for(node, 'ATTR12'),
40
+ attribute_13: content_for(node, 'ATTR13'),
41
+ attribute_14: content_for(node, 'ATTR14'),
42
+ attribute_15: content_for(node, 'ATTR15'),
43
+ attribute_16: content_for(node, 'ATTR16'),
44
+ attribute_17: content_for(node, 'ATTR17'),
45
+ attribute_18: content_for(node, 'ATTR18'),
46
+ attribute_19: content_for(node, 'ATTR19'),
47
+ attribute_20: content_for(node, 'ATTR20')
48
+ }
50
49
  end
51
50
  end
52
51
  end
@@ -13,8 +13,7 @@ module SportsSouth
13
13
  request.set_form_data(form_params(options).merge({ FFL: ffl }))
14
14
 
15
15
  response = http.request(request)
16
- body = sanitize_response(response)
17
- xml_doc = Nokogiri::XML(body)
16
+ xml_doc = Nokogiri::XML(sanitize_response(response))
18
17
 
19
18
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
20
19
 
@@ -13,12 +13,11 @@ module SportsSouth
13
13
  }))
14
14
 
15
15
  response = http.request(request)
16
- body = sanitize_response(response)
17
- xml_doc = Nokogiri::XML(body)
16
+ xml_doc = Nokogiri::XML(sanitize_response(response))
18
17
 
19
18
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
20
19
 
21
- images = {}
20
+ images = Hash.new
22
21
 
23
22
  xml_doc.css('Table').each do |image|
24
23
  size = content_for(image, 'ImageSize').to_sym
@@ -24,83 +24,21 @@ module SportsSouth
24
24
  def self.all(options = {})
25
25
  requires!(options, :username, :password, :source, :customer_number)
26
26
 
27
- options[:last_update] ||= '1/1/1990' # Return full catalog.
28
- options[:last_item] ||= '-1' # Return all items.
27
+ options[:last_update] ||= '1/1/1990' # Return full catalog.
28
+ options[:last_item] ||= '-1' # Return all items.
29
29
 
30
30
  http, request = get_http_and_request(API_URL, '/DailyItemUpdate')
31
31
 
32
32
  request.set_form_data(form_params(options).merge({
33
33
  LastUpdate: options[:last_update],
34
- LastItem: options[:last_item],
34
+ LastItem: options[:last_item].to_s,
35
35
  }))
36
36
 
37
- response = http.request(request)
38
- body = sanitize_response(response)
39
- xml_doc = Nokogiri::XML(body)
37
+ xml_doc = Nokogiri::XML(sanitize_response(http.request(request)))
40
38
 
41
39
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
42
40
 
43
- items = []
44
-
45
- xml_doc.css('Table').each do |item|
46
- items << {
47
- item_number: content_for(item, 'ITEMNO'),
48
- description: content_for(item, 'IDESC'),
49
- manufacturer_sequence: content_for(item, 'IMFSEQ'),
50
- manufacturer_number: content_for(item, 'IMFGNO'),
51
- catalog_sequence: content_for(item, 'CSEQ'),
52
- item_type: ITEM_TYPES[content_for(item, 'ITYPE')],
53
- short_description: content_for(item, 'SHDESC'),
54
- unit_of_measure: content_for(item, 'UOM'),
55
- catalog_price: content_for(item, 'PRC1'),
56
- customer_price: content_for(item, 'CPRC'),
57
- quantity_on_hand: content_for(item, 'QTYOH'),
58
- weight_per_box: content_for(item, 'WTPBX'),
59
- upc: content_for(item, 'ITUPC'),
60
- manufacturer_item_number: content_for(item, 'MFGINO'),
61
- scan_name_1: content_for(item, 'SCNAM1'),
62
- scan_name_2: content_for(item, 'SCNAM2'),
63
- catalog_code: CATALOG_CODES[content_for(item, 'CATCD')],
64
- mapp_price_code: content_for(item, 'MFPRTYP'),
65
- mapp_price: content_for(item, 'MFPRC'),
66
- category_id: content_for(item, 'CATID'),
67
- text_reference_number: content_for(item, 'TXTREF'),
68
- picture_reference_number: content_for(item, 'PICREF'),
69
- brand_id: content_for(item, 'ITBRDNO'),
70
- item_model_number: content_for(item, 'IMODEL'),
71
- item_purpose: content_for(item, 'IPURPOSE'),
72
- series_description: content_for(item, 'SERIES'),
73
- item_length: content_for(item, 'LENGTH'),
74
- item_height: content_for(item, 'HEIGHT'),
75
- item_width: content_for(item, 'WIDTH'),
76
- item_ships_hazmat_air: content_for(item, 'HAZAIR'),
77
- item_ships_hazmat_ground: content_for(item, 'HAZGRND'),
78
- date_of_last_change: content_for(item, 'CHGDTE'),
79
- date_added: content_for(item, 'CHGDTE'),
80
- attribute_1: content_for(item, 'ITATR1'),
81
- attribute_2: content_for(item, 'ITATR2'),
82
- attribute_3: content_for(item, 'ITATR3'),
83
- attribute_4: content_for(item, 'ITATR4'),
84
- attribute_5: content_for(item, 'ITATR5'),
85
- attribute_6: content_for(item, 'ITATR6'),
86
- attribute_7: content_for(item, 'ITATR7'),
87
- attribute_8: content_for(item, 'ITATR8'),
88
- attribute_9: content_for(item, 'ITATR9'),
89
- attribute_10: content_for(item, 'ITATR0'),
90
- attribute_11: content_for(item, 'ITATR11'),
91
- attribute_12: content_for(item, 'ITATR12'),
92
- attribute_13: content_for(item, 'ITATR13'),
93
- attribute_14: content_for(item, 'ITATR14'),
94
- attribute_15: content_for(item, 'ITATR15'),
95
- attribute_16: content_for(item, 'ITATR16'),
96
- attribute_17: content_for(item, 'ITATR17'),
97
- attribute_18: content_for(item, 'ITATR18'),
98
- attribute_19: content_for(item, 'ITATR19'),
99
- attribute_20: content_for(item, 'ITATR20'),
100
- }
101
- end
102
-
103
- items
41
+ xml_doc.css('Table').map { |item| map_hash(item) }
104
42
  end
105
43
 
106
44
  def self.get_text(item_number, options = {})
@@ -111,12 +49,14 @@ module SportsSouth
111
49
  request.set_form_data(form_params(options).merge({ ItemNumber: item_number }))
112
50
 
113
51
  response = http.request(request)
114
- body = sanitize_response(response)
115
- xml_doc = Nokogiri::XML(body)
52
+ xml_doc = Nokogiri::XML(sanitize_response(response))
116
53
 
117
54
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
118
55
 
119
- { catalog_text: content_for(xml_doc, 'CATALOGTEXT') }
56
+ {
57
+ item_number: item_number,
58
+ catalog_text: content_for(xml_doc, 'CATALOGTEXT')
59
+ }
120
60
  end
121
61
 
122
62
  def self.inquiry(item_number, options = {})
@@ -127,16 +67,15 @@ module SportsSouth
127
67
  request.set_form_data(form_params(options).merge({ ItemNumber: item_number }))
128
68
 
129
69
  response = http.request(request)
130
- body = sanitize_response(response)
131
- xml_doc = Nokogiri::XML(body)
70
+ xml_doc = Nokogiri::XML(sanitize_response(response))
132
71
 
133
72
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
134
73
 
135
74
  {
136
- item_number: content_for(xml_doc, 'I'),
75
+ item_number: content_for(xml_doc, 'I'),
137
76
  quantity_on_hand: content_for(xml_doc, 'Q').to_i,
138
- catalog_price: content_for(xml_doc, 'P'),
139
- customer_price: content_for(xml_doc, 'C'),
77
+ catalog_price: content_for(xml_doc, 'P'),
78
+ customer_price: content_for(xml_doc, 'C'),
140
79
  }
141
80
  end
142
81
 
@@ -149,22 +88,17 @@ module SportsSouth
149
88
  request.set_form_data(form_params(options).merge({ CSVItems: item_numbers.join(',') }))
150
89
 
151
90
  response = http.request(request)
152
- body = sanitize_response(response)
153
- xml_doc = Nokogiri::XML(body)
91
+ xml_doc = Nokogiri::XML(sanitize_response(response))
154
92
 
155
93
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
156
94
 
157
- items = []
158
-
159
- xml_doc.css('Table').each do |item|
160
- items << {
95
+ xml_doc.css('Table').map do |item|
96
+ {
161
97
  item_number: content_for(item, 'I'),
162
98
  quantity: content_for(item, 'Q'),
163
99
  price: content_for(item, 'P'),
164
100
  }
165
101
  end
166
-
167
- items
168
102
  end
169
103
 
170
104
  # Pass an optional `:since` option (YYYY-MM-DDTHH:mm:ss.mss-HH:00) to get items updated since that timestamp.
@@ -177,25 +111,19 @@ module SportsSouth
177
111
 
178
112
  request.set_form_data(form_params(options).merge({ SinceDateTime: options[:since] }))
179
113
 
180
- response = http.request(request)
181
- body = sanitize_response(response)
182
- xml_doc = Nokogiri::XML(body)
114
+ xml_doc = Nokogiri::XML(sanitize_response(http.request(request)))
183
115
 
184
116
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
185
117
 
186
- items = []
187
-
188
- xml_doc.css('Onhand').each do |item|
189
- items << {
190
- item_number: content_for(item, 'I'),
191
- quantity: content_for(item, 'Q'),
118
+ xml_doc.css('Onhand').map do |item|
119
+ {
120
+ item_number: content_for(item, 'I'),
121
+ quantity: content_for(item, 'Q'),
192
122
  quantity_changed: content_for(item, 'D'),
193
- catalog_price: content_for(item, 'P'),
194
- customer_price: content_for(item, 'C'),
123
+ catalog_price: content_for(item, 'P'),
124
+ customer_price: content_for(item, 'C'),
195
125
  }
196
126
  end
197
-
198
- items
199
127
  end
200
128
 
201
129
  def self.onhand_update(options = {})
@@ -206,23 +134,78 @@ module SportsSouth
206
134
  request.set_form_data(form_params(options))
207
135
 
208
136
  response = http.request(request)
209
- body = sanitize_response(response)
210
- xml_doc = Nokogiri::XML(body)
137
+ xml_doc = Nokogiri::XML(sanitize_response(response))
211
138
 
212
139
  raise SportsSouth::NotAuthenticated if not_authenticated?(xml_doc)
213
140
 
214
- items = []
215
-
216
- xml_doc.css('Table').each do |item|
217
- items << {
218
- item_number: content_for(item, 'I'),
219
- quantity: content_for(item, 'Q'),
220
- catalog_price: content_for(item, 'P'),
141
+ xml_doc.css('Table').map do |item|
142
+ {
143
+ item_number: content_for(item, 'I'),
144
+ quantity: content_for(item, 'Q').to_i,
145
+ catalog_price: content_for(item, 'P'),
221
146
  customer_price: content_for(item, 'C'),
222
147
  }
223
148
  end
149
+ end
150
+
151
+ protected
224
152
 
225
- items
153
+ def self.map_hash(node)
154
+ {
155
+ item_number: content_for(node, 'ITEMNO'),
156
+ description: content_for(node, 'IDESC'),
157
+ manufacturer_sequence: content_for(node, 'IMFSEQ'),
158
+ manufacturer_number: content_for(node, 'IMFGNO'),
159
+ catalog_sequence: content_for(node, 'CSEQ'),
160
+ item_type: ITEM_TYPES[content_for(node, 'ITYPE')],
161
+ short_description: content_for(node, 'SHDESC'),
162
+ unit_of_measure: content_for(node, 'UOM'),
163
+ catalog_price: content_for(node, 'PRC1'),
164
+ customer_price: content_for(node, 'CPRC'),
165
+ quantity_on_hand: content_for(node, 'QTYOH'),
166
+ weight_per_box: content_for(node, 'WTPBX'),
167
+ upc: content_for(node, 'ITUPC'),
168
+ manufacturer_item_number: content_for(node, 'MFGINO'),
169
+ scan_name_1: content_for(node, 'SCNAM1'),
170
+ scan_name_2: content_for(node, 'SCNAM2'),
171
+ catalog_code: CATALOG_CODES[content_for(node, 'CATCD')],
172
+ mapp_price_code: content_for(node, 'MFPRTYP'),
173
+ mapp_price: content_for(node, 'MFPRC'),
174
+ category_id: content_for(node, 'CATID'),
175
+ text_reference_number: content_for(node, 'TXTREF'),
176
+ picture_reference_number: content_for(node, 'PICREF'),
177
+ brand_id: content_for(node, 'ITBRDNO'),
178
+ item_model_number: content_for(node, 'IMODEL'),
179
+ item_purpose: content_for(node, 'IPURPOSE'),
180
+ series_description: content_for(node, 'SERIES'),
181
+ item_length: content_for(node, 'LENGTH'),
182
+ item_height: content_for(node, 'HEIGHT'),
183
+ item_width: content_for(node, 'WIDTH'),
184
+ item_ships_hazmat_air: content_for(node, 'HAZAIR'),
185
+ item_ships_hazmat_ground: content_for(node, 'HAZGRND'),
186
+ date_of_last_change: content_for(node, 'CHGDTE'),
187
+ date_added: content_for(node, 'CHGDTE'),
188
+ attribute_1: content_for(node, 'ITATR1'),
189
+ attribute_2: content_for(node, 'ITATR2'),
190
+ attribute_3: content_for(node, 'ITATR3'),
191
+ attribute_4: content_for(node, 'ITATR4'),
192
+ attribute_5: content_for(node, 'ITATR5'),
193
+ attribute_6: content_for(node, 'ITATR6'),
194
+ attribute_7: content_for(node, 'ITATR7'),
195
+ attribute_8: content_for(node, 'ITATR8'),
196
+ attribute_9: content_for(node, 'ITATR9'),
197
+ attribute_10: content_for(node, 'ITATR0'),
198
+ attribute_11: content_for(node, 'ITATR11'),
199
+ attribute_12: content_for(node, 'ITATR12'),
200
+ attribute_13: content_for(node, 'ITATR13'),
201
+ attribute_14: content_for(node, 'ITATR14'),
202
+ attribute_15: content_for(node, 'ITATR15'),
203
+ attribute_16: content_for(node, 'ITATR16'),
204
+ attribute_17: content_for(node, 'ITATR17'),
205
+ attribute_18: content_for(node, 'ITATR18'),
206
+ attribute_19: content_for(node, 'ITATR19'),
207
+ attribute_20: content_for(node, 'ITATR20')
208
+ }
226
209
  end
227
210
 
228
211
  end
@@ -1,3 +1,3 @@
1
1
  module SportsSouth
2
- VERSION = "0.15.0"
2
+ VERSION = '1.0.0.pre'.freeze
3
3
  end
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: 0.15.0
4
+ version: 1.0.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Campbell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-13 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -140,12 +140,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
140
  version: '2.0'
141
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - ">"
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 1.3.1
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.4.5
148
+ rubygems_version: 2.6.7
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Sports South API Ruby library.