Class: Adhearsion::Asterisk::ConfigGenerator::Agents

Inherits:
Adhearsion::Asterisk::ConfigGenerator show all
Defined in:
lib/adhearsion/asterisk/config_generator/agents.rb

Constant Summary

Constants inherited from Adhearsion::Asterisk::ConfigGenerator

SECTION_TITLE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Adhearsion::Asterisk::ConfigGenerator

create_sanitary_hash_from, #to_sanitary_hash, warning_message

Constructor Details

#initializeAgents

Returns a new instance of Agents.



9
10
11
12
13
14
15
16
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 9

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.



8
9
10
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 8

def agent_definitions
  @agent_definitions
end

#agent_sectionObject

Returns the value of attribute agent_section.



8
9
10
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 8

def agent_section
  @agent_section
end

#agent_section_specialObject

Returns the value of attribute agent_section_special.



8
9
10
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 8

def agent_section_special
  @agent_section_special
end

#general_sectionObject

Returns the value of attribute general_section.



8
9
10
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 8

def general_section
  @general_section
end

Instance Method Details

#agent(id, properties) ⇒ Object



29
30
31
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 29

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



48
49
50
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 48

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 ‘*’.



81
82
83
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 81

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



109
110
111
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 109

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?



35
36
37
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 35

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

#hold_music_class(music_class) ⇒ Object

Define the default musiconhold for agents musiconhold => music_class



94
95
96
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 94

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)



61
62
63
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 61

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”.



69
70
71
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 69

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



54
55
56
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 54

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.



42
43
44
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 42

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.



114
115
116
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 114

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



102
103
104
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 102

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

#record_agent_calls(yes_or_no) ⇒ Object



118
119
120
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 118

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

#recording_format(symbol) ⇒ Object

Raises:

  • (ArgumentError)


122
123
124
125
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 122

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

#recording_prefix(string) ⇒ Object



127
128
129
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 127

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”.



75
76
77
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 75

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



131
132
133
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 131

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.



88
89
90
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 88

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

#to_sObject Also known as: conf



18
19
20
21
22
23
24
25
26
# File 'lib/adhearsion/asterisk/config_generator/agents.rb', line 18

def to_s
  ConfigGenerator.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