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,587 @@
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.does_not_exist_error import DoesNotExistError
7
+ from ...commons.errors.internal_server_error import InternalServerError
8
+ from ...commons.errors.invalid_request import InvalidRequest
9
+ from ...commons.errors.unauthorized_error import UnauthorizedError
10
+ from ...commons.types.category_option import CategoryOption
11
+ from ...commons.types.error_response import ErrorResponse
12
+ from ...commons.types.organization_id import OrganizationId
13
+ from ...commons.types.purchase_channel import PurchaseChannel
14
+ from ...commons.types.state import State
15
+ from ...commons.types.user_id import UserId
16
+ from ...core.api_error import ApiError
17
+ from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
18
+ from ...core.http_response import AsyncHttpResponse, HttpResponse
19
+ from ...core.jsonable_encoder import jsonable_encoder
20
+ from ...core.pydantic_utilities import parse_obj_as
21
+ from ...core.request_options import RequestOptions
22
+ from .types.location_sort_options import LocationSortOptions
23
+ from .types.locations_response_object import LocationsResponseObject
24
+ from .types.offer_sort_options import OfferSortOptions
25
+ from .types.offers_response_object import OffersResponseObject
26
+
27
+
28
+ class RawRewardsClient:
29
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
30
+ self._client_wrapper = client_wrapper
31
+
32
+ def offers(
33
+ self,
34
+ organization_id: OrganizationId,
35
+ user_id: UserId,
36
+ *,
37
+ page_size: typing.Optional[int] = None,
38
+ page_after: typing.Optional[str] = None,
39
+ page_before: typing.Optional[str] = None,
40
+ filter_purchase_channel: typing.Optional[typing.Sequence[PurchaseChannel]] = None,
41
+ filter_category: typing.Optional[CategoryOption] = None,
42
+ filter_is_targeted: typing.Optional[bool] = None,
43
+ sort: typing.Optional[typing.Union[OfferSortOptions, typing.Sequence[OfferSortOptions]]] = None,
44
+ include: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
45
+ request_options: typing.Optional[RequestOptions] = None,
46
+ ) -> HttpResponse[OffersResponseObject]:
47
+ """
48
+ Retrieve national brand offers that a specified user is eligible for. Call this endpoint to build out your
49
+ [targeted offers UX experience](/2024-10-01/api/getting-started#b-discover-a-lapsed-customer-clo). Local offers details
50
+ can be found by calling the [Get Eligible Locations](/2024-10-01/api/rewards/locations) endpoint with the
51
+ `includeLocal` query parameter.<br/>
52
+ <b>Required scopes:</b> `rewards:read`
53
+
54
+ Parameters
55
+ ----------
56
+ organization_id : OrganizationId
57
+
58
+ user_id : UserId
59
+
60
+ page_size : typing.Optional[int]
61
+
62
+ page_after : typing.Optional[str]
63
+
64
+ page_before : typing.Optional[str]
65
+
66
+ filter_purchase_channel : typing.Optional[typing.Sequence[PurchaseChannel]]
67
+
68
+ filter_category : typing.Optional[CategoryOption]
69
+
70
+ filter_is_targeted : typing.Optional[bool]
71
+
72
+ sort : typing.Optional[typing.Union[OfferSortOptions, typing.Sequence[OfferSortOptions]]]
73
+ If provided, response will be sorted by the specified fields
74
+
75
+ include : typing.Optional[typing.Union[str, typing.Sequence[str]]]
76
+ CSV list of included resources in the response (e.g "categories"). Allowed value is `categories`.
77
+
78
+ request_options : typing.Optional[RequestOptions]
79
+ Request-specific configuration.
80
+
81
+ Returns
82
+ -------
83
+ HttpResponse[OffersResponseObject]
84
+ """
85
+ _response = self._client_wrapper.httpx_client.request(
86
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/offers",
87
+ method="GET",
88
+ params={
89
+ "page[size]": page_size,
90
+ "page[after]": page_after,
91
+ "page[before]": page_before,
92
+ "filter[purchaseChannel]": filter_purchase_channel,
93
+ "filter[category]": filter_category,
94
+ "filter[isTargeted]": filter_is_targeted,
95
+ "sort": sort,
96
+ "include": include,
97
+ },
98
+ request_options=request_options,
99
+ )
100
+ try:
101
+ if 200 <= _response.status_code < 300:
102
+ _data = typing.cast(
103
+ OffersResponseObject,
104
+ parse_obj_as(
105
+ type_=OffersResponseObject, # type: ignore
106
+ object_=_response.json(),
107
+ ),
108
+ )
109
+ return HttpResponse(response=_response, data=_data)
110
+ if _response.status_code == 500:
111
+ raise InternalServerError(
112
+ headers=dict(_response.headers),
113
+ body=typing.cast(
114
+ ErrorResponse,
115
+ parse_obj_as(
116
+ type_=ErrorResponse, # type: ignore
117
+ object_=_response.json(),
118
+ ),
119
+ ),
120
+ )
121
+ if _response.status_code == 400:
122
+ raise InvalidRequest(
123
+ headers=dict(_response.headers),
124
+ body=typing.cast(
125
+ ErrorResponse,
126
+ parse_obj_as(
127
+ type_=ErrorResponse, # type: ignore
128
+ object_=_response.json(),
129
+ ),
130
+ ),
131
+ )
132
+ if _response.status_code == 404:
133
+ raise DoesNotExistError(
134
+ headers=dict(_response.headers),
135
+ body=typing.cast(
136
+ ErrorResponse,
137
+ parse_obj_as(
138
+ type_=ErrorResponse, # type: ignore
139
+ object_=_response.json(),
140
+ ),
141
+ ),
142
+ )
143
+ if _response.status_code == 401:
144
+ raise UnauthorizedError(
145
+ headers=dict(_response.headers),
146
+ body=typing.cast(
147
+ ErrorResponse,
148
+ parse_obj_as(
149
+ type_=ErrorResponse, # type: ignore
150
+ object_=_response.json(),
151
+ ),
152
+ ),
153
+ )
154
+ _response_json = _response.json()
155
+ except JSONDecodeError:
156
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
157
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
158
+
159
+ def locations(
160
+ self,
161
+ organization_id: OrganizationId,
162
+ user_id: UserId,
163
+ *,
164
+ page_size: typing.Optional[int] = None,
165
+ page_after: typing.Optional[str] = None,
166
+ page_before: typing.Optional[str] = None,
167
+ filter_name: typing.Optional[str] = None,
168
+ filter_city: typing.Optional[str] = None,
169
+ filter_zip_code: typing.Optional[str] = None,
170
+ filter_state: typing.Optional[State] = None,
171
+ filter_category: typing.Optional[CategoryOption] = None,
172
+ filter_longitude: typing.Optional[float] = None,
173
+ filter_latitude: typing.Optional[float] = None,
174
+ filter_radius: typing.Optional[int] = None,
175
+ sort: typing.Optional[typing.Union[LocationSortOptions, typing.Sequence[LocationSortOptions]]] = None,
176
+ include: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
177
+ request_options: typing.Optional[RequestOptions] = None,
178
+ ) -> HttpResponse[LocationsResponseObject]:
179
+ """
180
+ Retrieve national and local geographic locations that a specified user has eligible in-store offers at. To
181
+ include local locations, add the `includeLocal` query parameter to your api call. Use this endpoint to build
182
+ out your [map-specific UX experiences](/2024-10-01/api/getting-started#c-discover-clos-near-you-map-view). Please note
183
+ that Longitude and Latitude fields are prioritized over State, City and Zipcode and are the recommended search
184
+ pattern.<br/>
185
+ <br/>
186
+ <b>Required scopes:</b> `rewards:read`
187
+
188
+ Parameters
189
+ ----------
190
+ organization_id : OrganizationId
191
+
192
+ user_id : UserId
193
+
194
+ page_size : typing.Optional[int]
195
+
196
+ page_after : typing.Optional[str]
197
+
198
+ page_before : typing.Optional[str]
199
+
200
+ filter_name : typing.Optional[str]
201
+
202
+ filter_city : typing.Optional[str]
203
+
204
+ filter_zip_code : typing.Optional[str]
205
+
206
+ filter_state : typing.Optional[State]
207
+
208
+ filter_category : typing.Optional[CategoryOption]
209
+
210
+ filter_longitude : typing.Optional[float]
211
+
212
+ filter_latitude : typing.Optional[float]
213
+
214
+ filter_radius : typing.Optional[int]
215
+
216
+ sort : typing.Optional[typing.Union[LocationSortOptions, typing.Sequence[LocationSortOptions]]]
217
+ If provided, response will be sorted by the specified fields
218
+
219
+ include : typing.Optional[typing.Union[str, typing.Sequence[str]]]
220
+ CSV list of included resources in the response (e.g "offers,categories"). Allowed values are `offers` and `categories`.
221
+
222
+ request_options : typing.Optional[RequestOptions]
223
+ Request-specific configuration.
224
+
225
+ Returns
226
+ -------
227
+ HttpResponse[LocationsResponseObject]
228
+ """
229
+ _response = self._client_wrapper.httpx_client.request(
230
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/locations",
231
+ method="GET",
232
+ params={
233
+ "page[size]": page_size,
234
+ "page[after]": page_after,
235
+ "page[before]": page_before,
236
+ "filter[name]": filter_name,
237
+ "filter[city]": filter_city,
238
+ "filter[zipCode]": filter_zip_code,
239
+ "filter[state]": filter_state,
240
+ "filter[category]": filter_category,
241
+ "filter[longitude]": filter_longitude,
242
+ "filter[latitude]": filter_latitude,
243
+ "filter[radius]": filter_radius,
244
+ "sort": sort,
245
+ "include": include,
246
+ },
247
+ request_options=request_options,
248
+ )
249
+ try:
250
+ if 200 <= _response.status_code < 300:
251
+ _data = typing.cast(
252
+ LocationsResponseObject,
253
+ parse_obj_as(
254
+ type_=LocationsResponseObject, # type: ignore
255
+ object_=_response.json(),
256
+ ),
257
+ )
258
+ return HttpResponse(response=_response, data=_data)
259
+ if _response.status_code == 500:
260
+ raise InternalServerError(
261
+ headers=dict(_response.headers),
262
+ body=typing.cast(
263
+ ErrorResponse,
264
+ parse_obj_as(
265
+ type_=ErrorResponse, # type: ignore
266
+ object_=_response.json(),
267
+ ),
268
+ ),
269
+ )
270
+ if _response.status_code == 400:
271
+ raise InvalidRequest(
272
+ headers=dict(_response.headers),
273
+ body=typing.cast(
274
+ ErrorResponse,
275
+ parse_obj_as(
276
+ type_=ErrorResponse, # type: ignore
277
+ object_=_response.json(),
278
+ ),
279
+ ),
280
+ )
281
+ if _response.status_code == 404:
282
+ raise DoesNotExistError(
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 == 401:
293
+ raise UnauthorizedError(
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
+ _response_json = _response.json()
304
+ except JSONDecodeError:
305
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
306
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
307
+
308
+
309
+ class AsyncRawRewardsClient:
310
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
311
+ self._client_wrapper = client_wrapper
312
+
313
+ async def offers(
314
+ self,
315
+ organization_id: OrganizationId,
316
+ user_id: UserId,
317
+ *,
318
+ page_size: typing.Optional[int] = None,
319
+ page_after: typing.Optional[str] = None,
320
+ page_before: typing.Optional[str] = None,
321
+ filter_purchase_channel: typing.Optional[typing.Sequence[PurchaseChannel]] = None,
322
+ filter_category: typing.Optional[CategoryOption] = None,
323
+ filter_is_targeted: typing.Optional[bool] = None,
324
+ sort: typing.Optional[typing.Union[OfferSortOptions, typing.Sequence[OfferSortOptions]]] = None,
325
+ include: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
326
+ request_options: typing.Optional[RequestOptions] = None,
327
+ ) -> AsyncHttpResponse[OffersResponseObject]:
328
+ """
329
+ Retrieve national brand offers that a specified user is eligible for. Call this endpoint to build out your
330
+ [targeted offers UX experience](/2024-10-01/api/getting-started#b-discover-a-lapsed-customer-clo). Local offers details
331
+ can be found by calling the [Get Eligible Locations](/2024-10-01/api/rewards/locations) endpoint with the
332
+ `includeLocal` query parameter.<br/>
333
+ <b>Required scopes:</b> `rewards:read`
334
+
335
+ Parameters
336
+ ----------
337
+ organization_id : OrganizationId
338
+
339
+ user_id : UserId
340
+
341
+ page_size : typing.Optional[int]
342
+
343
+ page_after : typing.Optional[str]
344
+
345
+ page_before : typing.Optional[str]
346
+
347
+ filter_purchase_channel : typing.Optional[typing.Sequence[PurchaseChannel]]
348
+
349
+ filter_category : typing.Optional[CategoryOption]
350
+
351
+ filter_is_targeted : typing.Optional[bool]
352
+
353
+ sort : typing.Optional[typing.Union[OfferSortOptions, typing.Sequence[OfferSortOptions]]]
354
+ If provided, response will be sorted by the specified fields
355
+
356
+ include : typing.Optional[typing.Union[str, typing.Sequence[str]]]
357
+ CSV list of included resources in the response (e.g "categories"). Allowed value is `categories`.
358
+
359
+ request_options : typing.Optional[RequestOptions]
360
+ Request-specific configuration.
361
+
362
+ Returns
363
+ -------
364
+ AsyncHttpResponse[OffersResponseObject]
365
+ """
366
+ _response = await self._client_wrapper.httpx_client.request(
367
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/offers",
368
+ method="GET",
369
+ params={
370
+ "page[size]": page_size,
371
+ "page[after]": page_after,
372
+ "page[before]": page_before,
373
+ "filter[purchaseChannel]": filter_purchase_channel,
374
+ "filter[category]": filter_category,
375
+ "filter[isTargeted]": filter_is_targeted,
376
+ "sort": sort,
377
+ "include": include,
378
+ },
379
+ request_options=request_options,
380
+ )
381
+ try:
382
+ if 200 <= _response.status_code < 300:
383
+ _data = typing.cast(
384
+ OffersResponseObject,
385
+ parse_obj_as(
386
+ type_=OffersResponseObject, # type: ignore
387
+ object_=_response.json(),
388
+ ),
389
+ )
390
+ return AsyncHttpResponse(response=_response, data=_data)
391
+ if _response.status_code == 500:
392
+ raise InternalServerError(
393
+ headers=dict(_response.headers),
394
+ body=typing.cast(
395
+ ErrorResponse,
396
+ parse_obj_as(
397
+ type_=ErrorResponse, # type: ignore
398
+ object_=_response.json(),
399
+ ),
400
+ ),
401
+ )
402
+ if _response.status_code == 400:
403
+ raise InvalidRequest(
404
+ headers=dict(_response.headers),
405
+ body=typing.cast(
406
+ ErrorResponse,
407
+ parse_obj_as(
408
+ type_=ErrorResponse, # type: ignore
409
+ object_=_response.json(),
410
+ ),
411
+ ),
412
+ )
413
+ if _response.status_code == 404:
414
+ raise DoesNotExistError(
415
+ headers=dict(_response.headers),
416
+ body=typing.cast(
417
+ ErrorResponse,
418
+ parse_obj_as(
419
+ type_=ErrorResponse, # type: ignore
420
+ object_=_response.json(),
421
+ ),
422
+ ),
423
+ )
424
+ if _response.status_code == 401:
425
+ raise UnauthorizedError(
426
+ headers=dict(_response.headers),
427
+ body=typing.cast(
428
+ ErrorResponse,
429
+ parse_obj_as(
430
+ type_=ErrorResponse, # type: ignore
431
+ object_=_response.json(),
432
+ ),
433
+ ),
434
+ )
435
+ _response_json = _response.json()
436
+ except JSONDecodeError:
437
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
438
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
439
+
440
+ async def locations(
441
+ self,
442
+ organization_id: OrganizationId,
443
+ user_id: UserId,
444
+ *,
445
+ page_size: typing.Optional[int] = None,
446
+ page_after: typing.Optional[str] = None,
447
+ page_before: typing.Optional[str] = None,
448
+ filter_name: typing.Optional[str] = None,
449
+ filter_city: typing.Optional[str] = None,
450
+ filter_zip_code: typing.Optional[str] = None,
451
+ filter_state: typing.Optional[State] = None,
452
+ filter_category: typing.Optional[CategoryOption] = None,
453
+ filter_longitude: typing.Optional[float] = None,
454
+ filter_latitude: typing.Optional[float] = None,
455
+ filter_radius: typing.Optional[int] = None,
456
+ sort: typing.Optional[typing.Union[LocationSortOptions, typing.Sequence[LocationSortOptions]]] = None,
457
+ include: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
458
+ request_options: typing.Optional[RequestOptions] = None,
459
+ ) -> AsyncHttpResponse[LocationsResponseObject]:
460
+ """
461
+ Retrieve national and local geographic locations that a specified user has eligible in-store offers at. To
462
+ include local locations, add the `includeLocal` query parameter to your api call. Use this endpoint to build
463
+ out your [map-specific UX experiences](/2024-10-01/api/getting-started#c-discover-clos-near-you-map-view). Please note
464
+ that Longitude and Latitude fields are prioritized over State, City and Zipcode and are the recommended search
465
+ pattern.<br/>
466
+ <br/>
467
+ <b>Required scopes:</b> `rewards:read`
468
+
469
+ Parameters
470
+ ----------
471
+ organization_id : OrganizationId
472
+
473
+ user_id : UserId
474
+
475
+ page_size : typing.Optional[int]
476
+
477
+ page_after : typing.Optional[str]
478
+
479
+ page_before : typing.Optional[str]
480
+
481
+ filter_name : typing.Optional[str]
482
+
483
+ filter_city : typing.Optional[str]
484
+
485
+ filter_zip_code : typing.Optional[str]
486
+
487
+ filter_state : typing.Optional[State]
488
+
489
+ filter_category : typing.Optional[CategoryOption]
490
+
491
+ filter_longitude : typing.Optional[float]
492
+
493
+ filter_latitude : typing.Optional[float]
494
+
495
+ filter_radius : typing.Optional[int]
496
+
497
+ sort : typing.Optional[typing.Union[LocationSortOptions, typing.Sequence[LocationSortOptions]]]
498
+ If provided, response will be sorted by the specified fields
499
+
500
+ include : typing.Optional[typing.Union[str, typing.Sequence[str]]]
501
+ CSV list of included resources in the response (e.g "offers,categories"). Allowed values are `offers` and `categories`.
502
+
503
+ request_options : typing.Optional[RequestOptions]
504
+ Request-specific configuration.
505
+
506
+ Returns
507
+ -------
508
+ AsyncHttpResponse[LocationsResponseObject]
509
+ """
510
+ _response = await self._client_wrapper.httpx_client.request(
511
+ f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/locations",
512
+ method="GET",
513
+ params={
514
+ "page[size]": page_size,
515
+ "page[after]": page_after,
516
+ "page[before]": page_before,
517
+ "filter[name]": filter_name,
518
+ "filter[city]": filter_city,
519
+ "filter[zipCode]": filter_zip_code,
520
+ "filter[state]": filter_state,
521
+ "filter[category]": filter_category,
522
+ "filter[longitude]": filter_longitude,
523
+ "filter[latitude]": filter_latitude,
524
+ "filter[radius]": filter_radius,
525
+ "sort": sort,
526
+ "include": include,
527
+ },
528
+ request_options=request_options,
529
+ )
530
+ try:
531
+ if 200 <= _response.status_code < 300:
532
+ _data = typing.cast(
533
+ LocationsResponseObject,
534
+ parse_obj_as(
535
+ type_=LocationsResponseObject, # type: ignore
536
+ object_=_response.json(),
537
+ ),
538
+ )
539
+ return AsyncHttpResponse(response=_response, data=_data)
540
+ if _response.status_code == 500:
541
+ raise InternalServerError(
542
+ headers=dict(_response.headers),
543
+ body=typing.cast(
544
+ ErrorResponse,
545
+ parse_obj_as(
546
+ type_=ErrorResponse, # type: ignore
547
+ object_=_response.json(),
548
+ ),
549
+ ),
550
+ )
551
+ if _response.status_code == 400:
552
+ raise InvalidRequest(
553
+ headers=dict(_response.headers),
554
+ body=typing.cast(
555
+ ErrorResponse,
556
+ parse_obj_as(
557
+ type_=ErrorResponse, # type: ignore
558
+ object_=_response.json(),
559
+ ),
560
+ ),
561
+ )
562
+ if _response.status_code == 404:
563
+ raise DoesNotExistError(
564
+ headers=dict(_response.headers),
565
+ body=typing.cast(
566
+ ErrorResponse,
567
+ parse_obj_as(
568
+ type_=ErrorResponse, # type: ignore
569
+ object_=_response.json(),
570
+ ),
571
+ ),
572
+ )
573
+ if _response.status_code == 401:
574
+ raise UnauthorizedError(
575
+ headers=dict(_response.headers),
576
+ body=typing.cast(
577
+ ErrorResponse,
578
+ parse_obj_as(
579
+ type_=ErrorResponse, # type: ignore
580
+ object_=_response.json(),
581
+ ),
582
+ ),
583
+ )
584
+ _response_json = _response.json()
585
+ except JSONDecodeError:
586
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
587
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)