Class: OctadeskApi::Client
- Inherits:
-
Object
- Object
- OctadeskApi::Client
show all
- Includes:
- HTTParty
- Defined in:
- lib/octadesk_api/client.rb,
lib/octadesk_api/client/person_api.rb,
lib/octadesk_api/client/organization_api.rb
Defined Under Namespace
Classes: OrganizationApi, PersonApi
Instance Method Summary
collapse
Constructor Details
#initialize(access_token = nil) ⇒ Client
Returns a new instance of Client.
8
9
10
11
12
|
# File 'lib/octadesk_api/client.rb', line 8
def initialize access_token = nil
@access_token = access_token || OctadeskApi.access_key || ENV['OCTADESK_ACCESS_TOKEN']
raise OctadeskApi::MissingTokenError unless @access_token
self.class.default_options.merge!(headers: { 'Authorization' => "Bearer #{access_token}", 'Content-Type' => 'application/json' } )
end
|
Instance Method Details
#get(path, options = {}) ⇒ Object
27
28
29
|
# File 'lib/octadesk_api/client.rb', line 27
def get(path, options = {})
self.class.get(path, options)
end
|
#organizations ⇒ Object
23
24
25
|
# File 'lib/octadesk_api/client.rb', line 23
def organizations
@organizations_client ||= OrganizationApi.new(self)
end
|
14
15
16
17
|
# File 'lib/octadesk_api/client.rb', line 14
def perform_request(path)
response = self.class.get(path)
response
end
|
#persons ⇒ Object
19
20
21
|
# File 'lib/octadesk_api/client.rb', line 19
def persons
@person_client ||= PersonApi.new(self)
end
|
#post(path, options = {}) ⇒ Object
31
32
33
|
# File 'lib/octadesk_api/client.rb', line 31
def post(path, options = {})
self.class.post(path, body: options.to_json, headers: )
end
|
#put(path, options = {}) ⇒ Object
35
36
37
|
# File 'lib/octadesk_api/client.rb', line 35
def put(path, options = {})
self.class.put(path, body: options.to_json, headers: )
end
|