Skip to main content

async HTTP client to communicate with transformer.bee/edifact-bo4e-converter

Project description

transformer.bee Client (Python)

License: MIT Python Versions (officially) supported Unittests status badge Coverage status badge Linting status badge Black status badge PyPi Status Badge

This library is a Python HTTP client for transformer.bee aka edifact-bo4e-converter. We also maintain a .NET version of this client.

It allows you to convert EDIFACT messages to BO4E and vice versa by speaking to Hochfrequenz's transformer.bee service. Note that the actual conversion happens in the transformer.bee service/backend, this library only provides a convenient way to use its API.

How to use this library

Prerequisites / Account

First of all, you need an account to use transformer.bee. Ask info@hochfrequenz.de or ping @JoschaMetze on GitHub to get one.

You can check if your account is working by logging into our stage environment.

Using the client

Install the library via pip:

pip install transformerbeeclient

Authentication

As of 2024-02-06 we support either no authentication or OAuth2 client ID/client secret authentication. Both the unauthenticated and the authenticated client implement the TransformerBeeClient protocol, so you can use them interchangeably.

No Authentication

If you're hosting transformer.bee in the same network or your localhost and there is no authentication, you can instantiate the client

from yarl import URL
from transformerbeeclient import UnauthenticatedTransformerBeeClient

client = UnauthenticatedTransformerBeeClient(base_url=URL("http://localhost:5021"))

OAuth2 with Client ID/Client Secret

If, which is more likely, Hochfrequenz provided you with a client Id and secret, you can use the AuthenticatedTransformerBeeClient class like this:

from yarl import URL
from transformerbeeclient import AuthenticatedTransformerBeeClient

client = AuthenticatedTransformerBeeClient(
    base_url=URL("https://transformer.utilibee.io"),
    client_id="your_client_id",
    client_secret="your_client_secret",
)

Minimal Working Examples

Find full examples of both conversions in the integration tests. Find the respective BO4E and EDIFACTs in the test data folder.

Conversion

There are two main methods to convert between EDIFACT and BO4E:

  • edifact_to_bo4e
  • bo4e_to_edifact

Both have an EdifactFormatVersion as argument (imported from efoli), which denotes which version of the EDIFACT format you want to use. We group all the different versions of the EDIFACT format into an enum, so you can easily choose the one you need. E.g. EdifactFormatVersion.FV2310 stands for all MIG/AHB versions valid since 2023-10-01.

Convert EDIFACT to BO4E

from efoli import EdifactFormatVersion
# client instantiation goes here

bo4e = await client.edifact_to_bo4e("UNA:+,? 'UNB...", EdifactFormatVersion.FV2310)

Convert BO4E to EDIFACT

from efoli import EdifactFormatVersion
from transformerbeeclient import BOneyComb
# client instantiation goes here

boney_comb = BOneyComb.model_validate({"stammdaten":[...], "transaktionsdaten":{...}})
edifact = await client.bo4e_to_edifact(boney_comb, EdifactFormatVersion.FV2310)

Development

For development of this library, follow the instructions in our Python Template Repository.

Release (CI/CD)

To release a new version of this library, create a new release in GitHub. Make sure its tag starts with v and the version number, e.g. v1.2.3. Releases are not restricted to the main branch but we prefer them to happen there.

Contribute

You are very welcome to contribute to this template repository by opening a pull request against the main branch.

Related Tools and Context

This repository is part of the Hochfrequenz Libraries and Tools for a truly digitized market communication.

Hochfrequenz

Hochfrequenz Unternehmensberatung GmbH is a Grünwald (near Munich) based consulting company with offices in Berlin and Bremen and attractive remote options. We're not only a main contributor for open source software for German utilities but, according to Kununu ratings, also among the most attractive employers within the German energy market. Applications of talented developers are welcome at any time! Please consider visiting our career page (German only).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

transformerbeeclient-0.2.4.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transformerbeeclient-0.2.4-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file transformerbeeclient-0.2.4.tar.gz.

File metadata

  • Download URL: transformerbeeclient-0.2.4.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for transformerbeeclient-0.2.4.tar.gz
Algorithm Hash digest
SHA256 0a9263c3f223ac9ff95c8746cb6090ce682200b5f1d222145423e6f79a67cb0c
MD5 0c04900182251b0da10a2fe2437f85a5
BLAKE2b-256 0c7ccc8e29818c1ebd30df977a09d8ffddd560dd44a77f2ef6f0e6753f6b2f87

See more details on using hashes here.

Provenance

The following attestation bundles were made for transformerbeeclient-0.2.4.tar.gz:

Publisher: python-publish.yml on Hochfrequenz/TransformerBeeClient.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file transformerbeeclient-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for transformerbeeclient-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1eed0de78c011b96c8fa983b7449ef0b97fd096cd9f0d39d929b1e3fce58b392
MD5 7ba9efac8238f4d24abc940b2b980c70
BLAKE2b-256 595b4dba77140e29c5ba9d0cee7a71e574ff2a667901eaba7d904967a6221bb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for transformerbeeclient-0.2.4-py3-none-any.whl:

Publisher: python-publish.yml on Hochfrequenz/TransformerBeeClient.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page