laximo 0.8.1 → 0.9.0
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.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/laximo/oem.rb +185 -0
- data/lib/laximo/request.rb +5 -3
- data/lib/laximo/respond.rb +57 -50
- data/lib/laximo/respond/am/find_detail.rb +1 -1
- data/lib/laximo/respond/am/find_oem.rb +1 -1
- data/lib/laximo/respond/am/find_oem_correction.rb +1 -1
- data/lib/laximo/respond/am/find_replacements.rb +1 -1
- data/lib/laximo/respond/am/list_manufacturer.rb +1 -1
- data/lib/laximo/respond/am/manufacturer_info.rb +1 -1
- data/lib/laximo/respond/oem/exec_custom_operation.rb +1 -1
- data/lib/laximo/respond/oem/find_vehicle.rb +1 -1
- data/lib/laximo/respond/oem/find_vehicle_by_frame.rb +1 -1
- data/lib/laximo/respond/oem/find_vehicle_by_frame_no.rb +1 -1
- data/lib/laximo/respond/oem/find_vehicle_by_vin.rb +1 -1
- data/lib/laximo/respond/oem/find_vehicle_by_wizard2.rb +1 -1
- data/lib/laximo/respond/oem/get_catalog_info.rb +2 -2
- data/lib/laximo/respond/oem/get_filter_by_detail.rb +1 -1
- data/lib/laximo/respond/oem/get_filter_by_unit.rb +1 -1
- data/lib/laximo/respond/oem/get_unit_info.rb +1 -1
- data/lib/laximo/respond/oem/get_vehicle_info.rb +2 -2
- data/lib/laximo/respond/oem/get_wizard2.rb +1 -1
- data/lib/laximo/respond/oem/get_wizard_next_step2.rb +1 -1
- data/lib/laximo/respond/oem/list_catalogs.rb +1 -1
- data/lib/laximo/respond/oem/list_categories.rb +2 -2
- data/lib/laximo/respond/oem/list_detail_by_unit.rb +1 -1
- data/lib/laximo/respond/oem/list_image_map_by_unit.rb +1 -1
- data/lib/laximo/respond/oem/list_quick_detail.rb +1 -1
- data/lib/laximo/respond/oem/list_quick_group.rb +1 -1
- data/lib/laximo/respond/oem/list_units.rb +2 -2
- data/lib/laximo/respond/oem/vehicle_with_list_categories.rb +25 -0
- data/lib/laximo/respond/oem/vehicle_with_list_details_by_unit.rb +26 -0
- data/lib/laximo/respond/oem/vehicle_with_list_quick_detail.rb +24 -0
- data/lib/laximo/respond/oem/vehicle_with_list_quick_groups.rb +24 -0
- data/lib/laximo/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9394f9ca0c3aa40b1623837b7aa2c7a4055700a14b36518df29adfba5a3e1710
|
|
4
|
+
data.tar.gz: 6ad9f364a288868355d321fc3e89da2349df68a4a43a874760dad8a439f38e51
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '087ab9b95e08255ebf453f9cc4bba3a8e4f06555687d41389848cfbfd702de639decf7c2460aed9f5d222ef46e2a0ea0103cca89a1d562a260d28cbf69658464'
|
|
7
|
+
data.tar.gz: 8d2e150454bbc85301fb4bc091a41f9b05162f382678a4d96496e171637f68b8102d2590a353963ca24762187f312583731f8820a86ce21cb3c2b2a8124e5fd5
|
data/README.md
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
Ruby 2.0+
|
|
9
9
|
|
|
10
10
|
### Установка (Rails)
|
|
11
|
-
1. Добавляем в Gemfile
|
|
12
|
-
2. В
|
|
11
|
+
1. Добавляем в Gemfile строку `gem 'laximo'`
|
|
12
|
+
2. В консоле `bundle install`
|
|
13
13
|
3. Задаем параметры конфигурации в файле `config/initializers/laximo.rb`:
|
|
14
14
|
```ruby
|
|
15
15
|
Laximo.options.login 'mylogin' # имейте в виду, что такие параметры
|
|
@@ -69,6 +69,12 @@ Laximo.options.locale 'ru_RU'
|
|
|
69
69
|
* [Laximo.oem.list_quick_group(catalog:, vehicle_id, ssd:, locale: 'ru_RU')](http://wiki.technologytrade.ru/index.php/Laximo_Web-services:OEM:ListQuickGroup)
|
|
70
70
|
* [Laximo.oem.list_quick_detail(catalog:, vehicle_id:, quick_group_id:, ssd:, all: 1, localized: true, locale: 'ru_RU')](http://wiki.technologytrade.ru/index.php/Laximo_Web-services:OEM:ListQuickDetail)
|
|
71
71
|
|
|
72
|
+
### Комбинированные методы web-сервиса [wsdemo.laximo](https://wsdemo.laximo.ru/)
|
|
73
|
+
* [Laximo.oem.vehicle_with_list_categories(vehicle_id:, catalog:, ssd:, category_id: -1,localized: true, locale: 'ru_RU')](https://wsdemo.laximo.ru/index.php?task=qgroups&oem=&useApplicability=1&c=CFIAT84&vid=5182&ssd=$*KwHZ7fzGvYurq5yGiNj16YGVtbKs2tne3czfwZ-1joOPqt69zN_IipmehZi1g4Dy5uaq2dze29rd34KIldrY296ViYKD3cnSq97d3pWOjJbt08a0h4KCn4Kt3YvCxJmDm4mruZOK3NvJhY-ygoSq3NuKipHc2pOFj6rckd_Tzp-Crd3ZlICZwfyR3trc2d7a3d6CjJCVnIiEgomBiu3Sz6va2t3Z0tjai8LZjoufrNna3dYAAAAAeCpr2w$)
|
|
74
|
+
* [Laximo.oem.vehicle_with_list_quick_groups(vehicle_id:, catalog:, ssd:, localized: true, locale: 'ru_RU')](https://wsdemo.laximo.ru/index.php?task=vehicle&c=CFIAT84&vid=5182&ssd=$*KwGFsaCa4df398Da1ISptd3J6e7whoWCgZCDncPp0t_T9oLhkIOU1sXC2cTp39yuurr2hYCCh4aBg97UyYaEh4LJ1d7fgZWO94KBgsnS0Mqxj5ro297ew97xgdeemMXfx9X35c_WgIeV2dPu3tj2gIfW1s2Ahs_Z0_aAzYOPksPe8YGFyNzFnaDNgoaAhYKGgYLe0MzJwNTY3tXd1rGOk_eGhoGFjoSG156F0tfD8IWGgYoAAAAAbHr5DQ$)
|
|
75
|
+
* [Laximo.oem.vehicle_with_list_quick_detail(vehicle_id:, catalog:, ssd:, quick_group_id:, all: 1, localized: true, locale: 'ru_RU')](https://wsdemo.laximo.ru/index.php?task=qgroups&c=CFIAT84&vid=5182&ssd=$*KwEbLz4Ef0lpaV5ESho3K0NXd3BuGBscHw4dA113TEFNaBx_Dh0KSFtcR1p3QUIwJCRoGx4cGRgfHUBKVxgaGRxXS0BBHwsQaRwfHFdMTlQvEQR2RUBAXUBvH0kABltBWUtpe1FIHhkLR01wQEZoHhlISFMeGFFHTWgeUx0RDF1Abx8bVkJbAz5THBgeGxwYHxxATlJXXkpGQEtDSC8QDWkYGB8bEBoYSQAbTEldbhsYHxQAAAAAnyRrTQ$&gid=2)
|
|
76
|
+
* [Laximo.oem.vehicle_with_list_details_by_unit(vehicle_id:, catalog:, ssd:, unit_id:,localized: true, locale: 'ru_RU')](https://wsdemo.laximo.ru/index.php?task=unit&c=CFIAT84&vid=5182&uid=38255&gid=2&cid=10301&ssd=$*KwEBNSQeZVNzc0ReUAAtMVlNbWp0AgEGBRQHGUdtVltXcgZlFAcQUkFGXUBtW1gqPj5yAQQGAwIFB1pQTQIAAwZNUVleCQwdcwJLV1xeWkIYJEwDAEtQUktqWAw7FVxcQVxzAAxJDhYRRVd1Z01XW1ADCh1sXFp0AgYNAVtTSE1VR0RsUVpTKlVIAExcUHMDS1oFCgxbcgQGTV9DRCpVTQMDAAEDAgQHWlQGQVdDXUBbWlkPJEhNQVJGQ21WWA4kSU1BUkdsUVpTKlQGR1NXWFZxWlMPJEkDAQUFHAIFSR8KEUd7UXQACgcCXxoOUkBcVV1GUHdZGg5WWlxXX1dqWQUkSAQDBwwGBwxJEwEZQXIHBAMLAAAAAGAPcDM$&coi=2&fromTask=qdetails)
|
|
77
|
+
|
|
72
78
|
Данные методы возвращают объект, у которого заданы методы:
|
|
73
79
|
|
|
74
80
|
* `success?` - успешна ли операция
|
|
@@ -113,4 +119,4 @@ res.result # []
|
|
|
113
119
|
|
|
114
120
|
[Список контрибьюторов](https://github.com/dancingbytes/laximo/graphs/contributors)
|
|
115
121
|
|
|
116
|
-
Copyright (c) 2015-
|
|
122
|
+
Copyright (c) 2015-2019 DansingBytes.ru, под лицензией BSD
|
data/lib/laximo/oem.rb
CHANGED
|
@@ -408,6 +408,191 @@ module Laximo
|
|
|
408
408
|
|
|
409
409
|
end # list_quick_detail
|
|
410
410
|
|
|
411
|
+
#
|
|
412
|
+
# Специальные комбинированные методы
|
|
413
|
+
#
|
|
414
|
+
|
|
415
|
+
def vehicle_with_list_categories(
|
|
416
|
+
vehicle_id:,
|
|
417
|
+
catalog:,
|
|
418
|
+
ssd:,
|
|
419
|
+
category_id: -1,
|
|
420
|
+
localized: true,
|
|
421
|
+
locale: ::Laximo.options.locale
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
# Информация о каталоге
|
|
425
|
+
r1 = ::Laximo::Query.
|
|
426
|
+
new('GetCatalogInfo').
|
|
427
|
+
locale(locale).
|
|
428
|
+
catalog(catalog).
|
|
429
|
+
ssd(ssd)
|
|
430
|
+
|
|
431
|
+
# Информация по конкретному автомобилю (модификации)
|
|
432
|
+
r2 = ::Laximo::Query.
|
|
433
|
+
new('GetVehicleInfo').
|
|
434
|
+
locale(locale).
|
|
435
|
+
catalog(catalog).
|
|
436
|
+
vehicle_id(vehicle_id).
|
|
437
|
+
ssd(ssd).
|
|
438
|
+
localized(localized)
|
|
439
|
+
|
|
440
|
+
# Список категорий каталога
|
|
441
|
+
r3 = ::Laximo::Query.
|
|
442
|
+
new('ListCategories').
|
|
443
|
+
locale(locale).
|
|
444
|
+
catalog(catalog).
|
|
445
|
+
vehicle_id(vehicle_id).
|
|
446
|
+
category_id(category_id).
|
|
447
|
+
ssd(ssd)
|
|
448
|
+
|
|
449
|
+
# Список агрегатов автомобиля.
|
|
450
|
+
r4 = ::Laximo::Query.
|
|
451
|
+
new('ListUnits').
|
|
452
|
+
locale(locale).
|
|
453
|
+
catalog(catalog).
|
|
454
|
+
vehicle_id(vehicle_id).
|
|
455
|
+
category_id(category_id).
|
|
456
|
+
ssd(ssd).
|
|
457
|
+
localized(localized)
|
|
458
|
+
|
|
459
|
+
::Laximo::Respond::VehicleWithListCategories.new(
|
|
460
|
+
@request.call(r1, r2, r3, r4)
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
end # vehicle_with_list_categories
|
|
464
|
+
|
|
465
|
+
def vehicle_with_list_quick_groups(
|
|
466
|
+
vehicle_id:,
|
|
467
|
+
catalog:,
|
|
468
|
+
ssd:,
|
|
469
|
+
localized: true,
|
|
470
|
+
locale: ::Laximo.options.locale
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
# Информация о каталоге
|
|
474
|
+
r1 = ::Laximo::Query.
|
|
475
|
+
new('GetCatalogInfo').
|
|
476
|
+
locale(locale).
|
|
477
|
+
catalog(catalog).
|
|
478
|
+
ssd(ssd)
|
|
479
|
+
|
|
480
|
+
# Информация по конкретному автомобилю (модификации)
|
|
481
|
+
r2 = ::Laximo::Query.
|
|
482
|
+
new('GetVehicleInfo').
|
|
483
|
+
locale(locale).
|
|
484
|
+
catalog(catalog).
|
|
485
|
+
vehicle_id(vehicle_id).
|
|
486
|
+
ssd(ssd).
|
|
487
|
+
localized(localized)
|
|
488
|
+
|
|
489
|
+
# Список групп быстрого поиска деталей
|
|
490
|
+
r3 = ::Laximo::Query.
|
|
491
|
+
new('ListQuickGroup').
|
|
492
|
+
locale(locale).
|
|
493
|
+
catalog(catalog).
|
|
494
|
+
vehicle_id(vehicle_id).
|
|
495
|
+
ssd(ssd)
|
|
496
|
+
|
|
497
|
+
::Laximo::Respond::VehicleWithListQuickGroups.new(
|
|
498
|
+
@request.call(r1, r2, r3)
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
def vehicle_with_list_quick_detail(
|
|
504
|
+
vehicle_id:,
|
|
505
|
+
catalog:,
|
|
506
|
+
ssd:,
|
|
507
|
+
quick_group_id:,
|
|
508
|
+
all: 1,
|
|
509
|
+
localized: true,
|
|
510
|
+
locale: ::Laximo.options.locale
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
# Информация о каталоге
|
|
514
|
+
r1 = ::Laximo::Query.
|
|
515
|
+
new('GetCatalogInfo').
|
|
516
|
+
locale(locale).
|
|
517
|
+
catalog(catalog).
|
|
518
|
+
ssd(ssd)
|
|
519
|
+
|
|
520
|
+
# Информация по конкретному автомобилю (модификации)
|
|
521
|
+
r2 = ::Laximo::Query.
|
|
522
|
+
new('GetVehicleInfo').
|
|
523
|
+
locale(locale).
|
|
524
|
+
catalog(catalog).
|
|
525
|
+
vehicle_id(vehicle_id).
|
|
526
|
+
ssd(ssd).
|
|
527
|
+
localized(localized)
|
|
528
|
+
|
|
529
|
+
# Список групп быстрого поиска деталей
|
|
530
|
+
r3 = ::Laximo::Query.
|
|
531
|
+
new('ListQuickDetail').
|
|
532
|
+
locale(locale).
|
|
533
|
+
catalog(catalog).
|
|
534
|
+
vehicle_id(vehicle_id).
|
|
535
|
+
quick_group_id(quick_group_id).
|
|
536
|
+
all(all).
|
|
537
|
+
ssd(ssd)
|
|
538
|
+
|
|
539
|
+
::Laximo::Respond::VehicleWithListQuickDetail.new(
|
|
540
|
+
@request.call(r1, r2, r3)
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
def vehicle_with_list_details_by_unit(
|
|
546
|
+
vehicle_id:,
|
|
547
|
+
catalog:,
|
|
548
|
+
ssd:,
|
|
549
|
+
unit_id:,
|
|
550
|
+
localized: true,
|
|
551
|
+
locale: ::Laximo.options.locale
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
r1 = ::Laximo::Query.
|
|
555
|
+
new('GetUnitInfo').
|
|
556
|
+
locale(locale).
|
|
557
|
+
catalog(catalog).
|
|
558
|
+
ssd(ssd).
|
|
559
|
+
unit_id(unit_id).
|
|
560
|
+
localized(localized)
|
|
561
|
+
|
|
562
|
+
r2 = ::Laximo::Query.
|
|
563
|
+
new('ListDetailByUnit').
|
|
564
|
+
locale(locale).
|
|
565
|
+
catalog(catalog).
|
|
566
|
+
ssd(ssd).
|
|
567
|
+
unit_id(unit_id).
|
|
568
|
+
localized(localized)
|
|
569
|
+
|
|
570
|
+
r3 = ::Laximo::Query.
|
|
571
|
+
new('ListImageMapByUnit').
|
|
572
|
+
catalog(catalog).
|
|
573
|
+
ssd(ssd).
|
|
574
|
+
unit_id(unit_id)
|
|
575
|
+
|
|
576
|
+
r4 = ::Laximo::Query.
|
|
577
|
+
new('GetCatalogInfo').
|
|
578
|
+
locale(locale).
|
|
579
|
+
catalog(catalog).
|
|
580
|
+
ssd(ssd)
|
|
581
|
+
|
|
582
|
+
r5 = ::Laximo::Query.
|
|
583
|
+
new('GetVehicleInfo').
|
|
584
|
+
locale(locale).
|
|
585
|
+
catalog(catalog).
|
|
586
|
+
vehicle_id(vehicle_id).
|
|
587
|
+
ssd(ssd).
|
|
588
|
+
localized(localized)
|
|
589
|
+
|
|
590
|
+
::Laximo::Respond::VehicleWithListDetailsByUnit.new(
|
|
591
|
+
@request.call(r1, r2, r3, r4, r5)
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
end
|
|
595
|
+
|
|
411
596
|
end # Oem
|
|
412
597
|
|
|
413
598
|
end # Laximo
|
data/lib/laximo/request.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
module Laximo
|
|
3
3
|
|
|
4
|
-
REQUEST_LOGIN_MSG = %
|
|
4
|
+
REQUEST_LOGIN_MSG = %{<?xml version="1.0" encoding="UTF-8"?>
|
|
5
5
|
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
|
|
6
6
|
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
7
7
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
|
|
@@ -12,7 +12,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
|
|
|
12
12
|
<hmac xsi:type="xsd:string">%{hash}</hmac>
|
|
13
13
|
</ns5692:QueryDataLogin>
|
|
14
14
|
</SOAP-ENV:Body>
|
|
15
|
-
</SOAP-ENV:Envelope>
|
|
15
|
+
</SOAP-ENV:Envelope>}.freeze
|
|
16
16
|
|
|
17
17
|
class Request
|
|
18
18
|
|
|
@@ -30,7 +30,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://sch
|
|
|
30
30
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
def call(
|
|
33
|
+
def call(*args)
|
|
34
|
+
|
|
35
|
+
msg = args.join("\n")
|
|
34
36
|
|
|
35
37
|
@request.body = (REQUEST_LOGIN_MSG % {
|
|
36
38
|
msg: msg,
|
data/lib/laximo/respond.rb
CHANGED
|
@@ -5,9 +5,57 @@ module Laximo
|
|
|
5
5
|
|
|
6
6
|
class Base
|
|
7
7
|
|
|
8
|
-
RESPONSE_RESULT
|
|
8
|
+
RESPONSE_RESULT = '//QueryDataResponse/return'.freeze
|
|
9
9
|
RESPONSE_LOGIN_RESULT = '//QueryDataLoginResponse/return'.freeze
|
|
10
|
-
RESPONSE_SOAP_ERROR
|
|
10
|
+
RESPONSE_SOAP_ERROR = '//Fault/faultstring'.freeze
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
|
|
15
|
+
def parsing_result(str)
|
|
16
|
+
::NotImplementedError.new("Метод `parsing_result` не реализован в классе #{self.class}")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def node_to_hash(node)
|
|
22
|
+
|
|
23
|
+
return {} if node.nil?
|
|
24
|
+
|
|
25
|
+
h = {}
|
|
26
|
+
node.attributes.each { |key, snd|
|
|
27
|
+
h[key.to_sym] = snd.value
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return {} if h.empty?
|
|
31
|
+
yield(h, node) if block_given?
|
|
32
|
+
|
|
33
|
+
h
|
|
34
|
+
|
|
35
|
+
end # node_to_hash
|
|
36
|
+
|
|
37
|
+
def nodes_to_hash(nodes, recursive: true)
|
|
38
|
+
|
|
39
|
+
arr = []
|
|
40
|
+
nodes.each { |node|
|
|
41
|
+
|
|
42
|
+
h = {}
|
|
43
|
+
node.attributes.each { |key, snd|
|
|
44
|
+
h[key.to_sym] = snd.value
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if recursive
|
|
48
|
+
children = nodes_to_hash(node.children, recursive: true)
|
|
49
|
+
h[:children] = children unless children.empty?
|
|
50
|
+
end
|
|
51
|
+
arr << h
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
arr
|
|
55
|
+
|
|
56
|
+
end # nodes_to_hash
|
|
57
|
+
|
|
58
|
+
end
|
|
11
59
|
|
|
12
60
|
def initialize(request)
|
|
13
61
|
|
|
@@ -20,72 +68,31 @@ module Laximo
|
|
|
20
68
|
|
|
21
69
|
def success?
|
|
22
70
|
@error.nil?
|
|
23
|
-
end
|
|
71
|
+
end
|
|
24
72
|
|
|
25
73
|
def failure?
|
|
26
74
|
!@error.nil?
|
|
27
|
-
end
|
|
75
|
+
end
|
|
28
76
|
|
|
29
77
|
alias :error? :failure?
|
|
30
78
|
|
|
31
79
|
def error
|
|
32
80
|
@error
|
|
33
|
-
end
|
|
81
|
+
end
|
|
34
82
|
|
|
35
83
|
def result
|
|
36
84
|
@result
|
|
37
|
-
end
|
|
85
|
+
end
|
|
38
86
|
|
|
39
87
|
def result!
|
|
40
88
|
|
|
41
89
|
raise error.class, error.message if failure?
|
|
42
90
|
result
|
|
43
91
|
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def parsing_result(str)
|
|
47
|
-
::NotImplementedError.new("Метод `parsing_result` не реализован в классе #{self.class.name}")
|
|
48
|
-
end # parsing_result
|
|
92
|
+
end
|
|
49
93
|
|
|
50
94
|
private
|
|
51
95
|
|
|
52
|
-
def node_to_hash(node)
|
|
53
|
-
|
|
54
|
-
return {} if node.nil?
|
|
55
|
-
|
|
56
|
-
h = {}
|
|
57
|
-
node.attributes.each { |key, snd|
|
|
58
|
-
h[key.to_sym] = snd.value
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return {} if h.empty?
|
|
62
|
-
yield(h, node) if block_given?
|
|
63
|
-
|
|
64
|
-
h
|
|
65
|
-
|
|
66
|
-
end # node_to_hash
|
|
67
|
-
|
|
68
|
-
def nodes_to_hash(nodes, recursive: true)
|
|
69
|
-
|
|
70
|
-
arr = []
|
|
71
|
-
nodes.each { |node|
|
|
72
|
-
|
|
73
|
-
h = {}
|
|
74
|
-
node.attributes.each { |key, snd|
|
|
75
|
-
h[key.to_sym] = snd.value
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if recursive
|
|
79
|
-
children = nodes_to_hash(node.children, recursive: true)
|
|
80
|
-
h[:children] = children unless children.empty?
|
|
81
|
-
end
|
|
82
|
-
arr << h
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
arr
|
|
86
|
-
|
|
87
|
-
end # nodes_to_hash
|
|
88
|
-
|
|
89
96
|
def prepare_request(request)
|
|
90
97
|
|
|
91
98
|
if request.is_a?(::Net::HTTPOK)
|
|
@@ -136,7 +143,7 @@ module Laximo
|
|
|
136
143
|
res = doc.xpath(RESPONSE_RESULT).children[0].to_s if res.blank?
|
|
137
144
|
|
|
138
145
|
@error = nil
|
|
139
|
-
@result = parsing_result(
|
|
146
|
+
@result = self.class.parsing_result(
|
|
140
147
|
::Nokogiri::XML(unescape(res))
|
|
141
148
|
) || []
|
|
142
149
|
|
|
@@ -160,7 +167,7 @@ module Laximo
|
|
|
160
167
|
|
|
161
168
|
def unescape(str)
|
|
162
169
|
::CGI::unescapeHTML str
|
|
163
|
-
end
|
|
170
|
+
end
|
|
164
171
|
|
|
165
172
|
end # Base
|
|
166
173
|
|
|
@@ -5,7 +5,7 @@ module Laximo
|
|
|
5
5
|
|
|
6
6
|
class GetCatalogInfo < Laximo::Respond::Base
|
|
7
7
|
|
|
8
|
-
def parsing_result(str)
|
|
8
|
+
def self.parsing_result(str)
|
|
9
9
|
|
|
10
10
|
str.xpath('//GetCatalogInfo/row').inject([]) { |arr, node|
|
|
11
11
|
|
|
@@ -25,7 +25,7 @@ module Laximo
|
|
|
25
25
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
end
|
|
28
|
+
end
|
|
29
29
|
|
|
30
30
|
end # GetCatalogInfo
|
|
31
31
|
|
|
@@ -5,7 +5,7 @@ module Laximo
|
|
|
5
5
|
|
|
6
6
|
class GetVehicleInfo < Laximo::Respond::Base
|
|
7
7
|
|
|
8
|
-
def parsing_result(str)
|
|
8
|
+
def self.parsing_result(str)
|
|
9
9
|
|
|
10
10
|
str.xpath('//GetVehicleInfo/row').inject([]) { |arr, node|
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ module Laximo
|
|
|
18
18
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
end
|
|
21
|
+
end
|
|
22
22
|
|
|
23
23
|
end # GetVehicleInfo
|
|
24
24
|
|
|
@@ -5,7 +5,7 @@ module Laximo
|
|
|
5
5
|
|
|
6
6
|
class ListCategories < Laximo::Respond::Base
|
|
7
7
|
|
|
8
|
-
def parsing_result(str)
|
|
8
|
+
def self.parsing_result(str)
|
|
9
9
|
|
|
10
10
|
nodes_to_hash(
|
|
11
11
|
str.xpath('//ListCategories/row')
|
|
@@ -13,7 +13,7 @@ module Laximo
|
|
|
13
13
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
end
|
|
16
|
+
end
|
|
17
17
|
|
|
18
18
|
end # Respond
|
|
19
19
|
|
|
@@ -5,7 +5,7 @@ module Laximo
|
|
|
5
5
|
|
|
6
6
|
class ListUnits < Laximo::Respond::Base
|
|
7
7
|
|
|
8
|
-
def parsing_result(str)
|
|
8
|
+
def self.parsing_result(str)
|
|
9
9
|
|
|
10
10
|
str.xpath('//ListUnits/row').inject([]) { |arr, node|
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ module Laximo
|
|
|
18
18
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
end
|
|
21
|
+
end
|
|
22
22
|
|
|
23
23
|
end # ListUnits
|
|
24
24
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Laximo
|
|
3
|
+
|
|
4
|
+
module Respond
|
|
5
|
+
|
|
6
|
+
class VehicleWithListCategories < Laximo::Respond::Base
|
|
7
|
+
|
|
8
|
+
def self.parsing_result(str)
|
|
9
|
+
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
get_catalog_info: GetCatalogInfo.parsing_result(str),
|
|
13
|
+
get_vehicle_info: GetVehicleInfo.parsing_result(str),
|
|
14
|
+
list_categories: ListCategories.parsing_result(str),
|
|
15
|
+
list_units: ListUnits.parsing_result(str)
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end # VehicleWithListCategories
|
|
22
|
+
|
|
23
|
+
end # Respond
|
|
24
|
+
|
|
25
|
+
end # Laximo
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Laximo
|
|
3
|
+
|
|
4
|
+
module Respond
|
|
5
|
+
|
|
6
|
+
class VehicleWithListDetailsByUnit < Laximo::Respond::Base
|
|
7
|
+
|
|
8
|
+
def self.parsing_result(str)
|
|
9
|
+
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
get_unit_info: GetUnitInfo.parsing_result(str),
|
|
13
|
+
list_detail_by_unit: ListDetailByUnit.parsing_result(str),
|
|
14
|
+
list_image_map_by_unit: ListImageMapByUnit.parsing_result(str),
|
|
15
|
+
get_catalog_info: GetCatalogInfo.parsing_result(str),
|
|
16
|
+
get_vehicle_info: GetVehicleInfo.parsing_result(str)
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end # VehicleWithListDetailsByUnit
|
|
23
|
+
|
|
24
|
+
end # Respond
|
|
25
|
+
|
|
26
|
+
end # Laximo
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Laximo
|
|
3
|
+
|
|
4
|
+
module Respond
|
|
5
|
+
|
|
6
|
+
class VehicleWithListQuickDetail < Laximo::Respond::Base
|
|
7
|
+
|
|
8
|
+
def self.parsing_result(str)
|
|
9
|
+
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
get_catalog_info: GetCatalogInfo.parsing_result(str),
|
|
13
|
+
get_vehicle_info: GetVehicleInfo.parsing_result(str),
|
|
14
|
+
list_quick_detail: ListQuickDetail.parsing_result(str)
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end # VehicleWithListQuickDetail
|
|
21
|
+
|
|
22
|
+
end # Respond
|
|
23
|
+
|
|
24
|
+
end # Laximo
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Laximo
|
|
3
|
+
|
|
4
|
+
module Respond
|
|
5
|
+
|
|
6
|
+
class VehicleWithListQuickGroups < Laximo::Respond::Base
|
|
7
|
+
|
|
8
|
+
def self.parsing_result(str)
|
|
9
|
+
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
get_catalog_info: GetCatalogInfo.parsing_result(str),
|
|
13
|
+
get_vehicle_info: GetVehicleInfo.parsing_result(str),
|
|
14
|
+
list_quick_group: ListQuickGroup.parsing_result(str)
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end # VehicleWithListQuickGroups
|
|
21
|
+
|
|
22
|
+
end # Respond
|
|
23
|
+
|
|
24
|
+
end # Laximo
|
data/lib/laximo/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan Pilyaev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -71,6 +71,10 @@ files:
|
|
|
71
71
|
- lib/laximo/respond/oem/list_quick_detail.rb
|
|
72
72
|
- lib/laximo/respond/oem/list_quick_group.rb
|
|
73
73
|
- lib/laximo/respond/oem/list_units.rb
|
|
74
|
+
- lib/laximo/respond/oem/vehicle_with_list_categories.rb
|
|
75
|
+
- lib/laximo/respond/oem/vehicle_with_list_details_by_unit.rb
|
|
76
|
+
- lib/laximo/respond/oem/vehicle_with_list_quick_detail.rb
|
|
77
|
+
- lib/laximo/respond/oem/vehicle_with_list_quick_groups.rb
|
|
74
78
|
- lib/laximo/version.rb
|
|
75
79
|
homepage: https://github.com/dancingbytes/laximo
|
|
76
80
|
licenses:
|