class Edmunds::Vehicle::Specification::Color::ColorsByStyle

Attributes

colors[R]
count[R]

Public Class Methods

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

    request.allowed_parameters = {
        category: %w[Interior Exterior],
        fmt: %w[json]
    }

    request.default_parameters = { 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/color.rb, line 15
def initialize(attributes)
  @colors = attributes['colors'].map { |json| ColorsDetails.new(json) } if attributes.key?('colors')
  @count = attributes['colorsCount']
end