Skip to main content

Thin Python 3 client for the InvoiceXpress REST API

Project description

PyPI Build Status Python Versions MIT License

Thin Python 3 client for the InvoiceXpress REST API.

API docs at: https://developers.invoicexpress.com/docs/versions/2.0.0/

Sample usage

import invoicexpress_api as ie

BASE_URL = 'https://mycompany.app.invoicexpress.com'
API_KEY = 'my api key'

invoice_data = {
  "invoice": {
        "date": "17/04/2018",
        "due_date": "17/04/2018",
        "client": {
                "name": "John Doe",
                "code": "XYZ123"
        },
        "items": [
                {
                  "name": "SRV1",
                  "description": "Service 1",
                  "unit_price": 10.0,
                  "quantity": 5.0,
                  "tax": {
                          "name": "IVA23"
                          }
                }
          ]
   }
}

c = ie.Client(BASE_URL, API_KEY)
inv_type = ie.invoices.Types.INVOICE_RECEIPT
inv = ie.invoices.create(c, invoice_data, inv_type)
print('## Create invoice result')
print(inv)

cli = ie.clients.code_search(c, inv[inv_type]['client']['code'])
cli_upd = {"client": {"fiscal_id": "212345678", "country": "Portugal"}}
ie.clients.update(c, cli['client']['id'], cli_upd)
print('## Client Updated')
print(cli)

inv[inv_type]['items'][0]['unit_price'] = 150
ie.invoices.update(c, inv[inv_type]['id'], inv, inv_type)
print('## Invoice Updated')
print(inv)

ie.invoices.change_state(c, inv[inv_type]['id'], ie.Invoices.States.FINAL)
inv = ie.invoices.get(c, inv[inv_type]['id'])
print('## Invoice Settled')
print(inv)

print('PDF URL: ', ie.invoices.get_pdf_url(c, inv[inv_type]['id']))

ie.invoices.send_email(c, inv[inv_type]['id'], 'email@domail.tld', 'New invoice!', 'Hi John,\r\nHere is your new invoice\r\nRegards,')
print('## E-mail sent')

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

invoicexpress_api-0.1.1.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

invoicexpress_api-0.1.1-py2.py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page