Class: Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Agents

Inherits:
AsteriskConfigGenerator show all
Defined in:
lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb

Constant Summary

Constants inherited from AsteriskConfigGenerator

Adhearsion::VoIP::Asterisk::ConfigFileGenerators::AsteriskConfigGenerator::SECTION_TITLE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AsteriskConfigGenerator

create_sanitary_hash_from, #to_sanitary_hash, warning_message

Constructor Details

#initializeAgents

Returns a new instance of Agents.



10
11
12
13
14
15
16
17
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 10

def initialize
  @general_section       = {}
  @agent_section         = {}
  @agent_section_special = {} # Uses => separator
  @agent_definitions     = []

  super
end

Instance Attribute Details

#agent_definitionsObject

Returns the value of attribute agent_definitions.



9
10
11
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 9

def agent_definitions
  @agent_definitions
end

#agent_sectionObject

Returns the value of attribute agent_section.



9
10
11
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 9

def agent_section
  @agent_section
end

#agent_section_specialObject

Returns the value of attribute agent_section_special.



9
10
11
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 9

def agent_section_special
  @agent_section_special
end

#general_sectionObject

Returns the value of attribute general_section.



9
10
11
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 9

def general_section
  @general_section
end

Instance Method Details

#agent(id, properties) ⇒ Object



30
31
32
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 30

def agent(id, properties)
  agent_definitions << {:id => id}.merge(properties)
end

#allow_multiple_logins_per_extension(yes_or_no) ⇒ Object

enable or disable a single extension from longing in as multiple agents, defaults to enabled



49
50
51
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 49

def allow_multiple_logins_per_extension(yes_or_no)
  general_section[:multiplelogin] = boolean_to_yes_no yes_or_no
end

#allow_star_to_hangup(yes_or_no) ⇒ Object

Define endcall to allow an agent to hangup a call by ‘*’. Default is “yes”. Set this to “no” to ignore ‘*’.



82
83
84
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 82

def allow_star_to_hangup(yes_or_no)
  agent_section[:endcall] = boolean_to_yes_no yes_or_no
end

#change_cdr_source(yes_or_no) ⇒ Object

Define updatecdr. This is whether or not to change the source channel in the CDR record for this call to agent/agent_id so that we know which agent generates the call



110
111
112
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 110

def change_cdr_source(yes_or_no)
  agent_section[:updatecdr] =  boolean_to_yes_no yes_or_no
end

#groups(*args) ⇒ Object

Group memberships for agents (may change in mid-file) WHAT DOES GROUPING ACCOMPLISH?



36
37
38
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 36

def groups(*args)
  agent_section[:group] = args.join(",")
end

#hold_music_class(music_class) ⇒ Object

Define the default musiconhold for agents musiconhold => music_class



95
96
97
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 95

def hold_music_class(music_class)
  agent_section_special[:musiconhold] = music_class.to_s
end

#log_off_after_duration(time_in_seconds) ⇒ Object

Define autologoff times if appropriate. This is how long the phone has to ring with no answer before the agent is automatically logged off (in seconds)



62
63
64
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 62

def log_off_after_duration(time_in_seconds)
  agent_section[:autologoff] = time_in_seconds
end

#log_off_if_unavailable(yes_or_no) ⇒ Object

Define autologoffunavail to have agents automatically logged out when the extension that they are at returns a CHANUNAVAIL status when a call is attempted to be sent there. Default is “no”.



70
71
72
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 70

def log_off_if_unavailable(yes_or_no)
  agent_section[:autologoffunavail] = boolean_to_yes_no yes_or_no
end

#max_login_tries(number_of_tries) ⇒ Object

Define maxlogintries to allow agent to try max logins before failed. Default to 3



55
56
57
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 55

def (number_of_tries)
  agent_section[:maxlogintries] = number_of_tries
end

#persistent_agents(yes_or_no) ⇒ Object

Define whether callbacklogins should be stored in astdb for persistence. Persistent logins will be reloaded after Asterisk restarts.



43
44
45
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 43

def persistent_agents(yes_or_no)
  general_section[:persistentagents] = boolean_to_yes_no yes_or_no
end

#play_for_waiting_keep_alive(sound_file) ⇒ Object

An optional custom beep sound file to play to always-connected agents.



115
116
117
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 115

def play_for_waiting_keep_alive(sound_file)
  agent_section[:custom_beep] = sound_file
end

#play_on_agent_goodbye(sound_file_name) ⇒ Object

Define the default good bye sound file for agents default to vm-goodbye



103
104
105
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 103

def play_on_agent_goodbye(sound_file_name)
  agent_section_special[:agentgoodbye] = sound_file_name
end

#record_agent_calls(yes_or_no) ⇒ Object



119
120
121
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 119

def record_agent_calls(yes_or_no)
  agent_section[:recordagentcalls] = boolean_to_yes_no yes_or_no
end

#recording_format(symbol) ⇒ Object

Raises:

  • (ArgumentError)


123
124
125
126
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 123

def recording_format(symbol)
  raise ArgumentError, "Unrecognized format #{symbol}" unless [:wav, :wav49, :gsm].include? symbol
  agent_section[:recordformat] = symbol
end

#recording_prefix(string) ⇒ Object



128
129
130
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 128

def recording_prefix(string)
  agent_section[:urlprefix] = string
end

#require_hash_to_acknowledge(yes_or_no) ⇒ Object

Define ackcall to require an acknowledgement by ‘#’ when an agent logs in using agentcallbacklogin. Default is “no”.



76
77
78
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 76

def require_hash_to_acknowledge(yes_or_no)
  agent_section[:ackcall] = boolean_to_yes_no yes_or_no
end

#save_recordings_in(path_to_directory) ⇒ Object



132
133
134
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 132

def save_recordings_in(path_to_directory)
  agent_section[:savecallsin] = path_to_directory
end

#time_between_calls(time_in_seconds) ⇒ Object

Define wrapuptime. This is the minimum amount of time when after disconnecting before the caller can receive a new call note this is in milliseconds.



89
90
91
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 89

def time_between_calls(time_in_seconds)
  agent_section[:wrapuptime] = (time_in_seconds * 1000).to_i
end

#to_sObject Also known as: conf



19
20
21
22
23
24
25
26
27
# File 'lib/adhearsion/voip/asterisk/config_generators/agents.conf.rb', line 19

def to_s
  AsteriskConfigGenerator.warning_message +
  general_section.inject("[general]") { |section,(key,value)| section + "\n#{key}=#{value}" } +
  agent_section.inject("\n[agents]")  { |section,(key,value)| section + "\n#{key}=#{value}" } +
  agent_section_special.inject("")    { |section,(key,value)| section + "\n#{key} => #{value}" } +
  agent_definitions.inject("\n") do |section,properties|
    section + "\nagent => #{properties[:id]},#{properties[:password]},#{properties[:name]}"
  end
end