Skip to main content

This library is a Python wrapper for accessing Som Connexió BI API.

Operations

  • Notify the BI API with an invoice number
  • Recreate the PDF of an invoice
  • Create a temporal token to access an invoice

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

  • Notify the BI API with an invoice number
    from bi_sc_client.services.notify_invoice_number import NotifyInvoiceNumber
    NotifyInvoiceNumber(invoice_id=123, invoice_number="AB-1234Z").run()
  • Recreate the PDF of group invoices
    from bi_sc_client.services.invoice_pdf_regenerate import InvoicePDFRegenerator
    InvoicePDFRegenerator(invoice_numbers=["AB-1234Z", "AB-1234Z"]).run()
  • Create a temporal token to access an invoice
    from bi_sc_client.resources.token import Token
    from bi_sc_client.client import BISomConnexioClient
    client = BISomConnexioClient()
    token_instance = Token(client=client)
    print(token_instance.token)

Development

Setup environment

  1. Install pyenv
curl https://pyenv.run | bash
  1. Build the Python version
pyenv install  3.7.13
  1. Create a virtualenv
pyenv virtualenv 3.7.13 bi-sc-client
  1. Install dependencies
pyenv exec pip install -r requirements.txt
  1. 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:

  1. Add any entries missing from merged merge requests.
  2. Duplicate the [Unreleased] header.
  3. 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:

  1. Update the __version__ var in __init__.py matching the version you specified in the CHANGELOG.
  2. Open a merge request with these changes for the team to approve
  3. Merge it, add a git tag on that merge commit and push it.
  4. Once the pipeline has successfully passed, your package had been published.

Release files for bi-sc-client 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bi-sc-client 0.0.7
File Size Uploaded
bi_sc_client-0.0.7.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bi-sc-client 0.0.7
File Interpreter ABI Platform
bi_sc_client-0.0.7-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 11.5 kB

Release files / bi_sc_client-0.0.7.tar.gz

Download URL bi_sc_client-0.0.7.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0686ec80428877f38a6e8ab8f42a2af61ed4aefb617fcdafb89dde09eaaf5124
BLAKE2b-256 checksum
How to use checksums
42b9a9d0b4e8f0394290808eb166d487b165b3ece7f805a18ea1494f2cd04a14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Release files / bi_sc_client-0.0.7-py2.py3-none-any.whl

Download URL bi_sc_client-0.0.7-py2.py3-none-any.whl
Size 6.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6a2bd40b43f96368353e023b57ee0f815b5587c7c28ce075f99f507e58bb0184
BLAKE2b-256 checksum
How to use checksums
c409aa3e4aa2ae1fc1cc00477f62198304282bd5d3f59dce2ef76a46fb969945
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.17

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page