class Edmunds::Vehicle::Specification::ModelYear::ModelYear
Attributes
id[R]
styles[R]
year[R]
Public Class Methods
find(make_name, model_name, model_year, api_params = {})
click to toggle source
# File lib/edmunds/vehicle/specification/model_year.rb, line 20 def self.find(make_name, model_name, model_year, api_params = {}) response = Edmunds::Api.get("#{MODEL_YEAR_API_URL}/#{make_name}/#{model_name}/#{model_year}") 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/model_year.rb, line 14 def initialize(attributes) @id = attributes['id'] @year = attributes['year'] @styles = attributes['styles'].map { |json| Edmunds::Vehicle::Specification::Style::Style.new(json) } if attributes.key?('styles') end