Resources

Base

class bexiopy.resources.base.BaseClientResource[source]

Bases: object

Base client resource that instantiates the Client.

client
class bexiopy.resources.base.BaseResource(*args, **kwargs)[source]

Bases: bexiopy.resources.base.BaseClientResource

Base resource that’s inherited by all other resources.

Inheriting classes may have additional methods, that are resource specific. Take a look at the resources to find these additional methods.

ENDPOINT

the endpoint that should be queried

Type:str

the serach endpoint that should be queried

Type:str
all()[source]

Get all objects of given endpoint.

Returns:List of all objects from requested endpoint.
Return type:list
create(data)[source]

Add new object.

Parameters:data (dict) – Dictionary object with appropriate data.
Returns:Object that has been created.
Return type:dict
delete(pk)[source]

Delete object.

Parameters:pk (str) – Bexio id of object.
Returns:Response dictionary of operation.
Return type:dict
get(pk)[source]

Get specific object.

Parameters:pk (str) – Bexio id of object.
Returns:Object that has been pulled.
Return type:dict
get_or_create(pk=None, data={})[source]

Return object if exists, else create object first.

Parameters:
  • pk (str) – Bexio id of object.
  • data (dict) – Data for possible object creation.
Returns:

Object that has been pulled.

Return type:

dict

overwrite(pk, data)[source]

Add new contact

Parameters:
  • pk (str) – Bexio id of object.
  • data (dict) – Data that should be overwritten.
Returns:

Object that has been overwritten.

Return type:

dict

search(params=[])[source]

Search for specific object and return response.

Parameters:params (list of dict, optional) – Parameters to narrow down the search.
Returns:List of results from request.
Return type:list
update(pk, data)[source]

Update existing object.

Parameters:
  • pk (str) – Bexio id of object.
  • data (dict) – Data that should be updated.
Returns:

Object that has been updated.

Return type:

dict

update_or_create(pk, data)[source]

Update object if exists, else create object.

Parameters:
  • pk (str) – Bexio id of object.
  • data (dict) – data for object update/creation.
Returns:

Object that has been pulled.

Return type:

dict

Contacts

class bexiopy.resources.contacts.ContactsResource(*args, **kwargs)[source]

Bases: bexiopy.resources.base.BaseResource

Resource to query the contacts endpoint.

Endpoint Docs:

Examples:

bexio = Bexiopy()

# get all contacts
contacts = bexio.contacts.all()

# create an invoice
contact = bexio.invoices.create(params={'attr1': 'val1', ...)

# search a contact
contact = bexio.contacts.search(params={'param1': 'some value'})

# get one specific contact with id 2
contact = bexio.contacts.get(pk=2)
ENDPOINT = 'contact'
create_contact_relation(id, sub_id, desc='')[source]

Create a contact relationship

Parameters:
  • id (int) – Bexio id of parent contact
  • sub_id (int) – Bexio id of child contact
Returns:

Dict of saved data

Return type:

dict

get_relations()[source]

Get relations from contacts

Returns:List of contact relations
Return type:list

General

class bexiopy.resources.general.GeneralResource[source]

Bases: bexiopy.resources.base.BaseClientResource

Resource to get general information about your Bexio instance.

get_salutations()[source]

Get available salutations

Returns:mixed
get_titles()[source]

Get available titles

Returns:mixed

Invoices

class bexiopy.resources.invoices.InvoicesResource(*args, **kwargs)[source]

Bases: bexiopy.resources.base.BaseResource

Resource to query the contacts endpoint.

Endpoint Docs:

Examples:

from bexiopy.api import *

api = Bexiopy()

# create invoice
invoice = api.invoices.create(invoice_data)

# get an invoice
invoice = api.invoices.get(23)

# update invoice
invoice = api.invoices.update(23,
    {
        'user_id': 1,
        'contact_id': 2,
        'header': 'New Header'
    }
)

# delete invoice
invoice = api.invoices.delete(23)

# search for invoices
api.invoices.search(
    [
        {'field': 'user_id', 'value': 1},
        {'field': 'contact_id', 'value': 2}
    ]
)
ENDPOINT = 'kb_invoice'
copy(pk, data)[source]

Return the PDF version of a given invoice.

Parameters:pk (str) – Bexio id of invoice
Returns:Invoice that was copied
Return type:dict
show_pdf(pk)[source]

Return the PDF version of a given invoice. Needs to be further processed so you can extract the file from the response.

Parameters:pk (str) – Bexio id of invoice
Returns:PDF file of invoice
Return type:file