NAME

Net::FreshBooks::API::Client - FreshBooks Client access

VERSION

version 0.24

SYNOPSIS

my $fb = Net::FreshBooks::API->new({ ... });
my $client = $fb->client;

create

# create a new client
my $client = $fb->client->create(
    {   first_name   => 'Larry',
        last_name    => 'Wall',
        organization => 'Perl HQ',
        email        => 'larry@example.com',
    }
);

Once you have a client object, you may set any of the mutable fields by calling the appropriate method on the object:

$client->first_name( 'Lawrence' );
$client->last_name( 'Wahl' );

These changes will not be reflected in your FreshBooks account until you call the update() method, which is described below.

update

# take the client object created above
# we can now make changes to the client and save them
$client->organization('Perl Foundation');
$client->update;

# or more quickly
$client->update( { organization => 'Perl Foundation', } );

get

# fetch a client based on a FreshBooks client_id
my $client = $fb->client->get({ client_id => $client_id });

delete

# fetch a client and then delete it
my $client = $fb->client->get({ client_id => $client_id });
$client->delete;

contacts

Returns an ARRAYREF of Net::FreshBooks::API::Client::Contact objects

foreach my $contact ( @{ $client->contacts } ) {
    print $contact->first_name, "\n";
}

add_contact

Create a new Net::FreshBooks::API::Client::Contact object and add it to the end of the list of cotacts.

my $bool = $client->add_contact(
    {   username   => 'chucknorris',
        first_name => 'Chuck',
        last_name  => 'Norris',
        email      => 'chuck@norris.com',
        phone1     => 1112223333,
        phone2     => 4445556666,
    }
);

Returns an Net::FreshBooks::API::Links object, which returns FreshBooks URLs.

print "Client view: " . $fb->client->links->client_view;

list

Returns an Net::FreshBooks::API::Iterator object. Currently, all list() functionality defaults to 15 items per page.

#list all active clients
my $clients = $fb->client->list();

print $clients->total . " active clients\n";
print $clients->pages . " pages of results\n";

while ( my $client = $clients->next ) {
    print join( "\t", $client->client_id, $client->first_name, $client->last_name ) . "\n";
}

To override the default pagination:

my $clients = $fb->client->list({ page => 2, per_page => 35 });

DESCRIPTION

This class gives you object to FreshBooks client information. Net::FreshBooks::API will construct this object for you.

AUTHORS

  • Edmund von der Burg <evdb@ecclestoad.co.uk>

  • Olaf Alders <olaf@wundercounter.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Edmund von der Burg & Olaf Alders.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.