airwallex-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airwallex_sdk-0.1.0/PKG-INFO +202 -0
- airwallex_sdk-0.1.0/README.md +183 -0
- airwallex_sdk-0.1.0/airwallex/__init__.py +74 -0
- airwallex_sdk-0.1.0/airwallex/api/__init__.py +37 -0
- airwallex_sdk-0.1.0/airwallex/api/account.py +107 -0
- airwallex_sdk-0.1.0/airwallex/api/account_detail.py +469 -0
- airwallex_sdk-0.1.0/airwallex/api/base.py +488 -0
- airwallex_sdk-0.1.0/airwallex/api/beneficiary.py +156 -0
- airwallex_sdk-0.1.0/airwallex/api/financial_transaction.py +123 -0
- airwallex_sdk-0.1.0/airwallex/api/invoice.py +257 -0
- airwallex_sdk-0.1.0/airwallex/api/issuing_authorization.py +313 -0
- airwallex_sdk-0.1.0/airwallex/api/issuing_card.py +411 -0
- airwallex_sdk-0.1.0/airwallex/api/issuing_cardholder.py +234 -0
- airwallex_sdk-0.1.0/airwallex/api/issuing_config.py +80 -0
- airwallex_sdk-0.1.0/airwallex/api/issuing_digital_wallet_token.py +249 -0
- airwallex_sdk-0.1.0/airwallex/api/issuing_transaction.py +231 -0
- airwallex_sdk-0.1.0/airwallex/api/issuing_transaction_dispute.py +339 -0
- airwallex_sdk-0.1.0/airwallex/api/payment.py +148 -0
- airwallex_sdk-0.1.0/airwallex/client.py +396 -0
- airwallex_sdk-0.1.0/airwallex/exceptions.py +222 -0
- airwallex_sdk-0.1.0/airwallex/models/__init__.py +69 -0
- airwallex_sdk-0.1.0/airwallex/models/account.py +51 -0
- airwallex_sdk-0.1.0/airwallex/models/account_detail.py +259 -0
- airwallex_sdk-0.1.0/airwallex/models/base.py +121 -0
- airwallex_sdk-0.1.0/airwallex/models/beneficiary.py +70 -0
- airwallex_sdk-0.1.0/airwallex/models/financial_transaction.py +30 -0
- airwallex_sdk-0.1.0/airwallex/models/fx.py +58 -0
- airwallex_sdk-0.1.0/airwallex/models/invoice.py +102 -0
- airwallex_sdk-0.1.0/airwallex/models/issuing_authorization.py +41 -0
- airwallex_sdk-0.1.0/airwallex/models/issuing_card.py +135 -0
- airwallex_sdk-0.1.0/airwallex/models/issuing_cardholder.py +52 -0
- airwallex_sdk-0.1.0/airwallex/models/issuing_common.py +83 -0
- airwallex_sdk-0.1.0/airwallex/models/issuing_config.py +62 -0
- airwallex_sdk-0.1.0/airwallex/models/issuing_digital_wallet_token.py +38 -0
- airwallex_sdk-0.1.0/airwallex/models/issuing_transaction.py +42 -0
- airwallex_sdk-0.1.0/airwallex/models/issuing_transaction_dispute.py +59 -0
- airwallex_sdk-0.1.0/airwallex/models/payment.py +81 -0
- airwallex_sdk-0.1.0/airwallex/utils.py +107 -0
- airwallex_sdk-0.1.0/pyproject.toml +27 -0
@@ -0,0 +1,202 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: airwallex-sdk
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Unofficial Airwallex SDK for Python
|
5
|
+
License: MIT
|
6
|
+
Author: duneraccoon
|
7
|
+
Author-email: benjamincsherro@hotmail.com
|
8
|
+
Requires-Python: >=3.10,<4.0
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
14
|
+
Requires-Dist: httpx (>=0.28.1,<0.29.0)
|
15
|
+
Requires-Dist: pydantic (>=2.11.3,<3.0.0)
|
16
|
+
Project-URL: Source, https://github.com/DuneRaccoon/airwallex-sdk
|
17
|
+
Description-Content-Type: text/markdown
|
18
|
+
|
19
|
+
# UNOFFICIAL Airwallex Python SDK
|
20
|
+
|
21
|
+
A simple SDK for interacting with the [Airwallex API](https://www.airwallex.com/docs/api).
|
22
|
+
|
23
|
+
## Features
|
24
|
+
|
25
|
+
- SOMEWHAT Comprehensive implementation of the Airwallex API
|
26
|
+
- Both synchronous and asynchronous client support
|
27
|
+
- Automatic authentication and token refresh
|
28
|
+
- Built-in rate limiting and retry logic
|
29
|
+
- Type checking with Pydantic models
|
30
|
+
|
31
|
+
## Installation
|
32
|
+
|
33
|
+
```bash
|
34
|
+
pip install airwallex-sdk
|
35
|
+
```
|
36
|
+
|
37
|
+
## Quick Start
|
38
|
+
|
39
|
+
### Payments API
|
40
|
+
|
41
|
+
#### Synchronous Usage
|
42
|
+
|
43
|
+
```python
|
44
|
+
from airwallex import AirwallexClient
|
45
|
+
from airwallex.models.payment import PaymentCreateRequest, PaymentAmount
|
46
|
+
|
47
|
+
# Initialize the client
|
48
|
+
client = AirwallexClient(
|
49
|
+
client_id="your_client_id",
|
50
|
+
api_key="your_api_key"
|
51
|
+
)
|
52
|
+
|
53
|
+
# List accounts
|
54
|
+
accounts = client.accounts.list()
|
55
|
+
for account in accounts:
|
56
|
+
print(f"Account: {account.account_name} ({account.id})")
|
57
|
+
|
58
|
+
# Fetch a specific account
|
59
|
+
account = client.accounts.fetch("account_id")
|
60
|
+
print(account.show()) # Print a formatted representation
|
61
|
+
|
62
|
+
# Create a payment
|
63
|
+
payment_request = PaymentCreateRequest(
|
64
|
+
request_id="unique_request_id",
|
65
|
+
amount=PaymentAmount(value=100.00, currency="USD"),
|
66
|
+
source={
|
67
|
+
"type": "account",
|
68
|
+
"account_id": "account_id"
|
69
|
+
},
|
70
|
+
beneficiary={
|
71
|
+
"type": "bank_account",
|
72
|
+
"id": "beneficiary_id"
|
73
|
+
},
|
74
|
+
payment_method="swift"
|
75
|
+
)
|
76
|
+
|
77
|
+
payment = client.payments.create_from_model(payment_request)
|
78
|
+
print(f"Payment created with ID: {payment.id}")
|
79
|
+
|
80
|
+
# Use generator to iterate through all payments
|
81
|
+
for payment in client.payments():
|
82
|
+
print(f"Payment {payment.id}: {payment.amount.value} {payment.amount.currency}")
|
83
|
+
```
|
84
|
+
|
85
|
+
#### Asynchronous Usage
|
86
|
+
|
87
|
+
```python
|
88
|
+
import asyncio
|
89
|
+
from airwallex import AirwallexAsyncClient
|
90
|
+
from airwallex.models.beneficiary import BeneficiaryCreateRequest, BankDetails
|
91
|
+
|
92
|
+
async def main():
|
93
|
+
# Initialize the async client
|
94
|
+
client = AirwallexAsyncClient(
|
95
|
+
client_id="your_client_id",
|
96
|
+
api_key="your_api_key"
|
97
|
+
)
|
98
|
+
|
99
|
+
# List accounts
|
100
|
+
accounts = await client.accounts.list_async()
|
101
|
+
|
102
|
+
# Create a beneficiary
|
103
|
+
beneficiary_request = BeneficiaryCreateRequest(
|
104
|
+
name="John Doe",
|
105
|
+
type="bank_account",
|
106
|
+
bank_details=BankDetails(
|
107
|
+
account_name="John Doe",
|
108
|
+
account_number="123456789",
|
109
|
+
swift_code="ABCDEFGH",
|
110
|
+
bank_country_code="US"
|
111
|
+
)
|
112
|
+
)
|
113
|
+
|
114
|
+
beneficiary = await client.beneficiaries.create_from_model_async(beneficiary_request)
|
115
|
+
print(f"Beneficiary created with ID: {beneficiary.id}")
|
116
|
+
|
117
|
+
# Async generator to iterate through all beneficiaries
|
118
|
+
async for ben in client.beneficiaries.paginate_async_generator():
|
119
|
+
print(f"Beneficiary: {ben.name}")
|
120
|
+
|
121
|
+
await client.close()
|
122
|
+
|
123
|
+
# Run the async function
|
124
|
+
asyncio.run(main())
|
125
|
+
```
|
126
|
+
|
127
|
+
### Issuing API
|
128
|
+
|
129
|
+
#### Working with Cardholders and Cards
|
130
|
+
|
131
|
+
```python
|
132
|
+
from airwallex import AirwallexClient
|
133
|
+
from airwallex.models.issuing_cardholder import CardholderCreateRequest, Individual, Name, Address
|
134
|
+
from airwallex.models.issuing_card import CardCreateRequest, AuthorizationControls, CardProgram
|
135
|
+
|
136
|
+
# Initialize the client
|
137
|
+
client = AirwallexClient(
|
138
|
+
client_id="your_client_id",
|
139
|
+
api_key="your_api_key"
|
140
|
+
)
|
141
|
+
|
142
|
+
# Create a cardholder
|
143
|
+
cardholder_request = CardholderCreateRequest(
|
144
|
+
email="john.doe@example.com",
|
145
|
+
individual=Individual(
|
146
|
+
name=Name(
|
147
|
+
first_name="John",
|
148
|
+
last_name="Doe",
|
149
|
+
title="Mr"
|
150
|
+
),
|
151
|
+
date_of_birth="1982-11-02",
|
152
|
+
address=Address(
|
153
|
+
city="Melbourne",
|
154
|
+
country="AU",
|
155
|
+
line1="44 Example St",
|
156
|
+
postcode="3121",
|
157
|
+
state="VIC"
|
158
|
+
),
|
159
|
+
cardholder_agreement_terms_consent_obtained="yes",
|
160
|
+
express_consent_obtained="yes"
|
161
|
+
),
|
162
|
+
type="INDIVIDUAL"
|
163
|
+
)
|
164
|
+
|
165
|
+
cardholder = client.issuing_cardholder.create_cardholder(cardholder_request)
|
166
|
+
print(f"Cardholder created with ID: {cardholder.cardholder_id}")
|
167
|
+
|
168
|
+
# Create a virtual card
|
169
|
+
card_request = CardCreateRequest(
|
170
|
+
cardholder_id=cardholder.cardholder_id,
|
171
|
+
request_id="unique-request-id",
|
172
|
+
created_by="API User",
|
173
|
+
form_factor="VIRTUAL",
|
174
|
+
is_personalized=True,
|
175
|
+
authorization_controls=AuthorizationControls(
|
176
|
+
allowed_currencies=["USD", "AUD"],
|
177
|
+
allowed_transaction_count="MULTIPLE"
|
178
|
+
),
|
179
|
+
program=CardProgram(
|
180
|
+
id="your_program_id",
|
181
|
+
name="Default Program"
|
182
|
+
)
|
183
|
+
)
|
184
|
+
|
185
|
+
card = client.issuing_card.create_card(card_request)
|
186
|
+
print(f"Card created with ID: {card.card_id}")
|
187
|
+
|
188
|
+
# Get card details
|
189
|
+
card_details = client.issuing_card.get_card_details(card.card_id)
|
190
|
+
print(f"Card Number: {card_details.card_number}")
|
191
|
+
print(f"CVV: {card_details.cvv}")
|
192
|
+
print(f"Expiry: {card_details.expiry_month}/{card_details.expiry_year}")
|
193
|
+
```
|
194
|
+
|
195
|
+
## Documentation
|
196
|
+
|
197
|
+
For detailed documentation, see [https://www.airwallex.com/docs/api](https://www.airwallex.com/docs/api).
|
198
|
+
|
199
|
+
## License
|
200
|
+
|
201
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
202
|
+
|
@@ -0,0 +1,183 @@
|
|
1
|
+
# UNOFFICIAL Airwallex Python SDK
|
2
|
+
|
3
|
+
A simple SDK for interacting with the [Airwallex API](https://www.airwallex.com/docs/api).
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- SOMEWHAT Comprehensive implementation of the Airwallex API
|
8
|
+
- Both synchronous and asynchronous client support
|
9
|
+
- Automatic authentication and token refresh
|
10
|
+
- Built-in rate limiting and retry logic
|
11
|
+
- Type checking with Pydantic models
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
```bash
|
16
|
+
pip install airwallex-sdk
|
17
|
+
```
|
18
|
+
|
19
|
+
## Quick Start
|
20
|
+
|
21
|
+
### Payments API
|
22
|
+
|
23
|
+
#### Synchronous Usage
|
24
|
+
|
25
|
+
```python
|
26
|
+
from airwallex import AirwallexClient
|
27
|
+
from airwallex.models.payment import PaymentCreateRequest, PaymentAmount
|
28
|
+
|
29
|
+
# Initialize the client
|
30
|
+
client = AirwallexClient(
|
31
|
+
client_id="your_client_id",
|
32
|
+
api_key="your_api_key"
|
33
|
+
)
|
34
|
+
|
35
|
+
# List accounts
|
36
|
+
accounts = client.accounts.list()
|
37
|
+
for account in accounts:
|
38
|
+
print(f"Account: {account.account_name} ({account.id})")
|
39
|
+
|
40
|
+
# Fetch a specific account
|
41
|
+
account = client.accounts.fetch("account_id")
|
42
|
+
print(account.show()) # Print a formatted representation
|
43
|
+
|
44
|
+
# Create a payment
|
45
|
+
payment_request = PaymentCreateRequest(
|
46
|
+
request_id="unique_request_id",
|
47
|
+
amount=PaymentAmount(value=100.00, currency="USD"),
|
48
|
+
source={
|
49
|
+
"type": "account",
|
50
|
+
"account_id": "account_id"
|
51
|
+
},
|
52
|
+
beneficiary={
|
53
|
+
"type": "bank_account",
|
54
|
+
"id": "beneficiary_id"
|
55
|
+
},
|
56
|
+
payment_method="swift"
|
57
|
+
)
|
58
|
+
|
59
|
+
payment = client.payments.create_from_model(payment_request)
|
60
|
+
print(f"Payment created with ID: {payment.id}")
|
61
|
+
|
62
|
+
# Use generator to iterate through all payments
|
63
|
+
for payment in client.payments():
|
64
|
+
print(f"Payment {payment.id}: {payment.amount.value} {payment.amount.currency}")
|
65
|
+
```
|
66
|
+
|
67
|
+
#### Asynchronous Usage
|
68
|
+
|
69
|
+
```python
|
70
|
+
import asyncio
|
71
|
+
from airwallex import AirwallexAsyncClient
|
72
|
+
from airwallex.models.beneficiary import BeneficiaryCreateRequest, BankDetails
|
73
|
+
|
74
|
+
async def main():
|
75
|
+
# Initialize the async client
|
76
|
+
client = AirwallexAsyncClient(
|
77
|
+
client_id="your_client_id",
|
78
|
+
api_key="your_api_key"
|
79
|
+
)
|
80
|
+
|
81
|
+
# List accounts
|
82
|
+
accounts = await client.accounts.list_async()
|
83
|
+
|
84
|
+
# Create a beneficiary
|
85
|
+
beneficiary_request = BeneficiaryCreateRequest(
|
86
|
+
name="John Doe",
|
87
|
+
type="bank_account",
|
88
|
+
bank_details=BankDetails(
|
89
|
+
account_name="John Doe",
|
90
|
+
account_number="123456789",
|
91
|
+
swift_code="ABCDEFGH",
|
92
|
+
bank_country_code="US"
|
93
|
+
)
|
94
|
+
)
|
95
|
+
|
96
|
+
beneficiary = await client.beneficiaries.create_from_model_async(beneficiary_request)
|
97
|
+
print(f"Beneficiary created with ID: {beneficiary.id}")
|
98
|
+
|
99
|
+
# Async generator to iterate through all beneficiaries
|
100
|
+
async for ben in client.beneficiaries.paginate_async_generator():
|
101
|
+
print(f"Beneficiary: {ben.name}")
|
102
|
+
|
103
|
+
await client.close()
|
104
|
+
|
105
|
+
# Run the async function
|
106
|
+
asyncio.run(main())
|
107
|
+
```
|
108
|
+
|
109
|
+
### Issuing API
|
110
|
+
|
111
|
+
#### Working with Cardholders and Cards
|
112
|
+
|
113
|
+
```python
|
114
|
+
from airwallex import AirwallexClient
|
115
|
+
from airwallex.models.issuing_cardholder import CardholderCreateRequest, Individual, Name, Address
|
116
|
+
from airwallex.models.issuing_card import CardCreateRequest, AuthorizationControls, CardProgram
|
117
|
+
|
118
|
+
# Initialize the client
|
119
|
+
client = AirwallexClient(
|
120
|
+
client_id="your_client_id",
|
121
|
+
api_key="your_api_key"
|
122
|
+
)
|
123
|
+
|
124
|
+
# Create a cardholder
|
125
|
+
cardholder_request = CardholderCreateRequest(
|
126
|
+
email="john.doe@example.com",
|
127
|
+
individual=Individual(
|
128
|
+
name=Name(
|
129
|
+
first_name="John",
|
130
|
+
last_name="Doe",
|
131
|
+
title="Mr"
|
132
|
+
),
|
133
|
+
date_of_birth="1982-11-02",
|
134
|
+
address=Address(
|
135
|
+
city="Melbourne",
|
136
|
+
country="AU",
|
137
|
+
line1="44 Example St",
|
138
|
+
postcode="3121",
|
139
|
+
state="VIC"
|
140
|
+
),
|
141
|
+
cardholder_agreement_terms_consent_obtained="yes",
|
142
|
+
express_consent_obtained="yes"
|
143
|
+
),
|
144
|
+
type="INDIVIDUAL"
|
145
|
+
)
|
146
|
+
|
147
|
+
cardholder = client.issuing_cardholder.create_cardholder(cardholder_request)
|
148
|
+
print(f"Cardholder created with ID: {cardholder.cardholder_id}")
|
149
|
+
|
150
|
+
# Create a virtual card
|
151
|
+
card_request = CardCreateRequest(
|
152
|
+
cardholder_id=cardholder.cardholder_id,
|
153
|
+
request_id="unique-request-id",
|
154
|
+
created_by="API User",
|
155
|
+
form_factor="VIRTUAL",
|
156
|
+
is_personalized=True,
|
157
|
+
authorization_controls=AuthorizationControls(
|
158
|
+
allowed_currencies=["USD", "AUD"],
|
159
|
+
allowed_transaction_count="MULTIPLE"
|
160
|
+
),
|
161
|
+
program=CardProgram(
|
162
|
+
id="your_program_id",
|
163
|
+
name="Default Program"
|
164
|
+
)
|
165
|
+
)
|
166
|
+
|
167
|
+
card = client.issuing_card.create_card(card_request)
|
168
|
+
print(f"Card created with ID: {card.card_id}")
|
169
|
+
|
170
|
+
# Get card details
|
171
|
+
card_details = client.issuing_card.get_card_details(card.card_id)
|
172
|
+
print(f"Card Number: {card_details.card_number}")
|
173
|
+
print(f"CVV: {card_details.cvv}")
|
174
|
+
print(f"Expiry: {card_details.expiry_month}/{card_details.expiry_year}")
|
175
|
+
```
|
176
|
+
|
177
|
+
## Documentation
|
178
|
+
|
179
|
+
For detailed documentation, see [https://www.airwallex.com/docs/api](https://www.airwallex.com/docs/api).
|
180
|
+
|
181
|
+
## License
|
182
|
+
|
183
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
@@ -0,0 +1,74 @@
|
|
1
|
+
"""
|
2
|
+
Airwallex Python SDK.
|
3
|
+
|
4
|
+
A fully-featured SDK for interacting with the Airwallex API.
|
5
|
+
"""
|
6
|
+
from .client import AirwallexClient, AirwallexAsyncClient
|
7
|
+
from .exceptions import (
|
8
|
+
AirwallexAPIError,
|
9
|
+
AuthenticationError,
|
10
|
+
RateLimitError,
|
11
|
+
ResourceNotFoundError,
|
12
|
+
ValidationError,
|
13
|
+
ServerError
|
14
|
+
)
|
15
|
+
|
16
|
+
# Import models
|
17
|
+
from .models import AirwallexModel
|
18
|
+
from .models.account import Account as AccountModel
|
19
|
+
from .models.payment import Payment as PaymentModel
|
20
|
+
from .models.beneficiary import Beneficiary as BeneficiaryModel
|
21
|
+
from .models.invoice import Invoice as InvoiceModel, InvoiceItem
|
22
|
+
from .models.financial_transaction import FinancialTransaction as FinancialTransactionModel
|
23
|
+
from .models.fx import FXConversion, FXQuote
|
24
|
+
from .models.account_detail import (
|
25
|
+
AccountDetailModel, AccountCreateRequest, AccountUpdateRequest,
|
26
|
+
Amendment, AmendmentCreateRequest, WalletInfo, TermsAndConditionsRequest
|
27
|
+
)
|
28
|
+
|
29
|
+
# Issuing API Models
|
30
|
+
from .models.issuing_authorization import Authorization as IssuingAuthorizationModel
|
31
|
+
from .models.issuing_cardholder import Cardholder as IssuingCardholderModel
|
32
|
+
from .models.issuing_card import Card as IssuingCardModel, CardDetails
|
33
|
+
from .models.issuing_digital_wallet_token import DigitalWalletToken as IssuingDigitalWalletTokenModel
|
34
|
+
from .models.issuing_transaction_dispute import TransactionDispute as IssuingTransactionDisputeModel
|
35
|
+
from .models.issuing_transaction import Transaction as IssuingTransactionModel
|
36
|
+
from .models.issuing_config import IssuingConfig as IssuingConfigModel
|
37
|
+
|
38
|
+
__all__ = [
|
39
|
+
"AirwallexClient",
|
40
|
+
"AirwallexAsyncClient",
|
41
|
+
"AirwallexAPIError",
|
42
|
+
"AuthenticationError",
|
43
|
+
"RateLimitError",
|
44
|
+
"ResourceNotFoundError",
|
45
|
+
"ValidationError",
|
46
|
+
"ServerError",
|
47
|
+
"AirwallexModel",
|
48
|
+
"AccountModel",
|
49
|
+
"PaymentModel",
|
50
|
+
"BeneficiaryModel",
|
51
|
+
"InvoiceModel",
|
52
|
+
"InvoiceItem",
|
53
|
+
"FinancialTransactionModel",
|
54
|
+
"FXConversion",
|
55
|
+
"FXQuote",
|
56
|
+
"AccountDetailModel",
|
57
|
+
"AccountCreateRequest",
|
58
|
+
"AccountUpdateRequest",
|
59
|
+
"Amendment",
|
60
|
+
"AmendmentCreateRequest",
|
61
|
+
"WalletInfo",
|
62
|
+
"TermsAndConditionsRequest",
|
63
|
+
# Issuing API
|
64
|
+
"IssuingAuthorizationModel",
|
65
|
+
"IssuingCardholderModel",
|
66
|
+
"IssuingCardModel",
|
67
|
+
"CardDetails",
|
68
|
+
"IssuingDigitalWalletTokenModel",
|
69
|
+
"IssuingTransactionDisputeModel",
|
70
|
+
"IssuingTransactionModel",
|
71
|
+
"IssuingConfigModel",
|
72
|
+
]
|
73
|
+
|
74
|
+
__version__ = "0.2.0"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"""
|
2
|
+
API modules for the Airwallex SDK.
|
3
|
+
"""
|
4
|
+
from .base import AirwallexAPIBase
|
5
|
+
from .account import Account
|
6
|
+
from .payment import Payment
|
7
|
+
from .beneficiary import Beneficiary
|
8
|
+
from .invoice import Invoice
|
9
|
+
from .financial_transaction import FinancialTransaction
|
10
|
+
from .account_detail import AccountDetail
|
11
|
+
|
12
|
+
# Issuing API
|
13
|
+
from .issuing_authorization import IssuingAuthorization
|
14
|
+
from .issuing_cardholder import IssuingCardholder
|
15
|
+
from .issuing_card import IssuingCard
|
16
|
+
from .issuing_digital_wallet_token import IssuingDigitalWalletToken
|
17
|
+
from .issuing_transaction_dispute import IssuingTransactionDispute
|
18
|
+
from .issuing_transaction import IssuingTransaction
|
19
|
+
from .issuing_config import IssuingConfig
|
20
|
+
|
21
|
+
__all__ = [
|
22
|
+
"AirwallexAPIBase",
|
23
|
+
"Account",
|
24
|
+
"Payment",
|
25
|
+
"Beneficiary",
|
26
|
+
"Invoice",
|
27
|
+
"FinancialTransaction",
|
28
|
+
"AccountDetail",
|
29
|
+
# Issuing API
|
30
|
+
"IssuingAuthorization",
|
31
|
+
"IssuingCardholder",
|
32
|
+
"IssuingCard",
|
33
|
+
"IssuingDigitalWalletToken",
|
34
|
+
"IssuingTransactionDispute",
|
35
|
+
"IssuingTransaction",
|
36
|
+
"IssuingConfig",
|
37
|
+
]
|
@@ -0,0 +1,107 @@
|
|
1
|
+
"""
|
2
|
+
Airwallex Account API.
|
3
|
+
"""
|
4
|
+
from typing import Dict, Any, List, Optional, Type, TypeVar, cast
|
5
|
+
from ..models.account import Account, AccountCreateRequest, AccountUpdateRequest
|
6
|
+
from .base import AirwallexAPIBase
|
7
|
+
|
8
|
+
T = TypeVar("T", bound=Account)
|
9
|
+
|
10
|
+
|
11
|
+
class Account(AirwallexAPIBase[Account]):
|
12
|
+
"""
|
13
|
+
Operations for Airwallex accounts.
|
14
|
+
|
15
|
+
Accounts represent the global accounts that can hold balances
|
16
|
+
in multiple currencies.
|
17
|
+
"""
|
18
|
+
endpoint = "accounts"
|
19
|
+
model_class = cast(Type[Account], Account)
|
20
|
+
|
21
|
+
def fetch_balance(self, account_id: str) -> Account:
|
22
|
+
"""
|
23
|
+
Fetch the balance for a specific account.
|
24
|
+
|
25
|
+
Args:
|
26
|
+
account_id: The ID of the account to fetch the balance for.
|
27
|
+
|
28
|
+
Returns:
|
29
|
+
Account: Account with balance information.
|
30
|
+
"""
|
31
|
+
url = self._build_url(account_id, "balance")
|
32
|
+
if not self.client.__class__.__name__.startswith('Async'):
|
33
|
+
response = self.client._request("GET", url)
|
34
|
+
data = response.json()
|
35
|
+
account_data = {"id": account_id, "balance": data}
|
36
|
+
return self.model_class.from_api_response(account_data)
|
37
|
+
else:
|
38
|
+
raise ValueError("Use fetch_balance_async for async clients")
|
39
|
+
|
40
|
+
async def fetch_balance_async(self, account_id: str) -> Account:
|
41
|
+
"""
|
42
|
+
Fetch the balance for a specific account asynchronously.
|
43
|
+
|
44
|
+
Args:
|
45
|
+
account_id: The ID of the account to fetch the balance for.
|
46
|
+
|
47
|
+
Returns:
|
48
|
+
Account: Account with balance information.
|
49
|
+
"""
|
50
|
+
url = self._build_url(account_id, "balance")
|
51
|
+
if self.client.__class__.__name__.startswith('Async'):
|
52
|
+
response = await self.client._request("GET", url)
|
53
|
+
data = response.json()
|
54
|
+
account_data = {"id": account_id, "balance": data}
|
55
|
+
return self.model_class.from_api_response(account_data)
|
56
|
+
else:
|
57
|
+
raise ValueError("Use fetch_balance for sync clients")
|
58
|
+
|
59
|
+
def create_from_model(self, account: AccountCreateRequest) -> Account:
|
60
|
+
"""
|
61
|
+
Create a new account using a Pydantic model.
|
62
|
+
|
63
|
+
Args:
|
64
|
+
account: AccountCreateRequest model with account creation details.
|
65
|
+
|
66
|
+
Returns:
|
67
|
+
Account: The newly created account.
|
68
|
+
"""
|
69
|
+
return self.create(account)
|
70
|
+
|
71
|
+
async def create_from_model_async(self, account: AccountCreateRequest) -> Account:
|
72
|
+
"""
|
73
|
+
Create a new account using a Pydantic model asynchronously.
|
74
|
+
|
75
|
+
Args:
|
76
|
+
account: AccountCreateRequest model with account creation details.
|
77
|
+
|
78
|
+
Returns:
|
79
|
+
Account: The newly created account.
|
80
|
+
"""
|
81
|
+
return await self.create_async(account)
|
82
|
+
|
83
|
+
def update_from_model(self, account_id: str, account: AccountUpdateRequest) -> Account:
|
84
|
+
"""
|
85
|
+
Update an account using a Pydantic model.
|
86
|
+
|
87
|
+
Args:
|
88
|
+
account_id: The ID of the account to update.
|
89
|
+
account: AccountUpdateRequest model with account update details.
|
90
|
+
|
91
|
+
Returns:
|
92
|
+
Account: The updated account.
|
93
|
+
"""
|
94
|
+
return self.update(account_id, account)
|
95
|
+
|
96
|
+
async def update_from_model_async(self, account_id: str, account: AccountUpdateRequest) -> Account:
|
97
|
+
"""
|
98
|
+
Update an account using a Pydantic model asynchronously.
|
99
|
+
|
100
|
+
Args:
|
101
|
+
account_id: The ID of the account to update.
|
102
|
+
account: AccountUpdateRequest model with account update details.
|
103
|
+
|
104
|
+
Returns:
|
105
|
+
Account: The updated account.
|
106
|
+
"""
|
107
|
+
return await self.update_async(account_id, account)
|