Class: Adhearsion::VoIP::Asterisk::ConfigFileGenerators::Queues::QueueDefinition

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

Constant Summary collapse

DEFAULT_QUEUE_PROPERTIES =
{
  :autofill          => 'yes',
  :eventwhencalled   => 'vars',
  :eventmemberstatus => 'yes',
  :setinterfacevar   => 'yes'
}
SUPPORTED_RING_STRATEGIES =
[:ringall, :roundrobin, :leastrecent, :fewestcalls, :random, :rrmemory]
DEFAULT_SOUND_FILES =
{
  'queue-youarenext'   => 'queue-youarenext',
  'queue-thereare'     => 'queue-thereare',
  'queue-callswaiting' => 'queue-callswaiting',
  'queue-holdtime'     => 'queue-holdtime',
  'queue-minutes'      => 'queue-minutes',
  'queue-seconds'      => 'queue-seconds',
  'queue-thankyou'     => 'queue-thankyou',
  'queue-lessthan'     => 'queue-less-than',
  'queue-reporthold'   => 'queue-reporthold',
  'periodic-announce'  => 'queue-periodic-announce'
}
SOUND_FILE_SYMBOL_INTERPRETATIONS =
{
  :you_are_next           => 'queue-youarenext',
  :there_are              => 'queue-thereare',
  :calls_waiting          => 'queue-callswaiting',
  :hold_time              => 'queue-holdtime',
  :minutes                => 'queue-minutes',
  :seconds                => 'queue-seconds',
  :thank_you              => 'queue-thankyou',
  :less_than              => 'queue-lessthan',
  :report_hold            => 'queue-reporthold',
  :periodic_announcement  => 'periodic-announce'
}

Constants inherited from AsteriskConfigGenerator

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

#initialize(name) ⇒ QueueDefinition

Returns a new instance of QueueDefinition.



88
89
90
91
92
93
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 88

def initialize(name)
  @name        = name
  @members     = []
  @properties  = DEFAULT_QUEUE_PROPERTIES.clone
  @sound_files = DEFAULT_SOUND_FILES.clone
end

Instance Attribute Details

#membersObject (readonly)

Returns the value of attribute members.



87
88
89
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 87

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name.



87
88
89
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 87

def name
  @name
end

#propertiesObject (readonly)

Returns the value of attribute properties.



87
88
89
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 87

def properties
  @properties
end

Instance Method Details

#announce_hold_time(seconds) ⇒ Object



167
168
169
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 167

def announce_hold_time(seconds)
  one_of [true, false, :once], "announce-holdtime" => seconds
end

#announce_round_seconds(yes_no_or_once) ⇒ Object



171
172
173
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 171

def announce_round_seconds(yes_no_or_once)
  int "announce-round-seconds" => yes_no_or_once
end

#autopause(yes_no) ⇒ Object



148
149
150
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 148

def autopause(yes_no)
  boolean :autopause => yes_no
end

#delay_connection_by(seconds) ⇒ Object

Number of seconds to wait when an agent is to be bridged with a caller. Normally you’d want this to be zero.



204
205
206
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 204

def delay_connection_by(seconds)
  int :memberdelay => seconds
end

#exit_to_context_on_digit_press(context_name) ⇒ Object

A context may be specified, in which if the user types a SINGLE digit extension while they are in the queue, they will be taken out of the queue and sent to that extension in this context. This context should obviously be a different context other than the one that normally forwards to Adhearsion (though the context that handles these digits should probably go out to Adhearsion too).



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

def exit_to_context_on_digit_press(context_name)
  string :context => context_name
end

#join_empty(yes_no_or_strict) ⇒ Object

Ex: join_empty true Ex: join_empty :strict



186
187
188
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 186

def join_empty(yes_no_or_strict)
  one_of [true, false, :strict], :joinempty => yes_no_or_strict
end

#leave_when_empty(yes_no) ⇒ Object



190
191
192
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 190

def leave_when_empty(yes_no)
  boolean :leavewhenempty => yes_no
end

#maximum_length(number) ⇒ Object



152
153
154
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 152

def maximum_length(number)
  int :maxlen => number
end

#member(driver) ⇒ Object



240
241
242
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 240

def member(driver)
  members << (driver.kind_of?(String) && driver =~ %r'/' ? driver : "Agent/#{driver}")
end

