Class: Awesomekit::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/awesomekit/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key) ⇒ Client

Returns a new instance of Client.



9
10
11
# File 'lib/awesomekit/client.rb', line 9

def initialize(api_key)
  self.class.headers('X-Typekit-Token' => api_key)
end

Instance Method Details

#get_kit(kit_id, published = false) ⇒ Object

PUBLIC: Returns information about a kit found by kit_id Endpoint reference: typekit.com/docs/api/v1/:format/kits/:kit

published=false returns the default, current draft version of the kit published=true returns the current published version of a kit



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/awesomekit/client.rb', line 28

def get_kit(kit_id, published=false)
  if published
    response = self.class.get("/kits/#{kit_id}/published")
  else
    response = self.class.get("/kits/#{kit_id}")
  end

  process_errors(response)

  response['kit']
end

#get_kitsObject

PUBLIC: Returns a list of kits owned by the authenticating user Endpoint reference: typekit.com/docs/api/v1/:format/kits



15
16
17
18
19
20
21
# File 'lib/awesomekit/client.rb', line 15

def get_kits
  response = self.class.get("/kits")

  process_errors(response)

  response['kits']
end