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

Attributes

makes[R]

Public Class Methods

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

    request.allowed_parameters = {
        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/make.rb, line 16
def initialize(attributes)
  @makes = attributes['makes'].map { |json| Make.new(json) } if attributes.key?('makes')
end