WWW::Billomat - API access to Billomat services
Version 0.01
use WWW::Billomat; my $billomat = WWW::Billomat->new( billomat_id => 'foo', api_key => 'blahblah12345678', ); my $client = $billomat->get_client(123); my $invoice = WWW::Billomat::Invoice->new( client_id => $client->id, number => 456, discount_rate => 50, ); if(not $billomat->create_invoice($invoice)) { die "ERROR creating invoice: " . $billomat->response_content(); }
This module is an interface to the Billomat API, "the simple online service for quoting, billing and more".
For more information:
Note the implementation is partial. The currently implement feature set is:
list, create, edit, delete clients
set client properties
list, create, edit, delete invoices
list, create invoice items
complete invoices and get PDF output
NOTE: all methods return either undef or false in case of failure. To investigate error conditions, three methods are delegated to the underlying REST::Client object:
response_code
response_content
response_headers
Example:
if(not $billomat->create_invoice($invoice)) { die "ERROR creating invoice: " . $billomat->response_content(); }
Returns an array of WWW::Billomat::Client objects, or undef on failure.
See WWW::Billomat::Client for search parameters.
my @clients = $billomat->get_clients( name => 'gmbh' );
Returns the WWW::Billomat::Client object with the given ID, or undef on failure.
my $client = $billomat->get_client( 123 );
Creates a new client. Expects a WWW::Billomat::Client object as argument.
Returns the created object, or undef on failure.
my $client = WWW::Billomat::Client->new( name => 'Musterfirma', salutation => 'Herr', first_name => 'Max', last_name => 'Muster', # etc. ); if( $billomat->create_client( $client ) ) { say "Client created"; }
Deletes a client. CLIENT can be either a WWW::Billomat::Client object, or its ID.
Returns true on success, false on failure.
$billomat->delete_client( $client ); $billomat->delete_client( 123 );
Updates a client with the current CLIENT (WWW::Billomat::Client) object properties.
my $client = $billomat->get_client( name => 'Foo' ); $client->name( 'FooBar' ); $billomat->edit_client($client);
Sets a custom property for a client.
$billomat->set_client_property( $client, 123 => 'foo' );
Returns an array of WWW::Billomat::Invoice objects, or undef on failure.
See WWW::Billomat::Invoice for search parameters.
my @invoices = $billomat->get_invoices( client_id => 1 );
Returns the WWW::Billomat::Invoice object with the given ID, or undef on failure.
my $invoice = $billomat->get_invoice( 123 );
Creates a new invoice. Expects a WWW::Billomat::Invoice object as argument.
my $invoice = WWW::Billomat::Invoice->new( client_id => 123, # etc. ); if( $billomat->create_invoice( $invoice ) ) { say "Invoice created"; }
Deletes an invoice. INVOICE can be either a WWW::Billomat::Invoice object, or its ID.
$billomat->delete_invoice( $invoice ); $billomat->delete_invoice( 123 );
Updates an invoice with the current INVOICE (WWW::Billomat::Invoice) object properties.
my $invoice = $billomat->get_invoice( 123 ); $invoice->due_date( 'yesterday' ); $billomat->edit_invoice($invoice);
Closes an invoice and generates a PDF for it with the given TEMPLATE_ID. INVOICE can be either a WWW::Billomat::Invoice object, or its ID.
die unless $billomat->complete_invoice( $invoice, 123 );
Returns the PDF for an invoice (note that you must call "complete_invoice" first). INVOICE can be either a WWW::Billomat::Invoice object, or its ID.
Returns the (binary) PDF data, or undef on failure.
if(my $pdf = $billomat->get_invoice_pdf($invoice)) { open(my $output, '>', 'foo.pdf'); binmode($output); print $output $pdf; close($output); }
Returns an array of WWW::Billomat::Invoice::Item objects, or undef on failure.
INVOICE can be either a WWW::Billomat::Invoice object, or its ID.
my @items = $billomat->get_invoice_items( $invoice );
Creates a new invoice item. Expects a WWW::Billomat::Invoice::Item object as argument.
my $item = WWW::Billomat::Invoice::Item->new( invoice_id => 123, title => 'Cookies', quantity => 1_000, unit_price => 0.50, # etc. ); if( $billomat->create_invoice_item( $item ) ) { say "Invoice item created"; }
Aldo Calpini, <dada at perl.it>
<dada at perl.it>
Please report any bugs or feature requests to bug-www-billomat at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-Billomat. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-www-billomat at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc WWW::Billomat
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Billomat
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/WWW-Billomat
CPAN Ratings
http://cpanratings.perl.org/d/WWW-Billomat
Search CPAN
http://search.cpan.org/dist/WWW-Billomat/
The development version is on github at http://github.com/dada/WWW-Billomat and may be cloned from git://github.com/dada/WWW-Billomat.git.
git://github.com/dada/WWW-Billomat.git
Copyright 2013 Aldo Calpini.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install WWW::Billomat, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Billomat
CPAN shell
perl -MCPAN -e shell install WWW::Billomat
For more information on module installation, please visit the detailed CPAN module installation guide.