class InContact::Api

Attributes

token[R]

Public Class Methods

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

Public Instance Methods

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

Private Instance Methods

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

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

  resource_model.new(connection)
end