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.
Files changed (302) hide show
  1. kard/__init__.py +579 -0
  2. kard/auth/__init__.py +34 -0
  3. kard/auth/client.py +121 -0
  4. kard/auth/raw_client.py +108 -0
  5. kard/auth/types/__init__.py +34 -0
  6. kard/auth/types/token_response.py +25 -0
  7. kard/client.py +416 -0
  8. kard/commons/__init__.py +120 -0
  9. kard/commons/errors/__init__.py +44 -0
  10. kard/commons/errors/conflict_error.py +11 -0
  11. kard/commons/errors/does_not_exist_error.py +11 -0
  12. kard/commons/errors/internal_server_error.py +11 -0
  13. kard/commons/errors/invalid_request.py +11 -0
  14. kard/commons/errors/unauthorized_error.py +11 -0
  15. kard/commons/types/__init__.py +107 -0
  16. kard/commons/types/category_option.py +26 -0
  17. kard/commons/types/commission_type.py +5 -0
  18. kard/commons/types/commission_value.py +28 -0
  19. kard/commons/types/commission_value_type.py +5 -0
  20. kard/commons/types/empty_object.py +17 -0
  21. kard/commons/types/enrolled_rewards_type.py +5 -0
  22. kard/commons/types/error_object.py +43 -0
  23. kard/commons/types/error_response.py +20 -0
  24. kard/commons/types/error_source.py +32 -0
  25. kard/commons/types/job.py +24 -0
  26. kard/commons/types/job_response.py +27 -0
  27. kard/commons/types/job_status.py +5 -0
  28. kard/commons/types/links.py +27 -0
  29. kard/commons/types/mongo_id.py +3 -0
  30. kard/commons/types/notification_type.py +19 -0
  31. kard/commons/types/organization_id.py +3 -0
  32. kard/commons/types/purchase_channel.py +5 -0
  33. kard/commons/types/relationship_data.py +24 -0
  34. kard/commons/types/relationship_multiple.py +20 -0
  35. kard/commons/types/relationship_single.py +20 -0
  36. kard/commons/types/resource_type.py +3 -0
  37. kard/commons/types/state.py +68 -0
  38. kard/commons/types/subscription_id.py +3 -0
  39. kard/commons/types/user_id.py +3 -0
  40. kard/core/__init__.py +105 -0
  41. kard/core/api_error.py +23 -0
  42. kard/core/client_wrapper.py +97 -0
  43. kard/core/datetime_utils.py +28 -0
  44. kard/core/file.py +67 -0
  45. kard/core/force_multipart.py +18 -0
  46. kard/core/http_client.py +613 -0
  47. kard/core/http_response.py +55 -0
  48. kard/core/http_sse/__init__.py +42 -0
  49. kard/core/http_sse/_api.py +112 -0
  50. kard/core/http_sse/_decoders.py +61 -0
  51. kard/core/http_sse/_exceptions.py +7 -0
  52. kard/core/http_sse/_models.py +17 -0
  53. kard/core/jsonable_encoder.py +100 -0
  54. kard/core/oauth_token_provider.py +73 -0
  55. kard/core/pydantic_utilities.py +260 -0
  56. kard/core/query_encoder.py +58 -0
  57. kard/core/remove_none_from_dict.py +11 -0
  58. kard/core/request_options.py +35 -0
  59. kard/core/serialization.py +276 -0
  60. kard/environment.py +8 -0
  61. kard/files/__init__.py +58 -0
  62. kard/files/client.py +213 -0
  63. kard/files/errors/__init__.py +34 -0
  64. kard/files/errors/forbidden_error.py +11 -0
  65. kard/files/raw_client.py +278 -0
  66. kard/files/types/__init__.py +53 -0
  67. kard/files/types/file_metadata_attribute.py +39 -0
  68. kard/files/types/file_metadata_with_url.py +34 -0
  69. kard/files/types/file_type.py +13 -0
  70. kard/files/types/files_metadata_sort_options.py +5 -0
  71. kard/files/types/get_files_metadata_response.py +71 -0
  72. kard/files/types/pagination_meta.py +29 -0
  73. kard/notifications/__init__.py +279 -0
  74. kard/notifications/client.py +63 -0
  75. kard/notifications/raw_client.py +13 -0
  76. kard/notifications/subscriptions/__init__.py +97 -0
  77. kard/notifications/subscriptions/client.py +372 -0
  78. kard/notifications/subscriptions/raw_client.py +581 -0
  79. kard/notifications/subscriptions/types/__init__.py +94 -0
  80. kard/notifications/subscriptions/types/create_subscription_union.py +27 -0
  81. kard/notifications/subscriptions/types/create_subscriptions_response_object.py +43 -0
  82. kard/notifications/subscriptions/types/created_subscription.py +23 -0
  83. kard/notifications/subscriptions/types/subscription.py +25 -0
  84. kard/notifications/subscriptions/types/subscription_attributes.py +35 -0
  85. kard/notifications/subscriptions/types/subscription_request.py +20 -0
  86. kard/notifications/subscriptions/types/subscription_request_attributes.py +35 -0
  87. kard/notifications/subscriptions/types/subscription_request_body.py +42 -0
  88. kard/notifications/subscriptions/types/subscription_request_union.py +26 -0
  89. kard/notifications/subscriptions/types/subscription_union.py +27 -0
  90. kard/notifications/subscriptions/types/subscriptions_response_object.py +43 -0
  91. kard/notifications/subscriptions/types/update_subscription_request.py +20 -0
  92. kard/notifications/subscriptions/types/update_subscription_request_attributes.py +39 -0
  93. kard/notifications/subscriptions/types/update_subscription_request_body.py +40 -0
  94. kard/notifications/subscriptions/types/update_subscription_request_union.py +26 -0
  95. kard/notifications/subscriptions/types/update_subscriptions_response_object.py +41 -0
  96. kard/notifications/types/__init__.py +214 -0
  97. kard/notifications/types/audit_update_attributes.py +88 -0
  98. kard/notifications/types/audit_update_data.py +27 -0
  99. kard/notifications/types/audit_update_relationships.py +21 -0
  100. kard/notifications/types/broker_amount.py +28 -0
  101. kard/notifications/types/broker_amount_type.py +5 -0
  102. kard/notifications/types/broker_asset.py +33 -0
  103. kard/notifications/types/broker_asset_type.py +5 -0
  104. kard/notifications/types/broker_operation_hours.py +30 -0
  105. kard/notifications/types/broker_operation_period.py +28 -0
  106. kard/notifications/types/broker_purchase_channel.py +5 -0
  107. kard/notifications/types/broker_reward.py +28 -0
  108. kard/notifications/types/broker_reward_type.py +5 -0
  109. kard/notifications/types/clawback_data.py +27 -0
  110. kard/notifications/types/earned_reward_approved_data.py +27 -0
  111. kard/notifications/types/earned_reward_attributes.py +18 -0
  112. kard/notifications/types/earned_reward_relationships.py +21 -0
  113. kard/notifications/types/earned_reward_settled_attributes.py +23 -0
  114. kard/notifications/types/earned_reward_settled_data.py +27 -0
  115. kard/notifications/types/failed_transaction_attributes.py +41 -0
  116. kard/notifications/types/failed_transaction_data.py +27 -0
  117. kard/notifications/types/failed_transaction_relationships.py +22 -0
  118. kard/notifications/types/location_address.py +39 -0
  119. kard/notifications/types/location_coordinates.py +27 -0
  120. kard/notifications/types/location_status.py +5 -0
  121. kard/notifications/types/merchant_source.py +5 -0
  122. kard/notifications/types/notification_data_union.py +203 -0
  123. kard/notifications/types/notification_metadata.py +22 -0
  124. kard/notifications/types/notification_payload.py +65 -0
  125. kard/notifications/types/offer_status.py +5 -0
  126. kard/notifications/types/offer_type.py +5 -0
  127. kard/notifications/types/reward_notification_attributes.py +48 -0
  128. kard/notifications/types/time_period.py +27 -0
  129. kard/notifications/types/transaction_relationships.py +22 -0
  130. kard/notifications/types/user_offer_status.py +5 -0
  131. kard/notifications/types/valid_transaction_attributes.py +25 -0
  132. kard/notifications/types/valid_transaction_commission_earned.py +21 -0
  133. kard/notifications/types/valid_transaction_data.py +27 -0
  134. kard/notifications/types/webhook_locations_attributes.py +71 -0
  135. kard/notifications/types/webhook_locations_data.py +27 -0
  136. kard/notifications/types/webhook_locations_relationships.py +20 -0
  137. kard/notifications/types/webhook_merchant_attributes.py +67 -0
  138. kard/notifications/types/webhook_merchant_data.py +27 -0
  139. kard/notifications/types/webhook_merchant_relationships.py +20 -0
  140. kard/notifications/types/webhook_offer_attributes.py +143 -0
  141. kard/notifications/types/webhook_offer_data.py +27 -0
  142. kard/notifications/types/webhook_offer_relationships.py +20 -0
  143. kard/notifications/types/webhook_user_offer_attributes.py +41 -0
  144. kard/notifications/types/webhook_user_offer_data.py +27 -0
  145. kard/notifications/types/webhook_user_offer_relationships.py +21 -0
  146. kard/ping/__init__.py +39 -0
  147. kard/ping/client.py +100 -0
  148. kard/ping/errors/__init__.py +34 -0
  149. kard/ping/errors/network_blocked_error.py +11 -0
  150. kard/ping/raw_client.py +113 -0
  151. kard/ping/types/__init__.py +38 -0
  152. kard/ping/types/network_blocked_error_body.py +34 -0
  153. kard/ping/types/ping_response_object.py +46 -0
  154. kard/py.typed +0 -0
  155. kard/transactions/__init__.py +212 -0
  156. kard/transactions/client.py +639 -0
  157. kard/transactions/errors/__init__.py +40 -0
  158. kard/transactions/errors/create_audit_multi_status.py +11 -0
  159. kard/transactions/errors/create_incoming_transactions_multi_status.py +11 -0
  160. kard/transactions/errors/fraud_multi_status.py +11 -0
  161. kard/transactions/raw_client.py +925 -0
  162. kard/transactions/types/__init__.py +199 -0
  163. kard/transactions/types/audit_attributes.py +44 -0
  164. kard/transactions/types/audit_request_data.py +20 -0
  165. kard/transactions/types/audit_response_attributes.py +24 -0
  166. kard/transactions/types/audit_response_data.py +25 -0
  167. kard/transactions/types/audit_status.py +5 -0
  168. kard/transactions/types/card_network.py +5 -0
  169. kard/transactions/types/commission_earned_details.py +21 -0
  170. kard/transactions/types/create_audit_multi_status_response.py +21 -0
  171. kard/transactions/types/create_audit_request_body.py +43 -0
  172. kard/transactions/types/create_audit_request_data_union.py +26 -0
  173. kard/transactions/types/create_audit_response_body.py +41 -0
  174. kard/transactions/types/create_audit_response_data_union.py +27 -0
  175. kard/transactions/types/direction_type.py +5 -0
  176. kard/transactions/types/fraudulent_transaction_attributes.py +24 -0
  177. kard/transactions/types/fraudulent_transaction_data.py +30 -0
  178. kard/transactions/types/fraudulent_transaction_object.py +42 -0
  179. kard/transactions/types/fraudulent_transaction_request_body.py +45 -0
  180. kard/transactions/types/fraudulent_transaction_response.py +21 -0
  181. kard/transactions/types/get_earned_rewards_response.py +133 -0
  182. kard/transactions/types/matched_transactions_attributes.py +156 -0
  183. kard/transactions/types/matched_transactions_request.py +25 -0
  184. kard/transactions/types/merchant.py +82 -0
  185. kard/transactions/types/payment_status.py +5 -0
  186. kard/transactions/types/payment_type.py +5 -0
  187. kard/transactions/types/processor_mid.py +26 -0
  188. kard/transactions/types/receipt_medium_type.py +5 -0
  189. kard/transactions/types/rewarded_transaction.py +27 -0
  190. kard/transactions/types/rewarded_transaction_attributes.py +74 -0
  191. kard/transactions/types/rewarded_transaction_relationships.py +22 -0
  192. kard/transactions/types/rewarded_transaction_status.py +5 -0
  193. kard/transactions/types/rewarded_transaction_union.py +29 -0
  194. kard/transactions/types/states.py +68 -0
  195. kard/transactions/types/transaction_included_resource.py +47 -0
  196. kard/transactions/types/transaction_merchant_attributes.py +22 -0
  197. kard/transactions/types/transaction_merchant_resource.py +28 -0
  198. kard/transactions/types/transaction_offer_attributes.py +26 -0
  199. kard/transactions/types/transaction_offer_resource.py +28 -0
  200. kard/transactions/types/transaction_payment_type.py +5 -0
  201. kard/transactions/types/transaction_status.py +5 -0
  202. kard/transactions/types/transactions.py +46 -0
  203. kard/transactions/types/transactions_attributes.py +198 -0
  204. kard/transactions/types/transactions_multi_response.py +21 -0
  205. kard/transactions/types/transactions_request.py +25 -0
  206. kard/transactions/types/transactions_request_body.py +90 -0
  207. kard/transactions/types/transactions_response.py +38 -0
  208. kard/transactions/types/transactions_response_data.py +27 -0
  209. kard/transactions/types/visa_mid.py +23 -0
  210. kard/transactions/types/visa_mid_details.py +27 -0
  211. kard/users/__init__.py +293 -0
  212. kard/users/attributions/__init__.py +73 -0
  213. kard/users/attributions/client.py +229 -0
  214. kard/users/attributions/raw_client.py +215 -0
  215. kard/users/attributions/types/__init__.py +73 -0
  216. kard/users/attributions/types/create_attribution_request_object.py +75 -0
  217. kard/users/attributions/types/create_attribution_request_union.py +45 -0
  218. kard/users/attributions/types/create_attribution_response.py +38 -0
  219. kard/users/attributions/types/event_code.py +5 -0
  220. kard/users/attributions/types/notification_attribution_attributes.py +35 -0
  221. kard/users/attributions/types/notification_attribution_request.py +20 -0
  222. kard/users/attributions/types/notification_medium.py +5 -0
  223. kard/users/attributions/types/offer_attribution_attributes.py +35 -0
  224. kard/users/attributions/types/offer_attribution_request.py +20 -0
  225. kard/users/attributions/types/offer_medium.py +5 -0
  226. kard/users/client.py +512 -0
  227. kard/users/errors/__init__.py +34 -0
  228. kard/users/errors/multi_status.py +11 -0
  229. kard/users/raw_client.py +783 -0
  230. kard/users/rewards/__init__.py +133 -0
  231. kard/users/rewards/client.py +448 -0
  232. kard/users/rewards/raw_client.py +587 -0
  233. kard/users/rewards/types/__init__.py +130 -0
  234. kard/users/rewards/types/amount.py +21 -0
  235. kard/users/rewards/types/amount_type.py +5 -0
  236. kard/users/rewards/types/asset.py +28 -0
  237. kard/users/rewards/types/category_data.py +18 -0
  238. kard/users/rewards/types/category_fields.py +23 -0
  239. kard/users/rewards/types/category_identifier.py +24 -0
  240. kard/users/rewards/types/category_included.py +21 -0
  241. kard/users/rewards/types/category_relationship.py +20 -0
  242. kard/users/rewards/types/category_relationship_object.py +20 -0
  243. kard/users/rewards/types/commission.py +21 -0
  244. kard/users/rewards/types/coordinates.py +20 -0
  245. kard/users/rewards/types/eligibility_location_address.py +24 -0
  246. kard/users/rewards/types/eligibility_location_included.py +8 -0
  247. kard/users/rewards/types/eligibility_offer_included.py +7 -0
  248. kard/users/rewards/types/eligibility_offer_relationship.py +7 -0
  249. kard/users/rewards/types/location_attributes.py +28 -0
  250. kard/users/rewards/types/location_data.py +32 -0
  251. kard/users/rewards/types/location_relationships.py +18 -0
  252. kard/users/rewards/types/location_sort_options.py +5 -0
  253. kard/users/rewards/types/locations_response_object.py +215 -0
  254. kard/users/rewards/types/offer_common_fields.py +103 -0
  255. kard/users/rewards/types/offer_data_union.py +30 -0
  256. kard/users/rewards/types/offer_relationship.py +21 -0
  257. kard/users/rewards/types/offer_sort_options.py +7 -0
  258. kard/users/rewards/types/offers_response_object.py +130 -0
  259. kard/users/rewards/types/operation_hours.py +23 -0
  260. kard/users/rewards/types/operation_period.py +21 -0
  261. kard/users/rewards/types/operation_time.py +20 -0
  262. kard/users/rewards/types/standard_offer.py +21 -0
  263. kard/users/rewards/types/standard_offer_core.py +26 -0
  264. kard/users/rewards/types/standard_offer_fields.py +18 -0
  265. kard/users/types/__init__.py +66 -0
  266. kard/users/types/create_users_multi_status_response.py +21 -0
  267. kard/users/types/create_users_object.py +42 -0
  268. kard/users/types/delete_user_response_object.py +34 -0
  269. kard/users/types/update_user_object.py +40 -0
  270. kard/users/types/user_request_attributes.py +60 -0
  271. kard/users/types/user_request_data.py +22 -0
  272. kard/users/types/user_request_data_union.py +28 -0
  273. kard/users/types/user_response_no_data.py +22 -0
  274. kard/users/types/user_response_union_no_data.py +28 -0
  275. kard/users/uploads/__init__.py +112 -0
  276. kard/users/uploads/client.py +484 -0
  277. kard/users/uploads/errors/__init__.py +34 -0
  278. kard/users/uploads/errors/upload_part_multi_status.py +13 -0
  279. kard/users/uploads/raw_client.py +625 -0
  280. kard/users/uploads/types/__init__.py +119 -0
  281. kard/users/uploads/types/create_upload_part_data_union.py +27 -0
  282. kard/users/uploads/types/create_upload_part_multi_status_response.py +21 -0
  283. kard/users/uploads/types/create_upload_part_request_object.py +74 -0
  284. kard/users/uploads/types/create_upload_part_response_data.py +25 -0
  285. kard/users/uploads/types/create_upload_part_response_data_union.py +27 -0
  286. kard/users/uploads/types/create_upload_part_response_object.py +39 -0
  287. kard/users/uploads/types/create_upload_request_data_union.py +26 -0
  288. kard/users/uploads/types/create_upload_request_object.py +36 -0
  289. kard/users/uploads/types/create_upload_response_data.py +25 -0
  290. kard/users/uploads/types/create_upload_response_data_union.py +27 -0
  291. kard/users/uploads/types/create_upload_response_object.py +37 -0
  292. kard/users/uploads/types/historical_transaction_complete_no_data.py +25 -0
  293. kard/users/uploads/types/start_historical_upload_no_data.py +20 -0
  294. kard/users/uploads/types/update_upload_request_data_union.py +27 -0
  295. kard/users/uploads/types/update_upload_request_object.py +37 -0
  296. kard/users/uploads/types/update_upload_response_data.py +25 -0
  297. kard/users/uploads/types/update_upload_response_data_union.py +27 -0
  298. kard/users/uploads/types/update_upload_response_object.py +37 -0
  299. kard/version.py +3 -0
  300. kard_financial_sdk-0.0.82.dist-info/METADATA +238 -0
  301. kard_financial_sdk-0.0.82.dist-info/RECORD +302 -0
  302. kard_financial_sdk-0.0.82.dist-info/WHEEL +4 -0
