Class: Gummy::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/gummy/product.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Product

Returns a new instance of Product.



10
11
12
# File 'lib/lib/gummy/product.rb', line 10

def initialize(attributes)
  #@description = attributes["description"]
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/lib/gummy/product.rb', line 8

def description
  @description
end

#idObject

Returns the value of attribute id.



8
9
10
# File 'lib/lib/gummy/product.rb', line 8

def id
  @id
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/lib/gummy/product.rb', line 8

def name
  @name
end

Class Method Details

.allObject



14
15
16
17
18
# File 'lib/lib/gummy/product.rb', line 14

def self.all
  response = Faraday.get("#{API_ROOT}", {'access_token' => Gummy.token})
  cars = JSON.parse(response.body)
  cars.map { |attributes| new(attributes)  }
end

.find(id) ⇒ Object



20
21
22
23
24
# File 'lib/lib/gummy/product.rb', line 20

def self.find(id)
  response = Faraday.get("#{API_ROOT}/#{id}", {'access_token' => Gummy.token})
  attributes = JSON.parse(response.body)
  new(attributes)
end