diff --git a/barte/__init__.py b/barte/__init__.py index e7f61d4..ca2bfe7 100644 --- a/barte/__init__.py +++ b/barte/__init__.py @@ -1,14 +1,13 @@ from .client import BarteClient from .models import ( - Charge, CardToken, - Refund, - PixCharge, + Charge, Customer, + PixCharge, PixQRCode, + Refund, ) -__version__ = "0.1.0" __all__ = [ "BarteClient", diff --git a/barte/__version__.py b/barte/__version__.py new file mode 100644 index 0000000..a7e2ff5 --- /dev/null +++ b/barte/__version__.py @@ -0,0 +1,7 @@ +from importlib.metadata import PackageNotFoundError, version + + +try: + __version__ = version("barte-python-sdk") +except PackageNotFoundError: + __version__ = "0.0.0-dev" diff --git a/barte/client.py b/barte/client.py index f4a38ec..f8e6cc0 100644 --- a/barte/client.py +++ b/barte/client.py @@ -1,20 +1,24 @@ -from decimal import Decimal -from typing import Dict, Any, Optional, Union, List from dataclasses import asdict +from decimal import Decimal +from typing import Any, Dict, List, Optional, Union + import requests from dacite import from_dict + +from barte.__version__ import __version__ + from .models import ( - Charge, - CardToken, - Refund, - PixCharge, DACITE_CONFIG, Buyer, BuyerList, - Order, + CardToken, + Charge, ChargeList, - OrderPayload, InstallmentOption, + Order, + OrderPayload, + PixCharge, + Refund, ) @@ -44,9 +48,14 @@ def __init__(self, api_key: str, environment: str = "production"): if environment == "production" else "https://sandbox-api.barte.com" ) - self.headers = {"X-Token-Api": api_key, "Content-Type": "application/json"} self.session = requests.Session() - self.session.headers.update(self.headers) + self.session.headers.update( + { + "X-Token-Api": api_key, + "Content-Type": "application/json", + "User-Agent": f"barte-client/python version={__version__}", + } + ) BarteClient._instance = self @classmethod