Supplai Client is a python3 wrapper for Supplai's REST API v1. This library currently implements the features released under version 0.100.1 of Supplai's REST API.
This project requires:
- Python 3.4 or earlier
- git client
- virtualenvwrapper/virtualenv for local development
$ pip install [email protected]:supplai/supplai-client.git
Or, you can download the source and
$ git clone [email protected]:supplai/supplai-client.git
$ cd supplai_client
$ python setup.py install
- Request to the Supplai Admin team to a API Access Token.
- Import the supplai_client module and create an instance with your access token:
>> from supplai_client import API
>> from supplai_client.exceptions import SupplaiError
>>
>> access_token = "<Supplai Access token>"
>> client = API(environment="practice", access_token=access_token)
>> try:
>> result = client.user.get_users()
>> # In case of http status 400
>> except SupplaiError as exc:
>> print(str(exc))
>>
>> # Use the result as object
>> print(result.as_obj())
UserUsers(
previous=None,
count=1,
next=None,
results=[
NamelessModel(occupation=None, full_name='Admin System',
image=None, cpf='', is_superuser=True, cellphone='', email='', sex=None, username='admin', birthdate='09/09/1999',
logged_as='', id=1, is_temp=False, is_active=True)
]
)
>>
>> # Use the result as dict
>> print(result.as_dict())
{'count': 1,
'next': None,
'previous': None,
'results': [{'id': 1,
'username': 'admin',
'full_name': 'Admin System',
'sex': None,
'birthdate': '09/09/1999',
'cpf': '',
'cellphone': '',
'email': '',
'image': None,
'occupation': None,
'logged_as': '',
'is_superuser': True,
'is_active': True,
'is_temp': False}
]
}
Please send pull requests, very much appreciated.
- Fork the repository on BitBucket.
- Create a virtualenv.
- Install requirements.
pip install -r requirements-dev.txt
- Install pre-commit.
pre-commit install
- Make a branch off of master and commit your changes to it.
- Create a Pull Request with your contribution
- Supplai API REST Client is still under development, some functionality have not yet been implemented, but I will keep an eye on it, and as soon as it gets implemented I will update this library accordingly.