The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Asterisk::LCR::Dialer - Generic dialer object

SYNOPSIS

  use Asterisk::LCR::Dialer;
  my $dialer = Asterisk::LCR::Dialer::<CONCRETE_CLASS>->new ();

SUMMARY

Represents a generic dialing strategy. The strategy is defined in the $self->process() method, which in this package is undefined.

ATTRIBUTES

lcr (scalar)

Location (directory) of the lcr object tree.

agi (Asterisk::AGI object)

An AGI object which can be used to grab some parameters from.

limit (numerical scalar)

Limit dialing strategies to 'limit' cheapest routes. Optional.

opts (scalar)

Options to be appended to the dialstring. Example:

  '120|HS(7200)'

METHODS

$self->validate();

Returns TRUE if this object validates, FALSE otherwise.

$self->validate_lcr();

Returns TRUE if there is a 'lcr' attribute and it's an existing directory, FALSE otherwise.

$self->lcr();

Returns the 'lcr' attribute.

$self->set_lcr ($lcr);

Sets the 'lcr' attribute to $lcr.

$self->locale();

Returns the 'locale' attribute.

$self->set_locale ($locale);

Sets the 'locale' attribute to $locale.

$self->validate_agi();

Returns TRUE if the 'agi' attribute exists, FALSE otherwise.

$self->agi();

Returns the 'agi' attribute.

$self->set_agi ($lcr);

Sets the 'agi' attribute to $agi.

$self->limit();

Returns the optional 'limit' attribute.

Returns 100000 if it's not defined (quasi-infinity)

$self->set_limit ($limit);

Sets the optional 'limit' attribute to $limit.

$self->opts();

Returns the optional 'opts' attribute.

If the 'opts' attribute is not TRUE, returns an empty string.

If the 'opts' attribute doesn't start with a pipe symbol, returns it prefixed with |.

$self->set_opts ($opts);

Sets the optional 'opts' attribute to $opts.

$self->process ($number);

Turns $number into a canonical, global number if $number if $self->locale() returns an Asterisk::LCR::Locale object.

Then calls $self->_process ($number). This method must be defined in subclasses.

$self->dial ($str);

Dials string $str, eventually with options $self->opts();

$self->dial_string ($number, $rate)

Returns a string from a variable template suitable for use within Dial()

Extract a string dial template from the asterisk config file.

For example, say $rate->{provider} = 'voipjet'. This method will look for an asterisk variable called 'ASTERISK_LCR_TMPL_VOIPJET'. The grammar to be used for this syntax is:

  VARIABLE: [LOCALE] DIAL_STRING

  LOCALE: (scalar string, i.e. 'us' or 'fr' or even /var/mylocale.txt)

  DIAL_STRING: <whateverwhatever>REPLACEME<whateverwhatever>

Where REPLACEME will be replaced by the phone number to dial.

If LOCALE is defined and an Asterisk::LCR::Locale object can be created, then $num is assumed to be given as a canonical, international number.

For example, if LOCALE is 'fr' and the number is 33575874745, then 05175874745 will be dialled instead.

Otherwise the number is dialed "as is".

$self->rates ($number);

Returns an array of rates for $number, sorted cheapest first.