kard-financial-sdk 0.0.82__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.
- kard/__init__.py +579 -0
- kard/auth/__init__.py +34 -0
- kard/auth/client.py +121 -0
- kard/auth/raw_client.py +108 -0
- kard/auth/types/__init__.py +34 -0
- kard/auth/types/token_response.py +25 -0
- kard/client.py +416 -0
- kard/commons/__init__.py +120 -0
- kard/commons/errors/__init__.py +44 -0
- kard/commons/errors/conflict_error.py +11 -0
- kard/commons/errors/does_not_exist_error.py +11 -0
- kard/commons/errors/internal_server_error.py +11 -0
- kard/commons/errors/invalid_request.py +11 -0
- kard/commons/errors/unauthorized_error.py +11 -0
- kard/commons/types/__init__.py +107 -0
- kard/commons/types/category_option.py +26 -0
- kard/commons/types/commission_type.py +5 -0
- kard/commons/types/commission_value.py +28 -0
- kard/commons/types/commission_value_type.py +5 -0
- kard/commons/types/empty_object.py +17 -0
- kard/commons/types/enrolled_rewards_type.py +5 -0
- kard/commons/types/error_object.py +43 -0
- kard/commons/types/error_response.py +20 -0
- kard/commons/types/error_source.py +32 -0
- kard/commons/types/job.py +24 -0
- kard/commons/types/job_response.py +27 -0
- kard/commons/types/job_status.py +5 -0
- kard/commons/types/links.py +27 -0
- kard/commons/types/mongo_id.py +3 -0
- kard/commons/types/notification_type.py +19 -0
- kard/commons/types/organization_id.py +3 -0
- kard/commons/types/purchase_channel.py +5 -0
- kard/commons/types/relationship_data.py +24 -0
- kard/commons/types/relationship_multiple.py +20 -0
- kard/commons/types/relationship_single.py +20 -0
- kard/commons/types/resource_type.py +3 -0
- kard/commons/types/state.py +68 -0
- kard/commons/types/subscription_id.py +3 -0
- kard/commons/types/user_id.py +3 -0
- kard/core/__init__.py +105 -0
- kard/core/api_error.py +23 -0
- kard/core/client_wrapper.py +97 -0
- kard/core/datetime_utils.py +28 -0
- kard/core/file.py +67 -0
- kard/core/force_multipart.py +18 -0
- kard/core/http_client.py +613 -0
- kard/core/http_response.py +55 -0
- kard/core/http_sse/__init__.py +42 -0
- kard/core/http_sse/_api.py +112 -0
- kard/core/http_sse/_decoders.py +61 -0
- kard/core/http_sse/_exceptions.py +7 -0
- kard/core/http_sse/_models.py +17 -0
- kard/core/jsonable_encoder.py +100 -0
- kard/core/oauth_token_provider.py +73 -0
- kard/core/pydantic_utilities.py +260 -0
- kard/core/query_encoder.py +58 -0
- kard/core/remove_none_from_dict.py +11 -0
- kard/core/request_options.py +35 -0
- kard/core/serialization.py +276 -0
- kard/environment.py +8 -0
- kard/files/__init__.py +58 -0
- kard/files/client.py +213 -0
- kard/files/errors/__init__.py +34 -0
- kard/files/errors/forbidden_error.py +11 -0
- kard/files/raw_client.py +278 -0
- kard/files/types/__init__.py +53 -0
- kard/files/types/file_metadata_attribute.py +39 -0
- kard/files/types/file_metadata_with_url.py +34 -0
- kard/files/types/file_type.py +13 -0
- kard/files/types/files_metadata_sort_options.py +5 -0
- kard/files/types/get_files_metadata_response.py +71 -0
- kard/files/types/pagination_meta.py +29 -0
- kard/notifications/__init__.py +279 -0
- kard/notifications/client.py +63 -0
- kard/notifications/raw_client.py +13 -0
- kard/notifications/subscriptions/__init__.py +97 -0
- kard/notifications/subscriptions/client.py +372 -0
- kard/notifications/subscriptions/raw_client.py +581 -0
- kard/notifications/subscriptions/types/__init__.py +94 -0
- kard/notifications/subscriptions/types/create_subscription_union.py +27 -0
- kard/notifications/subscriptions/types/create_subscriptions_response_object.py +43 -0
- kard/notifications/subscriptions/types/created_subscription.py +23 -0
- kard/notifications/subscriptions/types/subscription.py +25 -0
- kard/notifications/subscriptions/types/subscription_attributes.py +35 -0
- kard/notifications/subscriptions/types/subscription_request.py +20 -0
- kard/notifications/subscriptions/types/subscription_request_attributes.py +35 -0
- kard/notifications/subscriptions/types/subscription_request_body.py +42 -0
- kard/notifications/subscriptions/types/subscription_request_union.py +26 -0
- kard/notifications/subscriptions/types/subscription_union.py +27 -0
- kard/notifications/subscriptions/types/subscriptions_response_object.py +43 -0
- kard/notifications/subscriptions/types/update_subscription_request.py +20 -0
- kard/notifications/subscriptions/types/update_subscription_request_attributes.py +39 -0
- kard/notifications/subscriptions/types/update_subscription_request_body.py +40 -0
- kard/notifications/subscriptions/types/update_subscription_request_union.py +26 -0
- kard/notifications/subscriptions/types/update_subscriptions_response_object.py +41 -0
- kard/notifications/types/__init__.py +214 -0
- kard/notifications/types/audit_update_attributes.py +88 -0
- kard/notifications/types/audit_update_data.py +27 -0
- kard/notifications/types/audit_update_relationships.py +21 -0
- kard/notifications/types/broker_amount.py +28 -0
- kard/notifications/types/broker_amount_type.py +5 -0
- kard/notifications/types/broker_asset.py +33 -0
- kard/notifications/types/broker_asset_type.py +5 -0
- kard/notifications/types/broker_operation_hours.py +30 -0
- kard/notifications/types/broker_operation_period.py +28 -0
- kard/notifications/types/broker_purchase_channel.py +5 -0
- kard/notifications/types/broker_reward.py +28 -0
- kard/notifications/types/broker_reward_type.py +5 -0
- kard/notifications/types/clawback_data.py +27 -0
- kard/notifications/types/earned_reward_approved_data.py +27 -0
- kard/notifications/types/earned_reward_attributes.py +18 -0
- kard/notifications/types/earned_reward_relationships.py +21 -0
- kard/notifications/types/earned_reward_settled_attributes.py +23 -0
- kard/notifications/types/earned_reward_settled_data.py +27 -0
- kard/notifications/types/failed_transaction_attributes.py +41 -0
- kard/notifications/types/failed_transaction_data.py +27 -0
- kard/notifications/types/failed_transaction_relationships.py +22 -0
- kard/notifications/types/location_address.py +39 -0
- kard/notifications/types/location_coordinates.py +27 -0
- kard/notifications/types/location_status.py +5 -0
- kard/notifications/types/merchant_source.py +5 -0
- kard/notifications/types/notification_data_union.py +203 -0
- kard/notifications/types/notification_metadata.py +22 -0
- kard/notifications/types/notification_payload.py +65 -0
- kard/notifications/types/offer_status.py +5 -0
- kard/notifications/types/offer_type.py +5 -0
- kard/notifications/types/reward_notification_attributes.py +48 -0
- kard/notifications/types/time_period.py +27 -0
- kard/notifications/types/transaction_relationships.py +22 -0
- kard/notifications/types/user_offer_status.py +5 -0
- kard/notifications/types/valid_transaction_attributes.py +25 -0
- kard/notifications/types/valid_transaction_commission_earned.py +21 -0
- kard/notifications/types/valid_transaction_data.py +27 -0
- kard/notifications/types/webhook_locations_attributes.py +71 -0
- kard/notifications/types/webhook_locations_data.py +27 -0
- kard/notifications/types/webhook_locations_relationships.py +20 -0
- kard/notifications/types/webhook_merchant_attributes.py +67 -0
- kard/notifications/types/webhook_merchant_data.py +27 -0
- kard/notifications/types/webhook_merchant_relationships.py +20 -0
- kard/notifications/types/webhook_offer_attributes.py +143 -0
- kard/notifications/types/webhook_offer_data.py +27 -0
- kard/notifications/types/webhook_offer_relationships.py +20 -0
- kard/notifications/types/webhook_user_offer_attributes.py +41 -0
- kard/notifications/types/webhook_user_offer_data.py +27 -0
- kard/notifications/types/webhook_user_offer_relationships.py +21 -0
- kard/ping/__init__.py +39 -0
- kard/ping/client.py +100 -0
- kard/ping/errors/__init__.py +34 -0
- kard/ping/errors/network_blocked_error.py +11 -0
- kard/ping/raw_client.py +113 -0
- kard/ping/types/__init__.py +38 -0
- kard/ping/types/network_blocked_error_body.py +34 -0
- kard/ping/types/ping_response_object.py +46 -0
- kard/py.typed +0 -0
- kard/transactions/__init__.py +212 -0
- kard/transactions/client.py +639 -0
- kard/transactions/errors/__init__.py +40 -0
- kard/transactions/errors/create_audit_multi_status.py +11 -0
- kard/transactions/errors/create_incoming_transactions_multi_status.py +11 -0
- kard/transactions/errors/fraud_multi_status.py +11 -0
- kard/transactions/raw_client.py +925 -0
- kard/transactions/types/__init__.py +199 -0
- kard/transactions/types/audit_attributes.py +44 -0
- kard/transactions/types/audit_request_data.py +20 -0
- kard/transactions/types/audit_response_attributes.py +24 -0
- kard/transactions/types/audit_response_data.py +25 -0
- kard/transactions/types/audit_status.py +5 -0
- kard/transactions/types/card_network.py +5 -0
- kard/transactions/types/commission_earned_details.py +21 -0
- kard/transactions/types/create_audit_multi_status_response.py +21 -0
- kard/transactions/types/create_audit_request_body.py +43 -0
- kard/transactions/types/create_audit_request_data_union.py +26 -0
- kard/transactions/types/create_audit_response_body.py +41 -0
- kard/transactions/types/create_audit_response_data_union.py +27 -0
- kard/transactions/types/direction_type.py +5 -0
- kard/transactions/types/fraudulent_transaction_attributes.py +24 -0
- kard/transactions/types/fraudulent_transaction_data.py +30 -0
- kard/transactions/types/fraudulent_transaction_object.py +42 -0
- kard/transactions/types/fraudulent_transaction_request_body.py +45 -0
- kard/transactions/types/fraudulent_transaction_response.py +21 -0
- kard/transactions/types/get_earned_rewards_response.py +133 -0
- kard/transactions/types/matched_transactions_attributes.py +156 -0
- kard/transactions/types/matched_transactions_request.py +25 -0
- kard/transactions/types/merchant.py +82 -0
- kard/transactions/types/payment_status.py +5 -0
- kard/transactions/types/payment_type.py +5 -0
- kard/transactions/types/processor_mid.py +26 -0
- kard/transactions/types/receipt_medium_type.py +5 -0
- kard/transactions/types/rewarded_transaction.py +27 -0
- kard/transactions/types/rewarded_transaction_attributes.py +74 -0
- kard/transactions/types/rewarded_transaction_relationships.py +22 -0
- kard/transactions/types/rewarded_transaction_status.py +5 -0
- kard/transactions/types/rewarded_transaction_union.py +29 -0
- kard/transactions/types/states.py +68 -0
- kard/transactions/types/transaction_included_resource.py +47 -0
- kard/transactions/types/transaction_merchant_attributes.py +22 -0
- kard/transactions/types/transaction_merchant_resource.py +28 -0
- kard/transactions/types/transaction_offer_attributes.py +26 -0
- kard/transactions/types/transaction_offer_resource.py +28 -0
- kard/transactions/types/transaction_payment_type.py +5 -0
- kard/transactions/types/transaction_status.py +5 -0
- kard/transactions/types/transactions.py +46 -0
- kard/transactions/types/transactions_attributes.py +198 -0
- kard/transactions/types/transactions_multi_response.py +21 -0
- kard/transactions/types/transactions_request.py +25 -0
- kard/transactions/types/transactions_request_body.py +90 -0
- kard/transactions/types/transactions_response.py +38 -0
- kard/transactions/types/transactions_response_data.py +27 -0
- kard/transactions/types/visa_mid.py +23 -0
- kard/transactions/types/visa_mid_details.py +27 -0
- kard/users/__init__.py +293 -0
- kard/users/attributions/__init__.py +73 -0
- kard/users/attributions/client.py +229 -0
- kard/users/attributions/raw_client.py +215 -0
- kard/users/attributions/types/__init__.py +73 -0
- kard/users/attributions/types/create_attribution_request_object.py +75 -0
- kard/users/attributions/types/create_attribution_request_union.py +45 -0
- kard/users/attributions/types/create_attribution_response.py +38 -0
- kard/users/attributions/types/event_code.py +5 -0
- kard/users/attributions/types/notification_attribution_attributes.py +35 -0
- kard/users/attributions/types/notification_attribution_request.py +20 -0
- kard/users/attributions/types/notification_medium.py +5 -0
- kard/users/attributions/types/offer_attribution_attributes.py +35 -0
- kard/users/attributions/types/offer_attribution_request.py +20 -0
- kard/users/attributions/types/offer_medium.py +5 -0
- kard/users/client.py +512 -0
- kard/users/errors/__init__.py +34 -0
- kard/users/errors/multi_status.py +11 -0
- kard/users/raw_client.py +783 -0
- kard/users/rewards/__init__.py +133 -0
- kard/users/rewards/client.py +448 -0
- kard/users/rewards/raw_client.py +587 -0
- kard/users/rewards/types/__init__.py +130 -0
- kard/users/rewards/types/amount.py +21 -0
- kard/users/rewards/types/amount_type.py +5 -0
- kard/users/rewards/types/asset.py +28 -0
- kard/users/rewards/types/category_data.py +18 -0
- kard/users/rewards/types/category_fields.py +23 -0
- kard/users/rewards/types/category_identifier.py +24 -0
- kard/users/rewards/types/category_included.py +21 -0
- kard/users/rewards/types/category_relationship.py +20 -0
- kard/users/rewards/types/category_relationship_object.py +20 -0
- kard/users/rewards/types/commission.py +21 -0
- kard/users/rewards/types/coordinates.py +20 -0
- kard/users/rewards/types/eligibility_location_address.py +24 -0
- kard/users/rewards/types/eligibility_location_included.py +8 -0
- kard/users/rewards/types/eligibility_offer_included.py +7 -0
- kard/users/rewards/types/eligibility_offer_relationship.py +7 -0
- kard/users/rewards/types/location_attributes.py +28 -0
- kard/users/rewards/types/location_data.py +32 -0
- kard/users/rewards/types/location_relationships.py +18 -0
- kard/users/rewards/types/location_sort_options.py +5 -0
- kard/users/rewards/types/locations_response_object.py +215 -0
- kard/users/rewards/types/offer_common_fields.py +103 -0
- kard/users/rewards/types/offer_data_union.py +30 -0
- kard/users/rewards/types/offer_relationship.py +21 -0
- kard/users/rewards/types/offer_sort_options.py +7 -0
- kard/users/rewards/types/offers_response_object.py +130 -0
- kard/users/rewards/types/operation_hours.py +23 -0
- kard/users/rewards/types/operation_period.py +21 -0
- kard/users/rewards/types/operation_time.py +20 -0
- kard/users/rewards/types/standard_offer.py +21 -0
- kard/users/rewards/types/standard_offer_core.py +26 -0
- kard/users/rewards/types/standard_offer_fields.py +18 -0
- kard/users/types/__init__.py +66 -0
- kard/users/types/create_users_multi_status_response.py +21 -0
- kard/users/types/create_users_object.py +42 -0
- kard/users/types/delete_user_response_object.py +34 -0
- kard/users/types/update_user_object.py +40 -0
- kard/users/types/user_request_attributes.py +60 -0
- kard/users/types/user_request_data.py +22 -0
- kard/users/types/user_request_data_union.py +28 -0
- kard/users/types/user_response_no_data.py +22 -0
- kard/users/types/user_response_union_no_data.py +28 -0
- kard/users/uploads/__init__.py +112 -0
- kard/users/uploads/client.py +484 -0
- kard/users/uploads/errors/__init__.py +34 -0
- kard/users/uploads/errors/upload_part_multi_status.py +13 -0
- kard/users/uploads/raw_client.py +625 -0
- kard/users/uploads/types/__init__.py +119 -0
- kard/users/uploads/types/create_upload_part_data_union.py +27 -0
- kard/users/uploads/types/create_upload_part_multi_status_response.py +21 -0
- kard/users/uploads/types/create_upload_part_request_object.py +74 -0
- kard/users/uploads/types/create_upload_part_response_data.py +25 -0
- kard/users/uploads/types/create_upload_part_response_data_union.py +27 -0
- kard/users/uploads/types/create_upload_part_response_object.py +39 -0
- kard/users/uploads/types/create_upload_request_data_union.py +26 -0
- kard/users/uploads/types/create_upload_request_object.py +36 -0
- kard/users/uploads/types/create_upload_response_data.py +25 -0
- kard/users/uploads/types/create_upload_response_data_union.py +27 -0
- kard/users/uploads/types/create_upload_response_object.py +37 -0
- kard/users/uploads/types/historical_transaction_complete_no_data.py +25 -0
- kard/users/uploads/types/start_historical_upload_no_data.py +20 -0
- kard/users/uploads/types/update_upload_request_data_union.py +27 -0
- kard/users/uploads/types/update_upload_request_object.py +37 -0
- kard/users/uploads/types/update_upload_response_data.py +25 -0
- kard/users/uploads/types/update_upload_response_data_union.py +27 -0
- kard/users/uploads/types/update_upload_response_object.py +37 -0
- kard/version.py +3 -0
- kard_financial_sdk-0.0.82.dist-info/METADATA +238 -0
- kard_financial_sdk-0.0.82.dist-info/RECORD +302 -0
- kard_financial_sdk-0.0.82.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,925 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..commons.errors.conflict_error import ConflictError
|
|
7
|
+
from ..commons.errors.does_not_exist_error import DoesNotExistError
|
|
8
|
+
from ..commons.errors.internal_server_error import InternalServerError
|
|
9
|
+
from ..commons.errors.invalid_request import InvalidRequest
|
|
10
|
+
from ..commons.errors.unauthorized_error import UnauthorizedError
|
|
11
|
+
from ..commons.types.error_response import ErrorResponse
|
|
12
|
+
from ..commons.types.organization_id import OrganizationId
|
|
13
|
+
from ..core.api_error import ApiError
|
|
14
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
15
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
16
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
17
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
18
|
+
from ..core.request_options import RequestOptions
|
|
19
|
+
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
20
|
+
from .errors.create_audit_multi_status import CreateAuditMultiStatus
|
|
21
|
+
from .errors.create_incoming_transactions_multi_status import CreateIncomingTransactionsMultiStatus
|
|
22
|
+
from .errors.fraud_multi_status import FraudMultiStatus
|
|
23
|
+
from .types.create_audit_multi_status_response import CreateAuditMultiStatusResponse
|
|
24
|
+
from .types.create_audit_request_data_union import CreateAuditRequestDataUnion
|
|
25
|
+
from .types.create_audit_response_body import CreateAuditResponseBody
|
|
26
|
+
from .types.fraudulent_transaction_data import FraudulentTransactionData
|
|
27
|
+
from .types.fraudulent_transaction_object import FraudulentTransactionObject
|
|
28
|
+
from .types.fraudulent_transaction_response import FraudulentTransactionResponse
|
|
29
|
+
from .types.get_earned_rewards_response import GetEarnedRewardsResponse
|
|
30
|
+
from .types.transactions import Transactions
|
|
31
|
+
from .types.transactions_multi_response import TransactionsMultiResponse
|
|
32
|
+
from .types.transactions_response import TransactionsResponse
|
|
33
|
+
|
|
34
|
+
# this is used as the default value for optional parameters
|
|
35
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class RawTransactionsClient:
|
|
39
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
40
|
+
self._client_wrapper = client_wrapper
|
|
41
|
+
|
|
42
|
+
def create(
|
|
43
|
+
self,
|
|
44
|
+
organization_id: OrganizationId,
|
|
45
|
+
*,
|
|
46
|
+
data: typing.Sequence[Transactions],
|
|
47
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
48
|
+
) -> HttpResponse[TransactionsResponse]:
|
|
49
|
+
"""
|
|
50
|
+
Call this endpoint to send all transactions made by all your enrolled users in your rewards program. The request body will depend on the transaction type.<br/>
|
|
51
|
+
Please use the correct type when calling the endpoint:
|
|
52
|
+
- `transaction`: These incoming transactions will be processed and matched by the Kard system. Learn more about the [Transaction CLO Matching](https://github.com/kard-financial/kard-postman#c-transaction-clo-matching) flow here.
|
|
53
|
+
- `matchedTransaction`: For pre-matched transactions that need validation on match by the Kard system.<br/>
|
|
54
|
+
|
|
55
|
+
<b>Required scopes:</b> `transaction:write`<br/>
|
|
56
|
+
<b>Note:</b> `Maximum of 500 transactions can be created per request`.
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
organization_id : OrganizationId
|
|
61
|
+
|
|
62
|
+
data : typing.Sequence[Transactions]
|
|
63
|
+
Discriminated union representing the request body for submitting a transaction.
|
|
64
|
+
Use `type` to distinguish between the two:
|
|
65
|
+
- `transaction`: For transactions requiring processing and matching by the Kard system.
|
|
66
|
+
- `matchedTransaction`: For pre-matched transactions that need validation on match by the Kard system.
|
|
67
|
+
|
|
68
|
+
request_options : typing.Optional[RequestOptions]
|
|
69
|
+
Request-specific configuration.
|
|
70
|
+
|
|
71
|
+
Returns
|
|
72
|
+
-------
|
|
73
|
+
HttpResponse[TransactionsResponse]
|
|
74
|
+
"""
|
|
75
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
76
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/transactions",
|
|
77
|
+
method="POST",
|
|
78
|
+
json={
|
|
79
|
+
"data": convert_and_respect_annotation_metadata(
|
|
80
|
+
object_=data, annotation=typing.Sequence[Transactions], direction="write"
|
|
81
|
+
),
|
|
82
|
+
},
|
|
83
|
+
request_options=request_options,
|
|
84
|
+
omit=OMIT,
|
|
85
|
+
)
|
|
86
|
+
try:
|
|
87
|
+
if 200 <= _response.status_code < 300:
|
|
88
|
+
_data = typing.cast(
|
|
89
|
+
TransactionsResponse,
|
|
90
|
+
parse_obj_as(
|
|
91
|
+
type_=TransactionsResponse, # type: ignore
|
|
92
|
+
object_=_response.json(),
|
|
93
|
+
),
|
|
94
|
+
)
|
|
95
|
+
return HttpResponse(response=_response, data=_data)
|
|
96
|
+
if _response.status_code == 207:
|
|
97
|
+
raise CreateIncomingTransactionsMultiStatus(
|
|
98
|
+
headers=dict(_response.headers),
|
|
99
|
+
body=typing.cast(
|
|
100
|
+
TransactionsMultiResponse,
|
|
101
|
+
parse_obj_as(
|
|
102
|
+
type_=TransactionsMultiResponse, # type: ignore
|
|
103
|
+
object_=_response.json(),
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
if _response.status_code == 401:
|
|
108
|
+
raise UnauthorizedError(
|
|
109
|
+
headers=dict(_response.headers),
|
|
110
|
+
body=typing.cast(
|
|
111
|
+
ErrorResponse,
|
|
112
|
+
parse_obj_as(
|
|
113
|
+
type_=ErrorResponse, # type: ignore
|
|
114
|
+
object_=_response.json(),
|
|
115
|
+
),
|
|
116
|
+
),
|
|
117
|
+
)
|
|
118
|
+
if _response.status_code == 500:
|
|
119
|
+
raise InternalServerError(
|
|
120
|
+
headers=dict(_response.headers),
|
|
121
|
+
body=typing.cast(
|
|
122
|
+
ErrorResponse,
|
|
123
|
+
parse_obj_as(
|
|
124
|
+
type_=ErrorResponse, # type: ignore
|
|
125
|
+
object_=_response.json(),
|
|
126
|
+
),
|
|
127
|
+
),
|
|
128
|
+
)
|
|
129
|
+
if _response.status_code == 400:
|
|
130
|
+
raise InvalidRequest(
|
|
131
|
+
headers=dict(_response.headers),
|
|
132
|
+
body=typing.cast(
|
|
133
|
+
ErrorResponse,
|
|
134
|
+
parse_obj_as(
|
|
135
|
+
type_=ErrorResponse, # type: ignore
|
|
136
|
+
object_=_response.json(),
|
|
137
|
+
),
|
|
138
|
+
),
|
|
139
|
+
)
|
|
140
|
+
if _response.status_code == 409:
|
|
141
|
+
raise ConflictError(
|
|
142
|
+
headers=dict(_response.headers),
|
|
143
|
+
body=typing.cast(
|
|
144
|
+
ErrorResponse,
|
|
145
|
+
parse_obj_as(
|
|
146
|
+
type_=ErrorResponse, # type: ignore
|
|
147
|
+
object_=_response.json(),
|
|
148
|
+
),
|
|
149
|
+
),
|
|
150
|
+
)
|
|
151
|
+
_response_json = _response.json()
|
|
152
|
+
except JSONDecodeError:
|
|
153
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
154
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
155
|
+
|
|
156
|
+
def create_fraud_markers(
|
|
157
|
+
self,
|
|
158
|
+
organization_id: OrganizationId,
|
|
159
|
+
*,
|
|
160
|
+
data: typing.Sequence[FraudulentTransactionData],
|
|
161
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
162
|
+
) -> HttpResponse[FraudulentTransactionObject]:
|
|
163
|
+
"""
|
|
164
|
+
Call this endpoint to flag a submitted transaction as fraudulent. This will prevent it from being rewarded.<br/>
|
|
165
|
+
|
|
166
|
+
<b>Required scopes:</b> `transaction:write`<br/>
|
|
167
|
+
<b>Note:</b> `Maximum of 500 fraudulent transactions can be created per request`.
|
|
168
|
+
|
|
169
|
+
Parameters
|
|
170
|
+
----------
|
|
171
|
+
organization_id : OrganizationId
|
|
172
|
+
|
|
173
|
+
data : typing.Sequence[FraudulentTransactionData]
|
|
174
|
+
List of fraudulent transactions to report
|
|
175
|
+
|
|
176
|
+
request_options : typing.Optional[RequestOptions]
|
|
177
|
+
Request-specific configuration.
|
|
178
|
+
|
|
179
|
+
Returns
|
|
180
|
+
-------
|
|
181
|
+
HttpResponse[FraudulentTransactionObject]
|
|
182
|
+
"""
|
|
183
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
184
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/fraud",
|
|
185
|
+
method="POST",
|
|
186
|
+
json={
|
|
187
|
+
"data": convert_and_respect_annotation_metadata(
|
|
188
|
+
object_=data, annotation=typing.Sequence[FraudulentTransactionData], direction="write"
|
|
189
|
+
),
|
|
190
|
+
},
|
|
191
|
+
request_options=request_options,
|
|
192
|
+
omit=OMIT,
|
|
193
|
+
)
|
|
194
|
+
try:
|
|
195
|
+
if 200 <= _response.status_code < 300:
|
|
196
|
+
_data = typing.cast(
|
|
197
|
+
FraudulentTransactionObject,
|
|
198
|
+
parse_obj_as(
|
|
199
|
+
type_=FraudulentTransactionObject, # type: ignore
|
|
200
|
+
object_=_response.json(),
|
|
201
|
+
),
|
|
202
|
+
)
|
|
203
|
+
return HttpResponse(response=_response, data=_data)
|
|
204
|
+
if _response.status_code == 207:
|
|
205
|
+
raise FraudMultiStatus(
|
|
206
|
+
headers=dict(_response.headers),
|
|
207
|
+
body=typing.cast(
|
|
208
|
+
FraudulentTransactionResponse,
|
|
209
|
+
parse_obj_as(
|
|
210
|
+
type_=FraudulentTransactionResponse, # type: ignore
|
|
211
|
+
object_=_response.json(),
|
|
212
|
+
),
|
|
213
|
+
),
|
|
214
|
+
)
|
|
215
|
+
if _response.status_code == 401:
|
|
216
|
+
raise UnauthorizedError(
|
|
217
|
+
headers=dict(_response.headers),
|
|
218
|
+
body=typing.cast(
|
|
219
|
+
ErrorResponse,
|
|
220
|
+
parse_obj_as(
|
|
221
|
+
type_=ErrorResponse, # type: ignore
|
|
222
|
+
object_=_response.json(),
|
|
223
|
+
),
|
|
224
|
+
),
|
|
225
|
+
)
|
|
226
|
+
if _response.status_code == 500:
|
|
227
|
+
raise InternalServerError(
|
|
228
|
+
headers=dict(_response.headers),
|
|
229
|
+
body=typing.cast(
|
|
230
|
+
ErrorResponse,
|
|
231
|
+
parse_obj_as(
|
|
232
|
+
type_=ErrorResponse, # type: ignore
|
|
233
|
+
object_=_response.json(),
|
|
234
|
+
),
|
|
235
|
+
),
|
|
236
|
+
)
|
|
237
|
+
if _response.status_code == 400:
|
|
238
|
+
raise InvalidRequest(
|
|
239
|
+
headers=dict(_response.headers),
|
|
240
|
+
body=typing.cast(
|
|
241
|
+
ErrorResponse,
|
|
242
|
+
parse_obj_as(
|
|
243
|
+
type_=ErrorResponse, # type: ignore
|
|
244
|
+
object_=_response.json(),
|
|
245
|
+
),
|
|
246
|
+
),
|
|
247
|
+
)
|
|
248
|
+
_response_json = _response.json()
|
|
249
|
+
except JSONDecodeError:
|
|
250
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
251
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
252
|
+
|
|
253
|
+
def create_audits(
|
|
254
|
+
self,
|
|
255
|
+
organization_id: OrganizationId,
|
|
256
|
+
user_id: str,
|
|
257
|
+
*,
|
|
258
|
+
data: typing.Sequence[CreateAuditRequestDataUnion],
|
|
259
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
260
|
+
) -> HttpResponse[CreateAuditResponseBody]:
|
|
261
|
+
"""
|
|
262
|
+
Call this endpoint to request that a particular transaction be audited further by the Kard system, in the event of a missing cashback claim, incorrect cashback amount claim or other mis-match claims.<br/>
|
|
263
|
+
<b>Required scopes:</b> `audit:write`
|
|
264
|
+
|
|
265
|
+
Parameters
|
|
266
|
+
----------
|
|
267
|
+
organization_id : OrganizationId
|
|
268
|
+
|
|
269
|
+
user_id : str
|
|
270
|
+
The ID of the user as defined on the issuers system
|
|
271
|
+
|
|
272
|
+
data : typing.Sequence[CreateAuditRequestDataUnion]
|
|
273
|
+
|
|
274
|
+
request_options : typing.Optional[RequestOptions]
|
|
275
|
+
Request-specific configuration.
|
|
276
|
+
|
|
277
|
+
Returns
|
|
278
|
+
-------
|
|
279
|
+
HttpResponse[CreateAuditResponseBody]
|
|
280
|
+
"""
|
|
281
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
282
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/audits",
|
|
283
|
+
method="POST",
|
|
284
|
+
json={
|
|
285
|
+
"data": convert_and_respect_annotation_metadata(
|
|
286
|
+
object_=data, annotation=typing.Sequence[CreateAuditRequestDataUnion], direction="write"
|
|
287
|
+
),
|
|
288
|
+
},
|
|
289
|
+
request_options=request_options,
|
|
290
|
+
omit=OMIT,
|
|
291
|
+
)
|
|
292
|
+
try:
|
|
293
|
+
if 200 <= _response.status_code < 300:
|
|
294
|
+
_data = typing.cast(
|
|
295
|
+
CreateAuditResponseBody,
|
|
296
|
+
parse_obj_as(
|
|
297
|
+
type_=CreateAuditResponseBody, # type: ignore
|
|
298
|
+
object_=_response.json(),
|
|
299
|
+
),
|
|
300
|
+
)
|
|
301
|
+
return HttpResponse(response=_response, data=_data)
|
|
302
|
+
if _response.status_code == 207:
|
|
303
|
+
raise CreateAuditMultiStatus(
|
|
304
|
+
headers=dict(_response.headers),
|
|
305
|
+
body=typing.cast(
|
|
306
|
+
CreateAuditMultiStatusResponse,
|
|
307
|
+
parse_obj_as(
|
|
308
|
+
type_=CreateAuditMultiStatusResponse, # type: ignore
|
|
309
|
+
object_=_response.json(),
|
|
310
|
+
),
|
|
311
|
+
),
|
|
312
|
+
)
|
|
313
|
+
if _response.status_code == 401:
|
|
314
|
+
raise UnauthorizedError(
|
|
315
|
+
headers=dict(_response.headers),
|
|
316
|
+
body=typing.cast(
|
|
317
|
+
ErrorResponse,
|
|
318
|
+
parse_obj_as(
|
|
319
|
+
type_=ErrorResponse, # type: ignore
|
|
320
|
+
object_=_response.json(),
|
|
321
|
+
),
|
|
322
|
+
),
|
|
323
|
+
)
|
|
324
|
+
if _response.status_code == 500:
|
|
325
|
+
raise InternalServerError(
|
|
326
|
+
headers=dict(_response.headers),
|
|
327
|
+
body=typing.cast(
|
|
328
|
+
ErrorResponse,
|
|
329
|
+
parse_obj_as(
|
|
330
|
+
type_=ErrorResponse, # type: ignore
|
|
331
|
+
object_=_response.json(),
|
|
332
|
+
),
|
|
333
|
+
),
|
|
334
|
+
)
|
|
335
|
+
if _response.status_code == 400:
|
|
336
|
+
raise InvalidRequest(
|
|
337
|
+
headers=dict(_response.headers),
|
|
338
|
+
body=typing.cast(
|
|
339
|
+
ErrorResponse,
|
|
340
|
+
parse_obj_as(
|
|
341
|
+
type_=ErrorResponse, # type: ignore
|
|
342
|
+
object_=_response.json(),
|
|
343
|
+
),
|
|
344
|
+
),
|
|
345
|
+
)
|
|
346
|
+
if _response.status_code == 404:
|
|
347
|
+
raise DoesNotExistError(
|
|
348
|
+
headers=dict(_response.headers),
|
|
349
|
+
body=typing.cast(
|
|
350
|
+
ErrorResponse,
|
|
351
|
+
parse_obj_as(
|
|
352
|
+
type_=ErrorResponse, # type: ignore
|
|
353
|
+
object_=_response.json(),
|
|
354
|
+
),
|
|
355
|
+
),
|
|
356
|
+
)
|
|
357
|
+
if _response.status_code == 409:
|
|
358
|
+
raise ConflictError(
|
|
359
|
+
headers=dict(_response.headers),
|
|
360
|
+
body=typing.cast(
|
|
361
|
+
ErrorResponse,
|
|
362
|
+
parse_obj_as(
|
|
363
|
+
type_=ErrorResponse, # type: ignore
|
|
364
|
+
object_=_response.json(),
|
|
365
|
+
),
|
|
366
|
+
),
|
|
367
|
+
)
|
|
368
|
+
_response_json = _response.json()
|
|
369
|
+
except JSONDecodeError:
|
|
370
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
371
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
372
|
+
|
|
373
|
+
def get_earned_rewards(
|
|
374
|
+
self,
|
|
375
|
+
organization_id: OrganizationId,
|
|
376
|
+
user_id: str,
|
|
377
|
+
*,
|
|
378
|
+
page_after: typing.Optional[str] = None,
|
|
379
|
+
page_before: typing.Optional[str] = None,
|
|
380
|
+
page_size: typing.Optional[int] = None,
|
|
381
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
382
|
+
) -> HttpResponse[GetEarnedRewardsResponse]:
|
|
383
|
+
"""
|
|
384
|
+
Retrieve rewarded transaction history for a specific user. Returns only SETTLED transactions within the last 12 months.
|
|
385
|
+
<br/>
|
|
386
|
+
<b>Required scopes:</b> `transaction:read`
|
|
387
|
+
<br/>
|
|
388
|
+
<b>Query Limit:</b> Maximum of 12 months of transaction data can be queried.
|
|
389
|
+
|
|
390
|
+
Parameters
|
|
391
|
+
----------
|
|
392
|
+
organization_id : OrganizationId
|
|
393
|
+
|
|
394
|
+
user_id : str
|
|
395
|
+
The ID of the user as defined on the issuers system
|
|
396
|
+
|
|
397
|
+
page_after : typing.Optional[str]
|
|
398
|
+
Cursor for next page (base64-encoded timestamp + transaction ID)
|
|
399
|
+
|
|
400
|
+
page_before : typing.Optional[str]
|
|
401
|
+
Cursor for previous page (base64-encoded timestamp + transaction ID)
|
|
402
|
+
|
|
403
|
+
page_size : typing.Optional[int]
|
|
404
|
+
Number of results per page
|
|
405
|
+
|
|
406
|
+
request_options : typing.Optional[RequestOptions]
|
|
407
|
+
Request-specific configuration.
|
|
408
|
+
|
|
409
|
+
Returns
|
|
410
|
+
-------
|
|
411
|
+
HttpResponse[GetEarnedRewardsResponse]
|
|
412
|
+
"""
|
|
413
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
414
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/earned-rewards",
|
|
415
|
+
method="GET",
|
|
416
|
+
params={
|
|
417
|
+
"page[after]": page_after,
|
|
418
|
+
"page[before]": page_before,
|
|
419
|
+
"page[size]": page_size,
|
|
420
|
+
},
|
|
421
|
+
request_options=request_options,
|
|
422
|
+
)
|
|
423
|
+
try:
|
|
424
|
+
if 200 <= _response.status_code < 300:
|
|
425
|
+
_data = typing.cast(
|
|
426
|
+
GetEarnedRewardsResponse,
|
|
427
|
+
parse_obj_as(
|
|
428
|
+
type_=GetEarnedRewardsResponse, # type: ignore
|
|
429
|
+
object_=_response.json(),
|
|
430
|
+
),
|
|
431
|
+
)
|
|
432
|
+
return HttpResponse(response=_response, data=_data)
|
|
433
|
+
if _response.status_code == 400:
|
|
434
|
+
raise InvalidRequest(
|
|
435
|
+
headers=dict(_response.headers),
|
|
436
|
+
body=typing.cast(
|
|
437
|
+
ErrorResponse,
|
|
438
|
+
parse_obj_as(
|
|
439
|
+
type_=ErrorResponse, # type: ignore
|
|
440
|
+
object_=_response.json(),
|
|
441
|
+
),
|
|
442
|
+
),
|
|
443
|
+
)
|
|
444
|
+
if _response.status_code == 401:
|
|
445
|
+
raise UnauthorizedError(
|
|
446
|
+
headers=dict(_response.headers),
|
|
447
|
+
body=typing.cast(
|
|
448
|
+
ErrorResponse,
|
|
449
|
+
parse_obj_as(
|
|
450
|
+
type_=ErrorResponse, # type: ignore
|
|
451
|
+
object_=_response.json(),
|
|
452
|
+
),
|
|
453
|
+
),
|
|
454
|
+
)
|
|
455
|
+
if _response.status_code == 404:
|
|
456
|
+
raise DoesNotExistError(
|
|
457
|
+
headers=dict(_response.headers),
|
|
458
|
+
body=typing.cast(
|
|
459
|
+
ErrorResponse,
|
|
460
|
+
parse_obj_as(
|
|
461
|
+
type_=ErrorResponse, # type: ignore
|
|
462
|
+
object_=_response.json(),
|
|
463
|
+
),
|
|
464
|
+
),
|
|
465
|
+
)
|
|
466
|
+
if _response.status_code == 500:
|
|
467
|
+
raise InternalServerError(
|
|
468
|
+
headers=dict(_response.headers),
|
|
469
|
+
body=typing.cast(
|
|
470
|
+
ErrorResponse,
|
|
471
|
+
parse_obj_as(
|
|
472
|
+
type_=ErrorResponse, # type: ignore
|
|
473
|
+
object_=_response.json(),
|
|
474
|
+
),
|
|
475
|
+
),
|
|
476
|
+
)
|
|
477
|
+
_response_json = _response.json()
|
|
478
|
+
except JSONDecodeError:
|
|
479
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
480
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
class AsyncRawTransactionsClient:
|
|
484
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
485
|
+
self._client_wrapper = client_wrapper
|
|
486
|
+
|
|
487
|
+
async def create(
|
|
488
|
+
self,
|
|
489
|
+
organization_id: OrganizationId,
|
|
490
|
+
*,
|
|
491
|
+
data: typing.Sequence[Transactions],
|
|
492
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
493
|
+
) -> AsyncHttpResponse[TransactionsResponse]:
|
|
494
|
+
"""
|
|
495
|
+
Call this endpoint to send all transactions made by all your enrolled users in your rewards program. The request body will depend on the transaction type.<br/>
|
|
496
|
+
Please use the correct type when calling the endpoint:
|
|
497
|
+
- `transaction`: These incoming transactions will be processed and matched by the Kard system. Learn more about the [Transaction CLO Matching](https://github.com/kard-financial/kard-postman#c-transaction-clo-matching) flow here.
|
|
498
|
+
- `matchedTransaction`: For pre-matched transactions that need validation on match by the Kard system.<br/>
|
|
499
|
+
|
|
500
|
+
<b>Required scopes:</b> `transaction:write`<br/>
|
|
501
|
+
<b>Note:</b> `Maximum of 500 transactions can be created per request`.
|
|
502
|
+
|
|
503
|
+
Parameters
|
|
504
|
+
----------
|
|
505
|
+
organization_id : OrganizationId
|
|
506
|
+
|
|
507
|
+
data : typing.Sequence[Transactions]
|
|
508
|
+
Discriminated union representing the request body for submitting a transaction.
|
|
509
|
+
Use `type` to distinguish between the two:
|
|
510
|
+
- `transaction`: For transactions requiring processing and matching by the Kard system.
|
|
511
|
+
- `matchedTransaction`: For pre-matched transactions that need validation on match by the Kard system.
|
|
512
|
+
|
|
513
|
+
request_options : typing.Optional[RequestOptions]
|
|
514
|
+
Request-specific configuration.
|
|
515
|
+
|
|
516
|
+
Returns
|
|
517
|
+
-------
|
|
518
|
+
AsyncHttpResponse[TransactionsResponse]
|
|
519
|
+
"""
|
|
520
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
521
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/transactions",
|
|
522
|
+
method="POST",
|
|
523
|
+
json={
|
|
524
|
+
"data": convert_and_respect_annotation_metadata(
|
|
525
|
+
object_=data, annotation=typing.Sequence[Transactions], direction="write"
|
|
526
|
+
),
|
|
527
|
+
},
|
|
528
|
+
request_options=request_options,
|
|
529
|
+
omit=OMIT,
|
|
530
|
+
)
|
|
531
|
+
try:
|
|
532
|
+
if 200 <= _response.status_code < 300:
|
|
533
|
+
_data = typing.cast(
|
|
534
|
+
TransactionsResponse,
|
|
535
|
+
parse_obj_as(
|
|
536
|
+
type_=TransactionsResponse, # type: ignore
|
|
537
|
+
object_=_response.json(),
|
|
538
|
+
),
|
|
539
|
+
)
|
|
540
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
541
|
+
if _response.status_code == 207:
|
|
542
|
+
raise CreateIncomingTransactionsMultiStatus(
|
|
543
|
+
headers=dict(_response.headers),
|
|
544
|
+
body=typing.cast(
|
|
545
|
+
TransactionsMultiResponse,
|
|
546
|
+
parse_obj_as(
|
|
547
|
+
type_=TransactionsMultiResponse, # type: ignore
|
|
548
|
+
object_=_response.json(),
|
|
549
|
+
),
|
|
550
|
+
),
|
|
551
|
+
)
|
|
552
|
+
if _response.status_code == 401:
|
|
553
|
+
raise UnauthorizedError(
|
|
554
|
+
headers=dict(_response.headers),
|
|
555
|
+
body=typing.cast(
|
|
556
|
+
ErrorResponse,
|
|
557
|
+
parse_obj_as(
|
|
558
|
+
type_=ErrorResponse, # type: ignore
|
|
559
|
+
object_=_response.json(),
|
|
560
|
+
),
|
|
561
|
+
),
|
|
562
|
+
)
|
|
563
|
+
if _response.status_code == 500:
|
|
564
|
+
raise InternalServerError(
|
|
565
|
+
headers=dict(_response.headers),
|
|
566
|
+
body=typing.cast(
|
|
567
|
+
ErrorResponse,
|
|
568
|
+
parse_obj_as(
|
|
569
|
+
type_=ErrorResponse, # type: ignore
|
|
570
|
+
object_=_response.json(),
|
|
571
|
+
),
|
|
572
|
+
),
|
|
573
|
+
)
|
|
574
|
+
if _response.status_code == 400:
|
|
575
|
+
raise InvalidRequest(
|
|
576
|
+
headers=dict(_response.headers),
|
|
577
|
+
body=typing.cast(
|
|
578
|
+
ErrorResponse,
|
|
579
|
+
parse_obj_as(
|
|
580
|
+
type_=ErrorResponse, # type: ignore
|
|
581
|
+
object_=_response.json(),
|
|
582
|
+
),
|
|
583
|
+
),
|
|
584
|
+
)
|
|
585
|
+
if _response.status_code == 409:
|
|
586
|
+
raise ConflictError(
|
|
587
|
+
headers=dict(_response.headers),
|
|
588
|
+
body=typing.cast(
|
|
589
|
+
ErrorResponse,
|
|
590
|
+
parse_obj_as(
|
|
591
|
+
type_=ErrorResponse, # type: ignore
|
|
592
|
+
object_=_response.json(),
|
|
593
|
+
),
|
|
594
|
+
),
|
|
595
|
+
)
|
|
596
|
+
_response_json = _response.json()
|
|
597
|
+
except JSONDecodeError:
|
|
598
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
599
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
600
|
+
|
|
601
|
+
async def create_fraud_markers(
|
|
602
|
+
self,
|
|
603
|
+
organization_id: OrganizationId,
|
|
604
|
+
*,
|
|
605
|
+
data: typing.Sequence[FraudulentTransactionData],
|
|
606
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
607
|
+
) -> AsyncHttpResponse[FraudulentTransactionObject]:
|
|
608
|
+
"""
|
|
609
|
+
Call this endpoint to flag a submitted transaction as fraudulent. This will prevent it from being rewarded.<br/>
|
|
610
|
+
|
|
611
|
+
<b>Required scopes:</b> `transaction:write`<br/>
|
|
612
|
+
<b>Note:</b> `Maximum of 500 fraudulent transactions can be created per request`.
|
|
613
|
+
|
|
614
|
+
Parameters
|
|
615
|
+
----------
|
|
616
|
+
organization_id : OrganizationId
|
|
617
|
+
|
|
618
|
+
data : typing.Sequence[FraudulentTransactionData]
|
|
619
|
+
List of fraudulent transactions to report
|
|
620
|
+
|
|
621
|
+
request_options : typing.Optional[RequestOptions]
|
|
622
|
+
Request-specific configuration.
|
|
623
|
+
|
|
624
|
+
Returns
|
|
625
|
+
-------
|
|
626
|
+
AsyncHttpResponse[FraudulentTransactionObject]
|
|
627
|
+
"""
|
|
628
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
629
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/fraud",
|
|
630
|
+
method="POST",
|
|
631
|
+
json={
|
|
632
|
+
"data": convert_and_respect_annotation_metadata(
|
|
633
|
+
object_=data, annotation=typing.Sequence[FraudulentTransactionData], direction="write"
|
|
634
|
+
),
|
|
635
|
+
},
|
|
636
|
+
request_options=request_options,
|
|
637
|
+
omit=OMIT,
|
|
638
|
+
)
|
|
639
|
+
try:
|
|
640
|
+
if 200 <= _response.status_code < 300:
|
|
641
|
+
_data = typing.cast(
|
|
642
|
+
FraudulentTransactionObject,
|
|
643
|
+
parse_obj_as(
|
|
644
|
+
type_=FraudulentTransactionObject, # type: ignore
|
|
645
|
+
object_=_response.json(),
|
|
646
|
+
),
|
|
647
|
+
)
|
|
648
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
649
|
+
if _response.status_code == 207:
|
|
650
|
+
raise FraudMultiStatus(
|
|
651
|
+
headers=dict(_response.headers),
|
|
652
|
+
body=typing.cast(
|
|
653
|
+
FraudulentTransactionResponse,
|
|
654
|
+
parse_obj_as(
|
|
655
|
+
type_=FraudulentTransactionResponse, # type: ignore
|
|
656
|
+
object_=_response.json(),
|
|
657
|
+
),
|
|
658
|
+
),
|
|
659
|
+
)
|
|
660
|
+
if _response.status_code == 401:
|
|
661
|
+
raise UnauthorizedError(
|
|
662
|
+
headers=dict(_response.headers),
|
|
663
|
+
body=typing.cast(
|
|
664
|
+
ErrorResponse,
|
|
665
|
+
parse_obj_as(
|
|
666
|
+
type_=ErrorResponse, # type: ignore
|
|
667
|
+
object_=_response.json(),
|
|
668
|
+
),
|
|
669
|
+
),
|
|
670
|
+
)
|
|
671
|
+
if _response.status_code == 500:
|
|
672
|
+
raise InternalServerError(
|
|
673
|
+
headers=dict(_response.headers),
|
|
674
|
+
body=typing.cast(
|
|
675
|
+
ErrorResponse,
|
|
676
|
+
parse_obj_as(
|
|
677
|
+
type_=ErrorResponse, # type: ignore
|
|
678
|
+
object_=_response.json(),
|
|
679
|
+
),
|
|
680
|
+
),
|
|
681
|
+
)
|
|
682
|
+
if _response.status_code == 400:
|
|
683
|
+
raise InvalidRequest(
|
|
684
|
+
headers=dict(_response.headers),
|
|
685
|
+
body=typing.cast(
|
|
686
|
+
ErrorResponse,
|
|
687
|
+
parse_obj_as(
|
|
688
|
+
type_=ErrorResponse, # type: ignore
|
|
689
|
+
object_=_response.json(),
|
|
690
|
+
),
|
|
691
|
+
),
|
|
692
|
+
)
|
|
693
|
+
_response_json = _response.json()
|
|
694
|
+
except JSONDecodeError:
|
|
695
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
696
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
697
|
+
|
|
698
|
+
async def create_audits(
|
|
699
|
+
self,
|
|
700
|
+
organization_id: OrganizationId,
|
|
701
|
+
user_id: str,
|
|
702
|
+
*,
|
|
703
|
+
data: typing.Sequence[CreateAuditRequestDataUnion],
|
|
704
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
705
|
+
) -> AsyncHttpResponse[CreateAuditResponseBody]:
|
|
706
|
+
"""
|
|
707
|
+
Call this endpoint to request that a particular transaction be audited further by the Kard system, in the event of a missing cashback claim, incorrect cashback amount claim or other mis-match claims.<br/>
|
|
708
|
+
<b>Required scopes:</b> `audit:write`
|
|
709
|
+
|
|
710
|
+
Parameters
|
|
711
|
+
----------
|
|
712
|
+
organization_id : OrganizationId
|
|
713
|
+
|
|
714
|
+
user_id : str
|
|
715
|
+
The ID of the user as defined on the issuers system
|
|
716
|
+
|
|
717
|
+
data : typing.Sequence[CreateAuditRequestDataUnion]
|
|
718
|
+
|
|
719
|
+
request_options : typing.Optional[RequestOptions]
|
|
720
|
+
Request-specific configuration.
|
|
721
|
+
|
|
722
|
+
Returns
|
|
723
|
+
-------
|
|
724
|
+
AsyncHttpResponse[CreateAuditResponseBody]
|
|
725
|
+
"""
|
|
726
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
727
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/audits",
|
|
728
|
+
method="POST",
|
|
729
|
+
json={
|
|
730
|
+
"data": convert_and_respect_annotation_metadata(
|
|
731
|
+
object_=data, annotation=typing.Sequence[CreateAuditRequestDataUnion], direction="write"
|
|
732
|
+
),
|
|
733
|
+
},
|
|
734
|
+
request_options=request_options,
|
|
735
|
+
omit=OMIT,
|
|
736
|
+
)
|
|
737
|
+
try:
|
|
738
|
+
if 200 <= _response.status_code < 300:
|
|
739
|
+
_data = typing.cast(
|
|
740
|
+
CreateAuditResponseBody,
|
|
741
|
+
parse_obj_as(
|
|
742
|
+
type_=CreateAuditResponseBody, # type: ignore
|
|
743
|
+
object_=_response.json(),
|
|
744
|
+
),
|
|
745
|
+
)
|
|
746
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
747
|
+
if _response.status_code == 207:
|
|
748
|
+
raise CreateAuditMultiStatus(
|
|
749
|
+
headers=dict(_response.headers),
|
|
750
|
+
body=typing.cast(
|
|
751
|
+
CreateAuditMultiStatusResponse,
|
|
752
|
+
parse_obj_as(
|
|
753
|
+
type_=CreateAuditMultiStatusResponse, # type: ignore
|
|
754
|
+
object_=_response.json(),
|
|
755
|
+
),
|
|
756
|
+
),
|
|
757
|
+
)
|
|
758
|
+
if _response.status_code == 401:
|
|
759
|
+
raise UnauthorizedError(
|
|
760
|
+
headers=dict(_response.headers),
|
|
761
|
+
body=typing.cast(
|
|
762
|
+
ErrorResponse,
|
|
763
|
+
parse_obj_as(
|
|
764
|
+
type_=ErrorResponse, # type: ignore
|
|
765
|
+
object_=_response.json(),
|
|
766
|
+
),
|
|
767
|
+
),
|
|
768
|
+
)
|
|
769
|
+
if _response.status_code == 500:
|
|
770
|
+
raise InternalServerError(
|
|
771
|
+
headers=dict(_response.headers),
|
|
772
|
+
body=typing.cast(
|
|
773
|
+
ErrorResponse,
|
|
774
|
+
parse_obj_as(
|
|
775
|
+
type_=ErrorResponse, # type: ignore
|
|
776
|
+
object_=_response.json(),
|
|
777
|
+
),
|
|
778
|
+
),
|
|
779
|
+
)
|
|
780
|
+
if _response.status_code == 400:
|
|
781
|
+
raise InvalidRequest(
|
|
782
|
+
headers=dict(_response.headers),
|
|
783
|
+
body=typing.cast(
|
|
784
|
+
ErrorResponse,
|
|
785
|
+
parse_obj_as(
|
|
786
|
+
type_=ErrorResponse, # type: ignore
|
|
787
|
+
object_=_response.json(),
|
|
788
|
+
),
|
|
789
|
+
),
|
|
790
|
+
)
|
|
791
|
+
if _response.status_code == 404:
|
|
792
|
+
raise DoesNotExistError(
|
|
793
|
+
headers=dict(_response.headers),
|
|
794
|
+
body=typing.cast(
|
|
795
|
+
ErrorResponse,
|
|
796
|
+
parse_obj_as(
|
|
797
|
+
type_=ErrorResponse, # type: ignore
|
|
798
|
+
object_=_response.json(),
|
|
799
|
+
),
|
|
800
|
+
),
|
|
801
|
+
)
|
|
802
|
+
if _response.status_code == 409:
|
|
803
|
+
raise ConflictError(
|
|
804
|
+
headers=dict(_response.headers),
|
|
805
|
+
body=typing.cast(
|
|
806
|
+
ErrorResponse,
|
|
807
|
+
parse_obj_as(
|
|
808
|
+
type_=ErrorResponse, # type: ignore
|
|
809
|
+
object_=_response.json(),
|
|
810
|
+
),
|
|
811
|
+
),
|
|
812
|
+
)
|
|
813
|
+
_response_json = _response.json()
|
|
814
|
+
except JSONDecodeError:
|
|
815
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
816
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
817
|
+
|
|
818
|
+
async def get_earned_rewards(
|
|
819
|
+
self,
|
|
820
|
+
organization_id: OrganizationId,
|
|
821
|
+
user_id: str,
|
|
822
|
+
*,
|
|
823
|
+
page_after: typing.Optional[str] = None,
|
|
824
|
+
page_before: typing.Optional[str] = None,
|
|
825
|
+
page_size: typing.Optional[int] = None,
|
|
826
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
827
|
+
) -> AsyncHttpResponse[GetEarnedRewardsResponse]:
|
|
828
|
+
"""
|
|
829
|
+
Retrieve rewarded transaction history for a specific user. Returns only SETTLED transactions within the last 12 months.
|
|
830
|
+
<br/>
|
|
831
|
+
<b>Required scopes:</b> `transaction:read`
|
|
832
|
+
<br/>
|
|
833
|
+
<b>Query Limit:</b> Maximum of 12 months of transaction data can be queried.
|
|
834
|
+
|
|
835
|
+
Parameters
|
|
836
|
+
----------
|
|
837
|
+
organization_id : OrganizationId
|
|
838
|
+
|
|
839
|
+
user_id : str
|
|
840
|
+
The ID of the user as defined on the issuers system
|
|
841
|
+
|
|
842
|
+
page_after : typing.Optional[str]
|
|
843
|
+
Cursor for next page (base64-encoded timestamp + transaction ID)
|
|
844
|
+
|
|
845
|
+
page_before : typing.Optional[str]
|
|
846
|
+
Cursor for previous page (base64-encoded timestamp + transaction ID)
|
|
847
|
+
|
|
848
|
+
page_size : typing.Optional[int]
|
|
849
|
+
Number of results per page
|
|
850
|
+
|
|
851
|
+
request_options : typing.Optional[RequestOptions]
|
|
852
|
+
Request-specific configuration.
|
|
853
|
+
|
|
854
|
+
Returns
|
|
855
|
+
-------
|
|
856
|
+
AsyncHttpResponse[GetEarnedRewardsResponse]
|
|
857
|
+
"""
|
|
858
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
859
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/earned-rewards",
|
|
860
|
+
method="GET",
|
|
861
|
+
params={
|
|
862
|
+
"page[after]": page_after,
|
|
863
|
+
"page[before]": page_before,
|
|
864
|
+
"page[size]": page_size,
|
|
865
|
+
},
|
|
866
|
+
request_options=request_options,
|
|
867
|
+
)
|
|
868
|
+
try:
|
|
869
|
+
if 200 <= _response.status_code < 300:
|
|
870
|
+
_data = typing.cast(
|
|
871
|
+
GetEarnedRewardsResponse,
|
|
872
|
+
parse_obj_as(
|
|
873
|
+
type_=GetEarnedRewardsResponse, # type: ignore
|
|
874
|
+
object_=_response.json(),
|
|
875
|
+
),
|
|
876
|
+
)
|
|
877
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
878
|
+
if _response.status_code == 400:
|
|
879
|
+
raise InvalidRequest(
|
|
880
|
+
headers=dict(_response.headers),
|
|
881
|
+
body=typing.cast(
|
|
882
|
+
ErrorResponse,
|
|
883
|
+
parse_obj_as(
|
|
884
|
+
type_=ErrorResponse, # type: ignore
|
|
885
|
+
object_=_response.json(),
|
|
886
|
+
),
|
|
887
|
+
),
|
|
888
|
+
)
|
|
889
|
+
if _response.status_code == 401:
|
|
890
|
+
raise UnauthorizedError(
|
|
891
|
+
headers=dict(_response.headers),
|
|
892
|
+
body=typing.cast(
|
|
893
|
+
ErrorResponse,
|
|
894
|
+
parse_obj_as(
|
|
895
|
+
type_=ErrorResponse, # type: ignore
|
|
896
|
+
object_=_response.json(),
|
|
897
|
+
),
|
|
898
|
+
),
|
|
899
|
+
)
|
|
900
|
+
if _response.status_code == 404:
|
|
901
|
+
raise DoesNotExistError(
|
|
902
|
+
headers=dict(_response.headers),
|
|
903
|
+
body=typing.cast(
|
|
904
|
+
ErrorResponse,
|
|
905
|
+
parse_obj_as(
|
|
906
|
+
type_=ErrorResponse, # type: ignore
|
|
907
|
+
object_=_response.json(),
|
|
908
|
+
),
|
|
909
|
+
),
|
|
910
|
+
)
|
|
911
|
+
if _response.status_code == 500:
|
|
912
|
+
raise InternalServerError(
|
|
913
|
+
headers=dict(_response.headers),
|
|
914
|
+
body=typing.cast(
|
|
915
|
+
ErrorResponse,
|
|
916
|
+
parse_obj_as(
|
|
917
|
+
type_=ErrorResponse, # type: ignore
|
|
918
|
+
object_=_response.json(),
|
|
919
|
+
),
|
|
920
|
+
),
|
|
921
|
+
)
|
|
922
|
+
_response_json = _response.json()
|
|
923
|
+
except JSONDecodeError:
|
|
924
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
925
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|