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
31
32
33
34
35
36
|
# File 'lib/typekitty/api.rb', line 31
def self.handle_response response
case response.code
when 200 then response
when 401 then raise UnauthorizedError
end
end
|
.kit(id) ⇒ Object
19
20
21
22
23
|
# File 'lib/typekitty/api.rb', line 19
def self.kit id
response = handle_response get "/kits/#{id}"
response['kit']
end
|
.kits ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/typekitty/api.rb', line 11
def self.kits
response = handle_response get '/kits'
response['kits'].inject([]) do |kits, kit|
kits << self.kit(kit['id'])
end
end
|
.libraries ⇒ Object
25
26
27
28
29
|
# File 'lib/typekitty/api.rb', line 25
def self.libraries
response = handle_response get '/libraries'
response['libraries']
end
|