#monitor_format(symbol) ⇒ Object



175
176
177
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 175

def monitor_format(symbol)
  one_of [:wav, :gsm, :wav49], 'monitor-format' => symbol
end

#monitor_type(symbol) ⇒ Object



179
180
181
182
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 179

def monitor_type(symbol)
  criteria = {:monitor => "Monitor", :mix_monitor => "MixMonitor"}
  one_of_and_translate criteria, 'monitor-type' => symbol
end

#music_class(moh_identifier) ⇒ Object



101
102
103
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 101

def music_class(moh_identifier)
  string :musicclass => moh_identifier
end

#periodically_announce(sound_file, options = {}) ⇒ Object



160
161
162
163
164
165
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 160

def periodically_announce(sound_file, options={})
  frequency = options.delete(:every) || 1.minute

  string 'periodic-announce' => sound_file
  int 'periodic-announce-frequency' => frequency
end

#play_on_connect(sound_file) ⇒ Object



105
106
107
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 105

def play_on_connect(sound_file)
  string :announce => sound_file
end

#queue_status_announce_frequency(seconds) ⇒ Object



156
157
158
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 156

def queue_status_announce_frequency(seconds)
  int "announce-frequency" => seconds
end

#report_hold_time(yes_no) ⇒ Object



194
195
196
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 194

def report_hold_time(yes_no)
  boolean :reportholdtime => yes_no
end

#retry_after_waiting(seconds) ⇒ Object

Ex: retry_after_waiting 5.seconds



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

def retry_after_waiting(seconds)
  int :retry => seconds
end

#ring_in_use(yes_no) ⇒ Object



198
199
200
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 198

def ring_in_use(yes_no)
  boolean :ringinuse => yes_no
end

#ring_timeout(seconds) ⇒ Object

Ex: ring_timeout 15.seconds



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

def ring_timeout(seconds)
  int :timeout => seconds
end

#service_level(seconds) ⇒ Object



113
114
115
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 113

def service_level(seconds)
  int :servicelevel => seconds
end

#sound_files(hash_of_files) ⇒ Object

Give a Hash argument here to override the default sound files for this queue.

Usage:

queue.sound_files :you_are_next          => 'queue-youarenext',
                  :there_are             => 'queue-thereare',
                  :calls_waiting         => 'queue-callswaiting',
                  :hold_time             => 'queue-holdtime',
                  :minutes               => 'queue-minutes',
                  :seconds               => 'queue-seconds',
                  :thank_you             => 'queue-thankyou',
                  :less_than             => 'queue-less-than',
                  :report_hold           => 'queue-reporthold',
                  :periodic_announcement => 'queue-periodic-announce'

Note: the Hash values are the defaults. You only need to specify the ones you wish to override.



229
230
231
232
233
234
235
236
237
238
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 229

def sound_files(hash_of_files)
  hash_of_files.each_pair do |key, value|
    unless SOUND_FILE_SYMBOL_INTERPRETATIONS.has_key? key
      message = "Unrecogized sound file identifier #{key.inspect}. " +
            "Supported: " + SOUND_FILE_SYMBOL_INTERPRETATIONS.keys.map(&:inspect).to_sentence
      raise ArgumentError, message
    end
    @sound_files[SOUND_FILE_SYMBOL_INTERPRETATIONS[key]] = value
  end
end

#strategy(symbol) ⇒ Object



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

def strategy(symbol)
  one_of SUPPORTED_RING_STRATEGIES, :strategy => symbol
end

#timeout_restart(yes_no) ⇒ Object



208
209
210
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 208

def timeout_restart(yes_no)
  boolean :timeoutrestart => yes_no
end

#to_sObject



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

def to_s
  "[#{name}]\n" +
  properties.merge(@sound_files).map { |key, value| "#{key}=#{value}" }.sort.join("\n") + "\n\n" +
  members.map { |member| "member => #{member}" }.join("\n")
end

#weight(number) ⇒ Object

THIS IS UNSUPPORTED



138
139
140
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 138

def weight(number)
  int :weight => number
end

#wrapup_time(seconds) ⇒ Object

Ex: wrapup_time 1.minute



143
144
145
# File 'lib/adhearsion/voip/asterisk/config_generators/queues.conf.rb', line 143

def wrapup_time(seconds)
  int :wrapuptime => seconds
end