Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install refreshbooks

How to install refreshbooks

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install refreshbooks
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
1.7.2 Available View build log
1.6.1 Available View build log
1.6 Available View build log
1.5 Available View build log
1.4 Available View build log
1.3.2 Available View build log
1.3 Available View build log
1.2 Available View build log
1.1 Failed View build log
Windows (64-bit)
1.7.2 Available View build log
1.6.1 Available View build log
1.6 Available View build log
1.5 Available View build log
1.4 Available View build log
1.3.2 Available View build log
1.3 Failed View build log
1.2 Failed View build log
1.1 Available View build log
Mac OS X (10.5+)
1.7.2 Available View build log
1.6.1 Available View build log
1.6 Available View build log
1.5 Available View build log
1.4 Available View build log
1.3.2 Available View build log
1.3 Available View build log
1.2 Available View build log
1.1 Available View build log
Linux (32-bit)
1.7.2 Available View build log
1.6.1 Available View build log
1.6 Available View build log
1.5 Available View build log
1.4 Available View build log
1.3.2 Available View build log
1.3 Available View build log
1.2 Available View build log
1.1 Available View build log
Linux (64-bit)
1.7.2 Available View build log
1.6.1 Available View build log
1.6 Available View build log
1.5 Available View build log
1.4 Available View build log
1.3.2 Available View build log
1.3 Available View build log
1.2 Available View build log
1.1 Available View build log
 
Author
Dependencies
Depended by
Lastest release
version 1.7.2 on May 23rd, 2012

Refreshbooks provides a simple synchronous API for manipulating FreshBooks invoices, clients, and other data:

from refreshbooks import api

c = api.OAuthClient(
    'example.freshbooks.com',
    'consumerkey',
    'My Consumer Secret',
    'An existing token',
    'An existing token secret',
    user_agent='Example/1.0'
)

                                      # XML structure inferred from args
response = c.invoice.create(          # <request method="invoice.create">
    invoice=dict(                     #   <invoice>
        client_id='8',                #     <client_id>8</client_id>
        lines=[                       #     <lines>
            api.types.line(           #       <line>
                name='Yard Work',     #         <name>Yard Work</name>
                unit_cost='10',       #         <unit_cost>10</unit_cost>
                quantity='4'          #         <quantity>4</quantity>
            )                         #       </line>
        ]                             #     </lines>
    )                                 #   </invoice>
)                                     # </request>

invoice_response = c.invoice.get(     # <request method="invoice.get">
    invoice_id=response.invoice_id    #     <invoice_id>...</invoice_id>
)                                     # </request>

print "New invoice created: #%s (id %s)" % (
    invoice_response.invoice.number,
    invoice_response.invoice.invoice_id
)

invoices_response = c.invoice.list() # <request method="invoice.list" />

print "There are %s pages of invoices." % (
    invoices_response.invoices.attrib['pages'],
)

for invoice in invoices_response.invoices.invoice:
    print "Invoice %s total: %s" % (
        invoice.invoice_id,
        invoice.amount
    )

Consumer keys and secrets can be obtained from FreshBooks. This library does not handle negotiating for an OAuth token+secret pair; see the oauth module or the OAuth specification for details.

This library also supports the older token-based API authorization scheme:

c = api.TokenClient(
    'example.freshbooks.com',
    'My API token',
    user_agent='Example/1.0'
)

# ... as above ...

API methods return lxml.objectify.ObjectifiedDataElement trees, which can be manipulated as Python objects with the same structure as the underlying XML.

If you are having trouble accessing items as in:

items_response = c.items.list() for item in items_response.items.item:

System Message: ERROR/3 (<string>, line 73)

Unexpected indentation.
print item.item_id

Adjust your syntax to use dictionary item lookup:

items_response = c.items.list() for item in items_response['items'].item:

System Message: ERROR/3 (<string>, line 79)

Unexpected indentation.
print item.item_id

ObjectifiedDataElement provides a method named items which shadows the items element in the response. Accessing items with dictionary lookup syntax is the known work-around.

To run tests:

python setup.py nosetests

To run network-accessing integration tests against httpstat.us:

python setup.py nosetests --attr=integration

References:

Subscribe to package updates

Last updated May 23rd, 2012

Download Stats

Last month:19

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.