Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ extend-safe-fixes = [
"D415", # docstrings should end with a period, question mark, or exclamation point
]
ignore = [
"ANN101", # missing type annotation for self
"ANN102", # missing type annotation for cls
"ANN201",
"ANN204",
Expand Down
2 changes: 1 addition & 1 deletion src/multisafepay/api/base/abstract_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AbstractManager:

"""

def __init__(self, client: Client):
def __init__(self: "AbstractManager", client: Client):
"""
Initialize the AbstractManager with a Client instance.

Expand Down
48 changes: 30 additions & 18 deletions src/multisafepay/api/base/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class Decorator:

Attributes
----------
dependencies (Optional[dict]): A dictionary of dependencies to be used by the decorator.
dependencies (Optional[Dict]): A dictionary of dependencies to be used by the decorator.

"""

dependencies: Optional[dict]
dependencies: Optional[Dict]

def __init__(self, dependencies: dict = {}) -> None:
def __init__(self: "Decorator", dependencies: Dict = {}) -> None:
"""
Initialize the Decorator with optional dependencies.

Expand All @@ -32,7 +32,7 @@ def __init__(self, dependencies: dict = {}) -> None:
self.dependencies = dependencies

def adapt_checkout_options(
self,
self: "Decorator",
checkout_options: Optional[Dict],
) -> "Decorator":
"""
Expand All @@ -57,7 +57,7 @@ def adapt_checkout_options(
)
return self

def adapt_costs(self, costs: Optional[Dict]) -> "Decorator":
def adapt_costs(self: "Decorator", costs: Optional[Dict]) -> "Decorator":
"""
Adapt the costs and update the dependencies.

Expand All @@ -78,7 +78,10 @@ def adapt_costs(self, costs: Optional[Dict]) -> "Decorator":
]
return self

def adapt_custom_info(self, custom_info: Optional[Dict]) -> "Decorator":
def adapt_custom_info(
self: "Decorator",
custom_info: Optional[Dict],
) -> "Decorator":
"""
Adapt the custom information and update the dependencies.

Expand All @@ -100,7 +103,10 @@ def adapt_custom_info(self, custom_info: Optional[Dict]) -> "Decorator":

return self

def adapt_customer(self, customer: Optional[Dict]) -> "Decorator":
def adapt_customer(
self: "Decorator",
customer: Optional[Dict],
) -> "Decorator":
"""
Adapt the customer information and update the dependencies.

Expand All @@ -121,7 +127,7 @@ def adapt_customer(self, customer: Optional[Dict]) -> "Decorator":
return self

