NAME
WWW::Billomat - API access to Billomat services
VERSION
Version 0.01
SYNOPSIS
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();
}
DESCRIPTION
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
SUBROUTINES/METHODS
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();
}
get_clients( [PARAMS] )
Returns an array of WWW::Billomat::Client objects, or undef on failure.
See WWW::Billomat::Client for search parameters.
Example:
my @clients = $billomat->get_clients( name => 'gmbh' );
get_client( ID )
Returns the WWW::Billomat::Client object with the given ID, or undef on failure.
Example:
my $client = $billomat->get_client( 123 );
create_client( CLIENT )
Creates a new client. Expects a WWW::Billomat::Client object as argument.
Returns the created object, or undef on failure.
Example:
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";
}
delete_client( CLIENT )
Deletes a client. CLIENT can be either a WWW::Billomat::Client object, or its ID.
Returns true on success, false on failure.
Example:
$billomat->delete_client( $client );
$billomat->delete_client( 123 );
edit_client( CLIENT )
Updates a client with the current CLIENT (WWW::Billomat::Client) object properties.
Returns true on success, false on failure.
Example:
my $client = $billomat->get_client( name => 'Foo' );
$client->name( 'FooBar' );
$billomat->edit_client($client);
set_client_property( CLIENT, ID, VALUE )
Sets a custom property for a client.
Returns true on success, false on failure.
Example:
$billomat->set_client_property( $client, 123 => 'foo' );
get_invoices( [PARAMS] )
Returns an array of WWW::Billomat::Invoice objects, or undef on failure.
See WWW::Billomat::Invoice for search parameters.
Example:
my @invoices = $billomat->get_invoices( client_id => 1 );
get_invoice( ID )
Returns the WWW::Billomat::Invoice object with the given ID, or undef on failure.
Example:
my $invoice = $billomat->get_invoice( 123 );
create_invoice( INVOICE )
Creates a new invoice. Expects a WWW::Billomat::Invoice object as argument.
Returns the created object, or undef on failure.
Example:
my $invoice = WWW::Billomat::Invoice->new(
client_id => 123,
# etc.
);
if( $billomat->create_invoice( $invoice ) ) {
say "Invoice created";
}
delete_invoice( INVOICE )
Deletes an invoice. INVOICE can be either a WWW::Billomat::Invoice object, or its ID.
Returns true on success, false on failure.
Example:
$billomat->delete_invoice( $invoice );
$billomat->delete_invoice( 123 );
edit_invoice( INVOICE )
Updates an invoice with the current INVOICE (WWW::Billomat::Invoice) object properties.
Returns true on success, false on failure.
Example:
my $invoice = $billomat->get_invoice( 123 );
$invoice->due_date( 'yesterday' );
$billomat->edit_invoice($invoice);
complete_invoice( INVOICE, TEMPLATE_ID )
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.
Returns true on success, false on failure.
Example:
die unless $billomat->complete_invoice( $invoice, 123 );
get_invoice_pdf( INVOICE )
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.
Example:
if(my $pdf = $billomat->get_invoice_pdf($invoice)) {
open(my $output, '>', 'foo.pdf');
binmode($output);
print $output $pdf;
close($output);
}
get_invoice_items( INVOICE )
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.
Example:
my @items = $billomat->get_invoice_items( $invoice );
create_invoice_item( ITEM )
Creates a new invoice item. Expects a WWW::Billomat::Invoice::Item object as argument.
Returns the created object, or undef on failure.
Example:
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";
}
AUTHOR
Aldo Calpini, <dada at perl.it>
BUGS
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.
SUPPORT
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)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
SOURCE
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
.
LICENSE AND COPYRIGHT
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.