class Edmunds::Vehicle::Specification::Make::Make

Attributes

id[R]
models[R]
name[R]
nice_name[R]

Public Class Methods

find(name, api_params = {}) click to toggle source
# File lib/edmunds/vehicle/specification/make.rb, line 51
def self.find(name, api_params = {})
  response = Edmunds::Api.get("#{MAKE_API_URL}/#{name}") do |request|
    request.raw_parameters = api_params

    request.allowed_parameters = {
        state: %w[new used future],
        year: ((1990.to_s)..(Date.today.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/make.rb, line 44
def initialize(attributes)
  @id = attributes['id']
  @name = attributes['name']
  @nice_name = attributes['niceName']
  @models = attributes['models'].map { |json| Edmunds::Vehicle::Specification::Model::Model.new(json) } if attributes.key?('models')
end