Bill.com

Overview

Bill.com is an online billing and invoicing tool. This class contains methods to:

  • Get lists of customers, users, and invoices
  • Read, create, and send invoices
  • Read, create, and get customers
  • Check whether two customers are the same

For more information, see Bill.com developer docs

Note

Authentication
To instantiate the BillCom class, you must provide the username and password you used to sign up for Bill.com, and the Organization ID and Dev Key you received when API access was granted.

Quick Start

Your Username, Password, Organization ID, and Dev Key must be provided as arguments.

from parsons import BillCom

bc = BillCom(username='my_username',
             password='my_password',
             org_id='my_org_id',
             dev_key='my_dev_key',
             api_url='https://api-sandbox.bill.com/api/v2/')

# List all Customers currently in the system
all_contacts = bc.get_customer_list()

# Create a new customer
customer_data = {
    "contactFirstName": "Contact First Name",
}
bc.create_customer('Customer Name', 'customer.email@fakeemail.com', customer_data)

API

class parsons.BillCom(user_name, password, org_id, dev_key, api_url)[source]
Args:
user_name: str
The Bill.com username
password: str
The Bill.com password
org_id: str
The Bill.com organization id
dev_key: str
The Bill.com dev key
api_url:
The Bill.com end point url
get_user_list(start_user=0, max_user=999, **kwargs)[source]
Args:
start_user: int
The index of first user to return. Starts from 0 (not 1).
max_user: str
The index of the max user to return
**kwargs:
Any other fields to pass
Returns:
A Parsons Table of user information for every user from start_user to max_user.
get_customer_list(start_customer=0, max_customer=999, **kwargs)[source]
Args:
start_customer: int
The index of first customer to return. Starts from 1 (not 0).
max_customer: str
The index of the max customer to return
**kwargs:
Any other fields to pass
Returns:
A Parsons Table of customer information for every user from start_customer to max_customer.
get_invoice_list(start_invoice=0, max_invoice=999, **kwargs)[source]
Args:
start_invoice: int
The index of first customer to return. Starts from 1 (not 0).
max_invoice: str
The index of the max customer to return
**kwargs:
Any other fields to pass
Returns:
A list of dictionaries of invoice information for every invoice from start_invoice to max_invoice.
read_customer(customer_id)[source]
Args:
customer_id: str
The id of the customer to query
Returns:
A dictionary of the customer’s information.
read_invoice(invoice_id)[source]
Args:
invoice_id: str
The id of the invoice to query
Returns:
A dictionary of the invoice information.
check_customer(customer1, customer2)[source]
Args:
customer1: dict
A dictionary of data on customer1
customer2: dict
A dictionary of data on customer2
Returns:
True if either
1. customer1 and customer2 have the same id OR 2. customer1 has no id and customer1 customer2 have the same email address

False otherwise

get_or_create_customer(customer_name, customer_email, **kwargs)[source]
Args:
customer_name: str
The name of the customer
customer_email: str
The customer’s email
Keyword Args:
**kwargs:
Any other fields to store about the customer.
Returns:
A dictionary of the customer’s information including an id. If the customer already exists, this function will not create a new id and instead use the existing id.
create_invoice(customer_id, invoice_number, invoice_date, due_date, invoice_line_items, **kwargs)[source]
Args:
customer_id: str
The customer’s id
invoice_number: str
The invoice number. Every invoice must have a distinct invoice number.
invoice_date: str
The invoice date. This can be the date the invoice was generated of any other relevant date.
due_date: str
The date on which the invoice is due.
invoice_line_items: list
A list of dicts, one for each line item in the invoice. The only required field is “quantity”.
**kwargs:
Any other invoice details to pass.
Returns:
A dictionary of the invoice’s information including an id.
send_invoice(invoice_id, from_user_id, to_email_addresses, message_subject, message_body, **kwargs)[source]
Args:
invoice_id: str
The id of the invoice to send
from_user_id: str
The id of the Bill.com user from whom to send the email
to_email_addresses:
The customer’s email address
message_subject:
The subject of the email to send to the customer
message_body:
The body of the email to send to the customer
**kwargs:
Any other details for sending the invoice
Returns:
A dictionary of the sent invoice.