Class: Typekitable::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/typekitable/request.rb

Constant Summary collapse

BASE_URL =
"https://typekit.com/api/v1/json/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, verb, parameters) ⇒ Request

Returns a new instance of Request.



7
8
9
10
11
# File 'lib/typekitable/request.rb', line 7

def initialize(path, verb, parameters)
  @path = path
  @verb = verb
  @parameters = parameters
end

Instance Attribute Details

#parametersObject (readonly)

Returns the value of attribute parameters.



3
4
5
# File 'lib/typekitable/request.rb', line 3

def parameters
  @parameters
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/typekitable/request.rb', line 3

def path
  @path
end

#verbObject (readonly)

Returns the value of attribute verb.



3
4
5
# File 'lib/typekitable/request.rb', line 3

def verb
  @verb
end

Instance Method Details

#headersObject



28
29
30
# File 'lib/typekitable/request.rb', line 28

def headers
  { "X-Typekit-Token" => token }
end

#responseObject



17
18
19
20
21
22
# File 'lib/typekitable/request.rb', line 17

def response
  case verb
    when "GET" then get_request_response
    when "POST" then post_request_response
  end
end

#tokenObject



13
14
15
# File 'lib/typekitable/request.rb', line 13

def token
  Tokenizer.get_token
end

#uriObject



24
25
26
# File 'lib/typekitable/request.rb', line 24

def uri
  URI.parse(BASE_URL + path)
end