Class: Quill::Client

Inherits:
Object
  • Object
show all
Includes:
EndpointDefinitions
Defined in:
lib/quill/client.rb

Defined Under Namespace

Classes: InvalidKeys

Instance Attribute Summary collapse

Instance Method Summary collapse

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 options = {}
  @config = Configuration.new(options, api_url: 'http://api.quill.org/')
  # raise ArgumentError, 'Missing access_token' if config.access_token.blank?
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/quill/client.rb', line 4

def client
  @client
end

#configObject

Returns the value of attribute config.



4
5
6
# File 'lib/quill/client.rb', line 4

def config
  @config
end

#tokenObject

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