class InContactClient::Api

Attributes

token[R]

Public Class Methods

new() click to toggle source
# File lib/incontact_client/api.rb, line 5
def initialize
  @token = InContactClient::Tokens.get
end

Public Instance Methods

agent_sessions() click to toggle source
# File lib/incontact_client/api.rb, line 17
def agent_sessions
  @agent_sessions ||=  create_resource(InContactClient::Resources::AGENT_SESSIONS)
end
agents() click to toggle source
# File lib/incontact_client/api.rb, line 9
def agents
  @agents ||= create_resource(InContactClient::Resources::AGENTS)
end
contacts() click to toggle source
# File lib/incontact_client/api.rb, line 13
def contacts
  @contacts ||= create_resource(InContactClient::Resources::CONTACTS)
end

Private Instance Methods

create_connection(data_model) click to toggle source
# File lib/incontact_client/api.rb, line 31
def create_connection(data_model)
  url           = token.resource_server_base_uri
  authorization = token.authorization
  options       = { default_data_model: data_model }

  InContactClient::Connection.new(url, authorization, options)
end
create_resource(resource) click to toggle source
# File lib/incontact_client/api.rb, line 23
def create_resource(resource)
  resource_model = "InContactClient::#{resource}".constantize
  data_model     = "InContactClient::Responses::#{resource.singularize}Response".constantize
  connection     = create_connection(data_model)

  resource_model.new(connection)
end