Class: Quill::Client
- Inherits:
-
Object
- Object
- Quill::Client
- Includes:
- EndpointDefinitions
- Defined in:
- lib/quill/client.rb
Defined Under Namespace
Classes: InvalidKeys
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#config ⇒ Object
Returns the value of attribute config.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #get(path, params = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, params = {}) ⇒ Object
- #put(path, params = {}) ⇒ Object
- #request(verb, path, params = {}) ⇒ Object
Methods included from EndpointDefinitions
#activities, #activity_sessions, #me, #ping
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
8 9 10 11 |
# File 'lib/quill/client.rb', line 8 def initialize = {} @config = Configuration.new(, api_url: 'http://api.quill.org/') # raise ArgumentError, 'Missing access_token' if config.access_token.blank? end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/quill/client.rb', line 4 def client @client end |
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/quill/client.rb', line 4 def config @config end |
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'lib/quill/client.rb', line 4 def token @token end |
Instance Method Details
#get(path, params = {}) ⇒ Object
25 26 27 |
# File 'lib/quill/client.rb', line 25 def get path, params = {} request :get, path, params end |
#post(path, params = {}) ⇒ Object
29 30 31 |
# File 'lib/quill/client.rb', line 29 def post path, params = {} request :post, path, params end |
#put(path, params = {}) ⇒ Object
33 34 35 |
# File 'lib/quill/client.rb', line 33 def put path, params = {} request :put, path, params end |
#request(verb, path, params = {}) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/quill/client.rb', line 37 def request verb, path, params = {} key = if verb == :get then :params else :body end response = token.request verb, path, key => params raise response.error if response.status == 401 response end |