Class: EOL::Products

Inherits:
Object
  • Object
show all
Defined in:
lib/eol_rb/products.rb

Overview

Class for retrieving information about Products

Defined Under Namespace

Classes: NotFoundError

Class Method Summary collapse

Class Method Details

.all(client) ⇒ Object



11
12
13
# File 'lib/eol_rb/products.rb', line 11

def all(client)
  JSON.parse(client.get("/all.json").body)
end

.get(client, product) ⇒ Object

Raises:



15
16
17
18
19
20
# File 'lib/eol_rb/products.rb', line 15

def get(client, product)
  res = client.get("/#{product}.json")
  raise NotFoundError, "Product #{product} could not be found in the API" if res.status == 404

  JSON.parse(res.body).map { |p| Models::Cycle.new(p) }
end