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
3 changes: 2 additions & 1 deletion examples/category_manager/get_categories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import List

from dotenv import load_dotenv

Expand Down Expand Up @@ -27,6 +28,6 @@
# print(get_categories_response)

# Print the API response containing the categories
categories: list[Category] = get_categories_response.get_data()
categories: List[Category] = get_categories_response.get_data()

print(categories)
3 changes: 2 additions & 1 deletion examples/gateway_manager/get_gateways.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import List

from dotenv import load_dotenv

Expand Down Expand Up @@ -28,6 +29,6 @@
# print(get_gateways_response)

# Extract the listing of gateways from the response
gatewayListing: list[Gateway] = get_gateways_response.get_data()
gatewayListing: List[Gateway] = get_gateways_response.get_data()

print(gatewayListing)
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 = [
"ANN001",
"ANN003",
"ANN101", # missing type annotation for self
"ANN102", # missing type annotation for cls
Expand Down
1 change: 1 addition & 0 deletions src/multisafepay/api/base/abstract_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# See the DISCLAIMER.md file for disclaimer details.


from multisafepay.client.client import Client


Expand Down
2 changes: 1 addition & 1 deletion src/multisafepay/api/base/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def adapt_brands(

Parameters
----------
brands (Optional[list[Optional[dict]]]): A list of dictionaries containing brand information, by default None.
brands (Optional[List[Optional[dict]]]): A list of dictionaries containing brand information, by default None.

Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions src/multisafepay/api/base/listings/listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, data: List[Any], class_type: type, **kwargs):

Parameters
----------
data (list[Any]): A list of data to be converted into items of type T.
data (List[Any]): A list of data to be converted into items of type T.
class_type (type): The class type to convert the data into.
**kwargs: Additional keyword arguments to pass to the class type constructor.

Expand Down Expand Up @@ -59,7 +59,7 @@ def __iter__(self):
"""
return iter(self.data)

def __getitem__(self, index):
def __getitem__(self: "Listing", index: int) -> T:
"""
Get an item by index.

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 @@ -22,7 +22,7 @@ class CustomApiResponse(ApiResponse):

data: Optional[Any]

def __init__(self, data, **kwargs):
def __init__(self: "CustomApiResponse", data: Optional[Any], **kwargs):
"""
Initialize the CustomApiResponse with optional data and additional keyword arguments.

Expand Down
5 changes: 3 additions & 2 deletions src/multisafepay/api/paths/auth/auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
CustomApiResponse,
)
from multisafepay.api.paths.auth.api_token.response.api_token import ApiToken
from multisafepay.client.client import Client
from multisafepay.util.dict_utils import dict_empty
from multisafepay.util.message import MessageList, gen_could_not_created_msg

Expand All @@ -21,13 +22,13 @@ class AuthManager(AbstractManager):
A manager class for handling authentication-related operations.
"""

def __init__(self, client):
def __init__(self: "AuthManager", client: Client):
"""
Initialize the CaptureManager with a client.

Parameters
----------
client: The client used to make API requests.
client (Client): The client used to make API requests.

"""
super().__init__(client)
Expand Down
5 changes: 3 additions & 2 deletions src/multisafepay/api/paths/capture/capture_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
CaptureRequest,
)
from multisafepay.api.paths.capture.response.capture import CancelReservation
from multisafepay.client.client import Client
from multisafepay.util.dict_utils import dict_empty
from multisafepay.util.message import MessageList, gen_could_not_created_msg

Expand All @@ -25,13 +26,13 @@ class CaptureManager(AbstractManager):
A class to manage capture operations.
"""

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

Parameters
----------
client: The client used to make API requests.
client (Client): The client used to make API requests.

"""
super().__init__(client)
Expand Down
5 changes: 3 additions & 2 deletions src/multisafepay/api/paths/categories/category_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
CustomApiResponse,
)
from multisafepay.api.paths.categories.response.category import Category
from multisafepay.client.client import Client
from multisafepay.util.message import MessageList, gen_could_not_created_msg


Expand All @@ -19,13 +20,13 @@ class CategoryManager(AbstractManager):
A manager class for handling category-related API requests.
"""

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

Parameters
----------
client: The client used to make API requests.
client (Client): The client used to make API requests.

"""
super().__init__(client)
Expand Down
17 changes: 16 additions & 1 deletion src/multisafepay/api/paths/gateways/gateway_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
CustomApiResponse,
)
from multisafepay.api.paths.gateways.response.gateway import Gateway
from multisafepay.client.client import Client
from multisafepay.util.dict_utils import dict_empty
from multisafepay.util.message import MessageList, gen_could_not_created_msg

Expand All @@ -27,7 +28,21 @@ class GatewayManager(AbstractManager):
Manages gateway-related operations.
"""

def get_gateways(self, include_coupons: bool = True) -> CustomApiResponse:
def __init__(self: "GatewayManager", client: Client):
"""
Initialize the CategoryManager with a client.

Parameters
----------
client (Client): The client used to make API requests.

"""
super().__init__(client)

def get_gateways(
self: "GatewayManager",
include_coupons: bool = True,
) -> CustomApiResponse:
"""
Retrieve a list of gateways.

Expand Down
5 changes: 3 additions & 2 deletions src/multisafepay/api/paths/issuers/issuer_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ALLOWED_GATEWAY_CODES,
Issuer,
)
from multisafepay.client.client import Client
from multisafepay.exception.invalid_argument import InvalidArgumentException
from multisafepay.util.message import MessageList, gen_could_not_created_msg

