|
4 | 4 | from typing import Any, Callable, Dict, List |
5 | 5 |
|
6 | 6 | import requests |
| 7 | +from deprecated import deprecated |
7 | 8 | from requests import Response |
8 | 9 |
|
9 | 10 | from setu.auth import generate_jwt_token, generate_oauth_token |
|
18 | 19 | AUTH_TYPE_JWT, |
19 | 20 | MODE_PRODUCTION, |
20 | 21 | AuthType, |
21 | | - BatchRefundStatusResponse, |
22 | 22 | CreatePaymentLinkResponseData, |
23 | 23 | InitiateBatchRefundResponse, |
24 | 24 | MockCreditResponseData, |
25 | 25 | Mode, |
26 | 26 | PaymentLinkStatusResponseData, |
27 | 27 | RefundRequestItem, |
28 | 28 | RefundResponseItem, |
| 29 | + RefundStatusByIdentifierResponse, |
| 30 | + RefundStatusIdentifierType, |
29 | 31 | SettlementSplits, |
30 | 32 | SetuAPIException, |
31 | 33 | ValidationRules, |
32 | 34 | ) |
33 | 35 | from setu.endpoint import get_url_path |
34 | 36 | from setu.serial import ( |
35 | | - BatchRefundStatusResponseSchema, |
36 | 37 | CreatePaymentLinkResponseDataSchema, |
37 | 38 | InitiateBatchRefundResponseDataSchema, |
38 | 39 | MockCreditResponseDataSchema, |
39 | 40 | PaymentLinkStatusResponseDataSchema, |
40 | 41 | RefundResponseItemSchema, |
| 42 | + RefundStatusByIdentifierResponseSchema, |
41 | 43 | SetuErrorResponseSchema, |
42 | 44 | ) |
43 | 45 |
|
@@ -213,14 +215,29 @@ def initiate_batch_refund( |
213 | 215 | initiate_batch_refund_response_data_schema = InitiateBatchRefundResponseDataSchema() |
214 | 216 | return initiate_batch_refund_response_data_schema.load(api_response.json()['data']) |
215 | 217 |
|
| 218 | + @deprecated(version="1.2.0", reason="Use the more generic get_refund_status_by_identifier method instead") |
216 | 219 | @Decorators.auth_handler |
217 | | - def get_batch_refund_status(self, batch_refund_id: str) -> BatchRefundStatusResponse: |
| 220 | + def get_batch_refund_status(self, batch_refund_id: str) -> RefundStatusByIdentifierResponse: |
218 | 221 | """Get batch refund status.""" |
219 | 222 | api_response = self.session.get( |
220 | 223 | "{}/batch/{}".format(get_url_path(API.REFUNDS_BASE, self.auth_type, self.mode), batch_refund_id), |
221 | 224 | headers=self.headers, |
222 | 225 | ) |
223 | | - batch_refund_status_response_schema = BatchRefundStatusResponseSchema() |
| 226 | + batch_refund_status_response_schema = RefundStatusByIdentifierResponseSchema() |
| 227 | + return batch_refund_status_response_schema.load(api_response.json()['data']) |
| 228 | + |
| 229 | + @Decorators.auth_handler |
| 230 | + def get_refund_status_by_identifier( |
| 231 | + self, identifier_type: RefundStatusIdentifierType, identifier_value: str |
| 232 | + ) -> RefundStatusByIdentifierResponse: |
| 233 | + """Get batch refund status.""" |
| 234 | + api_response = self.session.get( |
| 235 | + "{}/{}/{}".format( |
| 236 | + get_url_path(API.REFUNDS_BASE, self.auth_type, self.mode), identifier_type, identifier_value |
| 237 | + ), |
| 238 | + headers=self.headers, |
| 239 | + ) |
| 240 | + batch_refund_status_response_schema = RefundStatusByIdentifierResponseSchema() |
224 | 241 | return batch_refund_status_response_schema.load(api_response.json()['data']) |
225 | 242 |
|
226 | 243 | @Decorators.auth_handler |
|
0 commit comments