diff --git a/examples/category_manager/get_categories.py b/examples/category_manager/get_categories.py index e16b4b1..1242711 100644 --- a/examples/category_manager/get_categories.py +++ b/examples/category_manager/get_categories.py @@ -1,4 +1,5 @@ import os +from typing import List from dotenv import load_dotenv @@ -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) diff --git a/examples/gateway_manager/get_gateways.py b/examples/gateway_manager/get_gateways.py index 1550f2e..e7d4288 100644 --- a/examples/gateway_manager/get_gateways.py +++ b/examples/gateway_manager/get_gateways.py @@ -1,4 +1,5 @@ import os +from typing import List from dotenv import load_dotenv @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 40cb0e0..76df706 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/src/multisafepay/api/base/abstract_manager.py b/src/multisafepay/api/base/abstract_manager.py index b81d2da..7d3f06c 100644 --- a/src/multisafepay/api/base/abstract_manager.py +++ b/src/multisafepay/api/base/abstract_manager.py @@ -5,6 +5,7 @@ # See the DISCLAIMER.md file for disclaimer details. + from multisafepay.client.client import Client diff --git a/src/multisafepay/api/base/decorator.py b/src/multisafepay/api/base/decorator.py index 06bf044..2a1381f 100644 --- a/src/multisafepay/api/base/decorator.py +++ b/src/multisafepay/api/base/decorator.py @@ -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 ------- diff --git a/src/multisafepay/api/base/listings/listing.py b/src/multisafepay/api/base/listings/listing.py index 34d04b3..0277d5f 100644 --- a/src/multisafepay/api/base/listings/listing.py +++ b/src/multisafepay/api/base/listings/listing.py @@ -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. @@ -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. diff --git a/src/multisafepay/api/base/response/custom_api_response.py b/src/multisafepay/api/base/response/custom_api_response.py index f37f839..6569ad3 100644 --- a/src/multisafepay/api/base/response/custom_api_response.py +++ b/src/multisafepay/api/base/response/custom_api_response.py @@ -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. diff --git a/src/multisafepay/api/paths/auth/auth_manager.py b/src/multisafepay/api/paths/auth/auth_manager.py index 3ade070..994fcd9 100644 --- a/src/multisafepay/api/paths/auth/auth_manager.py +++ b/src/multisafepay/api/paths/auth/auth_manager.py @@ -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 @@ -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) diff --git a/src/multisafepay/api/paths/capture/capture_manager.py b/src/multisafepay/api/paths/capture/capture_manager.py index 4b92f5f..39eb568 100644 --- a/src/multisafepay/api/paths/capture/capture_manager.py +++ b/src/multisafepay/api/paths/capture/capture_manager.py @@ -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 @@ -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) diff --git a/src/multisafepay/api/paths/categories/category_manager.py b/src/multisafepay/api/paths/categories/category_manager.py index 0d0055f..f84caad 100644 --- a/src/multisafepay/api/paths/categories/category_manager.py +++ b/src/multisafepay/api/paths/categories/category_manager.py @@ -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 @@ -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) diff --git a/src/multisafepay/api/paths/gateways/gateway_manager.py b/src/multisafepay/api/paths/gateways/gateway_manager.py index a9a41ee..c53f83d 100644 --- a/src/multisafepay/api/paths/gateways/gateway_manager.py +++ b/src/multisafepay/api/paths/gateways/gateway_manager.py @@ -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 @@ -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. diff --git a/src/multisafepay/api/paths/issuers/issuer_manager.py b/src/multisafepay/api/paths/issuers/issuer_manager.py index 26311bb..cf30635 100644 --- a/src/multisafepay/api/paths/issuers/issuer_manager.py +++ b/src/multisafepay/api/paths/issuers/issuer_manager.py @@ -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 @@ -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) diff --git a/src/multisafepay/api/paths/me/me_manager.py b/src/multisafepay/api/paths/me/me_manager.py index 069f3dc..66319e1 100644 --- a/src/multisafepay/api/paths/me/me_manager.py +++ b/src/multisafepay/api/paths/me/me_manager.py @@ -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 @@ -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) diff --git a/src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py b/src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py index 01d291e..d3eafae 100644 --- a/src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py +++ b/src/multisafepay/api/paths/orders/order_id/refund/request/components/checkout_data.py @@ -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 ------- @@ -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. @@ -69,7 +69,7 @@ def get_items(self): Returns ------- - list[CartItem]: The list of items. + List[CartItem]: The list of items. """ return self.items @@ -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. @@ -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 @@ -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 ------- diff --git a/src/multisafepay/api/paths/orders/order_manager.py b/src/multisafepay/api/paths/orders/order_manager.py index f516bc0..aa62ef7 100644 --- a/src/multisafepay/api/paths/orders/order_manager.py +++ b/src/multisafepay/api/paths/orders/order_manager.py @@ -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 @@ -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) diff --git a/src/multisafepay/api/paths/orders/request/order_request.py b/src/multisafepay/api/paths/orders/request/order_request.py index 9df2bc8..6bd6422 100644 --- a/src/multisafepay/api/paths/orders/request/order_request.py +++ b/src/multisafepay/api/paths/orders/request/order_request.py @@ -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 ------- diff --git a/src/multisafepay/api/paths/orders/response/order_response.py b/src/multisafepay/api/paths/orders/response/order_response.py index 8a89950..6ae6555 100644 --- a/src/multisafepay/api/paths/orders/response/order_response.py +++ b/src/multisafepay/api/paths/orders/response/order_response.py @@ -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. @@ -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. diff --git a/src/multisafepay/api/paths/payment_methods/payment_method_manager.py b/src/multisafepay/api/paths/payment_methods/payment_method_manager.py index e367b96..22e43c0 100644 --- a/src/multisafepay/api/paths/payment_methods/payment_method_manager.py +++ b/src/multisafepay/api/paths/payment_methods/payment_method_manager.py @@ -13,7 +13,7 @@ from multisafepay.api.paths.payment_methods.response.payment_method import ( PaymentMethod, ) -from multisafepay.client.client import ApiResponse +from multisafepay.client.client import ApiResponse, Client from multisafepay.util.dict_utils import dict_empty from multisafepay.util.message import MessageList, gen_could_not_created_msg @@ -30,13 +30,13 @@ class PaymentMethodManager(AbstractManager): A class representing the PaymentMethodManager. """ - def __init__(self, client): + def __init__(self, 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) diff --git a/src/multisafepay/api/paths/payment_methods/response/components/brand.py b/src/multisafepay/api/paths/payment_methods/response/components/brand.py index a8f7722..bbade26 100644 --- a/src/multisafepay/api/paths/payment_methods/response/components/brand.py +++ b/src/multisafepay/api/paths/payment_methods/response/components/brand.py @@ -20,7 +20,7 @@ class Brand(ResponseModel): Attributes ---------- - allowed_countries (Optional[list[str]]): The allowed countries for the brand. + allowed_countries (Optional[List[str]]): The allowed countries for the brand. icon_urls (Optional[IconUrls]): The icon URLs for the brand. id (Optional[str]): The ID of the brand. name (Optional[str]): The name of the brand. diff --git a/src/multisafepay/api/paths/payment_methods/response/payment_method.py b/src/multisafepay/api/paths/payment_methods/response/payment_method.py index ee459af..8d5a080 100644 --- a/src/multisafepay/api/paths/payment_methods/response/payment_method.py +++ b/src/multisafepay/api/paths/payment_methods/response/payment_method.py @@ -35,17 +35,17 @@ class PaymentMethod(ResponseModel): ---------- additional_data (Optional[dict]): Additional data for the payment method. allowed_amount (Optional[AllowedAmount]): The allowed amount for the payment method. - allowed_countries (Optional[list[str]]): The allowed countries for the payment method. - allowed_currencies (Optional[list[str]]): The allowed currencies for the payment method. + allowed_countries (Optional[List[str]]): The allowed countries for the payment method. + allowed_currencies (OptionalList[str]]): The allowed currencies for the payment method. apps (Optional[Apps]): The apps associated with the payment method. - brands (Optional[list[Brand]]): The brands associated with the payment method. + brands (Optional[List[Brand]]): The brands associated with the payment method. description (Optional[str]): The description of the payment method. icon_urls (Optional[IconUrls]): The icon URLs for the payment method. id (Optional[str]): The ID of the payment method. label (Optional[str]): The label of the payment method. name (Optional[str]): The name of the payment method. - preferred_countries (Optional[list[str]]): The preferred countries for the payment method. - required_customer_data (Optional[list[str]]): The required customer data for the payment method. + preferred_countries (Optional[List[str]]): The preferred countries for the payment method. + required_customer_data (Optional[List[str]]): The required customer data for the payment method. tokenization (Optional[Tokenization]): The tokenization support information for the payment method. type (Optional[str]): The type of the payment method. shopping_cart_required (Optional[bool]): Whether a shopping cart is required for the payment method. diff --git a/src/multisafepay/api/paths/recurring/recurring_manager.py b/src/multisafepay/api/paths/recurring/recurring_manager.py index d5f372b..d8b16e0 100644 --- a/src/multisafepay/api/paths/recurring/recurring_manager.py +++ b/src/multisafepay/api/paths/recurring/recurring_manager.py @@ -5,6 +5,7 @@ # See the DISCLAIMER.md file for disclaimer details. +from typing import Any from multisafepay.api.base.abstract_manager import AbstractManager from multisafepay.api.base.response.api_response import ApiResponse @@ -14,6 +15,7 @@ from multisafepay.api.paths.recurring.customer_reference.token.token import ( Token, ) +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 @@ -33,7 +35,7 @@ class RecurringManager(AbstractManager): CREDIT_CARD_GATEWAY_CODE = "CREDITCARD" CREDIT_CARD_GATEWAYS = ["VISA", "MASTERCARD", "AMEX", "MAESTRO"] - def __init__(self, client): + def __init__(self, client: Client): """ Initializes the RecurringManager with a client. @@ -43,7 +45,7 @@ def __init__(self, client): """ super().__init__(client) - self.tokens = {} + self.tokens: Any = {} def get_list( self, diff --git a/src/multisafepay/api/paths/transactions/response/transaction.py b/src/multisafepay/api/paths/transactions/response/transaction.py index 2e0e43e..04ae288 100644 --- a/src/multisafepay/api/paths/transactions/response/transaction.py +++ b/src/multisafepay/api/paths/transactions/response/transaction.py @@ -23,7 +23,7 @@ class Transaction(ResponseModel): ---------- amount (Optional[int]): The amount of the transaction. completed (Optional[str]): The completion date of the transaction. - costs (Optional[list[Costs]]): The costs of the transaction. + costs (Optional[List[Costs]]): The costs of the transaction. created (Optional[str]): The creation date of the transaction. modified (Optional[str]): The modification date of the transaction. currency (Optional[str]): The currency of the transaction. @@ -36,7 +36,7 @@ class Transaction(ResponseModel): net (Optional[int]): The net amount of the transaction. order_id (Optional[str]): The order ID of the transaction. payment_method (Optional[str]): The payment method of the transaction. - payment_methods (Optional[list[PaymentMethod]]): The payment methods of the transaction. + payment_methods (Optional[List[PaymentMethod]]): The payment methods of the transaction. reason (Optional[str]): The reason for the transaction. reason_code (Optional[str]): The reason code for the transaction. site_id (Optional[str]): The site ID of the transaction. diff --git a/src/multisafepay/api/paths/transactions/transaction_manager.py b/src/multisafepay/api/paths/transactions/transaction_manager.py index 939baf1..3060b56 100644 --- a/src/multisafepay/api/paths/transactions/transaction_manager.py +++ b/src/multisafepay/api/paths/transactions/transaction_manager.py @@ -16,6 +16,7 @@ from multisafepay.api.paths.transactions.response.transaction import ( Transaction, ) +from multisafepay.client.client import Client from multisafepay.util.message import MessageList, gen_could_not_created_msg ALLOWED_OPTIONS = { @@ -40,13 +41,13 @@ class TransactionManager(AbstractManager): A class representing the TransactionManager. """ - def __init__(self, client): + def __init__(self, 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) diff --git a/src/multisafepay/api/shared/cart/cart_item.py b/src/multisafepay/api/shared/cart/cart_item.py index fd3f667..d3ef30e 100644 --- a/src/multisafepay/api/shared/cart/cart_item.py +++ b/src/multisafepay/api/shared/cart/cart_item.py @@ -26,7 +26,7 @@ class CartItem(ApiModel): image: (Optional[str]) The image URL. merchant_item_id: (Optional[str]) The merchant item ID. name: (Optional[str]) The name. - options: (Optional[list[dict]]) The list of options. + options: (Optional[List[dict]]) The list of options. product_url: (Optional[str]) The product URL. quantity: (Optional[int]) The quantity. tax_table_selector: (Optional[str]) The tax table selector. @@ -150,7 +150,7 @@ def add_options(self, options: List[Dict]) -> "CartItem": Parameters ---------- - options: (list[dict]) The list of options to be added. + options: (List[dict]) The list of options to be added. Returns ------- diff --git a/src/multisafepay/api/shared/cart/shopping_cart.py b/src/multisafepay/api/shared/cart/shopping_cart.py index cac3d32..510dc3f 100644 --- a/src/multisafepay/api/shared/cart/shopping_cart.py +++ b/src/multisafepay/api/shared/cart/shopping_cart.py @@ -17,7 +17,7 @@ class ShoppingCart(ApiModel): Attributes ---------- - items: (Optional[list[CartItem]]) The list of items in the shopping cart. + items: (Optional[List[CartItem]]) The list of items in the shopping cart. """ @@ -29,7 +29,7 @@ def get_items(self) -> List[CartItem]: Returns ------- - list[CartItem]: The list of items in the shopping cart. + List[CartItem]: The list of items in the shopping cart. """ return self.items @@ -40,7 +40,7 @@ def add_items(self, items: List[CartItem]): Parameters ---------- - items: (list[CartItem]) The list of items to be added to the shopping cart. + items: (List[CartItem]) The list of items to be added to the shopping cart. Returns ------- diff --git a/src/multisafepay/api/shared/checkout/checkout_options.py b/src/multisafepay/api/shared/checkout/checkout_options.py index f545bd2..69fc02f 100644 --- a/src/multisafepay/api/shared/checkout/checkout_options.py +++ b/src/multisafepay/api/shared/checkout/checkout_options.py @@ -20,7 +20,7 @@ class CheckoutOptions(ApiModel): Attributes ---------- default (Optional[DefaultTaxRate]): The default tax rate. - alternate (Optional[list[TaxRate]]): A list of alternate tax rates. + alternate (Optional[List[TaxRate]]): A list of alternate tax rates. """ @@ -49,7 +49,7 @@ def add_alternate(self, alternate: List[TaxRule]) -> "CheckoutOptions": Parameters ---------- - alternate (list[TaxRule]): The list of alternate tax rates to be added. + alternate (List[TaxRule]): The list of alternate tax rates to be added. Returns ------- diff --git a/src/multisafepay/api/shared/checkout/tax_rule.py b/src/multisafepay/api/shared/checkout/tax_rule.py index 49278bb..14a5799 100644 --- a/src/multisafepay/api/shared/checkout/tax_rule.py +++ b/src/multisafepay/api/shared/checkout/tax_rule.py @@ -19,7 +19,7 @@ class TaxRule(ApiModel): Attributes ---------- name (Optional[str]): The name of the tax rule. - rules (Optional[list[TaxRate]]): A list of tax rates associated with the tax rule. + rules (Optional[List[TaxRate]]): A list of tax rates associated with the tax rule. standalone (Optional[bool]): Indicates if the tax rule is standalone. """ @@ -50,7 +50,7 @@ def add_rules(self, rules: List[TaxRate]) -> "TaxRule": Parameters ---------- - rules (list[TaxRate]): The list of tax rates to be added. + rules (List[TaxRate]): The list of tax rates to be added. Returns ------- diff --git a/src/multisafepay/util/dict_utils.py b/src/multisafepay/util/dict_utils.py index ce241d1..b2fd58f 100644 --- a/src/multisafepay/util/dict_utils.py +++ b/src/multisafepay/util/dict_utils.py @@ -5,10 +5,10 @@ # See the DISCLAIMER.md file for disclaimer details. -from typing import Any, Optional, Union +from typing import Any, Optional -def merge_recursive(dict1, dict2): +def merge_recursive(dict1: dict, dict2: dict): """ Recursively merge two dictionaries. @@ -66,7 +66,7 @@ def remove_null_recursive(input_data: dict) -> dict: """ - def process_value(value) -> Optional[Union[dict, list, Any]]: + def process_value(value: Any) -> Optional[Any]: if isinstance(value, dict): processed_dict = remove_null_recursive(value) return processed_dict if processed_dict else None @@ -85,7 +85,7 @@ def process_value(value) -> Optional[Union[dict, list, Any]]: } -def dict_empty(value) -> bool: +def dict_empty(value: Any) -> bool: """ Check if the given value is an empty dictionary. diff --git a/src/multisafepay/util/message.py b/src/multisafepay/util/message.py index a7a39ce..3489437 100644 --- a/src/multisafepay/util/message.py +++ b/src/multisafepay/util/message.py @@ -47,7 +47,7 @@ def __iter__(self): """ return iter(self.__root__) - def __getitem__(self, index): + def __getitem__(self, index: int): """ Get a message by index. diff --git a/src/multisafepay/util/total_amount.py b/src/multisafepay/util/total_amount.py index b7613cf..e8f8edd 100644 --- a/src/multisafepay/util/total_amount.py +++ b/src/multisafepay/util/total_amount.py @@ -85,7 +85,7 @@ def __get_tax_rate_by_item( Returns ------- - int | list[int | Any] | Any: The tax rate for the item, or 0 if no tax rate is found. + int | List[int | Any] | Any: The tax rate for the item, or 0 if no tax rate is found. """ if "tax_table_selector" not in item or not item["tax_table_selector"]: diff --git a/src/multisafepay/value_object/country.py b/src/multisafepay/value_object/country.py index bb06b0c..11ce34c 100644 --- a/src/multisafepay/value_object/country.py +++ b/src/multisafepay/value_object/country.py @@ -22,7 +22,7 @@ class Country(BaseModel): code: str @validator("code") - def validate_country(cls, value): + def validate_country(cls, value: str): """ Validate the country code. diff --git a/src/multisafepay/value_object/currency.py b/src/multisafepay/value_object/currency.py index 4161b29..4da8fcb 100644 --- a/src/multisafepay/value_object/currency.py +++ b/src/multisafepay/value_object/currency.py @@ -24,7 +24,7 @@ class Currency(InmutableModel): currency: str @validator("currency") - def validate_currency(cls, value): + def validate_currency(cls, value: str): """ Validate the currency code. diff --git a/src/multisafepay/value_object/email_address.py b/src/multisafepay/value_object/email_address.py index 5c8c39f..7d5324c 100644 --- a/src/multisafepay/value_object/email_address.py +++ b/src/multisafepay/value_object/email_address.py @@ -26,7 +26,7 @@ class EmailAddress(InmutableModel): email_address: str @validator("email_address") - def validate_email_address(cls, value): + def validate_email_address(cls, value: str): """ Validate the email address value. diff --git a/src/multisafepay/value_object/gender.py b/src/multisafepay/value_object/gender.py index 0df7290..b23e266 100644 --- a/src/multisafepay/value_object/gender.py +++ b/src/multisafepay/value_object/gender.py @@ -26,7 +26,7 @@ class Gender(InmutableModel): gender: str @validator("gender") - def validate_ip_address(cls, value): + def validate_ip_address(cls, value: str): """ Validate the gender value. diff --git a/src/multisafepay/value_object/iban_number.py b/src/multisafepay/value_object/iban_number.py index b60cf3c..5583e96 100644 --- a/src/multisafepay/value_object/iban_number.py +++ b/src/multisafepay/value_object/iban_number.py @@ -26,7 +26,7 @@ class IbanNumber(InmutableModel): iban_number: str @validator("iban_number") - def validate(cls, value): + def validate(cls, value: str): """ Validate the IBAN number. diff --git a/src/multisafepay/value_object/ip_address.py b/src/multisafepay/value_object/ip_address.py index 392ce89..d0e4a0e 100644 --- a/src/multisafepay/value_object/ip_address.py +++ b/src/multisafepay/value_object/ip_address.py @@ -26,7 +26,7 @@ class IpAddress(InmutableModel): ip_address: str @validator("ip_address") - def validate(cls, value): + def validate(cls, value: str): """ Validate the IP address. diff --git a/tests/multisafepay/e2e/examples/auth_manager/test_get_api_token.py b/tests/multisafepay/e2e/examples/auth_manager/test_get_api_token.py index b47fc97..8e51eec 100644 --- a/tests/multisafepay/e2e/examples/auth_manager/test_get_api_token.py +++ b/tests/multisafepay/e2e/examples/auth_manager/test_get_api_token.py @@ -9,28 +9,24 @@ import os import pytest from dotenv import load_dotenv -from typing import TYPE_CHECKING from multisafepay.api.base.response.custom_api_response import ( CustomApiResponse, ) from multisafepay.api.paths.auth.api_token.response.api_token import ApiToken +from multisafepay.api.paths.auth.auth_manager import AuthManager from multisafepay.sdk import Sdk -if TYPE_CHECKING: - from multisafepay.api.paths.auth.auth_manager import AuthManager - - @pytest.fixture(scope="module") -def auth_manager() -> "AuthManager": +def auth_manager() -> AuthManager: load_dotenv() api_key = os.getenv("API_KEY") multisafepay_sdk = Sdk(api_key, False) return multisafepay_sdk.get_auth_manager() -def test_get_api_token(auth_manager): +def test_get_api_token(auth_manager: AuthManager): """ Test the get_api_token method of the AuthManager. diff --git a/tests/multisafepay/e2e/examples/capture_manager/test_capture_reservation_cancel.py b/tests/multisafepay/e2e/examples/capture_manager/test_capture_reservation_cancel.py index 17c045e..ca3224f 100644 --- a/tests/multisafepay/e2e/examples/capture_manager/test_capture_reservation_cancel.py +++ b/tests/multisafepay/e2e/examples/capture_manager/test_capture_reservation_cancel.py @@ -53,7 +53,7 @@ def sdk() -> Sdk: return Sdk(api_key, False) -def test_capture_reservation_cancel(sdk): +def test_capture_reservation_cancel(sdk: Sdk): """ Test the capture reservation cancel method of the CaptureManager. diff --git a/tests/multisafepay/e2e/examples/category_manager/test_get_categories.py b/tests/multisafepay/e2e/examples/category_manager/test_get_categories.py index f93ce9a..d5d78c9 100644 --- a/tests/multisafepay/e2e/examples/category_manager/test_get_categories.py +++ b/tests/multisafepay/e2e/examples/category_manager/test_get_categories.py @@ -9,7 +9,6 @@ import os import pytest from dotenv import load_dotenv -from typing import TYPE_CHECKING from multisafepay.api.base.response.custom_api_response import ( CustomApiResponse, @@ -17,10 +16,9 @@ from multisafepay.api.paths.categories.response.category import Category from multisafepay.sdk import Sdk -if TYPE_CHECKING: - from multisafepay.api.paths.categories.category_manager import ( - CategoryManager, - ) +from multisafepay.api.paths.categories.category_manager import ( + CategoryManager, +) @pytest.fixture(scope="module") @@ -31,7 +29,7 @@ def category_manager() -> "CategoryManager": return multisafepay_sdk.get_category_manager() -def test_get_categories(category_manager): +def test_get_categories(category_manager: CategoryManager): """ Test the get_categories method of the CategoryManager. diff --git a/tests/multisafepay/e2e/examples/gateway_manager/test_get_by_code.py b/tests/multisafepay/e2e/examples/gateway_manager/test_get_by_code.py index fd342a0..ed89821 100644 --- a/tests/multisafepay/e2e/examples/gateway_manager/test_get_by_code.py +++ b/tests/multisafepay/e2e/examples/gateway_manager/test_get_by_code.py @@ -25,7 +25,7 @@ def gateway_manager() -> GatewayManager: return multisafepay_sdk.get_gateway_manager() -def test_get_by_code(gateway_manager): +def test_get_by_code(gateway_manager: GatewayManager): """ Test the get_by_code method of the GatewayManager. diff --git a/tests/multisafepay/e2e/examples/gateway_manager/test_get_gateways.py b/tests/multisafepay/e2e/examples/gateway_manager/test_get_gateways.py index 269b384..a029b70 100644 --- a/tests/multisafepay/e2e/examples/gateway_manager/test_get_gateways.py +++ b/tests/multisafepay/e2e/examples/gateway_manager/test_get_gateways.py @@ -25,7 +25,7 @@ def gateway_manager() -> GatewayManager: return multisafepay_sdk.get_gateway_manager() -def test_get_gateways(gateway_manager): +def test_get_gateways(gateway_manager: GatewayManager): """ Test the get_gateways method of the GatewayManager. diff --git a/tests/multisafepay/e2e/examples/issuer_manager/test_get_issuers_by_gateway_code.py b/tests/multisafepay/e2e/examples/issuer_manager/test_get_issuers_by_gateway_code.py index 01c3828..c10aa51 100644 --- a/tests/multisafepay/e2e/examples/issuer_manager/test_get_issuers_by_gateway_code.py +++ b/tests/multisafepay/e2e/examples/issuer_manager/test_get_issuers_by_gateway_code.py @@ -26,7 +26,7 @@ def issuer_manager() -> IssuerManager: return multisafepay_sdk.get_issuer_manager() -def test_get_issuers_by_gateway_code(issuer_manager): +def test_get_issuers_by_gateway_code(issuer_manager: IssuerManager): """ Test the get_issuers_by_gateway_code method of the IssuerManager. diff --git a/tests/multisafepay/e2e/examples/me_manager/test_get_me.py b/tests/multisafepay/e2e/examples/me_manager/test_get_me.py index 581f592..5079a42 100644 --- a/tests/multisafepay/e2e/examples/me_manager/test_get_me.py +++ b/tests/multisafepay/e2e/examples/me_manager/test_get_me.py @@ -9,7 +9,6 @@ import os import pytest from dotenv import load_dotenv -from typing import TYPE_CHECKING from multisafepay.api.paths.me.response.me import Me @@ -19,9 +18,7 @@ ) from multisafepay.sdk import Sdk - -if TYPE_CHECKING: - from multisafepay.api.paths.me.me_manager import MeManager +from multisafepay.api.paths.me.me_manager import MeManager @pytest.fixture(scope="module") @@ -32,7 +29,7 @@ def me_manager() -> "MeManager": return multisafepay_sdk.get_me_manager() -def test_get_me(me_manager): +def test_get_me(me_manager: MeManager): """ Test the get_me method of the MeManager. diff --git a/tests/multisafepay/e2e/examples/order_manager/test_capture.py b/tests/multisafepay/e2e/examples/order_manager/test_capture.py index 39bee02..43a9795 100644 --- a/tests/multisafepay/e2e/examples/order_manager/test_capture.py +++ b/tests/multisafepay/e2e/examples/order_manager/test_capture.py @@ -50,7 +50,7 @@ def order_manager() -> OrderManager: return multisafepay_sdk.get_order_manager() -def test_capture(order_manager): +def test_capture(order_manager: OrderManager): """ Test the capture method of the OrderManager. diff --git a/tests/multisafepay/e2e/examples/order_manager/test_create.py b/tests/multisafepay/e2e/examples/order_manager/test_create.py index 467920a..41d8277 100644 --- a/tests/multisafepay/e2e/examples/order_manager/test_create.py +++ b/tests/multisafepay/e2e/examples/order_manager/test_create.py @@ -10,7 +10,6 @@ import time import pytest from dotenv import load_dotenv -from typing import TYPE_CHECKING from multisafepay.value_object.weight import Weight from multisafepay.api.shared.cart.cart_item import CartItem @@ -38,8 +37,7 @@ from multisafepay.api.paths.orders.response.order_response import Order -if TYPE_CHECKING: - from multisafepay.api.paths.orders.order_manager import OrderManager +from multisafepay.api.paths.orders.order_manager import OrderManager @pytest.fixture(scope="module") @@ -50,7 +48,7 @@ def order_manager() -> "OrderManager": return multisafepay_sdk.get_order_manager() -def test_create_order(order_manager): +def test_create_order(order_manager: OrderManager): """ Test the create method of the OrderManager. diff --git a/tests/multisafepay/e2e/examples/order_manager/test_get_order.py b/tests/multisafepay/e2e/examples/order_manager/test_get_order.py index 01995ea..aa87b5e 100644 --- a/tests/multisafepay/e2e/examples/order_manager/test_get_order.py +++ b/tests/multisafepay/e2e/examples/order_manager/test_get_order.py @@ -45,7 +45,7 @@ def order_manager() -> OrderManager: return multisafepay_sdk.get_order_manager() -def test_get_order(order_manager): +def test_get_order(order_manager: OrderManager): """ Test the retrieval of an order. diff --git a/tests/multisafepay/e2e/examples/order_manager/test_refund.py b/tests/multisafepay/e2e/examples/order_manager/test_refund.py index 4425cc2..7bd8711 100644 --- a/tests/multisafepay/e2e/examples/order_manager/test_refund.py +++ b/tests/multisafepay/e2e/examples/order_manager/test_refund.py @@ -42,7 +42,7 @@ def order_manager() -> OrderManager: return multisafepay_sdk.get_order_manager() -def test_refund(order_manager): +def test_refund(order_manager: OrderManager): """ Test the refund method of the OrderManager. diff --git a/tests/multisafepay/e2e/examples/order_manager/test_refund_by_item.py b/tests/multisafepay/e2e/examples/order_manager/test_refund_by_item.py index ef228e0..f9f74bf 100644 --- a/tests/multisafepay/e2e/examples/order_manager/test_refund_by_item.py +++ b/tests/multisafepay/e2e/examples/order_manager/test_refund_by_item.py @@ -45,7 +45,7 @@ def order_manager() -> OrderManager: return multisafepay_sdk.get_order_manager() -def test_refund_by_item(order_manager): +def test_refund_by_item(order_manager: OrderManager): """ Test the refund_by_item method of the OrderManager. diff --git a/tests/multisafepay/e2e/examples/order_manager/test_refund_by_shopping_cart.py b/tests/multisafepay/e2e/examples/order_manager/test_refund_by_shopping_cart.py index 0220c08..b2e99f2 100644 --- a/tests/multisafepay/e2e/examples/order_manager/test_refund_by_shopping_cart.py +++ b/tests/multisafepay/e2e/examples/order_manager/test_refund_by_shopping_cart.py @@ -45,7 +45,7 @@ def order_manager() -> OrderManager: return multisafepay_sdk.get_order_manager() -def test_refund_by_shopping_cart(order_manager): +def test_refund_by_shopping_cart(order_manager: OrderManager): """ Test the create_refund_request method of the OrderManager. diff --git a/tests/multisafepay/e2e/examples/order_manager/test_update.py b/tests/multisafepay/e2e/examples/order_manager/test_update.py index 32810c8..eafe8ae 100644 --- a/tests/multisafepay/e2e/examples/order_manager/test_update.py +++ b/tests/multisafepay/e2e/examples/order_manager/test_update.py @@ -48,7 +48,7 @@ def order_manager() -> OrderManager: return multisafepay_sdk.get_order_manager() -def test_update(order_manager): +def test_update(order_manager: OrderManager): """ Test the update method of the OrderManager. diff --git a/tests/multisafepay/e2e/examples/payment_method_manager/test_get_by_gateway_code.py b/tests/multisafepay/e2e/examples/payment_method_manager/test_get_by_gateway_code.py index 98b2997..e38820b 100644 --- a/tests/multisafepay/e2e/examples/payment_method_manager/test_get_by_gateway_code.py +++ b/tests/multisafepay/e2e/examples/payment_method_manager/test_get_by_gateway_code.py @@ -30,7 +30,7 @@ def payment_method_manager() -> PaymentMethodManager: return multisafepay_sdk.get_payment_method_manager() -def test_get_by_gateway_code(payment_method_manager): +def test_get_by_gateway_code(payment_method_manager: PaymentMethodManager): """ Test the get_by_gateway_code method of the PaymentMethodManager. diff --git a/tests/multisafepay/e2e/examples/payment_method_manager/test_get_payment_methods.py b/tests/multisafepay/e2e/examples/payment_method_manager/test_get_payment_methods.py index d0779c6..9fe8c05 100644 --- a/tests/multisafepay/e2e/examples/payment_method_manager/test_get_payment_methods.py +++ b/tests/multisafepay/e2e/examples/payment_method_manager/test_get_payment_methods.py @@ -15,6 +15,9 @@ from multisafepay.api.paths.payment_methods.response.payment_method import ( PaymentMethod, ) +from multisafepay.api.paths.payment_methods.payment_method_manager import ( + PaymentMethodManager, +) from multisafepay.sdk import Sdk @@ -26,7 +29,7 @@ def payment_method_manager(): return multisafepay_sdk.get_payment_method_manager() -def test_get_payment_methods(payment_method_manager): +def test_get_payment_methods(payment_method_manager: PaymentMethodManager): """ Test the get_payment_methods method of the PaymentMethodManager. diff --git a/tests/multisafepay/e2e/examples/recurring_manager/test_recurring.py b/tests/multisafepay/e2e/examples/recurring_manager/test_recurring.py index 02946ca..5fd966e 100644 --- a/tests/multisafepay/e2e/examples/recurring_manager/test_recurring.py +++ b/tests/multisafepay/e2e/examples/recurring_manager/test_recurring.py @@ -39,7 +39,7 @@ def sdk() -> Sdk: return Sdk(api_key, False) -def test_recurring(sdk): +def test_recurring(sdk: Sdk): """ Test the recurring manager. diff --git a/tests/multisafepay/e2e/examples/transaction_manager/test_get_transactions.py b/tests/multisafepay/e2e/examples/transaction_manager/test_get_transactions.py index 5199af7..b25bce4 100644 --- a/tests/multisafepay/e2e/examples/transaction_manager/test_get_transactions.py +++ b/tests/multisafepay/e2e/examples/transaction_manager/test_get_transactions.py @@ -17,6 +17,9 @@ from multisafepay.api.paths.transactions.response.transaction import ( Transaction, ) +from multisafepay.api.paths.transactions.transaction_manager import ( + TransactionManager, +) from multisafepay.sdk import Sdk @@ -28,7 +31,7 @@ def transaction_manager(): return multisafepay_sdk.get_transaction_manager() -def test_retrieves_all_transactions(transaction_manager): +def test_retrieves_all_transactions(transaction_manager: TransactionManager): """ Test the get_transactions method of the TransactionManager. diff --git a/tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py b/tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py index db552b6..847a2c6 100644 --- a/tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py +++ b/tests/multisafepay/integration/api/base/listings/test_integration_listing_pager.py @@ -6,13 +6,15 @@ # See the DISCLAIMER.md file for disclaimer details. +from typing import Any + from multisafepay.api.base.listings.listing_pager import ListingPager from multisafepay.api.base.listings.pager import Pager from multisafepay.api.base.listings.cursor import Cursor class MockItem: - def __init__(self, value): + def __init__(self, value: Any): """ Initialize a MockItem with a given value. diff --git a/tests/multisafepay/unit/api/base/listings/test_unit_listing.py b/tests/multisafepay/unit/api/base/listings/test_unit_listing.py index 5a8af04..fcd44ff 100644 --- a/tests/multisafepay/unit/api/base/listings/test_unit_listing.py +++ b/tests/multisafepay/unit/api/base/listings/test_unit_listing.py @@ -5,12 +5,13 @@ # See the DISCLAIMER.md file for disclaimer details. +from typing import Any from multisafepay.api.base.listings.listing import Listing class MockItem: - def __init__(self, value): + def __init__(self, value: Any): self.value = value diff --git a/tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py b/tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py index 0eb0a81..2591fb3 100644 --- a/tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py +++ b/tests/multisafepay/unit/api/base/listings/test_unit_listing_pager.py @@ -5,12 +5,13 @@ # See the DISCLAIMER.md file for disclaimer details. +from typing import Any from multisafepay.api.base.listings.listing_pager import ListingPager class MockItem: - def __init__(self, value): + def __init__(self, value: Any): """ Initialize a MockItem with a given value. diff --git a/tests/multisafepay/unit/client/test_unit_client.py b/tests/multisafepay/unit/client/test_unit_client.py index 2230c81..04f0ffd 100644 --- a/tests/multisafepay/unit/client/test_unit_client.py +++ b/tests/multisafepay/unit/client/test_unit_client.py @@ -6,72 +6,11 @@ # See the DISCLAIMER.md file for disclaimer details. -import pytest from unittest.mock import Mock from requests import Session -from requests.exceptions import RequestException from multisafepay.client.client import Client -def api_response_mock(json_data, status_code=200): - """ - Create a mock API response with the given JSON data and status code. - - """ - mock_response = Mock() - mock_response.json.return_value = json_data - mock_response.status_code = status_code - mock_response.raise_for_status = Mock() - return mock_response - - -def api_response_mock_with_exception_server_error(json_data, status_code=500): - """ - Create a mock API response that raises a RequestException for server errors. - - """ - mock_response = Mock() - mock_response.json.return_value = json_data - mock_response.status_code = status_code - mock_response.raise_for_status.side_effect = RequestException( - "Server error", - ) - return mock_response - - -def api_response_mock_with_exception_wrong_request(json_data, status_code=400): - """ - Create a mock API response that raises a RequestException for bad requests. - - """ - mock_response = Mock() - mock_response.json.return_value = json_data - mock_response.status_code = status_code - mock_response.raise_for_status.side_effect = RequestException( - "Request failed", - ) - return mock_response - - -def api_key_mock(): - """ - Create a mock API key. - - """ - mock_api_key = Mock() - mock_api_key.get.return_value = "mock_api_key" - return mock_api_key - - -@pytest.fixture() -def client(): - """ - Fixture to create a Client instance with a mock API key. - - """ - return Client(api_key="mock_api_key", is_production=False) - - def test_initializes_with_default_http_client(): """ Test that the Client initializes with the default HTTP client.