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
kard/auth/client.py ADDED
@@ -0,0 +1,121 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from .raw_client import AsyncRawAuthClient, RawAuthClient
8
+ from .types.token_response import TokenResponse
9
+
10
+ # this is used as the default value for optional parameters
11
+ OMIT = typing.cast(typing.Any, ...)
12
+
13
+
14
+ class AuthClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._raw_client = RawAuthClient(client_wrapper=client_wrapper)
17
+
18
+ @property
19
+ def with_raw_response(self) -> RawAuthClient:
20
+ """
21
+ Retrieves a raw implementation of this client that returns raw responses.
22
+
23
+ Returns
24
+ -------
25
+ RawAuthClient
26
+ """
27
+ return self._raw_client
28
+
29
+ def get_token(
30
+ self, *, client_id: str, client_secret: str, request_options: typing.Optional[RequestOptions] = None
31
+ ) -> TokenResponse:
32
+ """
33
+ Parameters
34
+ ----------
35
+ client_id : str
36
+
37
+ client_secret : str
38
+
39
+ request_options : typing.Optional[RequestOptions]
40
+ Request-specific configuration.
41
+
42
+ Returns
43
+ -------
44
+ TokenResponse
45
+
46
+ Examples
47
+ --------
48
+ from kard import KardApi
49
+
50
+ client = KardApi(
51
+ client_id="YOUR_CLIENT_ID",
52
+ client_secret="YOUR_CLIENT_SECRET",
53
+ )
54
+ client.auth.get_token(
55
+ client_id="client_id",
56
+ client_secret="client_secret",
57
+ )
58
+ """
59
+ _response = self._raw_client.get_token(
60
+ client_id=client_id, client_secret=client_secret, request_options=request_options
61
+ )
62
+ return _response.data
63
+
64
+
65
+ class AsyncAuthClient:
66
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
67
+ self._raw_client = AsyncRawAuthClient(client_wrapper=client_wrapper)
68
+
69
+ @property
70
+ def with_raw_response(self) -> AsyncRawAuthClient:
71
+ """
72
+ Retrieves a raw implementation of this client that returns raw responses.
73
+
74
+ Returns
75
+ -------
76
+ AsyncRawAuthClient
77
+ """
78
+ return self._raw_client
79
+
80
+ async def get_token(
81
+ self, *, client_id: str, client_secret: str, request_options: typing.Optional[RequestOptions] = None
82
+ ) -> TokenResponse:
83
+ """
84
+ Parameters
85
+ ----------
86
+ client_id : str
87
+
88
+ client_secret : str
89
+
90
+ request_options : typing.Optional[RequestOptions]
91
+ Request-specific configuration.
92
+
93
+ Returns
94
+ -------
95
+ TokenResponse
96
+
97
+ Examples
98
+ --------
99
+ import asyncio
100
+
101
+ from kard import AsyncKardApi
102
+
103
+ client = AsyncKardApi(
104
+ client_id="YOUR_CLIENT_ID",
105
+ client_secret="YOUR_CLIENT_SECRET",
106
+ )
107
+
108
+
109
+ async def main() -> None:
110
+ await client.auth.get_token(
111
+ client_id="client_id",
112
+ client_secret="client_secret",
113
+ )
114
+
115
+
116
+ asyncio.run(main())
117
+ """
118
+ _response = await self._raw_client.get_token(
119
+ client_id=client_id, client_secret=client_secret, request_options=request_options
120
+ )
121
+ return _response.data
@@ -0,0 +1,108 @@
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 ..core.api_error import ApiError
7
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
+ from ..core.http_response import AsyncHttpResponse, HttpResponse
9
+ from ..core.pydantic_utilities import parse_obj_as
10
+ from ..core.request_options import RequestOptions
11
+ from .types.token_response import TokenResponse
12
+
13
+ # this is used as the default value for optional parameters
14
+ OMIT = typing.cast(typing.Any, ...)
15
+
16
+
17
+ class RawAuthClient:
18
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
19
+ self._client_wrapper = client_wrapper
20
+
21
+ def get_token(
22
+ self, *, client_id: str, client_secret: str, request_options: typing.Optional[RequestOptions] = None
23
+ ) -> HttpResponse[TokenResponse]:
24
+ """
25
+ Parameters
26
+ ----------
27
+ client_id : str
28
+
29
+ client_secret : str
30
+
31
+ request_options : typing.Optional[RequestOptions]
32
+ Request-specific configuration.
33
+
34
+ Returns
35
+ -------
36
+ HttpResponse[TokenResponse]
37
+ """
38
+ _response = self._client_wrapper.httpx_client.request(
39
+ "v2/auth/token",
40
+ method="POST",
41
+ json={
42
+ "client_id": client_id,
43
+ "client_secret": client_secret,
44
+ },
45
+ request_options=request_options,
46
+ omit=OMIT,
47
+ )
48
+ try:
49
+ if 200 <= _response.status_code < 300:
50
+ _data = typing.cast(
51
+ TokenResponse,
52
+ parse_obj_as(
53
+ type_=TokenResponse, # type: ignore
54
+ object_=_response.json(),
55
+ ),
56
+ )
57
+ return HttpResponse(response=_response, data=_data)
58
+ _response_json = _response.json()
59
+ except JSONDecodeError:
60
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
61
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
62
+
63
+
64
+ class AsyncRawAuthClient:
65
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
66
+ self._client_wrapper = client_wrapper
67
+
68
+ async def get_token(
69
+ self, *, client_id: str, client_secret: str, request_options: typing.Optional[RequestOptions] = None
70
+ ) -> AsyncHttpResponse[TokenResponse]:
71
+ """
72
+ Parameters
73
+ ----------
74
+ client_id : str
75
+
76
+ client_secret : str
77
+
78
+ request_options : typing.Optional[RequestOptions]
79
+ Request-specific configuration.
80
+
81
+ Returns
82
+ -------
83
+ AsyncHttpResponse[TokenResponse]
84
+ """
85
+ _response = await self._client_wrapper.httpx_client.request(
86
+ "v2/auth/token",
87
+ method="POST",
88
+ json={
89
+ "client_id": client_id,
90
+ "client_secret": client_secret,
91
+ },
92
+ request_options=request_options,
93
+ omit=OMIT,
94
+ )
95
+ try:
96
+ if 200 <= _response.status_code < 300:
97
+ _data = typing.cast(
98
+ TokenResponse,
99
+ parse_obj_as(
100
+ type_=TokenResponse, # type: ignore
101
+ object_=_response.json(),
102
+ ),
103
+ )
104
+ return AsyncHttpResponse(response=_response, data=_data)
105
+ _response_json = _response.json()
106
+ except JSONDecodeError:
107
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
108
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -0,0 +1,34 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .token_response import TokenResponse
10
+ _dynamic_imports: typing.Dict[str, str] = {"TokenResponse": ".token_response"}
11
+
12
+
13
+ def __getattr__(attr_name: str) -> typing.Any:
14
+ module_name = _dynamic_imports.get(attr_name)
15
+ if module_name is None:
16
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
17
+ try:
18
+ module = import_module(module_name, __package__)
19
+ if module_name == f".{attr_name}":
20
+ return module
21
+ else:
22
+ return getattr(module, attr_name)
23
+ except ImportError as e:
24
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
25
+ except AttributeError as e:
26
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
27
+
28
+
29
+ def __dir__():
30
+ lazy_attrs = list(_dynamic_imports.keys())
31
+ return sorted(lazy_attrs)
32
+
33
+
34
+ __all__ = ["TokenResponse"]
@@ -0,0 +1,25 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
7
+
8
+
9
+ class TokenResponse(UniversalBaseModel):
10
+ """
11
+ An OAuth token response.
12
+ """
13
+
14
+ access_token: str
15
+ expires_in: int
16
+ token_type: str
17
+
18
+ if IS_PYDANTIC_V2:
19
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
20
+ else:
21
+
22
+ class Config:
23
+ frozen = True
24
+ smart_union = True
25
+ extra = pydantic.Extra.allow