tec_doc 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +29 -0
- data/bin/tec_doc +51 -0
- data/lib/tec_doc.rb +28 -0
- data/lib/tec_doc/article.rb +317 -0
- data/lib/tec_doc/article_attribute.rb +17 -0
- data/lib/tec_doc/article_document.rb +49 -0
- data/lib/tec_doc/article_oe_number.rb +11 -0
- data/lib/tec_doc/article_thumbnail.rb +18 -0
- data/lib/tec_doc/assembly_group.rb +77 -0
- data/lib/tec_doc/brand.rb +18 -0
- data/lib/tec_doc/client.rb +84 -0
- data/lib/tec_doc/date_parser.rb +14 -0
- data/lib/tec_doc/error.rb +4 -0
- data/lib/tec_doc/fuel_type.rb +0 -0
- data/lib/tec_doc/generic_article.rb +47 -0
- data/lib/tec_doc/language.rb +22 -0
- data/lib/tec_doc/vehicle.rb +121 -0
- data/lib/tec_doc/vehicle_manufacturer.rb +46 -0
- data/lib/tec_doc/vehicle_model.rb +46 -0
- data/lib/tec_doc/version.rb +3 -0
- data/spec/cassettes/article_all.yml +88 -0
- data/spec/cassettes/article_all_with_details.yml +84 -0
- data/spec/cassettes/article_details.yml +68 -0
- data/spec/cassettes/article_details_for_trade_number.yml +56 -0
- data/spec/cassettes/article_document_all.yml +49 -0
- data/spec/cassettes/article_document_content.yml +763 -0
- data/spec/cassettes/article_information.yml +55 -0
- data/spec/cassettes/article_linked_manufacturers.yml +45 -0
- data/spec/cassettes/article_linked_vehicle_ids.yml +45 -0
- data/spec/cassettes/article_linked_vehicles.yml +372 -0
- data/spec/cassettes/article_linked_vehicles_with_details.yml +430 -0
- data/spec/cassettes/article_search.yml +62 -0
- data/spec/cassettes/article_search_for_linked_manufacturers.yml +47 -0
- data/spec/cassettes/article_thumbnail_all.yml +45 -0
- data/spec/cassettes/article_thumbnail_content.yml +399 -0
- data/spec/cassettes/article_trade_number.yml +46 -0
- data/spec/cassettes/article_with_a_lot_linked_vehicles.yml +60 -0
- data/spec/cassettes/assembly_group_all.yml +90 -0
- data/spec/cassettes/assembly_group_children.yml +55 -0
- data/spec/cassettes/brand_all.yml +81 -0
- data/spec/cassettes/generic_article_all.yml +46 -0
- data/spec/cassettes/language_all.yml +48 -0
- data/spec/cassettes/linked_targets_by_manufacturers.yml +2584 -0
- data/spec/cassettes/status_401.yml +38 -0
- data/spec/cassettes/vehicle_all.yml +79 -0
- data/spec/cassettes/vehicle_assembly_groups.yml +83 -0
- data/spec/cassettes/vehicle_child_assembly_groups.yml +49 -0
- data/spec/cassettes/vehicle_find_by_id.yml +50 -0
- data/spec/cassettes/vehicle_manufacturer_all.yml +52 -0
- data/spec/cassettes/vehicle_model_all.yml +119 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/tec_doc/article_document_spec.rb +34 -0
- data/spec/tec_doc/article_spec.rb +185 -0
- data/spec/tec_doc/article_thumbnail_spec.rb +34 -0
- data/spec/tec_doc/assembly_group_spec.rb +48 -0
- data/spec/tec_doc/brand_spec.rb +22 -0
- data/spec/tec_doc/client_spec.rb +11 -0
- data/spec/tec_doc/date_parser_spec.rb +17 -0
- data/spec/tec_doc/generic_article_spec.rb +30 -0
- data/spec/tec_doc/language_spec.rb +22 -0
- data/spec/tec_doc/vehicle_manufacturer_spec.rb +43 -0
- data/spec/tec_doc/vehicle_model_spec.rb +35 -0
- data/spec/tec_doc/vehicle_spec.rb +80 -0
- metadata +426 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 MAK IT
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Ruby client for TecDoc
|
2
|
+
|
3
|
+
## Usage
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
gem 'tec_doc', :git => 'git@github.com:mak-it/tec_doc.git'
|
7
|
+
```
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
require "tec_doc"
|
11
|
+
I18n.locale = "lv"
|
12
|
+
TecDoc.client = TecDoc::Client.new(:provider => 330, :country => "lv")
|
13
|
+
```
|
14
|
+
|
15
|
+
## Shell
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ tec_doc -h
|
19
|
+
$ tec_doc -p 100 -c lv -l lv
|
20
|
+
```
|
21
|
+
|
22
|
+
## Documentation
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
yardoc && open doc/index.html
|
26
|
+
```
|
27
|
+
|
28
|
+
The official TecDoc Web Service documentation
|
29
|
+
can be found [here](http://webservicepilot.tecdoc.net/pegasus-2-0).
|
data/bin/tec_doc
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
4
|
+
|
5
|
+
require "rubygems"
|
6
|
+
require "tec_doc"
|
7
|
+
require "optparse"
|
8
|
+
require "irb"
|
9
|
+
|
10
|
+
I18n.locale = "en"
|
11
|
+
TecDoc.client = TecDoc::Client.new
|
12
|
+
Savon.logger.level = Logger::INFO
|
13
|
+
HTTPI.logger.level = Logger::INFO
|
14
|
+
|
15
|
+
parser = OptionParser.new do |opts|
|
16
|
+
|
17
|
+
opts.banner = "Usage: tec_doc -p <provider id> -c <country code> [-l <language code>] [-m <mode>] [-v]"
|
18
|
+
|
19
|
+
opts.on("-p", "--provider <provider id>", "TecDoc provider ID") do |provider|
|
20
|
+
TecDoc.client.provider = provider
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on("-c", "--country <country code>", "Country code according to ISO 3166") do |country|
|
24
|
+
TecDoc.client.country = country
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("-l", "--lang <language code>", "Language code according to ISO 639") do |lang|
|
28
|
+
I18n.locale = lang
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-m", "--mode <test|live>", "Mode ('live' by default)") do |mode|
|
32
|
+
TecDoc.client.mode = mode.to_sym
|
33
|
+
end
|
34
|
+
|
35
|
+
opts.on("-v", "--verbose", "") do |verbose|
|
36
|
+
Savon.logger.level = Logger::DEBUG
|
37
|
+
HTTPI.logger.level = Logger::DEBUG
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
parser.parse!
|
43
|
+
|
44
|
+
unless TecDoc.client.provider && TecDoc.client.country
|
45
|
+
puts parser
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "TecDoc shell v#{TecDoc::VERSION} [provider:#{TecDoc.client.provider} country:#{TecDoc.client.country} lang:#{I18n.locale} mode: #{TecDoc.client.mode}]"
|
50
|
+
ARGV.clear # otherwise all script parameters get passed to IRB
|
51
|
+
IRB.start
|
data/lib/tec_doc.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "i18n"
|
2
|
+
require "savon"
|
3
|
+
|
4
|
+
require "tec_doc/version"
|
5
|
+
|
6
|
+
module TecDoc
|
7
|
+
extend self
|
8
|
+
|
9
|
+
autoload :Client, "tec_doc/client"
|
10
|
+
autoload :Error, "tec_doc/error"
|
11
|
+
|
12
|
+
autoload :Article, "tec_doc/article"
|
13
|
+
autoload :ArticleDocument, "tec_doc/article_document"
|
14
|
+
autoload :ArticleThumbnail, "tec_doc/article_thumbnail"
|
15
|
+
autoload :ArticleOENumber, "tec_doc/article_oe_number"
|
16
|
+
autoload :ArticleAttribute, "tec_doc/article_attribute"
|
17
|
+
autoload :AssemblyGroup, "tec_doc/assembly_group"
|
18
|
+
autoload :Brand, "tec_doc/brand"
|
19
|
+
autoload :GenericArticle, "tec_doc/generic_article"
|
20
|
+
autoload :Language, "tec_doc/language"
|
21
|
+
autoload :VehicleManufacturer, "tec_doc/vehicle_manufacturer"
|
22
|
+
autoload :VehicleModel, "tec_doc/vehicle_model"
|
23
|
+
autoload :Vehicle, "tec_doc/vehicle"
|
24
|
+
|
25
|
+
autoload :DateParser, "tec_doc/date_parser"
|
26
|
+
|
27
|
+
attr_accessor :client
|
28
|
+
end
|
@@ -0,0 +1,317 @@
|
|
1
|
+
module TecDoc
|
2
|
+
class Article
|
3
|
+
attr_accessor :id, :name, :number, :search_number, :brand_name, :brand_number,
|
4
|
+
:generic_article_id, :number_type, :state, :packing_unit
|
5
|
+
|
6
|
+
attr_accessor :scope
|
7
|
+
|
8
|
+
# Find article by all number types and brand number and generic article id.
|
9
|
+
#
|
10
|
+
# @option options [String] :article_number Article number will be converted within the search process to a simplified article number
|
11
|
+
# @option options [Integer] :brand_no result of brand selection (optional)
|
12
|
+
# @option options [String] :country country code according to ISO 3166
|
13
|
+
# @option options [Integer] :generic_article_id result of generic article selection (optional)
|
14
|
+
# @option options [String] :lang language code according to ISO 639
|
15
|
+
# @option options [String] :number_type Number type (0: Article number, 1: OE number, 2: Trade number, 3: Comparable number, 4: Replacement number, 5: Replaced number, 6: EAN number, 10: Any number)
|
16
|
+
# @option options [TrueClass, FalseClass] :search_exact Search mode (true: exact search, false: similar search)
|
17
|
+
# @option options [Integer] :sort_type Sort mode (1: Brand, 2: Product group)
|
18
|
+
# @return [Array<TecDoc::Article>] list of articles
|
19
|
+
def self.search(options = {})
|
20
|
+
options = {
|
21
|
+
:country => TecDoc.client.country,
|
22
|
+
:lang => I18n.locale.to_s,
|
23
|
+
:number_type => 10,
|
24
|
+
:search_exact => 1,
|
25
|
+
:sort_type => 1
|
26
|
+
}.merge(options)
|
27
|
+
TecDoc.client.request(:get_article_direct_search_all_numbers2, options).map do |attributes|
|
28
|
+
new(attributes, options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# All articles by linked vehicle and brand number, generic article and assembly group
|
33
|
+
#
|
34
|
+
# @option options [String] :lang
|
35
|
+
# @option options [String] :country
|
36
|
+
# @option options [String] :linking_target_type
|
37
|
+
# @option options [Integer] :linking_target_id
|
38
|
+
# @option options [LongList] :brand_id
|
39
|
+
# @option options [LongList] :generic_article_id
|
40
|
+
# @option options [Long] :article_assembly_group_node_id
|
41
|
+
# @return [Array<TecDoc::Article>] list of articles
|
42
|
+
def self.all(options)
|
43
|
+
options = {
|
44
|
+
:lang => I18n.locale.to_s,
|
45
|
+
:country => TecDoc.client.country
|
46
|
+
}.merge(options)
|
47
|
+
TecDoc.client.request(:get_article_ids3, options).map do |attributes|
|
48
|
+
new(attributes, options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
# All requested articles detail information
|
54
|
+
#
|
55
|
+
# @option options [String] :lang
|
56
|
+
# @option options [String] :country
|
57
|
+
# @option options [Array] :ids
|
58
|
+
# @option options [Boolean] :attributs
|
59
|
+
# @option options [Boolean] :ean_numbers
|
60
|
+
# @option options [Boolean] :info
|
61
|
+
# @option options [Boolean] :oe_numbers
|
62
|
+
# @option options [Boolean] :usage_numbers
|
63
|
+
# @return [Array<TecDoc::Article>] list of articles
|
64
|
+
def self.all_with_details(options)
|
65
|
+
options = {
|
66
|
+
:lang => I18n.locale.to_s,
|
67
|
+
:country => TecDoc.client.country,
|
68
|
+
:attributs => true,
|
69
|
+
:ean_numbers => true,
|
70
|
+
:info => true,
|
71
|
+
:oe_numbers => true,
|
72
|
+
:usage_numbers => true,
|
73
|
+
:article_id => { :array => { :ids => options.delete(:ids) } }
|
74
|
+
}.merge(options)
|
75
|
+
|
76
|
+
TecDoc.client.request(:get_direct_articles_by_ids2, options).map do |attributes|
|
77
|
+
new(attributes, options)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def initialize(attributes = {}, scope = {})
|
82
|
+
article_data = (attributes[:direct_article] || attributes)
|
83
|
+
|
84
|
+
@id = article_data[:article_id].to_i
|
85
|
+
@name = article_data[:article_name].to_s
|
86
|
+
@number = article_data[:article_no].to_s
|
87
|
+
@brand_name = article_data[:brand_name].to_s
|
88
|
+
@brand_number = article_data[:brand_no].to_i
|
89
|
+
@generic_article_id = article_data[:generic_article_id].to_i
|
90
|
+
@number_type = article_data[:number_type].to_i
|
91
|
+
@search_number = article_data[:article_search_no].to_s
|
92
|
+
@state = article_data[:article_state_name]
|
93
|
+
@scope = scope
|
94
|
+
|
95
|
+
@ean_number = attributes[:ean_number].to_a.map(&:values).flatten.first
|
96
|
+
@trade_number = attributes[:usage_numbers].to_a.map(&:values).flatten.first
|
97
|
+
|
98
|
+
if attributes[:article_attributes]
|
99
|
+
@attributes = attributes[:article_attributes].map do |attrs|
|
100
|
+
ArticleAttribute.new(attrs)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes[:oen_numbers]
|
105
|
+
@oe_numbers = attributes[:oen_numbers].map do |attrs|
|
106
|
+
ArticleOENumber.new(attrs)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def state
|
112
|
+
@state ||= (article_details[:direct_article] || {})[:article_state_name]
|
113
|
+
end
|
114
|
+
|
115
|
+
def packing_unit
|
116
|
+
@packing_unit ||= (article_details[:direct_article] || {})[:packing_unit]
|
117
|
+
end
|
118
|
+
|
119
|
+
def brand
|
120
|
+
unless defined?(@brand)
|
121
|
+
@brand = Brand.new
|
122
|
+
@brand.number = brand_number
|
123
|
+
@brand.name = brand_name
|
124
|
+
end
|
125
|
+
@brand
|
126
|
+
end
|
127
|
+
|
128
|
+
def documents
|
129
|
+
@documents ||= ArticleDocument.all({
|
130
|
+
:lang => scope[:lang],
|
131
|
+
:country => scope[:country],
|
132
|
+
:article_id => id
|
133
|
+
})
|
134
|
+
end
|
135
|
+
|
136
|
+
def thumbnails
|
137
|
+
@thumbnails ||= ArticleThumbnail.all(:article_id => id)
|
138
|
+
end
|
139
|
+
|
140
|
+
def attributes
|
141
|
+
@attributes ||= article_details[:article_attributes].map do |attrs|
|
142
|
+
ArticleAttribute.new(attrs)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def ean_number
|
147
|
+
@ean_number ||= article_details[:ean_number].map(&:values).flatten.first
|
148
|
+
end
|
149
|
+
|
150
|
+
def oe_numbers
|
151
|
+
@oe_numbers ||= article_details[:oen_numbers].map do |attrs|
|
152
|
+
ArticleOENumber.new(attrs)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def trade_numbers
|
157
|
+
@trade_numbers ||= article_details[:usage_numbers].map(&:values).flatten.join(", ")
|
158
|
+
end
|
159
|
+
|
160
|
+
def information
|
161
|
+
@information ||= direct_article_data_en[:article_info]
|
162
|
+
end
|
163
|
+
|
164
|
+
def linked_manufacturers
|
165
|
+
unless @linked_manufacturers
|
166
|
+
response = TecDoc.client.request(:get_article_linked_all_linking_target_manufacturer, {
|
167
|
+
:country => scope[:country],
|
168
|
+
:linking_target_type => "C",
|
169
|
+
:article_id => id
|
170
|
+
})
|
171
|
+
|
172
|
+
@linked_manufacturers = response.map do |attrs|
|
173
|
+
VehicleManufacturer.new(attrs)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
@linked_manufacturers
|
177
|
+
end
|
178
|
+
|
179
|
+
# Array with all linked target vehicles with article link id
|
180
|
+
# If request entity is too large, we have to request linked targets by manufacturers
|
181
|
+
def linked_targets
|
182
|
+
unless @linked_targets
|
183
|
+
options = {
|
184
|
+
:lang => scope[:lang],
|
185
|
+
:country => scope[:country],
|
186
|
+
:linking_target_type => "C",
|
187
|
+
:linking_target_id => -1,
|
188
|
+
:article_id => id
|
189
|
+
}
|
190
|
+
begin
|
191
|
+
@linked_targets = TecDoc.client.request(:get_article_linked_all_linking_target_2, options)
|
192
|
+
rescue
|
193
|
+
@linked_targets = linked_manufacturers.inject([]) do |result, manufacturer|
|
194
|
+
options[:linking_target_manu_id] = manufacturer.id
|
195
|
+
result += TecDoc.client.request(:get_article_linked_all_linking_target_2, options)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
@linked_targets
|
200
|
+
end
|
201
|
+
|
202
|
+
def linked_vehicle_ids
|
203
|
+
@linked_vehicle_ids ||= linked_targets.map{ |attrs| attrs[:linking_target_id].to_i }.uniq
|
204
|
+
end
|
205
|
+
|
206
|
+
def linked_vehicles(options = {})
|
207
|
+
unless @linked_vehicles
|
208
|
+
batch_list = linked_vehicle_ids.each_slice(25).to_a
|
209
|
+
|
210
|
+
# Response from all batches
|
211
|
+
response = batch_list.inject([]) do |result, long_list|
|
212
|
+
result += TecDoc.client.request(:get_vehicle_by_ids_2,
|
213
|
+
{:car_ids => {
|
214
|
+
:array => {:ids => long_list}
|
215
|
+
},
|
216
|
+
:lang => scope[:lang],
|
217
|
+
:country => scope[:country],
|
218
|
+
:country_user_setting => scope[:country],
|
219
|
+
:countries_car_selection => scope[:country],
|
220
|
+
:motor_codes => true,
|
221
|
+
:axles => false,
|
222
|
+
:cabs => false,
|
223
|
+
:secondary_types => false,
|
224
|
+
:vehicle_details2 => true,
|
225
|
+
:vehicle_terms => false,
|
226
|
+
:wheelbases => false
|
227
|
+
})
|
228
|
+
result
|
229
|
+
end
|
230
|
+
|
231
|
+
@linked_vehicles = response.map do |attrs|
|
232
|
+
details = (attrs[:vehicle_details2] || {})
|
233
|
+
vehicle = Vehicle.new
|
234
|
+
vehicle.id = attrs[:car_id].to_i
|
235
|
+
vehicle.name = "#{details[:manu_name]} - #{details[:model_name]} - #{details[:type_name]}"
|
236
|
+
vehicle.power_hp_from = details[:power_hp].to_i
|
237
|
+
vehicle.power_kw_from = details[:power_kw].to_i
|
238
|
+
vehicle.cylinder_capacity = details[:cylinder_capacity_ccm].to_i
|
239
|
+
vehicle.date_of_construction_from = DateParser.new(details[:year_of_construction_from]).to_date
|
240
|
+
vehicle.date_of_construction_to = DateParser.new(details[:year_of_construction_to]).to_date
|
241
|
+
vehicle.motor_codes = attrs[:motor_codes].map { |mc| mc[:motor_code] }
|
242
|
+
vehicle
|
243
|
+
end
|
244
|
+
end
|
245
|
+
@linked_vehicles
|
246
|
+
end
|
247
|
+
|
248
|
+
# Linked vehicles for article with car specific attributes
|
249
|
+
def linked_vehicles_with_details(options = {})
|
250
|
+
unless @linked_vehicles_with_details
|
251
|
+
links = linked_targets.map do |link|
|
252
|
+
new_link = link.dup
|
253
|
+
new_link.delete(:linking_target_type)
|
254
|
+
new_link
|
255
|
+
end
|
256
|
+
batch_list = links.each_slice(25).to_a
|
257
|
+
|
258
|
+
# Response from all batches
|
259
|
+
response = batch_list.inject([]) do |result, long_list|
|
260
|
+
result += TecDoc.client.request(:get_article_linked_all_linking_targets_by_ids_2, {
|
261
|
+
:linked_article_pairs => { :array => {:pairs => long_list} },
|
262
|
+
:lang => scope[:lang],
|
263
|
+
:country => scope[:country],
|
264
|
+
:linking_target_type => "C",
|
265
|
+
:immediate_attributs => true,
|
266
|
+
:article_id => id
|
267
|
+
})
|
268
|
+
result
|
269
|
+
end
|
270
|
+
|
271
|
+
@linked_vehicles_with_details = response.map do |attrs|
|
272
|
+
details = (attrs[:linked_vehicles].to_a[0] || {})
|
273
|
+
vehicle = Vehicle.new
|
274
|
+
vehicle.id = details[:car_id].to_i
|
275
|
+
vehicle.name = "#{details[:manu_desc]} - #{details[:model_desc]} - #{details[:car_desc]}"
|
276
|
+
vehicle.manu_id = details[:manu_id].to_i
|
277
|
+
vehicle.mod_id = details[:model_id].to_i
|
278
|
+
vehicle.power_hp_from = details[:power_hp_from].to_i
|
279
|
+
vehicle.power_kw_from = details[:power_kw_from].to_i
|
280
|
+
vehicle.power_hp_to = details[:power_hp_to].to_i
|
281
|
+
vehicle.power_kw_to = details[:power_kw_to].to_i
|
282
|
+
vehicle.cylinder_capacity = details[:cylinder_capacity].to_i
|
283
|
+
vehicle.date_of_construction_from = DateParser.new(details[:year_of_construction_from]).to_date
|
284
|
+
vehicle.date_of_construction_to = DateParser.new(details[:year_of_construction_to]).to_date
|
285
|
+
vehicle.attributes = attrs[:linked_article_immediate_attributs].to_a
|
286
|
+
vehicle.article_link_id = attrs[:article_link_id].to_i
|
287
|
+
vehicle
|
288
|
+
end
|
289
|
+
end
|
290
|
+
@linked_vehicles_with_details
|
291
|
+
end
|
292
|
+
|
293
|
+
private
|
294
|
+
|
295
|
+
def article_details
|
296
|
+
@article_details ||= TecDoc.client.request(:get_direct_articles_by_ids2, {
|
297
|
+
:lang => scope[:lang],
|
298
|
+
:country => scope[:country],
|
299
|
+
:article_id => { :array => { :ids => [id] } },
|
300
|
+
:attributs => true,
|
301
|
+
:ean_numbers => true,
|
302
|
+
:oe_numbers => true,
|
303
|
+
:usage_numbers => true
|
304
|
+
})[0]
|
305
|
+
end
|
306
|
+
|
307
|
+
# Direct article to get all detail info
|
308
|
+
def direct_article_data_en
|
309
|
+
@direct_article_data_en ||= TecDoc.client.request(:get_direct_articles_by_ids2, {
|
310
|
+
:lang => "en",
|
311
|
+
:country => TecDoc.client.country,
|
312
|
+
:info => true,
|
313
|
+
:article_id => { :array => { :ids => [id] } }
|
314
|
+
})[0]
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|