Class: Edmunds::Vehicle::Specification::Engine::EngineByStyle

Inherits:
Object
  • Object
show all
Defined in:
lib/edmunds/vehicle/specification/engine.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ EngineByStyle

Returns a new instance of EngineByStyle.



15
16
17
18
# File 'lib/edmunds/vehicle/specification/engine.rb', line 15

def initialize(attributes)
  @id = attributes['id']
  #TODO
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/edmunds/vehicle/specification/engine.rb', line 13

def id
  @id
end

Class Method Details

.find(style_id, api_params = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/edmunds/vehicle/specification/engine.rb', line 20

def self.find(style_id, api_params = {})
  response = Edmunds::Api.get("#{STYLE_API_URL}/#{style_id}/engines") do |request|
    request.raw_parameters = api_params

    request.allowed_parameters = {
      availability: Edmunds::Vehicle::ENGINE_AVAILABILITY, 
      name: /^s+/,
      fmt:  %w[json]
    }

    request.default_parameters = { fmt: 'json', availability: 'standard' }

    request.required_parameters = %w[fmt]
  end

  attributes = JSON.parse(response.body)
  new(attributes)
end