class OctadeskApi::Client

Public Class Methods

new(access_token = nil) click to toggle source
# File lib/octadesk_api/client.rb, line 9
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'}, verify: OctadeskApi.production? )
end

Public Instance Methods

get(path, options = {}) click to toggle source
# File lib/octadesk_api/client.rb, line 32
def get(path, options  = {})
  self.class.get(path, options)
end
organizations() click to toggle source
# File lib/octadesk_api/client.rb, line 24
def organizations
  @organizations_client ||= OrganizationApi.new(self)
end
perform_request(path) click to toggle source
# File lib/octadesk_api/client.rb, line 15
def perform_request(path)
  response = self.class.get(path)
  response
end
persons() click to toggle source
# File lib/octadesk_api/client.rb, line 20
def persons
  @person_client ||= PersonApi.new(self)
end
post(path, options = {}) click to toggle source
# File lib/octadesk_api/client.rb, line 36
def post(path, options = {})
  self.class.post(path, body: options.to_json, headers: default_headers)
end
put(path, options = {}) click to toggle source
# File lib/octadesk_api/client.rb, line 40
def put(path, options = {})
  self.class.put(path, body: options.to_json, headers: default_headers)
end
tickets() click to toggle source
# File lib/octadesk_api/client.rb, line 28
def tickets
  @tickets_client ||= TicketApi.new(self)
end

Private Instance Methods

default_headers() click to toggle source
# File lib/octadesk_api/client.rb, line 45
def default_headers
  { 'Content-Type' => 'application/json' }
end