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

NAME

Mojo::CallFire - A simple interface to the CallFire API

SYNOPSIS

  use Mojo::CallFire;

  my $cf = Mojo::CallFire->new(username => '...', password => '...');
  say $cf->get('/calls')->result->json('/items/0/id');
  

DESCRIPTION

A simple interface to the CallFire API.

Currently only get, post, put, and delete methods are available, and they offer no data validation or error handling. No built-in support for paging. Pull requests welcome!

The API reference guide is available at https://developers.callfire.com/docs.html

So what does this module do? It makes building the API URL easier and includes the username and password on all requests. So, not much. But it does offer a little bit of sugar, and, hopefully eventually, some data validation, error handling, and built-in support for paging.

ATTRIBUTES

Mojo::CallFire implements the following attributes.

base_url

  my $base_url = $cf->base_url;
  $cf          = $cf->base_url($url);

The base URL for the CallFire API, defaults to https://api.callfire.com/v2.

password

  my $password = $cf->password;
  $cf          = $cf->password($password);

The password for the CallFire API. Generate a password API credential on CallFire's API access page. Read more at the Authentication section of the API Reference at https://developers.callfire.com/docs.html#authentication.

username

  my $username = $cf->username;
  $cf          = $cf->username($username);

The username for the CallFire API. Generate a username API credential on CallFire's API access page. Read more at the Authentication section of the API Reference at https://developers.callfire.com/docs.html#authentication.

METHODS

Mojo::CallFire inherits all methods from Mojo::Base and implements the following new ones.

del

  # Blocking
  my $tx = $cf->del('/rest/endpoint', %args);
  say $tx->result->body;
  
  # Non-blocking
  $cf->del('/rest/endpoint', %args => sub {
    my ($ua, $tx) = @_;
    say $tx->result->body;
  });

A RESTful DELETE method. Accepts the same arguments as Mojo::UserAgent with the exception that the URL is built starting from the base_url and the Basic HTTP Athorization of the username and password are automatically applied on each request.

See the CallFire API Reference at https://developers.callfire.com/docs.html for the HTTP methods, URL path, and parameters to supply for each desired action.

get

  # Blocking
  my $tx = $cf->get('/rest/endpoint', %args);
  say $tx->result->body;
  
  # Non-blocking
  $cf->get('/rest/endpoint', %args => sub {
    my ($ua, $tx) = @_;
    say $tx->result->body;
  });

A RESTful GET method. Accepts the same arguments as Mojo::UserAgent with the exception that the URL is built starting from the base_url and the Basic HTTP Athorization of the username and password are automatically applied on each request.

See the CallFire API Reference at https://developers.callfire.com/docs.html for the HTTP methods, URL path, and parameters to supply for each desired action.

post

  # Blocking
  my $tx = $cf->post('/rest/endpoint', %args);
  say $tx->result->body;
  
  # Non-blocking
  $cf->post('/rest/endpoint', %args => sub {
    my ($ua, $tx) = @_;
    say $tx->result->body;
  });

A RESTful POST method. Accepts the same arguments as Mojo::UserAgent with the exception that the URL is built starting from the base_url and the Basic HTTP Athorization of the username and password are automatically applied on each request.

See the CallFire API Reference at https://developers.callfire.com/docs.html for the HTTP methods, URL path, and parameters to supply for each desired action.

put

  # Blocking
  my $tx = $cf->put('/rest/endpoint', %args);
  say $tx->result->body;
  
  # Non-blocking
  $cf->put('/rest/endpoint', %args => sub {
    my ($ua, $tx) = @_;
    say $tx->result->body;
  });

A RESTful PUT method. Accepts the same arguments as Mojo::UserAgent with the exception that the URL is built starting from the base_url and the Basic HTTP Athorization of the username and password are automatically applied on each request.

See the CallFire API Reference at https://developers.callfire.com/docs.html for the HTTP methods, URL path, and parameters to supply for each desired action.

SEE ALSO

http://callfire.com