Class: Inkdit::Client
- Inherits:
-
Object
- Object
- Inkdit::Client
- Defined in:
- lib/inkdit/client.rb
Overview
a client that can issue authenticated HTTP requests to Inkdit’s API.
Instance Method Summary collapse
-
#delete(path, params) ⇒ OAuth2::Response
issue an HTTP
DELETE
. -
#get(path) ⇒ OAuth2::Response
issue an HTTP
GET
. -
#get_entity ⇒ Entity
The entity that this access token belongs to.
-
#initialize(token) ⇒ Client
constructor
token
is a Hash containing the details of the access token returned by get_token. -
#post(path, params) ⇒ OAuth2::Response
issue an HTTP
POST
. -
#put(path, params) ⇒ OAuth2::Response
issue an HTTP
PUT
.
Constructor Details
#initialize(token) ⇒ Client
token
is a Hash containing the details of the access token returned by Inkdit.get_token. The keys access_token
, refresh_token
, and expires_at
are required.
6 7 8 9 |
# File 'lib/inkdit/client.rb', line 6 def initialize(token) # AccessToken#from_hash modifies the hash it's passed. @access_token = OAuth2::AccessToken.from_hash(oauth_client, token.clone) end |
Instance Method Details
#delete(path, params) ⇒ OAuth2::Response
issue an HTTP DELETE
.
39 40 41 |
# File 'lib/inkdit/client.rb', line 39 def delete(path, params) request(:delete, path, {}) end |
#get(path) ⇒ OAuth2::Response
issue an HTTP GET
.
21 22 23 |
# File 'lib/inkdit/client.rb', line 21 def get(path) request(:get, path, {}) end |
#get_entity ⇒ Entity
Returns the entity that this access token belongs to.
12 13 14 15 16 17 |
# File 'lib/inkdit/client.rb', line 12 def get_entity response = get '/v1/' entity = response.parsed["entities"].first Entity.new(self, entity) end |
#post(path, params) ⇒ OAuth2::Response
issue an HTTP POST
.
27 28 29 |
# File 'lib/inkdit/client.rb', line 27 def post(path, params) request(:post, path, params) end |
#put(path, params) ⇒ OAuth2::Response
issue an HTTP PUT
.
33 34 35 |
# File 'lib/inkdit/client.rb', line 33 def put(path, params) request(:put, path, params) end |