From 4728e065272ca93469fbc19a6807639072bee72e Mon Sep 17 00:00:00 2001 From: mozinova <148253541+mozinova@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:12:27 +0200 Subject: [PATCH 1/5] flowless: Update pyproject.toml Mitigate risks of future breaking changes in build and runtime dependencies by adding conservative version constraints. --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ff08145..a58ba26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=61.0,<70.0"] build-backend = "setuptools.build_meta" [project] @@ -17,8 +17,8 @@ classifiers = [ "Operating System :: OS Independent", ] dependencies = [ - "requests>=2.25.1", - "pydantic>=2.0.0" + "requests>=2.25.1,<3.0.0", + "pydantic>=2.0.0,<3.0.0" ] [project.urls] From 4bf540176acf88fcf992cd544522ab1ae9865cc4 Mon Sep 17 00:00:00 2001 From: mozinova <148253541+mozinova@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:12:28 +0200 Subject: [PATCH 2/5] flowless: Update src/paysgator/__init__.py Adding a docstring is a simple, non-breaking improvement that enhances the module's documentation and developer experience. --- src/paysgator/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/paysgator/__init__.py b/src/paysgator/__init__.py index d0cf227..a781604 100644 --- a/src/paysgator/__init__.py +++ b/src/paysgator/__init__.py @@ -1,3 +1,5 @@ +"""Paysgator SDK - A client library for the Paysgator API.""" + from .client import PaysgatorClient from .exceptions import PaysgatorError, AuthenticationError, APIError From e68e75ffee0717c31fc67a41dcc40031f98724ac Mon Sep 17 00:00:00 2001 From: mozinova <148253541+mozinova@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:12:29 +0200 Subject: [PATCH 3/5] flowless: Update src/paysgator/client.py Fixed two key inconsistencies: 1) Separated base URL storage by using instance attribute _base_url instead of modifying class variable, preventing unintended side effects across client instances. 2) Added proper authentication error handling by raising AuthenticationError for 401/403 status codes, improving error differentiation and utilizing all imported exceptions. --- src/paysgator/client.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/paysgator/client.py b/src/paysgator/client.py index a067367..5b0fb0f 100644 --- a/src/paysgator/client.py +++ b/src/paysgator/client.py @@ -50,10 +50,11 @@ def get_balance(self) -> WalletBalanceResponse: return WalletBalanceResponse(**response_data) class PaysgatorClient: - BASE_URL = "https://paysgator.com/api/v1" + DEFAULT_BASE_URL = "https://paysgator.com/api/v1" def __init__(self, api_key: str): self.api_key = api_key + self._base_url = self.DEFAULT_BASE_URL self.session = requests.Session() self.session.headers.update({ "X-Api-Key": self.api_key, @@ -66,13 +67,15 @@ def __init__(self, api_key: str): self.wallet = Wallet(self) def set_base_url(self, url: str): - self.BASE_URL = url + self._base_url = url def request(self, method: str, endpoint: str, data: Optional[dict] = None) -> dict: - url = f"{self.BASE_URL}{endpoint}" + url = f"{self._base_url}{endpoint}" response = self.session.request(method, url, json=data) - if response.status_code >= 400: - raise APIError(response.status_code, response.text) + if response.status_code == 401 or response.status_code == 403: + raise AuthenticationError(response.status_code, response.text) + elif response.status_code >= 400: + raise APIError(response.status_code, response.text) return response.json() From fcb1dcff87f48ec089eb6f28bf540cf00a4b2ed8 Mon Sep 17 00:00:00 2001 From: mozinova <148253541+mozinova@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:12:29 +0200 Subject: [PATCH 4/5] flowless: Update src/paysgator/exceptions.py Enhanced the APIError exception to include response_data attribute, allowing developers to access detailed error information from API responses for better debugging and error analysis. --- src/paysgator/exceptions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/paysgator/exceptions.py b/src/paysgator/exceptions.py index 3067741..5c0b53d 100644 --- a/src/paysgator/exceptions.py +++ b/src/paysgator/exceptions.py @@ -8,7 +8,8 @@ class AuthenticationError(PaysgatorError): class APIError(PaysgatorError): """Raised when the API returns an error""" - def __init__(self, status_code: int, message: str): + def __init__(self, status_code: int, message: str, response_data: dict = None): self.status_code = status_code self.message = message + self.response_data = response_data super().__init__(f"API Error {status_code}: {message}") From 3ec6f78ed3c74fe6f0a22415f8959f847c41971e Mon Sep 17 00:00:00 2001 From: mozinova <148253541+mozinova@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:12:30 +0200 Subject: [PATCH 5/5] flowless: Update src/paysgator/models.py Applied two surgical patches to address inconsistencies in the data models. First, corrected the alias for payment_methods to use camelCase ('paymentMethods') aligning with the project's JSON mapping conventions. Second, changed the balance field type from string to float to properly represent numeric values and prevent type-related errors. --- src/paysgator/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/paysgator/models.py b/src/paysgator/models.py index 8863e2d..00a1e4d 100644 --- a/src/paysgator/models.py +++ b/src/paysgator/models.py @@ -10,7 +10,7 @@ class PaymentCreateRequest(BaseModel): amount: float currency: str external_transaction_id: Optional[str] = Field(None, alias="externalTransactionId") - payment_methods: Optional[List[str]] = Field(None, alias="payment_methods") + payment_methods: Optional[List[str]] = Field(None, alias="paymentMethods") fields: Optional[List[str]] = None return_url: Optional[str] = Field(None, alias="returnUrl") metadata: Optional[Dict[str, Any]] = None @@ -73,5 +73,5 @@ class TransactionResponse(BaseModel): class WalletBalanceResponse(BaseModel): wallet_id: str = Field(..., alias="walletId") currency: str - balance: str + balance: float mode: str