laximo 0.3.3 → 0.4.1

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -8
  3. data/lib/laximo.rb +1 -0
  4. data/lib/laximo/defaults.rb +2 -2
  5. data/lib/laximo/errors.rb +35 -0
  6. data/lib/laximo/oem.rb +5 -5
  7. data/lib/laximo/query.rb +1 -1
  8. data/lib/laximo/respond.rb +63 -9
  9. data/lib/laximo/respond/find_detail.rb +5 -5
  10. data/lib/laximo/respond/find_oem.rb +5 -5
  11. data/lib/laximo/respond/find_oem_correction.rb +6 -12
  12. data/lib/laximo/respond/find_replacements.rb +1 -5
  13. data/lib/laximo/respond/find_vehicle_by_frame.rb +12 -2
  14. data/lib/laximo/respond/find_vehicle_by_vin.rb +12 -2
  15. data/lib/laximo/respond/find_vehicle_by_wizard.rb +12 -2
  16. data/lib/laximo/respond/find_vehicle_by_wizard2.rb +11 -1
  17. data/lib/laximo/respond/get_catalog_info.rb +20 -2
  18. data/lib/laximo/respond/get_filter_by_detail.rb +2 -2
  19. data/lib/laximo/respond/get_filter_by_unit.rb +12 -2
  20. data/lib/laximo/respond/get_unit_info.rb +12 -2
  21. data/lib/laximo/respond/get_vehicle_info.rb +12 -2
  22. data/lib/laximo/respond/get_wizard.rb +12 -2
  23. data/lib/laximo/respond/get_wizard2.rb +12 -2
  24. data/lib/laximo/respond/get_wizard_next_step2.rb +15 -2
  25. data/lib/laximo/respond/list_catalogs.rb +21 -2
  26. data/lib/laximo/respond/list_categories.rb +2 -2
  27. data/lib/laximo/respond/list_detail_by_unit.rb +12 -2
  28. data/lib/laximo/respond/list_image_map_by_unit.rb +2 -2
  29. data/lib/laximo/respond/list_manufacturer.rb +1 -5
  30. data/lib/laximo/respond/list_quick_detail.rb +23 -2
  31. data/lib/laximo/respond/list_quick_group.rb +2 -2
  32. data/lib/laximo/respond/list_units.rb +12 -2
  33. data/lib/laximo/respond/manufacturer_info.rb +1 -5
  34. data/lib/laximo/version.rb +1 -1
  35. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cfb39263229869df79357c9e5e3c6d3511d8a33
4
- data.tar.gz: bb889d80dc6c345651e22b5a7d501f4f922e95a6
3
+ metadata.gz: 99626c806c32592f492fe0e24d61994c33bf31be
4
+ data.tar.gz: e4ff2a1c16f399420784455ff5aff077bc8b7600
5
5
  SHA512:
