Class: Gista::ApiRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/gista/api_request.rb

Overview

Base class for JSON requests to the Github API. ApiRequest knows how to send a request with a JSON body and parse the results. Use fetch to read values from the JSON response.

Raises an exception when not authorized or when the API request responds with something other than an OK.

Direct Known Subclasses

GistRequest, TokenRequest

Constant Summary collapse

URL =
'api.github.com'
PORT =
443
OPEN_TIMEOUT =
10
READ_TIMEOUT =
10
CONTENT_TYPE =
'application/json'

Instance Method Summary collapse

Instance Method Details

#fetch(key) ⇒ Object

Read a key from the response.



20
21
22
# File 'lib/gista/api_request.rb', line 20

def fetch(key)
  result.fetch(key)
end