Net::FreshBooks::API::Base - Base class
my $new_object = $class->new_from_node( $node );
Create a new object from the node given.
my $new_object = $self->copy( );
Returns a new object with the fb object set on it.
my $new_object = $self->create( \%args );
Create a new object. Takes the arguments and uses 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 FreshBooks and to populate the object.
my $object = $object->update();
Update the object, saving any changes that have been made since the get.
my $object = $self->get( \%args );
Fetches the object using the FreshBooks API.
my $iterator = $self->list( $args );
Returns an iterator that represents the list fetched from the server. See Net::FreshBooks::API::Iterator for details.
my $result = $self->delete();
Delete the given object.
my $response_data = $self->send_request( $args );
Turn the args into xml, send it to FreshBooks, receive back the XML and convert it back into a Perl data structure.
my $method_string = $self->method_string( 'action' );
Returns a method string for this class - something like 'client.action'.
my $api_name = $self->api_name( );
Returns the name that should be used in the API for this class.
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.
my $id_field = $self->id_field( );
Returns the id field for this class.
my @names = $self->field_names();
Return the names of all the fields.
my @names = $self->field_names_rw();
Return the names of all the fields that are marked as read and write.
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.
Requires an XML::LibXML::Element object, followed by a HASHREF of attributes, text nodes, nested values or child elements or some combination thereof.
my $params = $self->response_xml_to_node( $xml );
Take XML from FB and turn it into a data structure that is easier to work with.
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.
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.