Mojo::CallFire - A simple interface to the CallFire API
use Mojo::CallFire; my $cf = Mojo::CallFire->new(username => '...', password => '...'); say $cf->get('/calls')->result->json('/items/0/id');
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.
Mojo::CallFire implements the following attributes.
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.
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.
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.
Mojo::CallFire inherits all methods from Mojo::Base and implements the following new ones.
# 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.
# 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.
# 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.
# 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.
http://callfire.com
To install Mojo::CallFire, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::CallFire
CPAN shell
perl -MCPAN -e shell install Mojo::CallFire
For more information on module installation, please visit the detailed CPAN module installation guide.