py-momo-api 1.0.2__py3-none-any.whl
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.
- py_momo_api-1.0.2.dist-info/METADATA +215 -0
- py_momo_api-1.0.2.dist-info/RECORD +38 -0
- py_momo_api-1.0.2.dist-info/WHEEL +4 -0
- py_momo_api-1.0.2.dist-info/entry_points.txt +2 -0
- py_momo_api-1.0.2.dist-info/licenses/LICENSE +201 -0
- pymomo/__init__.py +81 -0
- pymomo/_async/__init__.py +1 -0
- pymomo/_async/client.py +134 -0
- pymomo/_async/http.py +134 -0
- pymomo/_async/products/__init__.py +1 -0
- pymomo/_async/products/base.py +204 -0
- pymomo/_async/products/collection.py +293 -0
- pymomo/_async/products/disbursement.py +233 -0
- pymomo/_async/products/remittance.py +85 -0
- pymomo/_async/sandbox.py +145 -0
- pymomo/_cli.py +454 -0
- pymomo/airtel/__init__.py +6 -0
- pymomo/airtel/auth.py +156 -0
- pymomo/airtel/client.py +196 -0
- pymomo/airtel/config.py +53 -0
- pymomo/airtel/models.py +180 -0
- pymomo/airtel/products/collection.py +79 -0
- pymomo/airtel/products/disbursement.py +85 -0
- pymomo/auth.py +67 -0
- pymomo/client.py +141 -0
- pymomo/config.py +128 -0
- pymomo/exceptions.py +52 -0
- pymomo/http.py +169 -0
- pymomo/models.py +322 -0
- pymomo/products/__init__.py +1 -0
- pymomo/products/base.py +198 -0
- pymomo/products/collection.py +293 -0
- pymomo/products/disbursement.py +233 -0
- pymomo/products/remittance.py +85 -0
- pymomo/py.typed +0 -0
- pymomo/sandbox.py +142 -0
- pymomo/utils.py +387 -0
- pymomo/webhooks.py +144 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pymomo._async.products.base import AsyncBaseProduct
|
|
4
|
+
from pymomo.http import parse_model
|
|
5
|
+
from pymomo.models import (
|
|
6
|
+
DepositRequest,
|
|
7
|
+
Party,
|
|
8
|
+
RefundRequest,
|
|
9
|
+
TransactionResult,
|
|
10
|
+
TransferRequest,
|
|
11
|
+
)
|
|
12
|
+
from pymomo.utils import generate_reference_id, normalise_msisdn, validate_reference_id
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Disbursement(AsyncBaseProduct):
|
|
16
|
+
"""Asynchronous Disbursement product client."""
|
|
17
|
+
|
|
18
|
+
_product_name = "disbursement"
|
|
19
|
+
_token_path = "/disbursement/token/" # nosec B105
|
|
20
|
+
|
|
21
|
+
async def transfer(
|
|
22
|
+
self,
|
|
23
|
+
amount: str,
|
|
24
|
+
currency: str,
|
|
25
|
+
payee_msisdn: str,
|
|
26
|
+
external_id: str,
|
|
27
|
+
*,
|
|
28
|
+
payer_message: str = "",
|
|
29
|
+
payee_note: str = "",
|
|
30
|
+
reference_id: str | None = None,
|
|
31
|
+
) -> str:
|
|
32
|
+
"""Transfer funds to a payee.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
amount: The transaction amount.
|
|
36
|
+
currency: The transaction currency.
|
|
37
|
+
payee_msisdn: The MSISDN of the payee.
|
|
38
|
+
external_id: The external ID.
|
|
39
|
+
payer_message: Message to the payer.
|
|
40
|
+
payee_note: Note to the payee.
|
|
41
|
+
reference_id: Optional client-supplied reference ID.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
The reference ID associated with the transfer.
|
|
45
|
+
"""
|
|
46
|
+
if reference_id is not None:
|
|
47
|
+
validate_reference_id(reference_id)
|
|
48
|
+
ref = reference_id or generate_reference_id()
|
|
49
|
+
|
|
50
|
+
payload = TransferRequest(
|
|
51
|
+
amount=amount,
|
|
52
|
+
currency=currency,
|
|
53
|
+
externalId=external_id,
|
|
54
|
+
payee=Party(
|
|
55
|
+
partyIdType="MSISDN",
|
|
56
|
+
partyId=normalise_msisdn(payee_msisdn),
|
|
57
|
+
),
|
|
58
|
+
payerMessage=payer_message,
|
|
59
|
+
payeeNote=payee_note,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
await self._http.request(
|
|
63
|
+
"POST",
|
|
64
|
+
"/disbursement/v1_0/transfer",
|
|
65
|
+
headers=await self._build_headers(reference_id=ref, include_callback=True),
|
|
66
|
+
json=payload.model_dump(by_alias=True, mode="json"),
|
|
67
|
+
product_name=self._product_name,
|
|
68
|
+
token_cache=self._token_cache,
|
|
69
|
+
token_refresher=self._get_token,
|
|
70
|
+
)
|
|
71
|
+
return ref
|
|
72
|
+
|
|
73
|
+
async def get_transfer_status(self, reference_id: str) -> TransactionResult:
|
|
74
|
+
"""Poll the status of a transfer transaction.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
reference_id: The transaction reference ID.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
A TransactionResult object detailing the status of the transaction.
|
|
81
|
+
"""
|
|
82
|
+
validate_reference_id(reference_id)
|
|
83
|
+
response = await self._http.request(
|
|
84
|
+
"GET",
|
|
85
|
+
f"/disbursement/v1_0/transfer/{reference_id}",
|
|
86
|
+
headers=await self._build_headers(),
|
|
87
|
+
product_name=self._product_name,
|
|
88
|
+
token_cache=self._token_cache,
|
|
89
|
+
token_refresher=self._get_token,
|
|
90
|
+
)
|
|
91
|
+
return parse_model(response, TransactionResult)
|
|
92
|
+
|
|
93
|
+
async def deposit(
|
|
94
|
+
self,
|
|
95
|
+
amount: str,
|
|
96
|
+
currency: str,
|
|
97
|
+
payee_msisdn: str,
|
|
98
|
+
external_id: str,
|
|
99
|
+
*,
|
|
100
|
+
payer_message: str = "",
|
|
101
|
+
payee_note: str = "",
|
|
102
|
+
reference_id: str | None = None,
|
|
103
|
+
) -> str:
|
|
104
|
+
"""Initiate a Deposit (v2).
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
amount: The transaction amount.
|
|
108
|
+
currency: The transaction currency.
|
|
109
|
+
payee_msisdn: The MSISDN of the payee.
|
|
110
|
+
external_id: The external ID.
|
|
111
|
+
payer_message: Message to the payer.
|
|
112
|
+
payee_note: Note to the payee.
|
|
113
|
+
reference_id: Optional client-supplied reference ID.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
The reference ID associated with the deposit.
|
|
117
|
+
"""
|
|
118
|
+
if reference_id is not None:
|
|
119
|
+
validate_reference_id(reference_id)
|
|
120
|
+
ref = reference_id or generate_reference_id()
|
|
121
|
+
|
|
122
|
+
payload = DepositRequest(
|
|
123
|
+
amount=amount,
|
|
124
|
+
currency=currency,
|
|
125
|
+
externalId=external_id,
|
|
126
|
+
payee=Party(
|
|
127
|
+
partyIdType="MSISDN",
|
|
128
|
+
partyId=normalise_msisdn(payee_msisdn),
|
|
129
|
+
),
|
|
130
|
+
payerMessage=payer_message,
|
|
131
|
+
payeeNote=payee_note,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
await self._http.request(
|
|
135
|
+
"POST",
|
|
136
|
+
"/disbursement/v2_0/deposit",
|
|
137
|
+
headers=await self._build_headers(reference_id=ref, include_callback=True),
|
|
138
|
+
json=payload.model_dump(by_alias=True, mode="json"),
|
|
139
|
+
product_name=self._product_name,
|
|
140
|
+
token_cache=self._token_cache,
|
|
141
|
+
token_refresher=self._get_token,
|
|
142
|
+
)
|
|
143
|
+
return ref
|
|
144
|
+
|
|
145
|
+
async def get_deposit_status(self, reference_id: str) -> TransactionResult:
|
|
146
|
+
"""Poll the status of a deposit transaction.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
reference_id: The transaction reference ID.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
A TransactionResult object detailing the status of the transaction.
|
|
153
|
+
"""
|
|
154
|
+
validate_reference_id(reference_id)
|
|
155
|
+
response = await self._http.request(
|
|
156
|
+
"GET",
|
|
157
|
+
f"/disbursement/v2_0/deposit/{reference_id}",
|
|
158
|
+
headers=await self._build_headers(),
|
|
159
|
+
product_name=self._product_name,
|
|
160
|
+
token_cache=self._token_cache,
|
|
161
|
+
token_refresher=self._get_token,
|
|
162
|
+
)
|
|
163
|
+
return parse_model(response, TransactionResult)
|
|
164
|
+
|
|
165
|
+
async def refund(
|
|
166
|
+
self,
|
|
167
|
+
amount: str,
|
|
168
|
+
currency: str,
|
|
169
|
+
reference_id_to_refund: str,
|
|
170
|
+
external_id: str,
|
|
171
|
+
*,
|
|
172
|
+
payer_message: str = "",
|
|
173
|
+
payee_note: str = "",
|
|
174
|
+
reference_id: str | None = None,
|
|
175
|
+
) -> str:
|
|
176
|
+
"""Initiate a Refund (v2).
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
amount: The transaction amount.
|
|
180
|
+
currency: The transaction currency.
|
|
181
|
+
reference_id_to_refund: The reference ID of the transaction to refund.
|
|
182
|
+
external_id: The external ID.
|
|
183
|
+
payer_message: Message to the payer.
|
|
184
|
+
payee_note: Note to the payee.
|
|
185
|
+
reference_id: Optional client-supplied reference ID.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
The reference ID associated with the refund.
|
|
189
|
+
"""
|
|
190
|
+
if reference_id is not None:
|
|
191
|
+
validate_reference_id(reference_id)
|
|
192
|
+
validate_reference_id(reference_id_to_refund)
|
|
193
|
+
ref = reference_id or generate_reference_id()
|
|
194
|
+
|
|
195
|
+
payload = RefundRequest(
|
|
196
|
+
amount=amount,
|
|
197
|
+
currency=currency,
|
|
198
|
+
externalId=external_id,
|
|
199
|
+
referenceIdToRefund=reference_id_to_refund,
|
|
200
|
+
payerMessage=payer_message,
|
|
201
|
+
payeeNote=payee_note,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
await self._http.request(
|
|
205
|
+
"POST",
|
|
206
|
+
"/disbursement/v2_0/refund",
|
|
207
|
+
headers=await self._build_headers(reference_id=ref, include_callback=True),
|
|
208
|
+
json=payload.model_dump(by_alias=True, mode="json"),
|
|
209
|
+
product_name=self._product_name,
|
|
210
|
+
token_cache=self._token_cache,
|
|
211
|
+
token_refresher=self._get_token,
|
|
212
|
+
)
|
|
213
|
+
return ref
|
|
214
|
+
|
|
215
|
+
async def get_refund_status(self, reference_id: str) -> TransactionResult:
|
|
216
|
+
"""Poll the status of a refund transaction.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
reference_id: The transaction reference ID.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
A TransactionResult object detailing the status of the transaction.
|
|
223
|
+
"""
|
|
224
|
+
validate_reference_id(reference_id)
|
|
225
|
+
response = await self._http.request(
|
|
226
|
+
"GET",
|
|
227
|
+
f"/disbursement/v2_0/refund/{reference_id}",
|
|
228
|
+
headers=await self._build_headers(),
|
|
229
|
+
product_name=self._product_name,
|
|
230
|
+
token_cache=self._token_cache,
|
|
231
|
+
token_refresher=self._get_token,
|
|
232
|
+
)
|
|
233
|
+
return parse_model(response, TransactionResult)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pymomo._async.products.base import AsyncBaseProduct
|
|
4
|
+
from pymomo.http import parse_model
|
|
5
|
+
from pymomo.models import Party, TransactionResult, TransferRequest
|
|
6
|
+
from pymomo.utils import generate_reference_id, normalise_msisdn, validate_reference_id
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Remittance(AsyncBaseProduct):
|
|
10
|
+
"""Asynchronous Remittance product client."""
|
|
11
|
+
|
|
12
|
+
_product_name = "remittance"
|
|
13
|
+
_token_path = "/remittance/token/" # nosec B105
|
|
14
|
+
|
|
15
|
+
async def transfer(
|
|
16
|
+
self,
|
|
17
|
+
amount: str,
|
|
18
|
+
currency: str,
|
|
19
|
+
payee_msisdn: str,
|
|
20
|
+
external_id: str,
|
|
21
|
+
*,
|
|
22
|
+
payer_message: str = "",
|
|
23
|
+
payee_note: str = "",
|
|
24
|
+
reference_id: str | None = None,
|
|
25
|
+
) -> str:
|
|
26
|
+
"""Transfer funds to a payee.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
amount: The transaction amount.
|
|
30
|
+
currency: The transaction currency.
|
|
31
|
+
payee_msisdn: The MSISDN of the payee.
|
|
32
|
+
external_id: The external ID.
|
|
33
|
+
payer_message: Message to the payer.
|
|
34
|
+
payee_note: Note to the payee.
|
|
35
|
+
reference_id: Optional client-supplied reference ID.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
The reference ID associated with the transfer.
|
|
39
|
+
"""
|
|
40
|
+
if reference_id is not None:
|
|
41
|
+
validate_reference_id(reference_id)
|
|
42
|
+
ref = reference_id or generate_reference_id()
|
|
43
|
+
|
|
44
|
+
payload = TransferRequest(
|
|
45
|
+
amount=amount,
|
|
46
|
+
currency=currency,
|
|
47
|
+
externalId=external_id,
|
|
48
|
+
payee=Party(
|
|
49
|
+
partyIdType="MSISDN",
|
|
50
|
+
partyId=normalise_msisdn(payee_msisdn),
|
|
51
|
+
),
|
|
52
|
+
payerMessage=payer_message,
|
|
53
|
+
payeeNote=payee_note,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
await self._http.request(
|
|
57
|
+
"POST",
|
|
58
|
+
"/remittance/v1_0/transfer",
|
|
59
|
+
headers=await self._build_headers(reference_id=ref, include_callback=True),
|
|
60
|
+
json=payload.model_dump(by_alias=True, mode="json"),
|
|
61
|
+
product_name=self._product_name,
|
|
62
|
+
token_cache=self._token_cache,
|
|
63
|
+
token_refresher=self._get_token,
|
|
64
|
+
)
|
|
65
|
+
return ref
|
|
66
|
+
|
|
67
|
+
async def get_transfer_status(self, reference_id: str) -> TransactionResult:
|
|
68
|
+
"""Poll the status of a transfer transaction.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
reference_id: The transaction reference ID.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
A TransactionResult object detailing the status of the transaction.
|
|
75
|
+
"""
|
|
76
|
+
validate_reference_id(reference_id)
|
|
77
|
+
response = await self._http.request(
|
|
78
|
+
"GET",
|
|
79
|
+
f"/remittance/v1_0/transfer/{reference_id}",
|
|
80
|
+
headers=await self._build_headers(),
|
|
81
|
+
product_name=self._product_name,
|
|
82
|
+
token_cache=self._token_cache,
|
|
83
|
+
token_refresher=self._get_token,
|
|
84
|
+
)
|
|
85
|
+
return parse_model(response, TransactionResult)
|
pymomo/_async/sandbox.py
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pymomo._async.http import AsyncHttpClient
|
|
4
|
+
from pymomo.config import SANDBOX, MomoConfig
|
|
5
|
+
from pymomo.exceptions import MissingCredentialsError, PyMoMoError
|
|
6
|
+
from pymomo.http import parse_model
|
|
7
|
+
from pymomo.models import ApiKeyResult, ApiUserInfo
|
|
8
|
+
from pymomo.utils import (
|
|
9
|
+
generate_reference_id,
|
|
10
|
+
validate_callback_host,
|
|
11
|
+
validate_reference_id,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AsyncSandboxProvisioner:
|
|
16
|
+
"""Provisions sandbox API users and API keys asynchronously.
|
|
17
|
+
|
|
18
|
+
This class uses its own subscription key (provided at instantiation)
|
|
19
|
+
rather than per-product credentials, because the sandbox endpoints
|
|
20
|
+
sit outside the product hierarchy.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
_http: AsyncHttpClient
|
|
24
|
+
_config: MomoConfig | None
|
|
25
|
+
_subscription_key: str
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
subscription_key: str | MomoConfig | None = None,
|
|
30
|
+
config: MomoConfig | AsyncHttpClient | None = None,
|
|
31
|
+
http: AsyncHttpClient | None = None,
|
|
32
|
+
) -> None:
|
|
33
|
+
from typing import cast
|
|
34
|
+
|
|
35
|
+
if isinstance(subscription_key, MomoConfig):
|
|
36
|
+
# Property-based invocation: SandboxProvisioner(config, http)
|
|
37
|
+
self._config = subscription_key
|
|
38
|
+
self._http = cast(AsyncHttpClient, config)
|
|
39
|
+
self._subscription_key = self._extract_sub_key(self._config)
|
|
40
|
+
elif subscription_key is None and isinstance(config, MomoConfig):
|
|
41
|
+
# Keyword-based invocation: SandboxProvisioner(config=config, http=http)
|
|
42
|
+
self._config = config
|
|
43
|
+
self._http = cast(AsyncHttpClient, http)
|
|
44
|
+
self._subscription_key = self._extract_sub_key(self._config)
|
|
45
|
+
else:
|
|
46
|
+
# Standard instantiation: SandboxProvisioner(subscription_key, config, http)
|
|
47
|
+
self._subscription_key = subscription_key or ""
|
|
48
|
+
self._config = cast("MomoConfig | None", config)
|
|
49
|
+
self._http = cast(AsyncHttpClient, http)
|
|
50
|
+
|
|
51
|
+
if self._http is None:
|
|
52
|
+
raise PyMoMoError("HTTP client is required for sandbox provisioning")
|
|
53
|
+
if self._config is not None and self._config.environment != SANDBOX:
|
|
54
|
+
raise PyMoMoError(
|
|
55
|
+
"AsyncSandboxProvisioner can only be used with the sandbox environment"
|
|
56
|
+
)
|
|
57
|
+
if not self._subscription_key:
|
|
58
|
+
raise MissingCredentialsError(
|
|
59
|
+
"Subscription key is required for sandbox provisioning"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def __repr__(self) -> str:
|
|
63
|
+
env = self._config.environment if self._config else None
|
|
64
|
+
return (
|
|
65
|
+
f"AsyncSandboxProvisioner(subscription_key=<redacted>, environment={env!r})"
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
def __str__(self) -> str:
|
|
69
|
+
return self.__repr__()
|
|
70
|
+
|
|
71
|
+
def _extract_sub_key(self, config: MomoConfig) -> str:
|
|
72
|
+
return (
|
|
73
|
+
(config.collection.subscription_key if config.collection else "")
|
|
74
|
+
or (config.disbursement.subscription_key if config.disbursement else "")
|
|
75
|
+
or (config.remittance.subscription_key if config.remittance else "")
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
async def create_api_user(
|
|
79
|
+
self,
|
|
80
|
+
api_user: str | None = None,
|
|
81
|
+
*,
|
|
82
|
+
callback_host: str = "https://pymomo.aiforuganda.org",
|
|
83
|
+
) -> str:
|
|
84
|
+
"""Create a sandbox API user asynchronously. Returns the api_user UUID."""
|
|
85
|
+
validate_callback_host(callback_host)
|
|
86
|
+
if api_user is not None:
|
|
87
|
+
validate_reference_id(api_user)
|
|
88
|
+
ref = api_user or generate_reference_id()
|
|
89
|
+
await self._http.request(
|
|
90
|
+
"POST",
|
|
91
|
+
"/v1_0/apiuser",
|
|
92
|
+
headers={
|
|
93
|
+
"X-Reference-Id": ref,
|
|
94
|
+
"Ocp-Apim-Subscription-Key": self._subscription_key,
|
|
95
|
+
"Content-Type": "application/json",
|
|
96
|
+
},
|
|
97
|
+
json={"providerCallbackHost": callback_host},
|
|
98
|
+
)
|
|
99
|
+
return ref
|
|
100
|
+
|
|
101
|
+
async def get_api_user(self, api_user: str) -> ApiUserInfo:
|
|
102
|
+
"""Get information about a sandbox API user asynchronously.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
api_user: The API user UUID.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
An ApiUserInfo object containing provider callback host, etc.
|
|
109
|
+
"""
|
|
110
|
+
validate_reference_id(api_user)
|
|
111
|
+
response = await self._http.request(
|
|
112
|
+
"GET",
|
|
113
|
+
f"/v1_0/apiuser/{api_user}",
|
|
114
|
+
headers={
|
|
115
|
+
"Ocp-Apim-Subscription-Key": self._subscription_key,
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
return parse_model(response, ApiUserInfo)
|
|
119
|
+
|
|
120
|
+
async def create_api_key(self, api_user: str) -> str:
|
|
121
|
+
"""Create an API key for an existing sandbox user. Returns the api_key."""
|
|
122
|
+
validate_reference_id(api_user)
|
|
123
|
+
response = await self._http.request(
|
|
124
|
+
"POST",
|
|
125
|
+
f"/v1_0/apiuser/{api_user}/apikey",
|
|
126
|
+
headers={
|
|
127
|
+
"Ocp-Apim-Subscription-Key": self._subscription_key,
|
|
128
|
+
},
|
|
129
|
+
)
|
|
130
|
+
result = parse_model(response, ApiKeyResult)
|
|
131
|
+
return result.api_key
|
|
132
|
+
|
|
133
|
+
async def provision(
|
|
134
|
+
self,
|
|
135
|
+
*,
|
|
136
|
+
callback_host: str = "https://pymomo.aiforuganda.org",
|
|
137
|
+
) -> dict[str, str]:
|
|
138
|
+
"""Create a user and key in a single call. Returns both values.
|
|
139
|
+
|
|
140
|
+
Convenience method for bootstrapping a sandbox environment.
|
|
141
|
+
Returns {"api_user": "...", "api_key": "..."}.
|
|
142
|
+
"""
|
|
143
|
+
api_user = await self.create_api_user(callback_host=callback_host)
|
|
144
|
+
api_key = await self.create_api_key(api_user)
|
|
145
|
+
return {"api_user": api_user, "api_key": api_key}
|