The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::FreshBooks::API::Base

VERSION

version 0.19

new_from_node

  my $new_object = $class->new_from_node( $node );

Create a new object from the node given.

copy

  my $new_object = $self->copy(  );

Returns a new object with the fb object set on it.

create

  my $new_object = $self->create( \%args );

Create a new object. Takes the arguments and use them to create a new entry at the FreshBooks end. Once the object has been created a 'get' request is issued to fetch the data back from freshboks and to populate the object.

update

  my $object = $object->update();

Update the object, saving any changes that have been made since the get.

get

  my $object = $self->get( \%args );

Fetches the object using the FreshBooks API.

list

  my $iterator = $self->list( $args );

Returns an iterator that represents the list fetched from the server. See Net::FreshBooks::API::Iterator for details.

delete

  my $result = $self->delete();

Delete the given object.

INTERNAL METHODS

send_request

  my $response_data = $self->send_request( $args );

Turn the args into xml, send it to FreshBooks, recieve back the XML and convert it back into a perl data structure.

method_string

  my $method_string = $self->method_string( 'action' );

Returns a method string for this class - something like 'client.action'.

api_name

  my $api_name = $self->api_name(  );

Returns the name that should be used in the API for this class.

node_name

  my $node_name = $self->node_name(  );

Returns the name that should be used in the XML nodes for this class. Normally this is the same as the api_name but can be overridden if needed.

id_field

  my $id_field = $self->id_field(  );

Returns the id field for this class.

field_names

  my @names = $self->field_names();

Return the names of all the fields.

field_names_rw

  my @names = $self->field_names_rw();

Return the names of all the fields that are marked as read and write.

parameters_to_request_xml

  my $xml = $self->parameters_to_request_xml( \%parameters );

Takes the parameters given and turns them into the xml that should be sent to the server. This has some smarts that works around the tedium of processing perl datastructures -> XML. In particular any key starting with an underscore becomes an attribute. Any key pointing to an array is wrapped so that it appears correctly in the XML.

construct_element( $element, $hashref )

Requires an XML::LibXML::Element object, followed by a HASHREF of attributes, text nodes, nested values or child elements or some combination thereof.

response_xml_to_node

  my $params = $self->response_xml_to_node( $xml );

Take XML from FB and turn it into a datastructure that is easier to work with.

send_xml_to_freshbooks

  my $returned_xml = $self->send_xml_to_freshbooks( $xml_to_send );

Sends the xml to the FreshBooks API and returns the XML content returned. This is the lowest part and is encapsulated here so that it can be easily overridden for testing.

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.