Python wrapper for BI SomConnexió API
Project description
This library is a Python wrapper for accessing Som Connexió BI API.
Operations
- Start billing with a Billing Run number
- Notify the BI API with an invoice number
Installation
$ pip install bi-sc-client
Configuration Environment
To use this library you must expose the needed environment variables:
BI_URL:
BI_USER:
BI_PASSWORD:
These environment variables are needed to locate and access to the BI API.
Usage
- Start billing with a Billing Run number
billing_run_uuid = 1234
BISomConnexioClient().start_billing_run_invoicing(
billing_run_number=billing_run_uuid,
)
- Notify the BI API with an invoice number
invoice_number = "AB-1234Z"
BISomConnexioClient().notify_invoice_number(
invoice_number=invoice_number,
)
Development
Setup environment
- Install
pyenv
curl https://pyenv.run | bash
- Build the Python version
pyenv install 3.7.13
- Create a virtualenv
pyenv virtualenv 3.7.13 bi-sc-client
- Install dependencies
pyenv exec pip install -r requirements.txt
- Install pre-commit hooks
pyenv exec pre-commit install
Install the package locally in development mode
When we are using this package in other projects, we need to install it to use as import in the other files. Install the package in development mode helps us to modify the package and use the new version in live in the other project.
pip install -e .
Test the HTTP request
We are using the HTTP recording plugin of Pytest: pytest-recording.
With VRC we can catch the HTTP responses and then, execute the tests using them.
To add a new test:
- Expose the needed envvars. Look for them at the Configuration Environment section
- Execute the tests using
pytest
command: - If you are writing a new test that is making requests, you should run:
$ pytest --record-mode=once path/to/your/test
- You might need to record requests for an specific tests. In that case make sure to only run the tests affected and run
$ pytest --record-mode=rewrite path/to/your/test
- Add the new
cassetes
to the commit and push them. - The CI uses the cassetes to emulate the HTTP response in the test.
Run test suite
$ tox
Formatting
We use Black as formatter.
First to commit, tun the black
command:
$ black .
All done! ✨ 🍰 ✨
29 files left unchanged.
Darker
Black is a great formatter, but to mantain your code without execute the black
command avery time, you can configure your IDE to use darker to format only the changed or added code when you save the file.
Release process
Update CHANGELOG.md following this steps:
- Add any entries missing from merged merge requests.
- Duplicate the
[Unreleased]
header. - Replace the second
Unreleased
with a version number followed by the current date. Copy the exact format from previous releases.
Then, you can release and publish the package to PyPi:
- Update the
__version__
var in__init__.py
matching the version you specified in the CHANGELOG. - Open a merge request with these changes for the team to approve
- Merge it, add a git tag on that merge commit and push it.
- Once the pipeline has successfully passed, your package had been published.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bi-sc-client-0.0.4.tar.gz
.
File metadata
- Download URL: bi-sc-client-0.0.4.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebee8752de09fce04960e8aae32b78d137b5a156fd70ece548859880c633408a |
|
MD5 | 3529028c961ad20349ec3ea64e3f6aef |
|
BLAKE2b-256 | 1edd0a225c5816f14d856eddf7166dbe1d6d0013e09ac4e410f2c4d1197481d8 |
File details
Details for the file bi_sc_client-0.0.4-py2.py3-none-any.whl
.
File metadata
- Download URL: bi_sc_client-0.0.4-py2.py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59da095e84ca8ae848391df7473532d8f448c48d80ba566e6f7818f4f2e25e7f |
|
MD5 | a79abb386a983e31b26695e9c0b1438e |
|
BLAKE2b-256 | 21e96ba4fbc2072f934f3949faed8d655598122a5c56ab2636229feffc341136 |