endeca_xml 0.7.5 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -4,7 +4,7 @@ endeca_xml provides an interface between your web application and the thanxmedia
4
4
 
5
5
  == Features
6
6
 
7
- * Builds an XML query, formatted to thanxmedia specifications, via form filed hidden inputs which specify all the desired settings
7
+ * Builds an XML query, formatted to thanxmedia specifications, from a query string
8
8
  * Parses the settings parameters and sends a completed XML query to thanxmedia API
9
9
  * Handles the response XML and exposes methods to retrieve response data
10
10
 
@@ -28,27 +28,47 @@ Then bundle install:
28
28
 
29
29
  == Usage
30
30
 
31
- A lot more work has been done since the previous version. endeca_xml now constructs an XML query to send to thanxmedia via a form submission. An example of how the form is formatted is below:
32
-
33
- <form method="post" action="/endeca">
34
- <input type="hidden" name="endeca[host]" value="{'host' => ''}">
35
- <input type="hidden" name="endeca[base]" value="{'RecordsSet' => true, 'Dimensions' => true, 'BusinessRulesResult' => true, 'AppliedFilters' => true}" />
36
- <input type="hidden" name="endeca[nav]" value="{'type' => 'category [or] dimension', 'ids' => [1, 2, 3, 4]}" />
37
- <input type="hidden" name="endeca[search]" value="{'search-key' => 'key', 'search-term' => 'term'}" />
38
- <input type="hidden" name="endeca[sort]" value="{'sort-key' => 'key', 'direction' => 'direction'}" />
39
- <input type="hidden" name="endeca[paging]" value="{'RecordsOffset' => 0, 'RecordsPerPage' => 10}" />
40
- <input type="hidden" name="endeca[parameters]" value="{'AggregationKey' => 'key'}" />
41
- <input type="hidden" name="endeca[profiles]" value="{'profiles' => [1, 2, 3, 4]}" />
42
- <input type="hidden" name="endeca[filters]" value="{'Between' => {'lower-bound' => 1, 'upper-bound' => 2, 'attribute-name' => 'test', 'lat-long' => 123.4, 'distance' => '100'}, 'LessThan' => {}, 'LessThanOrEqual' => {}, 'GreaterThan' => {}, 'GreaterThanOrEqual' => {}, 'GeocodeLessThan' => {}, 'GeocodeGreaterThan' => {}, 'GeocodeBetween' => {}}" />
43
- <input type="submit" />
44
- </form>
45
-
46
- This example is a complete example. It is not necessary to include anything that you don't intend to use (ie. blank or empty hash's/values). If you don't need an option, don't include the input field, and if you don't need a value within an option don't include it.
31
+ A restructure has been done since previous versions. endeca_xml now constructs an XML query to send to thanxmedia via a query string:
32
+
33
+ <a href='.../url?search-key=primary&search-term=name&DimensionValueIds=1,2,3,4&sort-key=name&sort-direction=descending&RecordOffset=0&RecordsPerPage=9&AggregationKey=name&UserProfiles=1,2,3,4&filter=between'>FULL ENDECA REQUEST</a>
34
+
35
+ The following is an example of an empty 'options' hash that would then need to be constructed from a query string, and sent to the module (any static values are added before, and not from a query string):
36
+
37
+ host = 'your/thanxmedia/api/url'
38
+ options = {
39
+ 'add_base' => {'RecordsSet' => false, 'Dimensions' => true, 'BusinessRulesResult' => false, 'AppliedFilters' => true},
40
+ 'add_keyword_search' => {},
41
+ 'add_dimension_value_id_navigation' => {},
42
+ 'add_category_navigation_query' => "current_category_id",
43
+ 'add_sorting' => {},
44
+ 'add_paging' => {},
45
+ 'add_advanced_parameters' => {},
46
+ 'add_profiles' => {},
47
+ 'add_filters' => {}
48
+ }
49
+
50
+ The following is what a prepared 'options' hash would look like, that is then passed into the module, using the above example query string:
51
+
52
+ options = {
53
+ 'add_base' => {'RecordsSet' => true, 'Dimensions' => true, 'BusinessRulesResult' => true, 'AppliedFilters' => true},
54
+ 'add_keyword_search' => {'searh-key => 'key', search-term => 'term'},
55
+ 'add_dimension_value_id_navigation' => {[1, 2, 3, 4]},
56
+ 'add_category_navigation_query' => 1,
57
+ 'add_sorting' => {'sort-key' => 'key', 'sort-direction' => 'Descending'},
58
+ 'add_paging' => {'RecordOffset' => 0, 'RecordsPerPage' => 9},
59
+ 'add_advanced_parameters' => {'AggregationKey' => 'key'},
60
+ 'add_profiles' => {[1, 2, 3, 4]},
61
+ 'add_filters' => {}
62
+ }
63
+
64
+ NOTE: add_dimension_value_id_navigation and add_category_navigation_query are mutually exclusive (the example doesn't reflect that)
65
+
66
+ This example is a complete example. It is not necessary to include anything that you don't intend to use (ie. blank or empty hash's/values). If you don't need an option, don't include the query string, and if you don't need a value within an option don't include it.
47
67
 
48
- This is the command that would send the above request:
49
- EndecaXml.request(params[:endeca])
68
+ This is the command that would then send the above request:
69
+ EndecaXml.new(host, options)
50
70
 
51
- Below are examples of how you could access the response data:
71
+ Below are (ruby/rails) examples of how you could access the response data:
52
72
 
53
73
  Records:
54
74
 
data/lib/endeca_xml.rb CHANGED
@@ -6,80 +6,81 @@ require 'crackoid'
6
6
  require 'net/http'
7
7
  require 'uri'
8
8
 
9
- # This is an example of the form used to post all the desired options that will be used to construct the endeca XML query,
10
- # each input name corresponds to a function that is called when building the XML. It is important that the names stay the same (for now)!
11
- #
12
- # <form action="/endeca" method="post">
13
- # <input type="hidden" name="endeca[host]" value="{'host' => ''}">
14
- # <input type="hidden" name="endeca[base]" value="{'RecordsSet' => true, 'Dimensions' => true, 'BusinessRulesResult' => true, 'AppliedFilters' => true}" />
15
- # <input type="hidden" name="endeca[nav]" value="{'type' => 'category [or] dimension', 'ids' => [1, 2, 3, 4]}" />
16
- # <input type="hidden" name="endeca[search]" value="{'search-key' => 'key', 'search-term' => 'term'}" />
17
- # <input type="hidden" name="endeca[sort]" value="{'sort-key' => 'key', 'direction' => 'direction'}" />
18
- # <input type="hidden" name="endeca[paging]" value="{'RecordsOffset' => 0, 'RecordsPerPage' => 10}" />
19
- # <input type="hidden" name="endeca[parameters]" value="{'AggregationKey' => 'key'}" />
20
- # <input type="hidden" name="endeca[profiles]" value="{'profiles' => [1, 2, 3, 4]}" />
21
- # <input type="hidden" name="endeca[filters]" value="{'Between' => {'lower-bound' => 1, 'upper-bound' => 2, 'attribute-name' => 'test', 'lat-long' => 123.4, 'distance' => 100}, 'LessThan' => {}, 'LessThanOrEqual' => {}, 'GreaterThan' => {}, 'GreaterThanOrEqual' => {}, 'GeocodeLessThan' => {}, 'GeocodeGreaterThan' => {}, 'GeocodeBetween' => {}}" />
22
- # <input type="submit" />
23
- # </form>
9
+ # <a href='.../url?search-key=primary&search-term=name&DimensionValueIds=1,2,3,4&sort-key=name&sort-direction=descending&RecordOffset=0&RecordsPerPage=9&AggregationKey=name&UserProfiles=1,2,3,4&filter=between'>FULL ENDECA REQUEST</a>
24
10
 
25
- module EndecaXml
11
+ # host = 'http://eodhc.endecaondemand.net:30858/ws/main'
12
+ # options = {
13
+ # 'add_base' => {'RecordsSet' => true, 'Dimensions' => true, 'BusinessRulesResult' => true, 'AppliedFilters' => true},
14
+ # 'add_keyword_search' => {'searh-key => 'key', search-term => 'term'},
15
+ # 'add_dimension_value_id_navigation' => {[1, 2, 3, 4]},
16
+ # 'add_category_navigation_query' => 1,
17
+ # 'add_sorting' => {'sort-key' => 'key', 'sort-direction' => 'Descending'},
18
+ # 'add_paging' => {'RecordOffset' => 0, 'RecordsPerPage' => 9},
19
+ # 'add_advanced_parameters' => {'AggregationKey' => 'key'},
20
+ # 'add_profiles' => {[1, 2, 3, 4]},
21
+ # 'add_filters' => {}
22
+ # }
26
23
 
27
- def self.request(params)
28
- @body = Builder::XmlMarkup.new(:indent => 2)
29
-
30
- # puts "PARAMS: #{params}"
31
-
32
- # take the parameters past in a form post and creates the options hash out of each key|value pair, using the key as root key in a new hash, and the value as that hash's value
33
- options = {}
34
- params.each do |key, value|
35
- options.update(Hash[key, eval(value)])
36
- end
24
+ class EndecaXml
37
25
 
38
- # puts "OPTIONS: #{options}"
39
-
40
- # call a corresponding function based off the root key created for each hash in the options hash to build the endeca query
26
+ def initialize(host, options)
27
+ @body = Builder::XmlMarkup.new(:indent => 2)
28
+
29
+ #
30
+ set_host(host)
31
+
32
+ puts "OPTIONS: #{options}"
33
+
34
+ #
41
35
  options.each do |key, value|
42
- self.send(key.to_sym, value)
36
+ self.send(key.to_sym, value) unless value.empty?
43
37
  end
44
-
45
- # once the XML request is built send it off
38
+
39
+ #
46
40
  send_request
47
41
  end
48
-
49
- def self.records
42
+
43
+ ### API
44
+
45
+ def records
50
46
  @records
51
47
  end
52
48
 
53
- def self.breadcrumbs
49
+ def breadcrumbs
54
50
  @breadcrumbs
55
51
  end
56
52
 
57
- def self.dimensions
53
+ def dimensions
58
54
  @dimensions
59
55
  end
60
56
 
61
- def self.rules
57
+ def rules
62
58
  @business_rules
63
59
  end
64
60
 
65
- def self.filters
66
- @applied_filters
61
+ def search_reports
62
+ @search_reports
63
+ end
64
+
65
+ def selected_dimension_value_ids
66
+ @selected_dimension_value_ids
67
67
  end
68
68
 
69
69
  private
70
70
 
71
71
  ### XML REQUEST ###
72
72
 
73
- # constructs the http request
74
- def self.host(options)
75
- options.each do |key, value|
76
- @uri = URI.parse(value)
77
- end
73
+ ##
74
+ def set_host(host)
75
+ # puts "HOST: #{host}"
76
+ @uri = URI.parse(host)
78
77
  @http = Net::HTTP.new(@uri.host, @uri.port)
78
+ # puts "URI: #{@uri}"
79
+ # puts "HTTP: #{@http}"
79
80
  end
80
81
 
81
- # adds BASE OPTIONS to the XML request
82
- def self.base(options)
82
+ ##
83
+ def add_base(options)
83
84
  # puts "BASE: #{options}"
84
85
  options.each do |key, value|
85
86
  @body.tag!(key, value)
@@ -87,30 +88,30 @@ module EndecaXml
87
88
  # print @body.target!
88
89
  end
89
90
 
90
- # adds NAV to the XML request
91
- def self.nav(options)
92
- # puts "NAV: #{options}"
93
- case options['type']
94
- when 'category'
95
- @body.Category do
96
- options['ids'].each do |id|
97
- @body.tag!('Category', id)
98
- end
99
- end
100
- when 'dimension'
101
- @body.SelectedDimensionalValueIds do
102
- options['ids'].each do |id|
103
- @body.tag!('DimensionValueId', id)
104
- end
91
+ ## BUILD REQUEST BODY
92
+
93
+ # mutually exclusive to add_category_navigation_query
94
+ def add_dimension_value_id_navigation(options)
95
+ # puts "DIMENSIONS: #{options}"
96
+ @body.SelectedDimensionValueIds do
97
+ options.each do |dimension|
98
+ @body.tag!('DimensionValueId', dimension)
105
99
  end
106
- else
107
- #
108
100
  end
109
101
  # puts @body.target!
110
102
  end
111
103
 
112
- # adds SEARCHES to the XML request
113
- def self.search(options)
104
+ # mutually exclusive to dimension_value_id_navigation
105
+ def add_category_navigation_query(options)
106
+ # puts "CATEGORY: #{options}"
107
+ @body.Category do
108
+ @body.tag!('CategoryId', options)
109
+ end
110
+ # puts @body.target!
111
+ end
112
+
113
+ #
114
+ def add_keyword_search(options)
114
115
  # puts "SEARCH: #{options}"
115
116
  @body.Searches do
116
117
  @body.Search do
@@ -122,8 +123,8 @@ module EndecaXml
122
123
  # puts @body.target!
123
124
  end
124
125
 
125
- # adds SORTS to the XML request
126
- def self.sort(options)
126
+ #
127
+ def add_sorting(options)
127
128
  # puts "SORT: #{options}"
128
129
  @body.Sorts do
129
130
  @body.Sort do
@@ -135,8 +136,8 @@ module EndecaXml
135
136
  # puts @body.target!
136
137
  end
137
138
 
138
- # adds PAGING to the XML request
139
- def self.paging(options)
139
+ #
140
+ def add_paging(options)
140
141
  # puts "PAGING: #{options}"
141
142
  options.each do |key, value|
142
143
  @body.tag!(key, value)
@@ -144,8 +145,8 @@ module EndecaXml
144
145
  # puts @body.target!
145
146
  end
146
147
 
147
- # adds ADVANCED PARAMETERS to the XML request
148
- def self.parameters(options)
148
+ #
149
+ def add_advanced_parameters(options)
149
150
  # puts "PARAMETERS: #{options}"
150
151
  options.each do |key, value|
151
152
  @body.tag!(key, value)
@@ -153,22 +154,19 @@ module EndecaXml
153
154
  # puts @body.target!
154
155
  end
155
156
 
156
- # adds PROFILES to the XML request
157
- def self.profiles(options)
157
+ #
158
+ def add_profiles(options)
158
159
  # puts "PROFILES: #{options}"
159
160
  @body.UserProfiles do
160
- options.each do |key, value|
161
- # puts "#{key}: #{value}"
162
- value.each do |profile|
163
- @body.tag!('UserProfile', profile)
164
- end
161
+ options.each do |profile|
162
+ @body.tag!('UserProfile', profile)
165
163
  end
166
164
  end
167
165
  # puts @body.target!
168
166
  end
169
167
 
170
- # adds FILTERS to the XML request
171
- def self.filters(options)
168
+ #
169
+ def add_filters(options)
172
170
  # puts "FILTERS: #{options}"
173
171
  @body.RangeFilters do
174
172
  options.each do |key, value|
@@ -182,16 +180,16 @@ module EndecaXml
182
180
  end
183
181
  # puts @body.target!
184
182
  end
185
-
183
+
186
184
  # complete the endeca XML reqeust and send the request to the endeca API
187
- def self.send_request
185
+ def send_request
188
186
  # insert all of the XML blocks that have been included in the request into the endeca Query XML tag
189
187
  query = Builder::XmlMarkup.new(:indent => 2)
190
188
  query.Query do
191
189
  query << @body.target!
192
190
  end
193
191
 
194
- # puts "QUERY: #{query.target!}"
192
+ puts "QUERY: #{query.target!}"
195
193
 
196
194
  begin
197
195
  request, response = @http.post(@uri.path, query.target!, 'Content-type' => 'application/xml')
@@ -202,72 +200,227 @@ module EndecaXml
202
200
  end
203
201
 
204
202
  # get the request response and parse it into an hash
205
- def self.handle_response(response)
206
- # puts "RESPONSE: #{response}"
203
+ def handle_response(response)
204
+ puts "RESPONSE: #{response}"
207
205
  @response = response['Final']
208
206
 
209
- self.build_data
207
+ build_data
210
208
  end
211
209
 
212
- def self.build_data
213
- self.build_records
214
- self.build_breadcrumbs
215
- self.build_dimensions
216
- self.build_business_rules
217
- # self.build_applied_filters
210
+ def build_data
211
+ build_records
212
+ build_breadcrumbs
213
+ build_dimensions
214
+ build_business_rules
215
+ build_search_reports
216
+ build_selected_dimension_value_ids
218
217
  end
219
218
 
220
219
  # builds the RECORDS hash
221
- @records = []
222
- def self.build_records
223
- @response['RecordsSet']['Record'].each do |record|
224
- @records.push(EndecaXml::Record.new(record))
225
- end unless @response['RecordsSet'].nil?
220
+ def build_records
221
+ puts "RECORDS SET: #{@response['RecordsSet']}"
222
+
223
+ # NOTE: this may need to be reworked a little. look in recordset for nodes that our outside of records...
224
+ @records = []
225
+ unless @response['RecordsSet'].nil?
226
+ if @response['RecordsSet']['Record'].instance_of?(Hash)
227
+ @records.push(EndecaXml::Record.new(@response['RecordsSet']))
228
+ elsif @response['RecordsSet']['Record'].instance_of?(Array)
229
+ @response['RecordsSet']['Record'].each do |record|
230
+ @records.push(EndecaXml::Record.new(record))
231
+ end
232
+ else
233
+ puts "This record is a(n): #{@response['RecordsSet'].class}"
234
+ end
235
+ else
236
+ puts 'There are no records with this response!'
237
+ end
226
238
  end
227
239
 
228
240
  # builds the BREADCRUMBS hash
229
- @breadcrumbs = []
230
- def self.build_breadcrumbs
231
- @response['Breadcrumbs']['Breads'].each do |crumb|
232
- @breadcrumbs.pusn(EndecaXml::Crumb.new(crumb))
233
- end unless @response['Breadcrumbs'].nil?
241
+ def build_breadcrumbs
242
+ @breadcrumbs = []
243
+
244
+ # puts "BREADCRUMBS: #{@response['Breadcrumbs'}"
245
+ breadcrumbs = @response['Breadcrumbs']
246
+ unless breadcrumbs.nil?
247
+
248
+ # puts "BREADS: #{@response['Breadcrumbs']['Breads']}"
249
+ breads = @response['Breadcrumbs']['Breads']
250
+
251
+ if breads.instance_of?(Hash)
252
+ # puts "HASH 1: #{breads}"
253
+ if breads.instance_of?(Hash)
254
+ # puts "HASH 2: #{breads}"
255
+ @breadcrumbs.push(EndecaXml::Crumb.new(breads))
256
+ elsif bread.instance_of?(Array)
257
+ # puts "ARRAY 1: #{breads}"
258
+ breads.each do |crumb|
259
+ # puts "CRUMB: #{crumb}"
260
+ @breadcrumbs.push(EndecaXml::Crumb.new(crumb))
261
+ end
262
+ end
263
+ elsif breads.instance_of?(Array)
264
+ # puts "ARRAY 1: #{breads}"
265
+ breads.each do |bread|
266
+ # puts "BREAD: #{bread}"
267
+ if bread.instance_of?(Hash)
268
+ # puts "HASH 1: #{bread}"
269
+ if bread['Bread'].instance_of?(Hash)
270
+ # puts "HASH 2: #{bread}"
271
+ bread['Bread'].each do |key, value|
272
+ # puts "#{key} :: #{value}"
273
+ @breadcrumbs.push(EndecaXml::Crumb.new(bread['Bread']))
274
+ end
275
+ elsif bread['Bread'].instance_of?(Array)
276
+ # puts "ARRAY 2: #{bread}"
277
+ bread['Bread'].each do |crumb|
278
+ # puts "CRUMB 2: #{crumb}"
279
+ @breadcrumbs.push(EndecaXml::Crumb.new(crumb))
280
+ end
281
+ end
282
+ elsif bread.instance_of?(Array)
283
+ # puts "ARRAY 3: #{bread}"
284
+ bread['Bread'].each do |crumb|
285
+ # puts "CRUMB 3: #{crumb}"
286
+ @breadcrumbs.push(EndecaXml::Crumb.new(crumb))
287
+ end
288
+ end
289
+ end
290
+ end
291
+ else
292
+ puts 'There are no breadcrumbs with this response!'
293
+ end
234
294
  end
235
295
 
236
296
  # builds the DIMENSIONS hash
237
- @dimensions = []
238
- def self.build_dimensions
239
- @response['Dimensions']['Dimension'].each do |dimension|
240
- @dimension = EndecaXml::Dimension.new(dimension)
241
- dimension.each do |key, value|
242
- value['DimensionValue'].each do |value|
243
- @dimension.dimension_values.push(EndecaXml::Dimension.new(value))
244
- end if key == 'DimensionValues'
297
+ # NOTE: do what breadcrumbs is doing in terms of vars
298
+ def build_dimensions
299
+ @dimensions = []
300
+
301
+ puts "DIMENSIONS: #{@response['Dimensions']}"
302
+ dimensions = @response['Dimensions']
303
+ unless @response['Dimensions'].nil?
304
+
305
+ dimension = @response['Dimensions']['Dimension']
306
+ if dimension.instance_of?(Hash)
307
+ @dimension = EndecaXml::Dimension.new(dimensions)
308
+ unless dimension['DimensionValues'].nil?
309
+ if dimension['DimensionValues']['DimensionValue'].instance_of?(Hash)
310
+ @dimension.dimension_values.push(EndecaXml::Dimension.new(dimension['DimensionValues']))
311
+ elsif dimension['DimensionValues']['DimensionValue'].instance_of?(Array)
312
+ dimension['DimensionValues']['DimensionValue'].each do |dimension_value|
313
+ @dimension.dimension_values.push(EndecaXml::Dimension.new(dimension_value))
314
+ end
315
+ else
316
+ puts "This dimension value is a(n): #{dimension['DimensionValues']['DimensionValue'].class}"
317
+ end
318
+ @dimensions.push(@dimension)
319
+ else
320
+ puts "There are no dimension values on this dimension!"
321
+ end
322
+ elsif dimension.instance_of?(Array)
323
+ dimension.each do |dimension|
324
+ @dimension = EndecaXml::Dimension.new(dimension)
325
+ unless dimension['DimensionValues'].nil?
326
+ if dimension['DimensionValues']['DimensionValue'].instance_of?(Hash)
327
+ @dimension.dimension_values.push(EndecaXml::Dimension.new(dimension['DimensionValues']))
328
+ elsif dimension['DimensionValues']['DimensionValue'].instance_of?(Array)
329
+ dimension['DimensionValues']['DimensionValue'].each do |dimension_value|
330
+ @dimension.dimension_values.push(EndecaXml::Dimension.new(dimension_value))
331
+ end
332
+ else
333
+ puts "This dimension value is a(n): #{dimension['DimensionValues']['DimensionValue'].class}"
334
+ end
335
+ @dimensions.push(@dimension)
336
+ else
337
+ puts 'There are no dimension values on this dimension!'
338
+ end
339
+ end
340
+ else
341
+ puts "This dimension is a(n): #{dimensions.class}"
245
342
  end
246
- @dimensions.push(@dimension)
247
- end unless @response['Dimensions'].nil?
343
+ else
344
+ puts 'There are no dimensions with this response!'
345
+ end
248
346
  end
249
347
 
250
348
  # builds the BUSINESS RULES hash
251
- @business_rules = []
252
- def self.build_business_rules
253
- @response['BusinessRulesResult']['BusinessRules']['BusinessRule'].each do |rule|
254
- @business_rule = EndecaXml::Rule.new(rule)
255
- rule.each do |key, value|
256
- @business_rule.properties_array.push(EndecaXml::Rule.new(value)) if key == 'properties'
257
- if key == 'RecordSet'
258
- @business_rule.records.push(EndecaXml::Record.new(value['Record'])) unless value.nil?
349
+ def build_business_rules
350
+ puts "BUSINESS RULES: #{@response['BusinessRulesResult']}"
351
+
352
+ # NOTE: needs to be looked at again. look at where the array is being pushed
353
+ @business_rules = []
354
+ unless @response['BusinessRulesResult'].nil?
355
+ if @response['BusinessRulesResult']['BusinessRules'].instance_of?(Hash)
356
+ @business_rule = EndecaXml::Rule.new(@response['BusinessRulesResult']['BusinessRules'])
357
+ @response['BusinessRulesResult']['BusinessRules'].each do |key, value|
358
+ @business_rule.properties_array.push(EndecaXml::Rule.new(value)) if key == 'properties'
359
+ if key == 'RecordSet'
360
+ @business_rule.records.push(EndecaXml::Record.new(value['Record'])) unless value.nil?
361
+ end
259
362
  end
363
+ elsif @response['BusinessRulesResult']['BusinessRules'].instance_of?(Array)
364
+ @response['BusinessRulesResult']['BusinessRules']['BusinessRule'].each do |rule|
365
+ @business_rule = EndecaXml::Rule.new(rule)
366
+ rule.each do |key, value|
367
+ @business_rule.properties_array.push(EndecaXml::Rule.new(value)) if key == 'properties'
368
+ if key == 'RecordSet'
369
+ @business_rule.records.push(EndecaXml::Record.new(value['Record'])) unless value.nil?
370
+ end
371
+ end
372
+ end
373
+ else
374
+ puts "This busniess rule is a(n): #{@response['RecordsSet'].class}"
260
375
  end
261
376
  @business_rules.push(@business_rule)
262
- end unless @response['BusinessRulesResult'].nil?
377
+ else
378
+ puts 'There are no business rules with this response!'
379
+ end
263
380
  end
264
381
 
265
- # builds the APPLIED FILTERS hash
266
- @applied_filters = []
267
- def self.build_applied_filters
268
- @response['AppliedFilters'].each do |filter|
269
- # puts "FILTER: #{filter}"
270
- end unless @response['AppliedFilters'].nil?
382
+ # builds the SEARCH REPORTS hash
383
+ def build_search_reports
384
+ @search_reports = []
385
+
386
+ # puts "APPLIED FILTERS: #{@response['AppliedFilters']}"
387
+ applied_filters = @response['AppliedFilters']
388
+ unless applied_filters.nil?
389
+
390
+ # puts "SEARCH REPORTS: #{@response['AppliedFilters']['SearchReports']}"
391
+ search_reports = @response['AppliedFilters']['SearchReports']
392
+ unless search_reports.nil?
393
+ #do stuff
394
+ else
395
+ puts 'There are no search reports with this response!'
396
+ end
397
+
398
+ else
399
+ puts 'There were not applied filters with this response!'
400
+ end
271
401
  end
272
-
402
+
403
+ # builds the SELECTED DIMENSION VALUE IDS hash
404
+ def build_selected_dimension_value_ids
405
+ @selected_dimension_value_ids = []
406
+
407
+ # puts "SELECTED DIMENSION VALUE IDS: #{@response['AppliedFilters']['SelectedDimensionValueIds']}"
408
+ selected_dimension_value_ids = @response['AppliedFilters']['SelectedDimensionValueIds']
409
+ unless selected_dimension_value_ids.nil?
410
+
411
+ if selected_dimension_value_ids.instance_of?(Hash)
412
+ selected_dimension_value_id = EndecaXml::DimensionValueId.new(selected_dimension_value_ids)
413
+ elsif selected_dimension_value_ids.instance_of?(Array)
414
+ selected_dimension_value_ids.each do |key, value|
415
+ selected_dimension_value_id = EndecaXml::DimensionValueId.new(value)
416
+ end
417
+ end
418
+
419
+ @selected_dimension_value_ids.push(selected_dimension_value_id)
420
+
421
+ else
422
+ puts "There are no selected dimension value ids with this response!"
423
+ end
424
+ end
425
+
273
426
  end
@@ -1,8 +1,10 @@
1
- module EndecaXml
1
+ class EndecaXml
2
2
  class Crumb
3
3
 
4
4
  def initialize(crumb)
5
+ # puts "CRUMB: #{crumb}"
5
6
  crumb.each do |key, value|
7
+ # puts "#{key} | #{value}"
6
8
  self.instance_variable_set(:"@#{key.downcase}", value)
7
9
  end
8
10
  end
@@ -1,8 +1,10 @@
1
- module EndecaXml
1
+ class EndecaXml
2
2
  class Dimension
3
3
 
4
4
  def initialize(dimension)
5
+ # puts "DIMENSION: #{dimension}"
5
6
  dimension.each do |key, value|
7
+ # puts "#{key} | #{value}"
6
8
  self.instance_variable_set(:"@#{key.downcase}", value)
7
9
  end
8
10
 
@@ -10,7 +12,7 @@ module EndecaXml
10
12
  end
11
13
 
12
14
  # is there anyway to do this dynamically?
13
- attr_reader :name, :id, :group_name, :hasmore, :dimensionvalues, :dimension_values
15
+ attr_reader :name, :id, :group_name, :hasmore, :count, :dimensionvalues, :dimension_values
14
16
 
15
17
  end
16
18
  end
@@ -0,0 +1,16 @@
1
+ class EndecaXml
2
+ class DimensionValueId
3
+
4
+ def initialize(id)
5
+ # puts "ID: #{id}"
6
+ id.each do |key, value|
7
+ # puts "#{key} | #{value}"
8
+ self.instance_variable_set(:"@#{key.downcase}", value)
9
+ end
10
+ end
11
+
12
+ # is there anyway to do this dynamically?
13
+ attr_reader :dimensionvalueid
14
+
15
+ end
16
+ end
@@ -1,8 +1,10 @@
1
- module EndecaXml
1
+ class EndecaXml
2
2
  class Record
3
3
 
4
4
  def initialize(record)
5
+ # puts "RECORD: #{record}"
5
6
  record.each do |key, value|
7
+ # puts "#{key} | #{value}"
6
8
  self.instance_variable_set(:"@#{key.downcase}", value)
7
9
  end
8
10
  end
@@ -1,4 +1,4 @@
1
- module EndecaXml
1
+ class EndecaXml
2
2
  class Rule
3
3
 
4
4
  def initialize(rule)
@@ -0,0 +1,16 @@
1
+ class EndecaXml
2
+ class SearchReport
3
+
4
+ def initialize(report)
5
+ # puts "REPORT: #{report}"
6
+ report.each do |key, value|
7
+ # puts "#{key} | #{value}"
8
+ self.instance_variable_set(:"@#{key.downcase}", value)
9
+ end
10
+ end
11
+
12
+ # is there anyway to do this dynamically?
13
+ attr_reader :none
14
+
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
- module EndecaXml
2
- VERSION = "0.7.5"
1
+ class EndecaXml
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: endeca_xml
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.5
5
+ version: 0.8.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - sdomino
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-08 00:00:00 Z
13
+ date: 2011-07-19 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: crackoid
@@ -53,9 +53,10 @@ files:
53
53
  - lib/endeca_xml.rb
54
54
  - lib/endeca_xml/crumb.rb
55
55
  - lib/endeca_xml/dimension.rb
56
- - lib/endeca_xml/filter.rb
56
+ - lib/endeca_xml/dimension_value_id.rb
57
57
  - lib/endeca_xml/record.rb
58
58
  - lib/endeca_xml/rule.rb
59
+ - lib/endeca_xml/search_report.rb
59
60
  - lib/endeca_xml/version.rb
60
61
  homepage: http://github.com/sdomino/endeca_xml
61
62
  licenses: []
File without changes