@@ -0,0 +1,783 @@
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 ..commons.types.user_id import UserId
14
+ from ..core.api_error import ApiError
15
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
16
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
17
+ from ..core.jsonable_encoder import jsonable_encoder
18
+ from ..core.pydantic_utilities import parse_obj_as
19
+ from ..core.request_options import RequestOptions
20
+ from ..core.serialization import convert_and_respect_annotation_metadata
21
+ from .errors.multi_status import MultiStatus
22
+ from .types.create_users_multi_status_response import CreateUsersMultiStatusResponse
23
+ from .types.create_users_object import CreateUsersObject
24
+ from .types.delete_user_response_object import DeleteUserResponseObject
25
+ from .types.update_user_object import UpdateUserObject
26
+ from .types.user_request_data_union import UserRequestDataUnion
27
+
28
+ # this is used as the default value for optional parameters
29
+ OMIT = typing.cast(typing.Any, ...)
30
+
31
+
32
+ class RawUsersClient:
33
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
34
+ self._client_wrapper = client_wrapper
35
+
36
+ def create(
37
+ self,
38
+ organization_id: OrganizationId,
39
+ *,
40
+ data: typing.Sequence[UserRequestDataUnion],
41
+ request_options: typing.Optional[RequestOptions] = None,
42
+ ) -> HttpResponse[CreateUsersObject]:
43
+ """
44
+ Call this endpoint to enroll a specified user into your rewards program.<br/>
45
+
46
+ <b>Required scopes:</b>&nbsp;&nbsp;`user:write`<br/>
47
+ <b>Note:</b> `Maximum of 100 users can be created per request`.
48
+
49
+ Parameters
50
+ ----------
51
+ organization_id : OrganizationId
52
+
53
+ data : typing.Sequence[UserRequestDataUnion]
54
+
55
+ request_options : typing.Optional[RequestOptions]
56
+ Request-specific configuration.
57
+
58
+ Returns
59
+ -------
60
+ HttpResponse[CreateUsersObject]
61
+ """
62
+ _response = self._client_wrapper.httpx_client.request(
63
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users",
64
+ method="POST",
65
+ json={
66
+ "data": convert_and_respect_annotation_metadata(
67
+ object_=data, annotation=typing.Sequence[UserRequestDataUnion], direction="write"
68
+ ),
69
+ },
70
+ request_options=request_options,
71
+ omit=OMIT,
72
+ )
73
+ try:
74
+ if 200 <= _response.status_code < 300:
75
+ _data = typing.cast(
76
+ CreateUsersObject,
77
+ parse_obj_as(
78
+ type_=CreateUsersObject, # type: ignore
79
+ object_=_response.json(),
80
+ ),
81
+ )
82
+ return HttpResponse(response=_response, data=_data)
83
+ if _response.status_code == 207:
84
+ raise MultiStatus(
85
+ headers=dict(_response.headers),
86
+ body=typing.cast(
87
+ CreateUsersMultiStatusResponse,
88
+ parse_obj_as(
89
+ type_=CreateUsersMultiStatusResponse, # type: ignore
90
+ object_=_response.json(),
91
+ ),
92
+ ),
93
+ )
94
+ if _response.status_code == 401:
95
+ raise UnauthorizedError(
96
+ headers=dict(_response.headers),
97
+ body=typing.cast(
98
+ ErrorResponse,
99
+ parse_obj_as(
100
+ type_=ErrorResponse, # type: ignore
101
+ object_=_response.json(),
102
+ ),
103
+ ),
104
+ )
105
+ if _response.status_code == 400:
106
+ raise InvalidRequest(
107
+ headers=dict(_response.headers),
108
+ body=typing.cast(
109
+ ErrorResponse,
110
+ parse_obj_as(
111
+ type_=ErrorResponse, # type: ignore
112
+ object_=_response.json(),
113
+ ),
114
+ ),
115
+ )
116
+ if _response.status_code == 500:
117
+ raise InternalServerError(
118
+ headers=dict(_response.headers),
119
+ body=typing.cast(
120
+ ErrorResponse,
121
+ parse_obj_as(
122
+ type_=ErrorResponse, # type: ignore
123
+ object_=_response.json(),
124
+ ),
125
+ ),
126
+ )
127
+ if _response.status_code == 409:
128
+ raise ConflictError(
129
+ headers=dict(_response.headers),
130
+ body=typing.cast(
131
+ ErrorResponse,
132
+ parse_obj_as(
133
+ type_=ErrorResponse, # type: ignore
134
+ object_=_response.json(),
135
+ ),
136
+ ),
137
+ )
138
+ _response_json = _response.json()
139
+ except JSONDecodeError:
140
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
141
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
142
+
143
+ def update(
144
+ self,
145
+ organization_id: OrganizationId,
146
+ user_id: UserId,
147
+ *,
148
+ data: UserRequestDataUnion,
149
+ request_options: typing.Optional[RequestOptions] = None,
150
+ ) -> HttpResponse[UpdateUserObject]:
151
+ """
152
+ Call this endpoint to update the details on a specified user.<br/>
153
+
154
+ <b>Required scopes:</b> `user:update`
155
+
156
+ Parameters
157
+ ----------
158
+ organization_id : OrganizationId
159
+
160
+ user_id : UserId
161
+
162
+ data : UserRequestDataUnion
163
+
164
+ request_options : typing.Optional[RequestOptions]
165
+ Request-specific configuration.
166
+
167
+ Returns
168
+ -------
169
+ HttpResponse[UpdateUserObject]
170
+ """
171
+ _response = self._client_wrapper.httpx_client.request(
172
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}",
173
+ method="PUT",
174
+ json={
175
+ "data": convert_and_respect_annotation_metadata(
176
+ object_=data, annotation=UserRequestDataUnion, direction="write"
177
+ ),
178
+ },
179
+ request_options=request_options,
180
+ omit=OMIT,
181
+ )
182
+ try:
183
+ if 200 <= _response.status_code < 300:
184
+ _data = typing.cast(
185
+ UpdateUserObject,
186
+ parse_obj_as(
187
+ type_=UpdateUserObject, # type: ignore
188
+ object_=_response.json(),
189
+ ),
190
+ )
191
+ return HttpResponse(response=_response, data=_data)
192
+ if _response.status_code == 401:
193
+ raise UnauthorizedError(
194
+ headers=dict(_response.headers),
195
+ body=typing.cast(
196
+ ErrorResponse,
197
+ parse_obj_as(
198
+ type_=ErrorResponse, # type: ignore
199
+ object_=_response.json(),
200
+ ),
201
+ ),
202
+ )
203
+ if _response.status_code == 400:
204
+ raise InvalidRequest(
205
+ headers=dict(_response.headers),
206
+ body=typing.cast(
207
+ ErrorResponse,
208
+ parse_obj_as(
209
+ type_=ErrorResponse, # type: ignore
210
+ object_=_response.json(),
211
+ ),
212
+ ),
213
+ )
214
+ if _response.status_code == 500:
215
+ raise InternalServerError(
216
+ headers=dict(_response.headers),
217
+ body=typing.cast(
218
+ ErrorResponse,
219
+ parse_obj_as(
220
+ type_=ErrorResponse, # type: ignore
221
+ object_=_response.json(),
222
+ ),
223
+ ),
224
+ )
225
+ if _response.status_code == 404:
226
+ raise DoesNotExistError(
227
+ headers=dict(_response.headers),
228
+ body=typing.cast(
229
+ ErrorResponse,
230
+ parse_obj_as(
231
+ type_=ErrorResponse, # type: ignore
232
+ object_=_response.json(),
233
+ ),
234
+ ),
235
+ )
236
+ _response_json = _response.json()
237
+ except JSONDecodeError:
238
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
239
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
240
+
241
+ def delete(
242
+ self,
243
+ organization_id: OrganizationId,
244
+ user_id: UserId,
245
+ *,
246
+ request_options: typing.Optional[RequestOptions] = None,
247
+ ) -> HttpResponse[DeleteUserResponseObject]:
248
+ """
249
+ Call this endpoint to delete a specified enrolled user from the rewards program and Kard's system. Users can be re-enrolled into rewards by calling the [Create User](/2024-10-01/api/users/create) endpoint using the same `id` from before.<br/>
250
+
251
+ <b>Required scopes:</b> `user:delete`
252
+
253
+ Parameters
254
+ ----------
255
+ organization_id : OrganizationId
256
+
257
+ user_id : UserId
258
+
259
+ request_options : typing.Optional[RequestOptions]
260
+ Request-specific configuration.
261
+
262
+ Returns
263
+ -------
264
+ HttpResponse[DeleteUserResponseObject]
265
+ """
266
+ _response = self._client_wrapper.httpx_client.request(
267
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}",
268
+ method="DELETE",
269
+ request_options=request_options,
270
+ )
271
+ try:
272
+ if 200 <= _response.status_code < 300:
273
+ _data = typing.cast(
274
+ DeleteUserResponseObject,
275
+ parse_obj_as(
276
+ type_=DeleteUserResponseObject, # type: ignore
277
+ object_=_response.json(),
278
+ ),
279
+ )
280
+ return HttpResponse(response=_response, data=_data)
281
+ if _response.status_code == 401:
282
+ raise UnauthorizedError(
283
+ headers=dict(_response.headers),
284
+ body=typing.cast(
285
+ ErrorResponse,
286
+ parse_obj_as(
287
+ type_=ErrorResponse, # type: ignore
288
+ object_=_response.json(),
289
+ ),
290
+ ),
291
+ )
292
+ if _response.status_code == 400:
293
+ raise InvalidRequest(
294
+ headers=dict(_response.headers),
295
+ body=typing.cast(
296
+ ErrorResponse,
297
+ parse_obj_as(
298
+ type_=ErrorResponse, # type: ignore
299
+ object_=_response.json(),
300
+ ),
301
+ ),
302
+ )
303
+ if _response.status_code == 500:
304
+ raise InternalServerError(
305
+ headers=dict(_response.headers),
306
+ body=typing.cast(
307
+ ErrorResponse,
308
+ parse_obj_as(
309
+ type_=ErrorResponse, # type: ignore
310
+ object_=_response.json(),
311
+ ),
312
+ ),
313
+ )
314
+ if _response.status_code == 404:
315
+ raise DoesNotExistError(
316
+ headers=dict(_response.headers),
317
+ body=typing.cast(
318
+ ErrorResponse,
319
+ parse_obj_as(
320
+ type_=ErrorResponse, # type: ignore
321
+ object_=_response.json(),
322
+ ),
323
+ ),
324
+ )
325
+ _response_json = _response.json()
326
+ except JSONDecodeError:
327
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
328
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
329
+
330
+ def get(
331
+ self,
332
+ organization_id: OrganizationId,
333
+ user_id: UserId,
334
+ *,
335
+ request_options: typing.Optional[RequestOptions] = None,
336
+ ) -> HttpResponse[UpdateUserObject]:
337
+ """
338
+ Call this endpoint to fetch the details on a specified user.<br/>
339
+ <br/>
340
+ <b>Required scopes:</b>&nbsp;&nbsp;`user:read`
341
+
342
+ Parameters
343
+ ----------
344
+ organization_id : OrganizationId
345
+
346
+ user_id : UserId
347
+
348
+ request_options : typing.Optional[RequestOptions]
349
+ Request-specific configuration.
350
+
351
+ Returns
352
+ -------
353
+ HttpResponse[UpdateUserObject]
354
+ """
355
+ _response = self._client_wrapper.httpx_client.request(
356
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}",
357
+ method="GET",
358
+ request_options=request_options,
359
+ )
360
+ try:
361
+ if 200 <= _response.status_code < 300:
362
+ _data = typing.cast(
363
+ UpdateUserObject,
364
+ parse_obj_as(
365
+ type_=UpdateUserObject, # type: ignore
366
+ object_=_response.json(),
367
+ ),
368
+ )
369
+ return HttpResponse(response=_response, data=_data)
370
+ if _response.status_code == 401:
371
+ raise UnauthorizedError(
372
+ headers=dict(_response.headers),
373
+ body=typing.cast(
374
+ ErrorResponse,
375
+ parse_obj_as(
376
+ type_=ErrorResponse, # type: ignore
377
+ object_=_response.json(),
378
+ ),
379
+ ),
380
+ )
381
+ if _response.status_code == 500:
382
+ raise InternalServerError(
383
+ headers=dict(_response.headers),
384
+ body=typing.cast(
385
+ ErrorResponse,
386
+ parse_obj_as(
387
+ type_=ErrorResponse, # type: ignore
388
+ object_=_response.json(),
389
+ ),
390
+ ),
391
+ )
392
+ if _response.status_code == 404:
393
+ raise DoesNotExistError(
394
+ headers=dict(_response.headers),
395
+ body=typing.cast(
396
+ ErrorResponse,
397
+ parse_obj_as(
398
+ type_=ErrorResponse, # type: ignore
399
+ object_=_response.json(),
400
+ ),
401
+ ),
402
+ )
403
+ _response_json = _response.json()
404
+ except JSONDecodeError:
405
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
406
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
407
+
408
+
409
+ class AsyncRawUsersClient:
410
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
411
+ self._client_wrapper = client_wrapper
412
+
413
+ async def create(
414
+ self,
415
+ organization_id: OrganizationId,
416
+ *,
417
+ data: typing.Sequence[UserRequestDataUnion],
418
+ request_options: typing.Optional[RequestOptions] = None,
419
+ ) -> AsyncHttpResponse[CreateUsersObject]:
420
+ """
421
+ Call this endpoint to enroll a specified user into your rewards program.<br/>
422
+
423
+ <b>Required scopes:</b>&nbsp;&nbsp;`user:write`<br/>
424
+ <b>Note:</b> `Maximum of 100 users can be created per request`.
425
+
426
+ Parameters
427
+ ----------
428
+ organization_id : OrganizationId
429
+
430
+ data : typing.Sequence[UserRequestDataUnion]
431
+
432
+ request_options : typing.Optional[RequestOptions]
433
+ Request-specific configuration.
434
+
435
+ Returns
436
+ -------
437
+ AsyncHttpResponse[CreateUsersObject]
438
+ """
439
+ _response = await self._client_wrapper.httpx_client.request(
440
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users",
441
+ method="POST",
442
+ json={
443
+ "data": convert_and_respect_annotation_metadata(
444
+ object_=data, annotation=typing.Sequence[UserRequestDataUnion], direction="write"
445
+ ),
446
+ },
447
+ request_options=request_options,
448
+ omit=OMIT,
449
+ )
450
+ try:
451
+ if 200 <= _response.status_code < 300:
452
+ _data = typing.cast(
453
+ CreateUsersObject,
454
+ parse_obj_as(
455
+ type_=CreateUsersObject, # type: ignore
456
+ object_=_response.json(),
457
+ ),
458
+ )
459
+ return AsyncHttpResponse(response=_response, data=_data)
460
+ if _response.status_code == 207:
461
+ raise MultiStatus(
462
+ headers=dict(_response.headers),
463
+ body=typing.cast(
464
+ CreateUsersMultiStatusResponse,
465
+ parse_obj_as(
466
+ type_=CreateUsersMultiStatusResponse, # type: ignore
467
+ object_=_response.json(),
468
+ ),
469
+ ),
470
+ )
471
+ if _response.status_code == 401:
472
+ raise UnauthorizedError(
473
+ headers=dict(_response.headers),
474
+ body=typing.cast(
475
+ ErrorResponse,
476
+ parse_obj_as(
477
+ type_=ErrorResponse, # type: ignore
478
+ object_=_response.json(),
479
+ ),
480
+ ),
481
+ )
482
+ if _response.status_code == 400:
483
+ raise InvalidRequest(
484
+ headers=dict(_response.headers),
485
+ body=typing.cast(
486
+ ErrorResponse,
487
+ parse_obj_as(
488
+ type_=ErrorResponse, # type: ignore
489
+ object_=_response.json(),
490
+ ),
491
+ ),
492
+ )
493
+ if _response.status_code == 500:
494
+ raise InternalServerError(
495
+ headers=dict(_response.headers),
496
+ body=typing.cast(
497
+ ErrorResponse,
498
+ parse_obj_as(
499
+ type_=ErrorResponse, # type: ignore
500
+ object_=_response.json(),
501
+ ),
502
+ ),
503
+ )
504
+ if _response.status_code == 409:
505
+ raise ConflictError(
506
+ headers=dict(_response.headers),
507
+ body=typing.cast(
508
+ ErrorResponse,
509
+ parse_obj_as(
510
+ type_=ErrorResponse, # type: ignore
511
+ object_=_response.json(),
512
+ ),
513
+ ),
514
+ )
515
+ _response_json = _response.json()
516
+ except JSONDecodeError:
517
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
518
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
519
+
520
+ async def update(
521
+ self,
522
+ organization_id: OrganizationId,
523
+ user_id: UserId,
524
+ *,
525
+ data: UserRequestDataUnion,
526
+ request_options: typing.Optional[RequestOptions] = None,
527
+ ) -> AsyncHttpResponse[UpdateUserObject]:
528
+ """
529
+ Call this endpoint to update the details on a specified user.<br/>
530
+
531
+ <b>Required scopes:</b> `user:update`
532
+
533
+ Parameters
534
+ ----------
535
+ organization_id : OrganizationId
536
+
537
+ user_id : UserId
538
+
539
+ data : UserRequestDataUnion
540
+
541
+ request_options : typing.Optional[RequestOptions]
542
+ Request-specific configuration.
543
+
544
+ Returns
545
+ -------
546
+ AsyncHttpResponse[UpdateUserObject]
547
+ """
548
+ _response = await self._client_wrapper.httpx_client.request(
549
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}",
550
+ method="PUT",
551
+ json={
552
+ "data": convert_and_respect_annotation_metadata(
553
+ object_=data, annotation=UserRequestDataUnion, direction="write"
554
+ ),
555
+ },
556
+ request_options=request_options,
557
+ omit=OMIT,
558
+ )
559
+ try:
560
+ if 200 <= _response.status_code < 300:
561
+ _data = typing.cast(
562
+ UpdateUserObject,
563
+ parse_obj_as(
564
+ type_=UpdateUserObject, # type: ignore
565
+ object_=_response.json(),
566
+ ),
567
+ )
568
+ return AsyncHttpResponse(response=_response, data=_data)
569
+ if _response.status_code == 401:
570
+ raise UnauthorizedError(
571
+ headers=dict(_response.headers),
572
+ body=typing.cast(
573
+ ErrorResponse,
574
+ parse_obj_as(
575
+ type_=ErrorResponse, # type: ignore
576
+ object_=_response.json(),
577
+ ),
578
+ ),
579
+ )
580
+ if _response.status_code == 400:
581
+ raise InvalidRequest(
582
+ headers=dict(_response.headers),
583
+ body=typing.cast(
584
+ ErrorResponse,
585
+ parse_obj_as(
586
+ type_=ErrorResponse, # type: ignore
587
+ object_=_response.json(),
588
+ ),
589
+ ),
590
+ )
591
+ if _response.status_code == 500:
592
+ raise InternalServerError(
593
+ headers=dict(_response.headers),
594
+ body=typing.cast(
595
+ ErrorResponse,
596
+ parse_obj_as(
597
+ type_=ErrorResponse, # type: ignore
598
+ object_=_response.json(),
599
+ ),
600
+ ),
601
+ )
602
+ if _response.status_code == 404:
603
+ raise DoesNotExistError(
604
+ headers=dict(_response.headers),
605
+ body=typing.cast(
606
+ ErrorResponse,
607
+ parse_obj_as(
608
+ type_=ErrorResponse, # type: ignore
609
+ object_=_response.json(),
610
+ ),
611
+ ),
612
+ )
613
+ _response_json = _response.json()
614
+ except JSONDecodeError:
615
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
616
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
617
+
618
+ async def delete(
619
+ self,
620
+ organization_id: OrganizationId,
621
+ user_id: UserId,
622
+ *,
623
+ request_options: typing.Optional[RequestOptions] = None,
624
+ ) -> AsyncHttpResponse[DeleteUserResponseObject]:
625
+ """
626
+ Call this endpoint to delete a specified enrolled user from the rewards program and Kard's system. Users can be re-enrolled into rewards by calling the [Create User](/2024-10-01/api/users/create) endpoint using the same `id` from before.<br/>
627
+
628
+ <b>Required scopes:</b> `user:delete`
629
+
630
+ Parameters
631
+ ----------
632
+ organization_id : OrganizationId
633
+
634
+ user_id : UserId
635
+
636
+ request_options : typing.Optional[RequestOptions]
637
+ Request-specific configuration.
638
+
639
+ Returns
640
+ -------
641
+ AsyncHttpResponse[DeleteUserResponseObject]
642
+ """
643
+ _response = await self._client_wrapper.httpx_client.request(
644
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}",
645
+ method="DELETE",
646
+ request_options=request_options,
647
+ )
648
+ try:
649
+ if 200 <= _response.status_code < 300:
650
+ _data = typing.cast(
651
+ DeleteUserResponseObject,
652
+ parse_obj_as(
653
+ type_=DeleteUserResponseObject, # type: ignore
654
+ object_=_response.json(),
655
+ ),
656
+ )
657
+ return AsyncHttpResponse(response=_response, data=_data)
658
+ if _response.status_code == 401:
659
+ raise UnauthorizedError(
660
+ headers=dict(_response.headers),
661
+ body=typing.cast(
662
+ ErrorResponse,
663
+ parse_obj_as(
664
+ type_=ErrorResponse, # type: ignore
665
+ object_=_response.json(),
666
+ ),
667
+ ),
668
+ )
669
+ if _response.status_code == 400:
670
+ raise InvalidRequest(
671
+ headers=dict(_response.headers),
672
+ body=typing.cast(
673
+ ErrorResponse,
674
+ parse_obj_as(
675
+ type_=ErrorResponse, # type: ignore
676
+ object_=_response.json(),
677
+ ),
678
+ ),
679
+ )
680
+ if _response.status_code == 500:
681
+ raise InternalServerError(
682
+ headers=dict(_response.headers),
683
+ body=typing.cast(
684
+ ErrorResponse,
685
+ parse_obj_as(
686
+ type_=ErrorResponse, # type: ignore
687
+ object_=_response.json(),
688
+ ),
689
+ ),
690
+ )
691
+ if _response.status_code == 404:
692
+ raise DoesNotExistError(
693
+ headers=dict(_response.headers),
694
+ body=typing.cast(
695
+ ErrorResponse,
696
+ parse_obj_as(
697
+ type_=ErrorResponse, # type: ignore
698
+ object_=_response.json(),
699
+ ),
700
+ ),
701
+ )
702
+ _response_json = _response.json()
703
+ except JSONDecodeError:
704
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
705
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
706
+
707
+ async def get(
708
+ self,
709
+ organization_id: OrganizationId,
710
+ user_id: UserId,
711
+ *,
712
+ request_options: typing.Optional[RequestOptions] = None,
713
+ ) -> AsyncHttpResponse[UpdateUserObject]:
714
+ """
715
+ Call this endpoint to fetch the details on a specified user.<br/>
716
+ <br/>
717
+ <b>Required scopes:</b>&nbsp;&nbsp;`user:read`
718
+
719
+ Parameters
720
+ ----------
721
+ organization_id : OrganizationId
722
+
723
+ user_id : UserId
724
+
725
+ request_options : typing.Optional[RequestOptions]
726
+ Request-specific configuration.
727
+
728
+ Returns
729
+ -------
730
+ AsyncHttpResponse[UpdateUserObject]
731
+ """
732
+ _response = await self._client_wrapper.httpx_client.request(
733
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}",
734
+ method="GET",
735
+ request_options=request_options,
736
+ )
737
+ try:
738
+ if 200 <= _response.status_code < 300:
739
+ _data = typing.cast(
740
+ UpdateUserObject,
741
+ parse_obj_as(
742
+ type_=UpdateUserObject, # type: ignore
743
+ object_=_response.json(),
744
+ ),
745
+ )
746
+ return AsyncHttpResponse(response=_response, data=_data)
747
+ if _response.status_code == 401:
748
+ raise UnauthorizedError(
749
+ headers=dict(_response.headers),
750
+ body=typing.cast(
751
+ ErrorResponse,
752
+ parse_obj_as(
753
+ type_=ErrorResponse, # type: ignore
754
+ object_=_response.json(),
755
+ ),
756
+ ),
757
+ )
758
+ if _response.status_code == 500:
759
+ raise InternalServerError(
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 == 404:
770
+ raise DoesNotExistError(
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
+ _response_json = _response.json()
781
+ except JSONDecodeError:
782
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
783
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)