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


Net-FreshBooks-API documentation  | view source Contained in the Net-FreshBooks-API distribution.

Index


NAME

Top

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

VERSION

Top

version 0.21

SYNOPSIS

Top

    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;

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

Top

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

AUTHORS

Top

COPYRIGHT AND LICENSE

Top


Net-FreshBooks-API documentation  | view source Contained in the Net-FreshBooks-API distribution.