def adapt_order_adjustment(
self,
self: "Decorator",
order_adjustment: Optional[Dict],
) -> "Decorator":
"""
Expand All @@ -148,7 +154,7 @@ def adapt_order_adjustment(
return self

def adapt_payment_details(
self,
self: "Decorator",
payment_details: Optional[Dict],
) -> "Decorator":
"""
Expand All @@ -175,7 +181,7 @@ def adapt_payment_details(
return self

def adapt_payment_methods(
self,
self: "Decorator",
payment_methods: Optional[Dict],
) -> "Decorator":
"""
Expand All @@ -200,7 +206,7 @@ def adapt_payment_methods(
return self

def adapt_shopping_cart(
self,
self: "Decorator",
shopping_cart: Optional[Dict],
) -> "Decorator":
"""
Expand All @@ -224,7 +230,7 @@ def adapt_shopping_cart(
return self

def adapt_related_transactions(
self,
self: "Decorator",
related_transactions: Optional[Dict],
) -> "Decorator":
"""
Expand All @@ -250,7 +256,7 @@ def adapt_related_transactions(
]
return self

def adapt_apps(self, apps: Optional[Dict]) -> "Decorator":
def adapt_apps(self: "Decorator", apps: Optional[Dict]) -> "Decorator":
"""
Adapt the apps and update the dependencies.

Expand All @@ -273,7 +279,7 @@ def adapt_apps(self, apps: Optional[Dict]) -> "Decorator":
return self

def adapt_brands(
self,
self: "Decorator",
brands: Optional[List[Optional[Dict]]],
) -> "Decorator":
"""
Expand All @@ -298,7 +304,10 @@ def adapt_brands(
]
return self

def adapt_icon_urls(self, icon_urls: Optional[Dict]) -> "Decorator":
def adapt_icon_urls(
self: "Decorator",
icon_urls: Optional[Dict],
) -> "Decorator":
"""
Adapt the icon URLs and update the dependencies.

Expand All @@ -320,7 +329,10 @@ def adapt_icon_urls(self, icon_urls: Optional[Dict]) -> "Decorator":

return self

def adapt_tokenization(self, tokenization: Optional[Dict]) -> "Decorator":
def adapt_tokenization(
self: "Decorator",
tokenization: Optional[Dict],
) -> "Decorator":
"""
Adapt the tokenization and update the dependencies.

Expand All @@ -345,7 +357,7 @@ def adapt_tokenization(self, tokenization: Optional[Dict]) -> "Decorator":
return self

def adapt_allowed_amount(
self,
self: "Decorator",
allowed_amount: Optional[Dict],
) -> "Decorator":
"""
Expand All @@ -370,7 +382,7 @@ def adapt_allowed_amount(
)
return self

def get_dependencies(self) -> Dict[str, Any]:
def get_dependencies(self: "Decorator") -> Dict[str, Any]:
"""
Get the current dependencies.

Expand Down
10 changes: 5 additions & 5 deletions src/multisafepay/api/base/listings/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Listing(Generic[T], BaseModel):
data: List[T]

def __init__(
self,
self: "Listing",
data: List[Any],
class_type: type,
**kwargs: Dict[str, Any],
Expand Down Expand Up @@ -53,7 +53,7 @@ def __init__(

super().__init__(data=elements)

def __iter__(self):
def __iter__(self: "Listing"):
"""
Return an iterator over the items in the listing.

Expand All @@ -79,7 +79,7 @@ def __getitem__(self: "Listing", index: int) -> T:
"""
return self.data[index]

def __len__(self):
def __len__(self: "Listing"):
"""
Get the number of items in the listing.

Expand All @@ -90,7 +90,7 @@ def __len__(self):
"""
return len(self.data)

def get_data(self) -> List[T]:
def get_data(self: "Listing") -> List[T]:
"""
Get the list of items in the listing.

Expand All @@ -101,7 +101,7 @@ def get_data(self) -> List[T]:
"""
return self.data

def append(self, item: T):
def append(self: "Listing", item: T):
"""
Append an item to the listing.

Expand Down
15 changes: 11 additions & 4 deletions src/multisafepay/api/base/listings/listing_pager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

# See the DISCLAIMER.md file for disclaimer details.

from typing import Optional

from multisafepay.api.base.listings.listing import Listing
from multisafepay.api.base.listings.pager import Pager

Expand All @@ -19,23 +21,28 @@ class ListingPager(Listing):

"""

pager: Pager = None
pager: Optional[Pager] = None

def __init__(self, data: list, pager: Pager, class_type: type):
def __init__(
self: "ListingPager",
data: list,
pager: Optional[Pager],
class_type: type,
):
"""
Initialize the ListingPager with data, pager, and class type.

Parameters
----------
data (list): A list of data to be converted into items of type T.
pager (Pager): The pager object for pagination.
pager (Optional[Pager]): The pager object for pagination.
class_type (type): The class type to convert the data into.

"""
super().__init__(data=data, class_type=class_type)
self.pager = pager

def get_pager(self) -> Pager:
def get_pager(self: "ListingPager") -> Optional[Pager]:
"""
Get the pager object.

Expand Down
18 changes: 9 additions & 9 deletions src/multisafepay/api/base/response/api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def with_json(
raw=json_data.__str__(),
)

def get_body_data(self) -> Optional[Any]:
def get_body_data(self: "ApiResponse") -> Optional[Any]:
"""
Get the data from the body of the response.

Expand All @@ -76,7 +76,7 @@ def get_body_data(self) -> Optional[Any]:
"""
return self.body.get("data", None)

def get_body_success(self) -> Optional[bool]:
def get_body_success(self: "ApiResponse") -> Optional[bool]:
"""
Get the success status from the body of the response.

Expand All @@ -87,7 +87,7 @@ def get_body_success(self) -> Optional[bool]:
"""
return self.body.get("success", None)

def get_body_error_code(self) -> Optional[int]:
def get_body_error_code(self: "ApiResponse") -> Optional[int]:
"""
Get the error code from the body of the response.

Expand All @@ -98,7 +98,7 @@ def get_body_error_code(self) -> Optional[int]:
"""
return self.body.get("error_code", None)

def get_body_error_info(self) -> Optional[str]:
def get_body_error_info(self: "ApiResponse") -> Optional[str]:
"""
Get the error information from the body of the response.

Expand All @@ -109,7 +109,7 @@ def get_body_error_info(self) -> Optional[str]:
"""
return self.body.get("error_info", None)

def get_context(self) -> dict:
def get_context(self: "ApiResponse") -> dict:
"""
Get the context of the response.

Expand All @@ -120,7 +120,7 @@ def get_context(self) -> dict:
"""
return self.context

def get_headers(self) -> dict:
def get_headers(self: "ApiResponse") -> dict:
"""
Get the headers of the response.

Expand All @@ -131,7 +131,7 @@ def get_headers(self) -> dict:
"""
return self.headers

def get_status_code(self) -> int:
def get_status_code(self: "ApiResponse") -> int:
"""
Get the status code of the response.

Expand All @@ -142,7 +142,7 @@ def get_status_code(self) -> int:
"""
return self.status_code

def get_raw(self) -> str:
def get_raw(self: "ApiResponse") -> str:
"""
Get the raw response data as a string.

Expand All @@ -153,7 +153,7 @@ def get_raw(self) -> str:
"""
return self.raw

def get_pager(self) -> Optional[Pager]:
def get_pager(self: "ApiResponse") -> Optional[Pager]:
"""
Get the pager object from the body of the response.

Expand Down
2 changes: 1 addition & 1 deletion src/multisafepay/api/base/response/custom_api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
for key, value in kwargs.items():
setattr(self, key, value)

def get_data(self):
def get_data(self: "CustomApiResponse"):
"""
Get the data contained in the response.

Expand Down
2 changes: 1 addition & 1 deletion src/multisafepay/api/paths/auth/auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self: "AuthManager", client: Client):
"""
super().__init__(client)

def get_api_token(self) -> CustomApiResponse:
def get_api_token(self: "AuthManager") -> CustomApiResponse:
"""
Retrieve the API token.

Expand Down
2 changes: 1 addition & 1 deletion src/multisafepay/api/paths/capture/capture_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self: "CaptureManager", client: Client):
super().__init__(client)

def capture_reservation_cancel(
self,
self: "CaptureManager",
order_id: str,
capture_request: CaptureRequest,
) -> CustomApiResponse:
Expand Down
4 changes: 2 additions & 2 deletions src/multisafepay/api/paths/capture/request/capture_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CaptureRequest(RequestModel):
status: Optional[str]
reason: Optional[str]

def add_status(self, status: str):
def add_status(self: "CaptureRequest", status: str):
"""
Add a status to the capture request.

Expand All @@ -41,7 +41,7 @@ def add_status(self, status: str):
self.status = status
return self

def add_reason(self, reason: str):
def add_reason(self: "CaptureRequest", reason: str):
"""
Add a reason to the capture request.

Expand Down
Loading