Expand All @@ -23,13 +24,13 @@ class IssuerManager(AbstractManager):
Manager class for handling issuer-related operations.
"""

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

Parameters
----------
client: The client used to make API requests.
client (Client): The client used to make API requests.

"""
super().__init__(client)
Expand Down
5 changes: 3 additions & 2 deletions src/multisafepay/api/paths/me/me_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
CustomApiResponse,
)
from multisafepay.api.paths.me.response.me import Me
from multisafepay.client.client import Client
from multisafepay.util.dict_utils import dict_empty
from multisafepay.util.message import MessageList, gen_could_not_created_msg

Expand All @@ -20,13 +21,13 @@ class MeManager(AbstractManager):
A manager class for handling 'me' related API requests.
"""

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

Parameters
----------
client: The client used to make API requests.
client (Client): The client used to make API requests.

"""
super().__init__(client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ class CheckoutData(RequestModel):

Attributes
----------
items (Optional[list[CartItem]]): The list of cart items.
items (Optional[List[CartItem]]): The list of cart items.

"""

items: Optional[List[CartItem]]

def add_items(self, items=[]):
def add_items(self, items: List[CartItem] = ()):
"""
Adds multiple items to the checkout data.

Parameters
----------
items (list[CartItem]): The list of items to add.
items (List[CartItem]): The list of items to add.

Returns
-------
Expand All @@ -45,7 +45,7 @@ def add_items(self, items=[]):
self.add_item(item)
return self

def add_item(self, item):
def add_item(self, item: CartItem):
"""
Adds a single item to the checkout data.

Expand All @@ -69,7 +69,7 @@ def get_items(self):

Returns
-------
list[CartItem]: The list of items.
List[CartItem]: The list of items.

"""
return self.items
Expand All @@ -92,7 +92,7 @@ def get_item(self, index: int):
def generate_from_shopping_cart(
self,
shopping_cart: ShoppingCart,
tax_table_selector="",
tax_table_selector: str = "",
):
"""
Generates checkout data from a shopping cart.
Expand All @@ -110,13 +110,17 @@ def generate_from_shopping_cart(
shopping_cart_item.add_tax_table_selector(tax_table_selector)
self.add_item(shopping_cart_item)

def refund_by_merchant_item_id(self, merchant_item_id, quantity=0):
def refund_by_merchant_item_id(
self,
merchant_item_id: str,
quantity: int = 0,
):
"""
Processes a refund by merchant item ID.

Parameters
----------
merchant_item_id: The merchant item ID to refund.
merchant_item_id (str): The merchant item ID to refund.
quantity (int): The quantity to refund.

Raises
Expand All @@ -139,13 +143,13 @@ def refund_by_merchant_item_id(self, merchant_item_id, quantity=0):

self.add_item(refund_item)

def get_item_by_merchant_item_id(self, merchant_item_id):
def get_item_by_merchant_item_id(self, merchant_item_id: str):
"""
Retrieves an item by its merchant item ID.

Parameters
----------
merchant_item_id: The merchant item ID to search for.
merchant_item_id (str): The merchant item ID to search for.

Returns
-------
Expand Down
5 changes: 3 additions & 2 deletions src/multisafepay/api/paths/orders/order_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from multisafepay.api.paths.orders.response.order_response import Order
from multisafepay.api.shared.cart.shopping_cart import ShoppingCart
from multisafepay.api.shared.description import Description
from multisafepay.client.client import Client
from multisafepay.util.dict_utils import dict_empty
from multisafepay.util.message import MessageList, gen_could_not_created_msg
from multisafepay.value_object.amount import Amount
Expand All @@ -47,13 +48,13 @@ class OrderManager(AbstractManager):
Manages operations related to orders, such as creating, updating, capturing, and refunding orders.
"""

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

Parameters
----------
client: The client used to make API requests.
client (Client): The client used to make API requests.

"""
super().__init__(client)
Expand Down
4 changes: 2 additions & 2 deletions src/multisafepay/api/paths/orders/request/order_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ def add_customer(self, customer: Customer) -> "OrderRequest":
self.customer = customer
return self

def add_gateway(self, gateway) -> "OrderRequest":
def add_gateway(self, gateway: str) -> "OrderRequest":
"""
Adds the gateway to the order request.

Parameters
----------
gateway: The gateway.
gateway (str): The gateway.

Returns
-------
Expand Down
6 changes: 3 additions & 3 deletions src/multisafepay/api/paths/orders/response/order_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Order(ResponseModel):
amount (Optional[int]): The amount of the order.
amount_refunded (Optional[int]): The amount refunded.
checkout_options (Optional[CheckoutOptions]): The checkout options.
costs (Optional[list[Costs]]): The costs of the order.
costs (Optional[List[Costs]]): The costs of the order.
created (Optional[str]): The creation date of the order.
modified (Optional[str]): The modification date of the order.
currency (Optional[str]): The currency of the order.
Expand All @@ -50,10 +50,10 @@ class Order(ResponseModel):
order_id (Optional[str]): The ID of the order.
order_total (Optional[float]): The total amount of the order.
payment_details (Optional[PaymentDetails]): The payment details.
payment_method (Optional[list[PaymentMethod]]): The payment methods.
payment_method (Optional[List[PaymentMethod]]): The payment methods.
reason (Optional[str]): The reason for the order.
reason_code (Optional[str]): The reason code for the order.
related_transactions (Optional[list[Transaction]]): The related transactions.
related_transactions (Optional[List[Transaction]]): The related transactions.
shopping_cart (Optional[ShoppingCart]): The shopping cart.
status (Optional[str]): The status of the order.
transaction_id (Optional[str]): The ID of the transaction.
Expand Down
Loading