Skip to content

Commit ffdfce0

Browse files
authored
PTHMINT-89: Improve imports (#38)
1 parent ec4ccf1 commit ffdfce0

File tree

61 files changed

+606
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+606
-203
lines changed

examples/auth_manager/get_api_token.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
from dotenv import load_dotenv
44

5-
from multisafepay.api.base.response.custom_api_response import CustomApiResponse
6-
from multisafepay.api.paths.auth.api_token.response.api_token import ApiToken
7-
from multisafepay.api.paths.auth.auth_manager import AuthManager
8-
from multisafepay.sdk import Sdk
5+
from multisafepay import Sdk
6+
from multisafepay.api.base.response import CustomApiResponse
7+
from multisafepay.api.paths import AuthManager
8+
from multisafepay.api.paths.auth import ApiToken
99

1010
# Load environment variables from a .env file
1111
load_dotenv()

examples/capture_manager/capture_reservation_cancel.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
from dotenv import load_dotenv
44

5-
from multisafepay.api.base.response.custom_api_response import CustomApiResponse
6-
from multisafepay.api.paths.capture.request.capture_request import CaptureRequest
7-
from multisafepay.api.paths.capture.response.capture import CancelReservation
8-
from multisafepay.sdk import Sdk
5+
from multisafepay import Sdk
6+
from multisafepay.api.base.response import CustomApiResponse
7+
from multisafepay.api.paths.capture.request import CaptureRequest
98

109
# Load environment variables from a .env file
1110
load_dotenv()
@@ -21,12 +20,16 @@
2120
capture_manager = multisafepay_sdk.get_capture_manager()
2221

2322
# Create a capture request with status 'cancelled' and a reason
24-
capture_request = (CaptureRequest().add_status('cancelled').add_reason('<reason>'))
23+
capture_request = (
24+
CaptureRequest().add_status('cancelled').add_reason('<reason>')
25+
)
2526

2627
# Cancel the capture reservation for the given order ID
27-
capture_reservation_cancel_response: CustomApiResponse = capture_manager.capture_reservation_cancel(
28-
'<order_id>',
29-
capture_request)
28+
capture_reservation_cancel_response: CustomApiResponse = (
29+
capture_manager.capture_reservation_cancel(
30+
'<order_id>', capture_request
31+
)
32+
)
3033
# Print the API response containing the capture reservation cancel information
3134
# print(capture_reservation_cancel_response)
3235

examples/category_manager/get_categories.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33

44
from dotenv import load_dotenv
55

6-
from multisafepay.api.base.listings.listing import Listing
7-
from multisafepay.api.base.response.custom_api_response import CustomApiResponse
8-
from multisafepay.api.paths.categories.response.category import Category
9-
from multisafepay.sdk import Sdk
6+
from multisafepay import Sdk
7+
from multisafepay.api.base.response import CustomApiResponse
8+
from multisafepay.api.paths.categories.response import Category
109

1110
# Load environment variables from a .env file
1211
load_dotenv()
@@ -22,7 +21,9 @@
2221
category_manager = multisafepay_sdk.get_category_manager()
2322

2423
# Request categories through the category manager
25-
get_categories_response: CustomApiResponse = category_manager.get_categories()
24+
get_categories_response: CustomApiResponse = (
25+
category_manager.get_categories()
26+
)
2627

2728
# Print the API response containing the categories
2829
# print(get_categories_response)

examples/gateway_manager/get_by_code.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
from dotenv import load_dotenv
44

5-
from multisafepay.api.base.response.custom_api_response import CustomApiResponse
6-
from multisafepay.api.paths.gateways.gateway_manager import GatewayManager
7-
from multisafepay.api.paths.gateways.response.gateway import Gateway
8-
from multisafepay.sdk import Sdk
5+
from multisafepay import Sdk
6+
from multisafepay.api.base.response import CustomApiResponse
7+
from multisafepay.api.paths.gateways.response import Gateway
98

109
# Load environment variables from a .env file
1110
load_dotenv()
@@ -18,10 +17,12 @@
1817
multisafepay_sdk: Sdk = Sdk(API_KEY, False)
1918

2019
# Get the gateway manager from the SDK
21-
gateway_manager: GatewayManager = multisafepay_sdk.get_gateway_manager()
20+
gateway_manager = multisafepay_sdk.get_gateway_manager()
2221

2322
# Request the gateway information by its code
24-
get_by_code_response: CustomApiResponse = gateway_manager.get_by_code("IDEAL")
23+
get_by_code_response: CustomApiResponse = gateway_manager.get_by_code(
24+
"IDEAL"
25+
)
2526

2627
# Print the API response containing the gateway information
2728
# print(get_by_code_response)

examples/gateway_manager/get_gateways.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
from dotenv import load_dotenv
55

6-
from multisafepay.api.base.listings.listing import Listing
7-
from multisafepay.api.base.response.custom_api_response import CustomApiResponse
8-
from multisafepay.api.paths.gateways.gateway_manager import GatewayManager
9-
from multisafepay.api.paths.gateways.response.gateway import Gateway
10-
from multisafepay.sdk import Sdk
6+
from multisafepay import Sdk
7+
from multisafepay.api.base.response import CustomApiResponse
8+
from multisafepay.api.paths import GatewayManager
9+
from multisafepay.api.paths.gateways.response import Gateway
1110

1211
# Load environment variables from a .env file
1312
load_dotenv()
@@ -23,12 +22,14 @@
2322
gateway_manager: GatewayManager = multisafepay_sdk.get_gateway_manager()
2423

2524
# Request the list of gateways
26-
get_gateways_response: CustomApiResponse = gateway_manager.get_gateways()
25+
get_gateways_response: CustomApiResponse = (
26+
gateway_manager.get_gateways()
27+
)
2728

2829
# Print the API response containing the list of gateways
2930
# print(get_gateways_response)
3031

3132
# Extract the listing of gateways from the response
32-
gatewayListing: List[Gateway] = get_gateways_response.get_data()
33+
gateway_listing: List[Gateway] = get_gateways_response.get_data()
3334

34-
print(gatewayListing)
35+
print(gateway_listing)

examples/issuer_manager/get_issuers_by_gateway_code.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
from dotenv import load_dotenv
44

5-
from multisafepay.api.base.response.custom_api_response import CustomApiResponse
6-
from multisafepay.api.paths.issuers.issuer_manager import IssuerManager
7-
from multisafepay.sdk import Sdk
5+
from multisafepay import Sdk
6+
from multisafepay.api.base.response import CustomApiResponse
87

98
# Load environment variables from a .env file
109
load_dotenv()
@@ -17,15 +16,19 @@
1716
multisafepay_sdk = Sdk(API_KEY, False)
1817

1918
# Get the issuer manager from the SDK
20-
issuer_manager: IssuerManager = multisafepay_sdk.get_issuer_manager()
19+
issuer_manager = multisafepay_sdk.get_issuer_manager()
2120

2221
# Request the list of issuers by the gateway code "MYBANK"
23-
get_issuers_by_gateway_code_response: CustomApiResponse = issuer_manager.get_issuers_by_gateway_code("MYBANK")
22+
get_issuers_by_gateway_code_response: CustomApiResponse = (
23+
issuer_manager.get_issuers_by_gateway_code("MYBANK")
24+
)
2425

2526
# Print the API response containing the list of issuers
2627
# print(get_issuers_by_gateway_code_response)
2728

2829
# Print the API response containing the list of issuers
29-
issuers_by_gateway_code = get_issuers_by_gateway_code_response.get_data()
30+
issuers_by_gateway_code = (
31+
get_issuers_by_gateway_code_response.get_data()
32+
)
3033

3134
print(issuers_by_gateway_code)

examples/me_manager/get.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from dotenv import load_dotenv
44

5-
from multisafepay.sdk import Sdk
5+
from multisafepay import Sdk
66

77
# Load environment variables from a .env file
88
load_dotenv()

examples/order_manager/capture.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
from dotenv import load_dotenv
44

5-
from multisafepay.api.paths.orders.order_id.capture.request.capture_request import CaptureOrderRequest
6-
from multisafepay.sdk import Sdk
7-
from multisafepay.value_object.amount import Amount
8-
from multisafepay.value_object.currency import Currency
5+
from multisafepay import Sdk
6+
from multisafepay.api.paths.orders.order_id.capture.request import (
7+
CaptureOrderRequest,
8+
)
9+
from multisafepay.value_object import Amount
910

1011
# Load environment variables from a .env file
1112
load_dotenv()
@@ -24,11 +25,13 @@
2425
amount = Amount(amount=10)
2526

2627
# Create a CaptureOrderRequest object and add the capture details
27-
capture_request = (CaptureOrderRequest()
28-
.add_amount(amount)
29-
.add_reason('Order captured')
30-
.add_new_order_id('<capture_order_id>')
31-
.add_new_order_status('completed'))
28+
capture_request = (
29+
CaptureOrderRequest()
30+
.add_amount(amount)
31+
.add_reason('Order captured')
32+
.add_new_order_id('<capture_order_id>')
33+
.add_new_order_status('completed')
34+
)
3235

3336
# Capture the order with the specified order ID using the order manager
3437
capture_response = order_manager.capture('<order_id>', capture_request)

examples/order_manager/create.py

Lines changed: 69 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
import time
21
import os
2+
import time
3+
34
from dotenv import load_dotenv
4-
from multisafepay.value_object.weight import Weight
5-
from multisafepay.api.shared.cart.cart_item import CartItem
6-
from multisafepay.api.paths.orders.request.components.checkout_options import CheckoutOptions
7-
from multisafepay.api.paths.orders.request.components.payment_options import PaymentOptions
8-
from multisafepay.api.paths.orders.request.components.plugin import Plugin
9-
from multisafepay.api.paths.orders.request.order_request import OrderRequest
10-
from multisafepay.api.shared.cart.shopping_cart import ShoppingCart
11-
from multisafepay.api.shared.customer import Customer
12-
from multisafepay.sdk import Sdk
13-
from multisafepay.value_object.amount import Amount
14-
from multisafepay.value_object.country import Country
15-
from multisafepay.value_object.currency import Currency
16-
from multisafepay.api.shared.description import Description
17-
from multisafepay.value_object.email_address import EmailAddress
18-
from multisafepay.value_object.ip_address import IpAddress
19-
from multisafepay.value_object.phone_number import PhoneNumber
20-
from multisafepay.api.paths.orders.response.order_response import Order
5+
6+
from multisafepay import Sdk
7+
from multisafepay.api.paths.orders.request import OrderRequest
8+
from multisafepay.api.paths.orders.request.components import (
9+
CheckoutOptions,
10+
PaymentOptions,
11+
Plugin,
12+
)
13+
from multisafepay.api.paths.orders.response import Order
14+
from multisafepay.api.shared import Customer, Description
15+
from multisafepay.api.shared.cart import CartItem, ShoppingCart
16+
from multisafepay.value_object import (
17+
Amount,
18+
Country,
19+
Currency,
20+
EmailAddress,
21+
IpAddress,
22+
PhoneNumber,
23+
Weight,
24+
)
2125

2226
# Load environment variables from a .env file
2327
load_dotenv()
@@ -83,52 +87,59 @@
8387

8488
# Create cart items
8589
cart_items = [
86-
CartItem()
87-
.add_name('Geometric Candle Holders')
88-
.add_description('Geometric Candle Holders description')
89-
.add_unit_price(90)
90-
.add_quantity(3)
91-
.add_merchant_item_id('1111')
92-
.add_tax_rate_percentage(21)
93-
.add_weight(Weight(value=1.0, unit='kg')),
94-
95-
CartItem()
96-
.add_name('Nice apple')
97-
.add_description('Nice apple description')
98-
.add_unit_price(35)
99-
.add_quantity(1)
100-
.add_merchant_item_id('666666')
101-
.add_tax_rate_percentage(9)
102-
.add_weight(Weight(value=20, unit='kg')),
103-
104-
CartItem()
105-
.add_name('Flat Rate - Fixed')
106-
.add_description('Shipping')
107-
.add_unit_price(10)
108-
.add_quantity(1)
109-
.add_merchant_item_id('msp-shipping')
110-
.add_tax_rate_percentage(0)
111-
.add_weight(Weight(value=0, unit='kg'))
90+
(
91+
CartItem()
92+
.add_name('Geometric Candle Holders')
93+
.add_description('Geometric Candle Holders description')
94+
.add_unit_price(90)
95+
.add_quantity(3)
96+
.add_merchant_item_id('1111')
97+
.add_tax_rate_percentage(21)
98+
.add_weight(Weight(value=1.0, unit='kg'))
99+
),
100+
(
101+
CartItem()
102+
.add_name('Nice apple')
103+
.add_description('Nice apple description')
104+
.add_unit_price(35)
105+
.add_quantity(1)
106+
.add_merchant_item_id('666666')
107+
.add_tax_rate_percentage(9)
108+
.add_weight(Weight(value=20, unit='kg'))
109+
),
110+
(
111+
CartItem()
112+
.add_name('Flat Rate - Fixed')
113+
.add_description('Shipping')
114+
.add_unit_price(10)
115+
.add_quantity(1)
116+
.add_merchant_item_id('msp-shipping')
117+
.add_tax_rate_percentage(0)
118+
.add_weight(Weight(value=0, unit='kg'))
119+
),
112120
]
113121

114122
# Create shopping_cart
115123
shopping_cart = ShoppingCart().add_items(cart_items)
116124

117125
# Create an OrderRequest object and add the order details
118-
order_request = (OrderRequest()
119-
.add_type('direct')
120-
.add_order_id(order_id)
121-
.add_description(description)
122-
.add_amount(amount)
123-
.add_currency(currency)
124-
.add_gateway('IDEAL')
125-
.add_customer(customer)
126-
.add_delivery(customer)
127-
.add_plugin(plugin)
128-
.add_payment_options(payment_options)
129-
.add_shopping_cart(shopping_cart)
130-
.add_checkout_options(CheckoutOptions.generate_from_shopping_cart(shopping_cart))
131-
)
126+
order_request = (
127+
OrderRequest()
128+
.add_type('direct')
129+
.add_order_id(order_id)
130+
.add_description(description)
131+
.add_amount(amount)
132+
.add_currency(currency)
133+
.add_gateway('IDEAL')
134+
.add_customer(customer)
135+
.add_delivery(customer)
136+
.add_plugin(plugin)
137+
.add_payment_options(payment_options)
138+
.add_shopping_cart(shopping_cart)
139+
.add_checkout_options(
140+
CheckoutOptions.generate_from_shopping_cart(shopping_cart)
141+
)
142+
)
132143

133144
# Get the order manager from the SDK
134145
order_manager = multisafepay_sdk.get_order_manager()

examples/order_manager/create_refund_request.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import os
2+
23
from dotenv import load_dotenv
4+
5+
from multisafepay import Sdk
36
from multisafepay.api.paths.orders.order_manager import OrderManager
4-
from multisafepay.sdk import Sdk
57

68
# Load environment variables from a .env file
79
load_dotenv()
@@ -20,7 +22,9 @@
2022
order_response = order_manager.get('<order_id>')
2123

2224
# Create a refund request for the retrieved order
23-
create_refund_request_response = OrderManager.create_refund_request(order_response.get_data())
25+
create_refund_request_response = OrderManager.create_refund_request(
26+
order_response.get_data()
27+
)
2428

2529
# Print the response of the refund request
2630
print(create_refund_request_response)

0 commit comments

Comments
 (0)