6
- metadata.gz: 9557e607046696bbcf1cb2ccc262bc84b5b945cc0e56f33f540c8e895a598e4fa3a56326d33a6ed7d1a16cb410a9fea92ab7d2228281782bce53ab8562d6c2ce
7
- data.tar.gz: 766f30bf452ddffcf1194ea364273b706be2751fdaca4387b391b3991ebca1992dcd260302a419e24dbc1ee43773f5e4a78910fbc104f62cf5769dc44ac8eb84
6
+ metadata.gz: 41c05199fe8bc5247468224cb5a0330750cfa50f9c120891da834cb6cee7e89fa9b2425385f91abe7c553aa2546f27ae1ca7e107a352907e6155f91f9b8ee229
7
+ data.tar.gz: bbc5bc26cf6e488055f13a4b04db2f1408912c4b1b3f39b9e7aaf3cf0d2b0d2ec513db958f8bd71335615e973dcb2d696553a30040e95f44d56671b3d5e374e6
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ### Поддержка web-сервисов:
4
4
  * [Laximo.Aftermarket](http://laximo.net/index.php/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:%D0%9C%D0%BE%D0%B9_%D1%8F%D0%B7%D1%8B%D0%BA/:Laximo_Web-services:AM:Laximo.Aftermarket)
5
- * [Laximo.OЕМ](http://laximo.net/index.php/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:%D0%9C%D0%BE%D0%B9_%D1%8F%D0%B7%D1%8B%D0%BA/:Laximo_Web-services:OEM:Laximo.OEM) (в разработке)
5
+ * [Laximo.OЕМ](http://laximo.net/index.php/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:%D0%9C%D0%BE%D0%B9_%D1%8F%D0%B7%D1%8B%D0%BA/:Laximo_Web-services:OEM:Laximo.OEM)
6
6
 
7
7
  ### Поддерживаемые версии Ruby
8
8
  Ruby 1.9.3+
@@ -63,9 +63,9 @@ Laximo.options.debug false
63
63
  * [Laximo.oem.list_units(catalog, vehicle_id, ssd, category_id: nil, localized: false, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:ListUnits)
64
64
  * [Laximo.oem.list_categories(catalog, vehicle_id, ssd, category_id: nil, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:ListCategories)
65
65
  * [Laximo.oem.get_filter_by_unit(catalog, unit_id, vehicle_id, filter, ssd, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:GetFilterByUnit)
66
- * [Laximo.oem.get_unit_info(catalog, ssd, unit_id: nil, localized: false, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:GetUnitInfo)
67
- * [Laximo.oem.list_detail_by_unit(catalog, ssd, unit_id: nil, localized: false, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:ListDetailByUnit)
68
- * [Laximo.oem.list_image_map_by_unit(catalog, ssd, unit_id: nil)](http://laximo.net/index.php/Laximo_Web-services:OEM:ListImageMapByUnit)
66
+ * [Laximo.oem.get_unit_info(catalog, ssd, unit_id, localized: false, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:GetUnitInfo)
67
+ * [Laximo.oem.list_detail_by_unit(catalog, ssd, unit_id, localized: false, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:ListDetailByUnit)
68
+ * [Laximo.oem.list_image_map_by_unit(catalog, ssd, unit_id)](http://laximo.net/index.php/Laximo_Web-services:OEM:ListImageMapByUnit)
69
69
  * [Laximo.oem.get_filter_by_detail(catalog, unit_id, detail_id, filter, ssd, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:GetFilterByDetail)
70
70
  * [Laximo.oem.list_quick_group(catalog, vehicle_id, ssd: nil, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:ListQuickGroup)
71
71
  * [Laximo.oem.list_quick_detail(catalog, vehicle_id, quick_group_id, all, ssd: nil, localized: false, locale: 'ru_RU')](http://laximo.net/index.php/Laximo_Web-services:OEM:ListQuickDetail)
@@ -86,12 +86,30 @@ res.error # nil
86
86
  res.result # [{:detailid=>"31454425", :formattedoem=>"078100105NX", :manufacturer=>"SEAT", ...]
87
87
  ```
88
88
 
89
- ### Замечание
90
- После вызова одного из методов апи, может быть возвращены разного рода ошибки. Но, есть спец. ошибки:
91
- * `Net::HTTPNotFound` (404) -- ваш ssl-сертификат не позвоялет вызывать данный метод апи
92
- * `Net::HTTPBadRequest` (400) -- не задан ssl-сертификат
89
+ ### Ошибки
90
+ После вызова одного из методов апи, может быть возвращены разного рода ошибки.
91
+ * `Laximo::SslCertificateError` - ваш ssl-сертификат не найден или недействителен
92
+ * `Laximo::SoapInvalidParameterError` - неверное значение параметра в запросе к web-сервису
93
+ * `Laximo::SoapCatalogNotExistsError` - каталог не зарегистрирован в системе
94
+ * `Laximo::SoapInvalidRequestError` - не верно сформирован запрос к web-сервису
95
+ * `Laximo::SoapUnknownCommandError` - команда не известна
96
+ * `Laximo::SoapAccessDeniedError` - доступ запрещен
97
+ * `Laximo::SoapNotSupportedError` - функция не поддерживается каталогом
98
+ * `SoapGroupIsNotSearchableError` - поиск по группе запрещён, в связи с слишком большим количеством входящих в группу узлов
99
+ * `Laximo::SoapError` - общая ошибка протокола SOAP
100
+
101
+ ```ruby
102
+ res = Laximo.oem.get_filter_by_detail('AP1211', '', '', '', '')
103
+ res.success? # false
104
+ res.error? # true
105
+ res.error # <Laximo::SoapInvalidParameterError: UnitId>
106
+ res.result # []
107
+ ```
108
+
109
+ Помимо переисленного списка ошибок, в ответе могут быть возвращены стандартные ошибки библиотеки `Net::HTTP` и интерпретатора Ruby.
93
110
 
94
111
  ### Лицензия
95
112
 
96
113
  Автор: [Tyralion](mailto:piliaiev@gmail.com)
114
+
97
115
  Copyright (c) 2015 DansingBytes.ru, под лицензией BSD
data/lib/laximo.rb CHANGED
@@ -6,6 +6,7 @@ require 'net/http'
6
6
 
7
7
  require 'laximo/version'
8
8
  require 'laximo/options'
9
+ require 'laximo/errors'
9
10
  require 'laximo/request'
10
11
  require 'laximo/respond'
11
12
 
@@ -4,7 +4,7 @@ Laximo.options.user_agent "LaximoRuby [#{Laximo::VERSION}]"
4
4
  Laximo.options.timeout 10
5
5
 
6
6
  Laximo.options.am_soap_action 'http://Aftermarket.Kito.ec'
7
- Laximo.options.am_soap_endpoint 'https://aws.laximo.net/ec.Kito.Aftermarket/services/Catalog.CatalogHttpSoap12Endpoint/'
7
+ Laximo.options.am_soap_endpoint 'https://aws.laximo.net/ec.Kito.Aftermarket/services/Catalog.CatalogHttpSoap11Endpoint/'
8
8
 
9
9
  Laximo.options.oem_soap_action 'http://WebCatalog.Kito.ec'
10
- Laximo.options.oem_soap_endpoint 'https://ws.laximo.net/ec.Kito.WebCatalog/services/Catalog.CatalogHttpSoap12Endpoint/'
10
+ Laximo.options.oem_soap_endpoint 'https://ws.laximo.net/ec.Kito.WebCatalog/services/Catalog.CatalogHttpSoap11Endpoint/'
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ module Laximo
3
+
4
+ class Error < ::StandardError; end
5
+
6
+ class SslCertificateError < ::Laximo::Error; end
7
+
8
+ class SoapError < ::Laximo::Error; end
9
+
10
+ class SoapInvalidParameterError < ::Laximo::Error; end
11
+
12
+ class SoapCatalogNotExistsError < ::Laximo::Error; end
13
+
14
+ class SoapInvalidRequestError < ::Laximo::Error; end
15
+
16
+ class SoapUnknownCommandError < ::Laximo::Error; end
17
+
18
+ class SoapAccessDeniedError < ::Laximo::Error; end
19
+
20
+ class SoapNotSupportedError < ::Laximo::Error; end
21
+
22
+ class SoapGroupIsNotSearchableError < ::Laximo::Error; end
23
+
24
+ ERRORS = {
25
+ 'E_CATALOGNOTEXISTS' => SoapCatalogNotExistsError,
26
+ 'E_INVALIDPARAMETER' => SoapInvalidParameterError,
27
+ 'E_INVALIDREQUEST' => SoapInvalidRequestError,
28
+ 'E_UNKNOWNCOMMAND' => SoapUnknownCommandError,
29
+ 'E_ACCESSDENIED' => SoapAccessDeniedError,
30
+ 'E_NOTSUPPORTED' => SoapNotSupportedError,
31
+ 'E_GROUP_IS_NOT_SEARCHABLE' => SoapGroupIsNotSearchableError
32
+
33
+ }.freeze
34
+
35
+ end # Laximo
data/lib/laximo/oem.rb CHANGED
@@ -204,7 +204,7 @@ module Laximo
204
204
  catalog,
205
205
  vehicle_id,
206
206
  ssd,
207
- category_id: nil,
207
+ category_id: -1,
208
208
  localized: false,
209
209
  locale: 'ru_RU'
210
210
  )
@@ -227,7 +227,7 @@ module Laximo
227
227
  catalog,
228
228
  vehicle_id,
229
229
  ssd,
230
- category_id: nil,
230
+ category_id: -1,
231
231
  locale: 'ru_RU'
232
232
  )
233
233
 
@@ -270,7 +270,7 @@ module Laximo
270
270
  def get_unit_info(
271
271
  catalog,
272
272
  ssd,
273
- unit_id: nil,
273
+ unit_id,
274
274
  localized: false,
275
275
  locale: 'ru_RU'
276
276
  )
@@ -291,7 +291,7 @@ module Laximo
291
291
  def list_detail_by_unit(
292
292
  catalog,
293
293
  ssd,
294
- unit_id: nil,
294
+ unit_id,
295
295
  localized: false,
296
296
  locale: 'ru_RU'
297
297
  )
@@ -312,7 +312,7 @@ module Laximo
312
312
  def list_image_map_by_unit(
313
313
  catalog,
314
314
  ssd,
315
- unit_id: nil
315
+ unit_id
316
316
  )
317
317
 
318
318
  resp = ::Laximo::Query.
data/lib/laximo/query.rb CHANGED
@@ -193,7 +193,7 @@ module Laximo
193
193
  private
194
194
 
195
195
  def escape(str)
196
- str.nil? ? nil : ::String.new(str)
196
+ str.nil? ? nil : String(str)
197
197
  end # escape
198
198
 
199
199
  end # Query
@@ -5,7 +5,8 @@ module Laximo
5
5
 
6
6
  class Base
7
7
 
8
- RESPONSE_PATH = '//QueryDataResponse/return'.freeze
8
+ RESPONSE_RESULT = '//QueryDataResponse/return'.freeze
9
+ RESPONSE_SOAP_ERROR = '//Fault/faultstring'.freeze
9
10
 
10
11
  def initialize(request)
11
12
 
@@ -40,7 +41,7 @@ module Laximo
40
41
 
41
42
  private
42
43
 
43
- def attrs_to_hash(node)
44
+ def node_to_hash(node)
44
45
 
45
46
  return {} if node.nil?
46
47
 
@@ -48,9 +49,31 @@ module Laximo
48
49
  node.attributes.each { |key, snd|
49
50
  h[key.to_sym] = snd.value
50
51
  }
52
+
53
+ return {} if h.empty?
54
+ yield(h, node) if block_given?
55
+
51
56
  h
52
57
 
53
- end # attrs_to_hash
58
+ end # node_to_hash
59
+
60
+ def nodes_to_hash(nodes, recursive: true)
61
+
62
+ arr = []
63
+ nodes.each { |node|
64
+
65
+ h = {}
66
+ node.attributes.each { |key, snd|
67
+ h[key.to_sym] = snd.value
68
+ }
69
+
70
+ h[:children] = nodes_to_hash(node.children, recursive: true) if recursive
71
+ arr << h
72
+
73
+ }
74
+ arr
75
+
76
+ end # nodes_to_hash
54
77
 
55
78
  def prepare_request(request)
56
79
 
@@ -62,10 +85,30 @@ module Laximo
62
85
 
63
86
  end # prepare_request
64
87
 
65
- def prepare_error(err)
88
+ def prepare_error(http)
66
89
 
67
90
  @result = []
68
- @error = err
91
+
92
+ if http.is_a?(::Net::HTTPBadRequest)
93
+ @error = ::Laximo::SslCertificateError.new('SSL cetificate not found or invalidate')
94
+ else
95
+
96
+ begin
97
+
98
+ doc = ::Nokogiri::XML(http.body)
99
+ doc.remove_namespaces!
100
+
101
+ if (res = doc.xpath(RESPONSE_SOAP_ERROR)).empty?
102
+ @error = http
103
+ else
104
+ @error = soap_errors(res.text)
105
+ end
106
+
107
+ rescue => ex
108
+ @error = ex
109
+ end
110
+
111
+ end
69
112
 
70
113
  end # prepare_error
71
114
 
@@ -76,21 +119,32 @@ module Laximo
76
119
  doc = ::Nokogiri::XML(http.body)
77
120
  doc.remove_namespaces!
78
121
 
79
- res = doc.xpath(RESPONSE_PATH).children[0].to_s
122
+ res = doc.xpath(RESPONSE_RESULT).children[0].to_s
80
123
  str_to_xml_tags!(res)
81
124
 
82
125
  @error = nil
83
- @result = parsing_result(::Nokogiri::XML(res))
126
+ @result = parsing_result(::Nokogiri::XML(res)) || []
84
127
 
85
128
  rescue => ex
86
- prepare_error(ex)
129
+
130
+ @result = []
131
+ @error = ex
132
+
87
133
  end
88
134
 
89
135
  end # prepare_http
90
136
 
137
+ def soap_errors(err_txt)
138
+
139
+ err_name, msg = err_txt.split(':')
140
+
141
+ err_cls = Laximo::ERRORS[err_name] || ::Laximo::SoapError
142
+ err_cls.new(msg)
143
+
144
+ end # soap_errors
145
+
91
146
  def str_to_xml_tags!(str)
92
147
 
93
- str.gsub!('&amp;', '&')
94
148
  str.gsub!('&apos;', "'")
95
149
  str.gsub!('&quot;', '"')
96
150
  str.gsub!('&gt;', '>')
@@ -9,20 +9,20 @@ module Laximo
9
9
 
10
10
  str.xpath('//FindDetails/detail').inject([]) { |arr, node|
11
11
 
12
- h = attrs_to_hash(node)
12
+ h = node_to_hash(node)
13
13
 
14
14
  h[:images] = node.xpath('./images/image').inject([]) { |arr1, n1|
15
- arr1 << attrs_to_hash(n1)
15
+ arr1 << node_to_hash(n1)
16
16
  }
17
17
 
18
18
  h[:properties] = node.xpath('./properties/property').inject([]) { |arr1, n1|
19
- arr1 << attrs_to_hash(n1)
19
+ arr1 << node_to_hash(n1)
20
20
  }
21
21
 
22
22
  h[:replacements] = node.xpath('./replacements/replacement').inject([]) { |arr1, n1|
23
23
 
24
- h1 = attrs_to_hash(n1)
25
- h2 = attrs_to_hash(n1.children[0])
24
+ h1 = node_to_hash(n1)
25
+ h2 = node_to_hash(n1.children[0])
26
26
  h1.merge!(h2)
27
27
 
28
28
  arr1 << h1
@@ -9,20 +9,20 @@ module Laximo
9
9
 
10
10
  str.xpath('//FindOEM/detail').inject([]) { |arr, node|
11
11
 
12
- h = attrs_to_hash(node)
12
+ h = node_to_hash(node)
13
13
 
14
14
  h[:images] = node.xpath('./images/image').inject([]) { |arr1, n1|
15
- arr1 << attrs_to_hash(n1)
15
+ arr1 << node_to_hash(n1)
16
16
  }
17
17
 
18
18
  h[:properties] = node.xpath('./properties/property').inject([]) { |arr1, n1|
19
- arr1 << attrs_to_hash(n1)
19
+ arr1 << node_to_hash(n1)
20
20
  }
21
21
 
22
22
  h[:replacements] = node.xpath('./replacements/replacement').inject([]) { |arr1, n1|
23
23
 
24
- h1 = attrs_to_hash(n1)
25
- h2 = attrs_to_hash(n1.children[0])
24
+ h1 = node_to_hash(n1)
25
+ h2 = node_to_hash(n1.children[0])
26
26
  h1.merge!(h2)
27
27
 
28
28
  arr1 << h1
@@ -9,20 +9,14 @@ module Laximo
9
9
 
10
10
  str.xpath('//FindOEMCorrection/detail').inject([]) { |arr, node|
11
11
 
12
- h = attrs_to_hash(node)
12
+ h = node_to_hash(node)
13
13
 
14
- h[:images] = node.xpath('./images/image').inject([]) { |arr1, n1|
15
- arr1 << attrs_to_hash(n1)
16
- }
17
-
18
- h[:properties] = node.xpath('./properties/property').inject([]) { |arr1, n1|
19
- arr1 << attrs_to_hash(n1)
20
- }
21
-
22
- h[:replacements] = node.xpath('./replacements/replacement').inject([]) { |arr1, n1|
14
+ h[:images] = nodes_to_hash(node.xpath('./images/image'))
15
+ h[:properties] = nodes_to_hash(node.xpath('./properties/property'))
16
+ h[:replacements] = node.xpath('./replacements/replacement').inject([]) { |arr1, n1|
23
17
 
24
- h1 = attrs_to_hash(n1)
25
- h2 = attrs_to_hash(n1.children[0])
18
+ h1 = node_to_hash(n1)
19
+ h2 = node_to_hash(n1.children[0])
26
20
  h1.merge!(h2)
27
21
 
28
22
  arr1 << h1
@@ -6,11 +6,7 @@ module Laximo
6
6
  class FindReplacements < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
-
10
- str.xpath('//FindReplacements/row').inject([]) { |arr, node|
11
- arr << attrs_to_hash(node)
12
- }
13
-
9
+ nodes_to_hash(str.xpath('//FindReplacements/row'), recursive: false)
14
10
  end # parsing_result
15
11
 
16
12
  end # FindReplacements
@@ -6,8 +6,18 @@ module Laximo
6
6
  class FindVehicleByFrame < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//FindVehicleByFrame/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:attributes] = nodes_to_hash(n1.xpath('./attribute'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # FindVehicleByFrame
13
23
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class FindVehicleByVin < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//FindVehicleByVIN/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:attributes] = nodes_to_hash(n1.xpath('./attribute'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # FindVehicleByVin
13
23
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class FindVehicleByWizard < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//FindVehicleByWizard/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:attributes] = nodes_to_hash(n1.xpath('./attribute'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # FindVehicleByWizard
13
23
 
@@ -6,7 +6,17 @@ module Laximo
6
6
  class FindVehicleByWizard2 < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
9
+
10
+ str.xpath('//FindVehicleByWizard/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:attributes] = nodes_to_hash(n1.xpath('./attribute'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
10
20
  end
11
21
 
12
22
  end # FindVehicleByWizard2
@@ -6,8 +6,26 @@ module Laximo
6
6
  class GetCatalogInfo < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//GetCatalogInfo/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node)
13
+
14
+ h[:features] = nodes_to_hash(node.xpath('./features/feature'))
15
+ h[:operations] = node.xpath('./extensions/operations/opration').inject([]) { |arr1, n1|
16
+
17
+ h1 = node_to_hash(n1)
18
+ h1[:params] = nodes_to_hash(n1.xpath('./params/param'))
19
+
20
+ arr1 << h1
21
+
22
+ }
23
+
24
+ arr << h
25
+
26
+ }
27
+
28
+ end # parsing_result
11
29
 
12
30
  end # GetCatalogInfo
13
31
 
@@ -6,8 +6,8 @@ module Laximo
6
6
  class GetFilterByDetail < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+ nodes_to_hash(str.xpath('//GetFilterByDetail/row'))
10
+ end # parsing_result
11
11
 
12
12
  end # GetFilterByDetail
13
13
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class GetFilterByUnit < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//GetFilterByUnit/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:values] = nodes_to_hash(n1.xpath('./values/row'))
14
+ }
15
+
16
+ arr < h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # GetFilterByUnit
13
23
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class GetUnitInfo < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//GetUnitInfo/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:attributes] = nodes_to_hash(n1.xpath('./attribute'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # GetUnitInfo
13
23
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class GetVehicleInfo < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//GetVehicleInfo/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:attributes] = nodes_to_hash(n1.xpath('./attribute'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # GetVehicleInfo
13
23
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class GetWizard < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//GetWizard/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:options] = nodes_to_hash(node.xpath('./options/row'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # GetWizard
13
23
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class GetWizard2 < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//GetWizard2/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:options] = nodes_to_hash(node.xpath('./options/row'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # GetWizard2
13
23
 
@@ -6,8 +6,21 @@ module Laximo
6
6
  class GetWizardNextStep2 < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//GetWizardNextStep2').inject([]) { |arr, node|
11
+
12
+ h = {}
13
+
14
+ h[:previous_step] = nodes_to_hash(node.xpath('./previousStep/row'))
15
+ h[:currentStep] = node_to_hash(node.xpath('./currentStep')[0]) { |h1, n2|
16
+ h1[:options] = nodes_to_hash(n2.xpath('./options/row'))
17
+ }
18
+
19
+ arr << h
20
+
21
+ }
22
+
23
+ end # parsing_result
11
24
 
12
25
  end # GetWizardNextStep2
13
26
 
@@ -6,8 +6,27 @@ module Laximo
6
6
  class ListCatalogs < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//ListCatalogs/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node)
13
+
14
+ h[:features] = nodes_to_hash(node.xpath('./features/feature'))
15
+
16
+ h[:operations] = node.xpath('./extensions/operations/opration').inject([]) { |arr1, n1|
17
+
18
+ h1 = node_to_hash(n1)
19
+ h1[:params] = nodes_to_hash(n1.xpath('./params/param'))
20
+
21
+ arr1 << h1
22
+
23
+ }
24
+
25
+ arr << h unless h.empty?
26
+
27
+ }
28
+
29
+ end # parsing_result
11
30
 
12
31
  end # ListCatalogs
13
32
 
@@ -6,8 +6,8 @@ module Laximo
6
6
  class ListCategories < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+ nodes_to_hash(str.xpath('//ListCategories/row'))
10
+ end # parsing_result
11
11
 
12
12
  end # ListCategories
13
13
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class ListDetailByUnit < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//ListDetailsByUnit/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:attributes] = nodes_to_hash(n1.xpath('./attribute'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # ListDetailByUnit
13
23
 
@@ -6,8 +6,8 @@ module Laximo
6
6
  class ListImageMapByUnit < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+ nodes_to_hash(str.xpath('//ListImageMapByUnit/row'))
10
+ end # parsing_result
11
11
 
12
12
  end # ListImageMapByUnit
13
13
 
@@ -6,11 +6,7 @@ module Laximo
6
6
  class ListManufacturer < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
-
10
- str.xpath('//ListManufacturer/row').inject([]) { |arr, node|
11
- arr << attrs_to_hash(node)
12
- }
13
-
9
+ nodes_to_hash(str.xpath('//ListManufacturer/row'))
14
10
  end # parsing_result
15
11
 
16
12
  end # ListManufacturer
@@ -6,8 +6,29 @@ module Laximo
6
6
  class ListQuickDetail < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//ListQuickDetail/Category').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+
14
+ h1[:unit] = n1.xpath('./Unit').inject([]) { |arr1, n2|
15
+
16
+ arr1 << node_to_hash(n2) { |h2, n3|
17
+
18
+ h1[:attributes] = nodes_to_hash(n3.xpath('./attribute'))
19
+ h1[:details] = nodes_to_hash(n3.xpath('./Detail/attribute'))
20
+
21
+ }
22
+
23
+ }
24
+
25
+ }
26
+
27
+ arr << h unless h.empty?
28
+
29
+ }
30
+
31
+ end # parsing_result
11
32
 
12
33
  end # ListQuickDetail
13
34
 
@@ -6,8 +6,8 @@ module Laximo
6
6
  class ListQuickGroup < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+ nodes_to_hash(str.xpath('//ListQuickGroups/row'))
10
+ end # parsing_result
11
11
 
12
12
  end # ListQuickGroup
13
13
 
@@ -6,8 +6,18 @@ module Laximo
6
6
  class ListUnits < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
- str
10
- end
9
+
10
+ str.xpath('//ListUnits/row').inject([]) { |arr, node|
11
+
12
+ h = node_to_hash(node) { |h1, n1|
13
+ h1[:attributes] = nodes_to_hash(n1.xpath('./attribute'))
14
+ }
15
+
16
+ arr << h unless h.empty?
17
+
18
+ }
19
+
20
+ end # parsing_result
11
21
 
12
22
  end # ListUnits
13
23
 
@@ -6,11 +6,7 @@ module Laximo
6
6
  class Manufacturer_Info < Laximo::Respond::Base
7
7
 
8
8
  def parsing_result(str)
9
-
10
- str.xpath('//ManufacturerInfo/row').inject([]) { |arr, node|
11
- arr << attrs_to_hash(node)
12
- }
13
-
9
+ nodes_to_hash(str.xpath('//ManufacturerInfo/row'))
14
10
  end # parsing_result
15
11
 
16
12
  end # Manufacturer_Info
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module Laximo
3
3
 
4
- VERSION = '0.3.3'.freeze
4
+ VERSION = '0.4.1'.freeze
5
5
 
6
6
  end # Laximo
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laximo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Piliaiev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-29 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -39,6 +39,7 @@ files:
39
39
  - lib/laximo.rb
40
40
  - lib/laximo/am.rb
41
41
  - lib/laximo/defaults.rb
42
+ - lib/laximo/errors.rb
42
43
  - lib/laximo/oem.rb
43
44
  - lib/laximo/options.rb
44
45
  - lib/laximo/query.rb