IMPY - A Python Wrapper for InvoiceMachine
A while back I coded this little gem because I didn’t want to have to create an invoicing app for one of my projects, instead I thought it easiest to just export that functionality to a service.
My service of choice (and a great one for freelancers everywhere) is InvoiceMachine - a really simple, really pretty invoice manager.
So here I present IMPY - a python wrapper for invoice machine.
Functions:
- Create client
- Create Invoice
- Get Invoice
- Remove invoice
- Get Client
- Create Itrem
- Remove Item
- Get all clients
Objects:
- Client
- Item
- Invoice
Usage is quite simple, I’ve lsited out the test case functions below to illustrate how the code works:
First, we put this at the top of where you want to use the functions:
API_TOKEN = "YOUR_API_TOKEN_HERE"
MACHINE_NAME = "YOUR_USERNAME"
Then you can use the following functions (these are demo’s!) to do the related tasks, note that the returned objects’ properties can be accessed with a key (e.g. object['keyname']):
i = impy(API_TOKEN, MACHINE_NAME)
client = im_client(name='TestClient', email='test@test.com', company='TestCo',
address_line_01 = 'Addr1', address_line_02 = 'Addr2', address_line_03 = 'Addr3',
city = 'London', country = 'United Kingdom')
ret = i.create_client(client)
return ret
def test_invoice():
i = impy(API_TOKEN, MACHINE_NAME)
item = im_item(qty='2', kind='hour', description='Web design', price='40.00', send='true')
ret = i.create_invoice('CLIENTID', [item])
return ret
def test_getinvoice():
i = impy(API_TOKEN, MACHINE_NAME)
ret = i.get_invoice('INVOICEID')
return ret
def test_removeinvoice():
i = impy(API_TOKEN, MACHINE_NAME)
ret = i.remove_invoice('INVOICEID')
return ret
def test_getclient():
i = impy(API_TOKEN, MACHINE_NAME)
ret = i.get_client('CLIENTID')
return ret
def test_createitem():
i = impy(API_TOKEN, MACHINE_NAME)
thisitem = im_item(qty='1', kind='hour', description='graphic design', price='25.00')
ret = i.create_item(thisitem)
return ret
def test_removeitem():
i = impy(API_TOKEN, MACHINE_NAME)
ret = i.remove_item('ITEMID')
return ret
def test_getallclients():
i = impy(API_TOKEN, MACHINE_NAME)
ret = i.get_clients()
return ret
I hope you enjoy, you can download it here and it is completely open source, would be nice if you kept the credit in the file though.
You’re currently reading “IMPY - A Python Wrapper for InvoiceMachine”, an entry on Lonely Code
- Published:
- 23.10.09 / 6am
- Category:
- Development, Open Source
- Tags:
- API, Invoice Machine, python
- Post Navigation:
- « Great Little Helpers For Django
Amazon RDS and Django »








