Module: Typekitty::API
- Includes:
- HTTParty
- Defined in:
- lib/typekitty/api.rb
Defined Under Namespace
Classes: UnauthorizedError
Class Method Summary
collapse
Class Method Details
.handle_response(response) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/typekitty/api.rb', line 26
def self.handle_response response
case response.code
when 200 then response
when 401 then raise UnauthorizedError
end
end
|
.kit(id) ⇒ Object
20
21
22
23
24
|
# File 'lib/typekitty/api.rb', line 20
def self.kit id
response = handle_response get "/kits/#{id}"
Typekitty::Kit.new response['kit']
end
|
.kits ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/typekitty/api.rb', line 12
def self.kits
response = handle_response get '/kits'
response['kits'].inject([]) do |kits, kit|
kits << self.kit(kit['id'])
end
end
|