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


Net-FreshBooks-API documentation Contained in the Net-FreshBooks-API distribution.

Index


Code 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 Contained in the Net-FreshBooks-API distribution.

use strict;
use warnings;

package Net::FreshBooks::API::Client;
BEGIN {
  $Net::FreshBooks::API::Client::VERSION = '0.21';
}

use Moose;
extends 'Net::FreshBooks::API::Base';
with 'Net::FreshBooks::API::Role::CRUD';

has $_ => ( is => _fields()->{$_}->{is} ) for sort keys %{ _fields() };

sub _fields {
    return {
        client_id     => { is => 'ro' },
        currency_code => { is => 'rw' },
        first_name    => { is => 'rw' },
        last_name     => { is => 'rw' },
        language      => { is => 'rw' },
        notes         => { is => 'rw' },
        organization  => { is => 'rw' },
        p_city        => { is => 'rw' },
        p_code        => { is => 'rw' },
        p_country     => { is => 'rw' },
        p_state       => { is => 'rw' },
        p_street1     => { is => 'rw' },
        p_street2     => { is => 'rw' },
        vat_name      => { is => 'rw' },
        vat_number    => { is => 'rw' },

        # custom fields
        credit     => { is => 'ro' },
        email      => { is => 'rw' },
        fax        => { is => 'rw' },
        home_phone => { is => 'rw' },
        links      => {
            is           => 'ro',
            made_of      => 'Net::FreshBooks::API::Links',
            presented_as => 'single',
        },
        mobile     => { is => 'rw' },
        password   => { is => 'rw' },
        s_city     => { is => 'rw' },
        s_code     => { is => 'rw' },
        s_country  => { is => 'rw' },
        s_state    => { is => 'rw' },
        s_street1  => { is => 'rw' },
        s_street2  => { is => 'rw' },
        username   => { is => 'rw' },
        work_phone => { is => 'rw' },

        folder     => { is => 'ro' },

    };
}

__PACKAGE__->meta->make_immutable();

1;

# ABSTRACT: FreshBooks Client access


__END__