Method: TecDoc::Vehicle.all

Defined in:
lib/tec_doc/vehicle.rb

.all(options = {}) ⇒ Array<TecDoc::VehicleManufacturer>

Find vehicles for simplified selection with motor codes

Options Hash (options):

  • :car_type (Integer)

    vehicle type (1: Passenger car, 2: Commercial vehicle, 3: Light commercial)

  • :countries_car_selection (String)

    country code according to ISO 3166

  • :country_group_flag (TrueClass, FalseClass)

    country group selection

  • :country_user_setting (String)

    country for article assignments, country code according to assignments ISO 3166 (optional)

  • :favoured_list (Integer, NilClass)

    simplified vehicle selection (1: first list selection, 0: rest)

  • :lang (String)

    language code according to ISO 639

  • :linked (TrueClass, FalseClass)

    selection with/without article assignments (false: all, true: only linked articles)

  • :manu_id (Integer)

    manufacturer ID

  • :mod_id (Integer)

    vehicle ID



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/tec_doc/vehicle.rb', line 35

def self.all(options = {})
  options = {
    :car_type => 1,
    :countries_car_selection => TecDoc.client.country,
    :country_group_flag => false,
    :favoured_list => 1,
    :lang => I18n.locale.to_s,
    :linked => false
  }.merge(options)
  response = TecDoc.client.request(:get_vehicle_simplified_selection4, options)
  response.map do |attributes|
    vehicle = new
    car_attributes = attributes[:car_details]
    if car_attributes
      vehicle.manu_id                   = options[:manu_id].to_i
      vehicle.mod_id                    = options[:mod_id].to_i
      vehicle.id                        = car_attributes[:car_id].to_i
      vehicle.name                      = car_attributes[:car_name].to_s
      vehicle.cylinder_capacity         = car_attributes[:cylinder_capacity].to_i
      vehicle.first_country             = car_attributes[:first_country].to_s
      vehicle.linked                    = car_attributes[:linked]
      vehicle.power_hp_from             = car_attributes[:power_hp_from].to_i
      vehicle.power_hp_to               = car_attributes[:power_hp_to].to_i
      vehicle.power_kw_from             = car_attributes[:power_kw_from].to_i
      vehicle.power_kw_to               = car_attributes[:power_kw_to].to_i
      vehicle.date_of_construction_from = DateParser.new(car_attributes[:year_of_constr_from]).to_date
      vehicle.date_of_construction_to   = DateParser.new(car_attributes[:year_of_constr_to]).to_date
    end
    vehicle.motor_codes = attributes[:motor_codes].map { |mc| mc[:motor_code] }
    vehicle
  end
end