Class: Typekitable::Request
- Inherits:
-
Object
- Object
- Typekitable::Request
- Defined in:
- lib/typekitable/request.rb
Constant Summary collapse
- BASE_URL =
"https://typekit.com/api/v1/json/"
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#verb ⇒ Object
readonly
Returns the value of attribute verb.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(path, verb, parameters) ⇒ Request
constructor
A new instance of Request.
- #response ⇒ Object
- #token ⇒ Object
- #uri ⇒ Object
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
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
3 4 5 |
# File 'lib/typekitable/request.rb', line 3 def parameters @parameters end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/typekitable/request.rb', line 3 def path @path end |
#verb ⇒ Object (readonly)
Returns the value of attribute verb.
3 4 5 |
# File 'lib/typekitable/request.rb', line 3 def verb @verb end |
Instance Method Details
#headers ⇒ Object
28 29 30 |
# File 'lib/typekitable/request.rb', line 28 def headers { "X-Typekit-Token" => token } end |
#response ⇒ Object
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 |
#token ⇒ Object
13 14 15 |
# File 'lib/typekitable/request.rb', line 13 def token Tokenizer.get_token end |
#uri ⇒ Object
24 25 26 |
# File 'lib/typekitable/request.rb', line 24 def uri URI.parse(BASE_URL + path) end |