Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Asterisk::LCR::Importer
Provider's rates importer base class

Asterisk::LCR::Importer - Provider's rates importer base class


NAME

Asterisk::LCR::Importer - Provider's rates importer base class


SYNOPSIS

Asterisk::LCR::Importer is just a base class. To write your own importer:


  package MyOwnImporter;

  use base qw /Asterisk::LCR::Importer/;

  use warnings;

  use strict;

  

  sub new

  {

    my $class = shift;

    my $self  = $class->SUPER::new (@_);

    $self->{prefix_locale}            = 'us'

    $self->{prefix_position}          = '0'

    $self->{label_position}           = '1'

    $self->{rate_position}            = '4'

    $self->{first_increment_position} = '2'

    $self->{increment_position}       = '3'

    $self->{connection_fee}           = '0'

    $self->{currency}                 = 'USD'

    $self->{uri}                      = 'http://www.plainvoip.com/ratedump.php'

    $self->{separator}                = '(?:,|(?<=\d)\/(?=\d))'

    return $self;

  }

    

  1;

  

  __END__

In your config file:


  [import:myownprovider]

  package    = MyOwnProvider

  dialstring = IAX2/jhiver@plainvoip/REPLACEME

  

=head1 METHODS

$self->uri();

Returns the URI which $self should fetch. If not overriden, returns $self->{uri}

$self->target();

Returns a 'target', i.e. a name file to fill with the current Importer's rates.

Returns $self->provider() + ``.csv'' by default. If $self->{target} is defined, returns it instead.

$self->get_data();

Fetches the data contained in $self->uri(). Returns an array of lines.

$self->separator();

Returns the CSV separator, which is ',' by default. If $self->{separator} is defined, returns it instead.

$self->prefix ($rec);

Extracts and returns the prefix from $rec.

$self->prefix_pos();

Returns the position of the field which contains the prefix in the CSV data. By default, returns 0. If $self->{prefix_position} is defined, returns it instead.

$self->prefix_locale();

Returns the locale which should be used for normalizing / translating the prefix.

Returns undef unless $self->{prefix_locale} is defined.

See the Asterisk::LCR::Locale manpage for more details.

$self->label ($rec);

Extracts and returns the label from $rec.

$self->label_pos();

Returns the position of the field which contains the prefix in the CSV data. By default, returns 1. If $self->{prefix_position} is defined, returns it instead.

$self->provider();

Returns a sensible string to designate the provider.

For example, for 'VoIPJet' should return something called ``voipjet'.

By default, the result is derived from the domain name contained in $self->uri(). If $self->{provider} is defined, returns it instead.

$self->currency();

Returns the currency which this Importer's provider uses.

Returns 'EUR' unless $self->{currency} is defined, in which case it returns the latter instead.

$self->rate ($rec);

Extracts and return the rate from $rec.

$self->rate_pos();

Returns the position of the field which contains the rate in the CSV data. By default, returns 2. If $self->{rate_position} is defined, returns it instead.

$self->connection_fee ($rec);

Extracts and returns the connection_fee for $rec. If $self->{connection_fee} is defined, returns it instead.

$self->connection_fee_pos();

Returns the position of the field which contains the connection fee in the CSV data. By default, returns 3.

$self->first_increment ($rec);

Extracts and returns the first_increment for $rec. If $self->{first_increment} is defined, returns it instead.

$self->first_increment_pos();

Returns the position of the field which contains the first increment in the CSV data. By default, returns 3.

$self->increment ($rec);

Extracts and returns the increment for $rec. If $self->{increment} is defined, returns it instead.

$self->increment_pos();

Returns the position of the field which contains the increment in the CSV data. By default, returns 3.

$self->filter();

Returns a filter which matches all the CSV lines which are valid. Returns $self->{filter}, or '^\d+,' by default

$self->rates();

Imports and returns this Importer's rates.

$self->prefixes();

Returns a list of all available prefixes.

$self->fetch_rate ($prefix);

Returns a list of rates matching $prefix exactly.

$self->search_rate ($prefix);

Say $prefix = 12345. If 12345 has a list of rates, return the list. If 1234 has a list of rates, return the list. If 123 has a list of rates, return the list. etc.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy