class Edmunds::Vehicle::Specification::Style::StylesDetails

Attributes

count[R]
styles[R]

Public Class Methods

find(make_name, model_name, model_year, api_params = {}) click to toggle source
# File lib/edmunds/vehicle/specification/style.rb, line 52
def self.find(make_name, model_name, model_year, api_params = {})
  response = Edmunds::Api.get("#{BASE_API_URL}/#{make_name}/#{model_name}/#{model_year}/styles") do |request|
    request.raw_parameters = api_params

    request.allowed_parameters = {
      submodel: Edmunds::Vehicle::SUBMODEL_REGEX,
      category: Edmunds::Vehicle::VEHICLE_CATEGORIES,
      state: %w[new used future],
      year: ((1990.to_s)..(Date.current.year.to_s)),
      view: %w[basic full],
      fmt:  %w[json]
    }

    request.default_parameters = { view: 'basic', fmt: 'json' }

    request.required_parameters = %w[fmt]
  end

  attributes = JSON.parse(response.body)
  new(attributes)
end
new(attributes) click to toggle source
# File lib/edmunds/vehicle/specification/style.rb, line 47
def initialize(attributes)
  @count = attributes['stylesCount']
  @styles = attributes['styles'].map { |json| Style.new(json) } if attributes.key?('styles')
end