kard-financial-sdk 2.0.0__py3-none-any.whl → 2.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kard/__init__.py +15 -0
- kard/core/client_wrapper.py +2 -2
- kard/transactions/__init__.py +15 -0
- kard/transactions/client.py +6 -2
- kard/transactions/raw_client.py +6 -2
- kard/transactions/types/__init__.py +20 -1
- kard/transactions/types/core_merchant.py +24 -0
- kard/transactions/types/core_transaction_attributes.py +82 -0
- kard/transactions/types/core_transaction_request.py +25 -0
- kard/transactions/types/financial_institution.py +29 -0
- kard/transactions/types/matched_transactions_attributes.py +1 -1
- kard/transactions/types/transactions.py +18 -1
- kard/transactions/types/transactions_attributes.py +3 -3
- kard/transactions/types/transactions_request_body.py +1 -0
- kard/users/__init__.py +27 -0
- kard/users/attributions/__init__.py +15 -0
- kard/users/attributions/client.py +135 -0
- kard/users/attributions/raw_client.py +193 -0
- kard/users/attributions/types/__init__.py +15 -0
- kard/users/attributions/types/activate_offer_include_option.py +5 -0
- kard/users/attributions/types/activate_offer_included.py +8 -0
- kard/users/attributions/types/activate_offer_response.py +49 -0
- kard/users/attributions/types/activate_offer_response_attributes.py +25 -0
- kard/users/attributions/types/activate_offer_response_data.py +22 -0
- kard/users/attributions/types/event_code.py +1 -1
- kard/users/attributions/types/offer_medium.py +1 -1
- kard/users/rewards/__init__.py +12 -0
- kard/users/rewards/client.py +25 -8
- kard/users/rewards/raw_client.py +25 -8
- kard/users/rewards/types/__init__.py +12 -0
- kard/users/rewards/types/button_style.py +5 -0
- kard/users/rewards/types/component_type.py +7 -0
- kard/users/rewards/types/cta_component.py +34 -0
- kard/users/rewards/types/offer_common_fields.py +6 -0
- kard/users/rewards/types/offer_components.py +55 -0
- {kard_financial_sdk-2.0.0.dist-info → kard_financial_sdk-2.2.0.dist-info}/METADATA +1 -1
- {kard_financial_sdk-2.0.0.dist-info → kard_financial_sdk-2.2.0.dist-info}/RECORD +38 -25
- {kard_financial_sdk-2.0.0.dist-info → kard_financial_sdk-2.2.0.dist-info}/WHEEL +0 -0
kard/users/__init__.py
CHANGED
|
@@ -22,6 +22,11 @@ if typing.TYPE_CHECKING:
|
|
|
22
22
|
from .errors import MultiStatus
|
|
23
23
|
from . import attributions, auth, rewards, uploads
|
|
24
24
|
from .attributions import (
|
|
25
|
+
ActivateOfferIncludeOption,
|
|
26
|
+
ActivateOfferIncluded,
|
|
27
|
+
ActivateOfferResponse,
|
|
28
|
+
ActivateOfferResponseAttributes,
|
|
29
|
+
ActivateOfferResponseData,
|
|
25
30
|
CreateAttributionRequestObject,
|
|
26
31
|
CreateAttributionRequestUnion,
|
|
27
32
|
CreateAttributionRequestUnion_NotificationAttribution,
|
|
@@ -40,6 +45,7 @@ if typing.TYPE_CHECKING:
|
|
|
40
45
|
Amount,
|
|
41
46
|
AmountType,
|
|
42
47
|
Asset,
|
|
48
|
+
ButtonStyle,
|
|
43
49
|
CategoryData,
|
|
44
50
|
CategoryFields,
|
|
45
51
|
CategoryIdentifier,
|
|
@@ -47,7 +53,9 @@ if typing.TYPE_CHECKING:
|
|
|
47
53
|
CategoryRelationship,
|
|
48
54
|
CategoryRelationshipObject,
|
|
49
55
|
Commission,
|
|
56
|
+
ComponentType,
|
|
50
57
|
Coordinates,
|
|
58
|
+
CtaComponent,
|
|
51
59
|
EligibilityLocationAddress,
|
|
52
60
|
EligibilityLocationIncluded,
|
|
53
61
|
EligibilityOfferIncluded,
|
|
@@ -58,6 +66,7 @@ if typing.TYPE_CHECKING:
|
|
|
58
66
|
LocationSortOptions,
|
|
59
67
|
LocationsResponseObject,
|
|
60
68
|
OfferCommonFields,
|
|
69
|
+
OfferComponents,
|
|
61
70
|
OfferDataUnion,
|
|
62
71
|
OfferDataUnion_StandardOffer,
|
|
63
72
|
OfferRelationship,
|
|
@@ -98,9 +107,15 @@ if typing.TYPE_CHECKING:
|
|
|
98
107
|
UploadPartMultiStatus,
|
|
99
108
|
)
|
|
100
109
|
_dynamic_imports: typing.Dict[str, str] = {
|
|
110
|
+
"ActivateOfferIncludeOption": ".attributions",
|
|
111
|
+
"ActivateOfferIncluded": ".attributions",
|
|
112
|
+
"ActivateOfferResponse": ".attributions",
|
|
113
|
+
"ActivateOfferResponseAttributes": ".attributions",
|
|
114
|
+
"ActivateOfferResponseData": ".attributions",
|
|
101
115
|
"Amount": ".rewards",
|
|
102
116
|
"AmountType": ".rewards",
|
|
103
117
|
"Asset": ".rewards",
|
|
118
|
+
"ButtonStyle": ".rewards",
|
|
104
119
|
"CategoryData": ".rewards",
|
|
105
120
|
"CategoryFields": ".rewards",
|
|
106
121
|
"CategoryIdentifier": ".rewards",
|
|
@@ -108,6 +123,7 @@ _dynamic_imports: typing.Dict[str, str] = {
|
|
|
108
123
|
"CategoryRelationship": ".rewards",
|
|
109
124
|
"CategoryRelationshipObject": ".rewards",
|
|
110
125
|
"Commission": ".rewards",
|
|
126
|
+
"ComponentType": ".rewards",
|
|
111
127
|
"Coordinates": ".rewards",
|
|
112
128
|
"CreateAttributionRequestObject": ".attributions",
|
|
113
129
|
"CreateAttributionRequestUnion": ".attributions",
|
|
@@ -131,6 +147,7 @@ _dynamic_imports: typing.Dict[str, str] = {
|
|
|
131
147
|
"CreateUploadResponseObject": ".uploads",
|
|
132
148
|
"CreateUsersMultiStatusResponse": ".types",
|
|
133
149
|
"CreateUsersObject": ".types",
|
|
150
|
+
"CtaComponent": ".rewards",
|
|
134
151
|
"DeleteUserResponseObject": ".types",
|
|
135
152
|
"EligibilityLocationAddress": ".rewards",
|
|
136
153
|
"EligibilityLocationIncluded": ".rewards",
|
|
@@ -150,6 +167,7 @@ _dynamic_imports: typing.Dict[str, str] = {
|
|
|
150
167
|
"OfferAttributionAttributes": ".attributions",
|
|
151
168
|
"OfferAttributionRequest": ".attributions",
|
|
152
169
|
"OfferCommonFields": ".rewards",
|
|
170
|
+
"OfferComponents": ".rewards",
|
|
153
171
|
"OfferDataUnion": ".rewards",
|
|
154
172
|
"OfferDataUnion_StandardOffer": ".rewards",
|
|
155
173
|
"OfferMedium": ".attributions",
|
|
@@ -209,9 +227,15 @@ def __dir__():
|
|
|
209
227
|
|
|
210
228
|
|
|
211
229
|
__all__ = [
|
|
230
|
+
"ActivateOfferIncludeOption",
|
|
231
|
+
"ActivateOfferIncluded",
|
|
232
|
+
"ActivateOfferResponse",
|
|
233
|
+
"ActivateOfferResponseAttributes",
|
|
234
|
+
"ActivateOfferResponseData",
|
|
212
235
|
"Amount",
|
|
213
236
|
"AmountType",
|
|
214
237
|
"Asset",
|
|
238
|
+
"ButtonStyle",
|
|
215
239
|
"CategoryData",
|
|
216
240
|
"CategoryFields",
|
|
217
241
|
"CategoryIdentifier",
|
|
@@ -219,6 +243,7 @@ __all__ = [
|
|
|
219
243
|
"CategoryRelationship",
|
|
220
244
|
"CategoryRelationshipObject",
|
|
221
245
|
"Commission",
|
|
246
|
+
"ComponentType",
|
|
222
247
|
"Coordinates",
|
|
223
248
|
"CreateAttributionRequestObject",
|
|
224
249
|
"CreateAttributionRequestUnion",
|
|
@@ -242,6 +267,7 @@ __all__ = [
|
|
|
242
267
|
"CreateUploadResponseObject",
|
|
243
268
|
"CreateUsersMultiStatusResponse",
|
|
244
269
|
"CreateUsersObject",
|
|
270
|
+
"CtaComponent",
|
|
245
271
|
"DeleteUserResponseObject",
|
|
246
272
|
"EligibilityLocationAddress",
|
|
247
273
|
"EligibilityLocationIncluded",
|
|
@@ -261,6 +287,7 @@ __all__ = [
|
|
|
261
287
|
"OfferAttributionAttributes",
|
|
262
288
|
"OfferAttributionRequest",
|
|
263
289
|
"OfferCommonFields",
|
|
290
|
+
"OfferComponents",
|
|
264
291
|
"OfferDataUnion",
|
|
265
292
|
"OfferDataUnion_StandardOffer",
|
|
266
293
|
"OfferMedium",
|
|
@@ -7,6 +7,11 @@ from importlib import import_module
|
|
|
7
7
|
|
|
8
8
|
if typing.TYPE_CHECKING:
|
|
9
9
|
from .types import (
|
|
10
|
+
ActivateOfferIncludeOption,
|
|
11
|
+
ActivateOfferIncluded,
|
|
12
|
+
ActivateOfferResponse,
|
|
13
|
+
ActivateOfferResponseAttributes,
|
|
14
|
+
ActivateOfferResponseData,
|
|
10
15
|
CreateAttributionRequestObject,
|
|
11
16
|
CreateAttributionRequestUnion,
|
|
12
17
|
CreateAttributionRequestUnion_NotificationAttribution,
|
|
@@ -21,6 +26,11 @@ if typing.TYPE_CHECKING:
|
|
|
21
26
|
OfferMedium,
|
|
22
27
|
)
|
|
23
28
|
_dynamic_imports: typing.Dict[str, str] = {
|
|
29
|
+
"ActivateOfferIncludeOption": ".types",
|
|
30
|
+
"ActivateOfferIncluded": ".types",
|
|
31
|
+
"ActivateOfferResponse": ".types",
|
|
32
|
+
"ActivateOfferResponseAttributes": ".types",
|
|
33
|
+
"ActivateOfferResponseData": ".types",
|
|
24
34
|
"CreateAttributionRequestObject": ".types",
|
|
25
35
|
"CreateAttributionRequestUnion": ".types",
|
|
26
36
|
"CreateAttributionRequestUnion_NotificationAttribution": ".types",
|
|
@@ -58,6 +68,11 @@ def __dir__():
|
|
|
58
68
|
|
|
59
69
|
|
|
60
70
|
__all__ = [
|
|
71
|
+
"ActivateOfferIncludeOption",
|
|
72
|
+
"ActivateOfferIncluded",
|
|
73
|
+
"ActivateOfferResponse",
|
|
74
|
+
"ActivateOfferResponseAttributes",
|
|
75
|
+
"ActivateOfferResponseData",
|
|
61
76
|
"CreateAttributionRequestObject",
|
|
62
77
|
"CreateAttributionRequestUnion",
|
|
63
78
|
"CreateAttributionRequestUnion_NotificationAttribution",
|
|
@@ -6,7 +6,10 @@ from ...commons.types.organization_id import OrganizationId
|
|
|
6
6
|
from ...commons.types.user_id import UserId
|
|
7
7
|
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
8
|
from ...core.request_options import RequestOptions
|
|
9
|
+
from ..rewards.types.component_type import ComponentType
|
|
9
10
|
from .raw_client import AsyncRawAttributionsClient, RawAttributionsClient
|
|
11
|
+
from .types.activate_offer_include_option import ActivateOfferIncludeOption
|
|
12
|
+
from .types.activate_offer_response import ActivateOfferResponse
|
|
10
13
|
from .types.create_attribution_request_union import CreateAttributionRequestUnion
|
|
11
14
|
from .types.create_attribution_response import CreateAttributionResponse
|
|
12
15
|
|
|
@@ -117,6 +120,68 @@ class AttributionsClient:
|
|
|
117
120
|
_response = self._raw_client.create(organization_id, user_id, data=data, request_options=request_options)
|
|
118
121
|
return _response.data
|
|
119
122
|
|
|
123
|
+
def activate(
|
|
124
|
+
self,
|
|
125
|
+
organization_id: OrganizationId,
|
|
126
|
+
user_id: UserId,
|
|
127
|
+
offer_id: str,
|
|
128
|
+
*,
|
|
129
|
+
supported_components: typing.Optional[typing.Union[ComponentType, typing.Sequence[ComponentType]]] = None,
|
|
130
|
+
include: typing.Optional[
|
|
131
|
+
typing.Union[ActivateOfferIncludeOption, typing.Sequence[ActivateOfferIncludeOption]]
|
|
132
|
+
] = None,
|
|
133
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
134
|
+
) -> ActivateOfferResponse:
|
|
135
|
+
"""
|
|
136
|
+
Record when a user activates an offer. Creates an attribution event with eventCode=ACTIVATE and medium=CTA.
|
|
137
|
+
Optionally include the offer data by passing `include=offer`.
|
|
138
|
+
|
|
139
|
+
Parameters
|
|
140
|
+
----------
|
|
141
|
+
organization_id : OrganizationId
|
|
142
|
+
|
|
143
|
+
user_id : UserId
|
|
144
|
+
|
|
145
|
+
offer_id : str
|
|
146
|
+
The unique identifier of the offer being activated
|
|
147
|
+
|
|
148
|
+
supported_components : typing.Optional[typing.Union[ComponentType, typing.Sequence[ComponentType]]]
|
|
149
|
+
UI component types to include in the offer response (when include=offer).
|
|
150
|
+
|
|
151
|
+
include : typing.Optional[typing.Union[ActivateOfferIncludeOption, typing.Sequence[ActivateOfferIncludeOption]]]
|
|
152
|
+
Related resources to include in the response. Allowed value is `offer`.
|
|
153
|
+
|
|
154
|
+
request_options : typing.Optional[RequestOptions]
|
|
155
|
+
Request-specific configuration.
|
|
156
|
+
|
|
157
|
+
Returns
|
|
158
|
+
-------
|
|
159
|
+
ActivateOfferResponse
|
|
160
|
+
|
|
161
|
+
Examples
|
|
162
|
+
--------
|
|
163
|
+
from kard import KardApi
|
|
164
|
+
|
|
165
|
+
client = KardApi(
|
|
166
|
+
client_id="YOUR_CLIENT_ID",
|
|
167
|
+
client_secret="YOUR_CLIENT_SECRET",
|
|
168
|
+
)
|
|
169
|
+
client.users.attributions.activate(
|
|
170
|
+
organization_id="organization-123",
|
|
171
|
+
user_id="user-123",
|
|
172
|
+
offer_id="offer-456",
|
|
173
|
+
)
|
|
174
|
+
"""
|
|
175
|
+
_response = self._raw_client.activate(
|
|
176
|
+
organization_id,
|
|
177
|
+
user_id,
|
|
178
|
+
offer_id,
|
|
179
|
+
supported_components=supported_components,
|
|
180
|
+
include=include,
|
|
181
|
+
request_options=request_options,
|
|
182
|
+
)
|
|
183
|
+
return _response.data
|
|
184
|
+
|
|
120
185
|
|
|
121
186
|
class AsyncAttributionsClient:
|
|
122
187
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -227,3 +292,73 @@ class AsyncAttributionsClient:
|
|
|
227
292
|
"""
|
|
228
293
|
_response = await self._raw_client.create(organization_id, user_id, data=data, request_options=request_options)
|
|
229
294
|
return _response.data
|
|
295
|
+
|
|
296
|
+
async def activate(
|
|
297
|
+
self,
|
|
298
|
+
organization_id: OrganizationId,
|
|
299
|
+
user_id: UserId,
|
|
300
|
+
offer_id: str,
|
|
301
|
+
*,
|
|
302
|
+
supported_components: typing.Optional[typing.Union[ComponentType, typing.Sequence[ComponentType]]] = None,
|
|
303
|
+
include: typing.Optional[
|
|
304
|
+
typing.Union[ActivateOfferIncludeOption, typing.Sequence[ActivateOfferIncludeOption]]
|
|
305
|
+
] = None,
|
|
306
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
307
|
+
) -> ActivateOfferResponse:
|
|
308
|
+
"""
|
|
309
|
+
Record when a user activates an offer. Creates an attribution event with eventCode=ACTIVATE and medium=CTA.
|
|
310
|
+
Optionally include the offer data by passing `include=offer`.
|
|
311
|
+
|
|
312
|
+
Parameters
|
|
313
|
+
----------
|
|
314
|
+
organization_id : OrganizationId
|
|
315
|
+
|
|
316
|
+
user_id : UserId
|
|
317
|
+
|
|
318
|
+
offer_id : str
|
|
319
|
+
The unique identifier of the offer being activated
|
|
320
|
+
|
|
321
|
+
supported_components : typing.Optional[typing.Union[ComponentType, typing.Sequence[ComponentType]]]
|
|
322
|
+
UI component types to include in the offer response (when include=offer).
|
|
323
|
+
|
|
324
|
+
include : typing.Optional[typing.Union[ActivateOfferIncludeOption, typing.Sequence[ActivateOfferIncludeOption]]]
|
|
325
|
+
Related resources to include in the response. Allowed value is `offer`.
|
|
326
|
+
|
|
327
|
+
request_options : typing.Optional[RequestOptions]
|
|
328
|
+
Request-specific configuration.
|
|
329
|
+
|
|
330
|
+
Returns
|
|
331
|
+
-------
|
|
332
|
+
ActivateOfferResponse
|
|
333
|
+
|
|
334
|
+
Examples
|
|
335
|
+
--------
|
|
336
|
+
import asyncio
|
|
337
|
+
|
|
338
|
+
from kard import AsyncKardApi
|
|
339
|
+
|
|
340
|
+
client = AsyncKardApi(
|
|
341
|
+
client_id="YOUR_CLIENT_ID",
|
|
342
|
+
client_secret="YOUR_CLIENT_SECRET",
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
async def main() -> None:
|
|
347
|
+
await client.users.attributions.activate(
|
|
348
|
+
organization_id="organization-123",
|
|
349
|
+
user_id="user-123",
|
|
350
|
+
offer_id="offer-456",
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
asyncio.run(main())
|
|
355
|
+
"""
|
|
356
|
+
_response = await self._raw_client.activate(
|
|
357
|
+
organization_id,
|
|
358
|
+
user_id,
|
|
359
|
+
offer_id,
|
|
360
|
+
supported_components=supported_components,
|
|
361
|
+
include=include,
|
|
362
|
+
request_options=request_options,
|
|
363
|
+
)
|
|
364
|
+
return _response.data
|
|
@@ -16,6 +16,9 @@ from ...core.jsonable_encoder import jsonable_encoder
|
|
|
16
16
|
from ...core.pydantic_utilities import parse_obj_as
|
|
17
17
|
from ...core.request_options import RequestOptions
|
|
18
18
|
from ...core.serialization import convert_and_respect_annotation_metadata
|
|
19
|
+
from ..rewards.types.component_type import ComponentType
|
|
20
|
+
from .types.activate_offer_include_option import ActivateOfferIncludeOption
|
|
21
|
+
from .types.activate_offer_response import ActivateOfferResponse
|
|
19
22
|
from .types.create_attribution_request_union import CreateAttributionRequestUnion
|
|
20
23
|
from .types.create_attribution_response import CreateAttributionResponse
|
|
21
24
|
|
|
@@ -118,6 +121,101 @@ class RawAttributionsClient:
|
|
|
118
121
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
119
122
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
120
123
|
|
|
124
|
+
def activate(
|
|
125
|
+
self,
|
|
126
|
+
organization_id: OrganizationId,
|
|
127
|
+
user_id: UserId,
|
|
128
|
+
offer_id: str,
|
|
129
|
+
*,
|
|
130
|
+
supported_components: typing.Optional[typing.Union[ComponentType, typing.Sequence[ComponentType]]] = None,
|
|
131
|
+
include: typing.Optional[
|
|
132
|
+
typing.Union[ActivateOfferIncludeOption, typing.Sequence[ActivateOfferIncludeOption]]
|
|
133
|
+
] = None,
|
|
134
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
135
|
+
) -> HttpResponse[ActivateOfferResponse]:
|
|
136
|
+
"""
|
|
137
|
+
Record when a user activates an offer. Creates an attribution event with eventCode=ACTIVATE and medium=CTA.
|
|
138
|
+
Optionally include the offer data by passing `include=offer`.
|
|
139
|
+
|
|
140
|
+
Parameters
|
|
141
|
+
----------
|
|
142
|
+
organization_id : OrganizationId
|
|
143
|
+
|
|
144
|
+
user_id : UserId
|
|
145
|
+
|
|
146
|
+
offer_id : str
|
|
147
|
+
The unique identifier of the offer being activated
|
|
148
|
+
|
|
149
|
+
supported_components : typing.Optional[typing.Union[ComponentType, typing.Sequence[ComponentType]]]
|
|
150
|
+
UI component types to include in the offer response (when include=offer).
|
|
151
|
+
|
|
152
|
+
include : typing.Optional[typing.Union[ActivateOfferIncludeOption, typing.Sequence[ActivateOfferIncludeOption]]]
|
|
153
|
+
Related resources to include in the response. Allowed value is `offer`.
|
|
154
|
+
|
|
155
|
+
request_options : typing.Optional[RequestOptions]
|
|
156
|
+
Request-specific configuration.
|
|
157
|
+
|
|
158
|
+
Returns
|
|
159
|
+
-------
|
|
160
|
+
HttpResponse[ActivateOfferResponse]
|
|
161
|
+
"""
|
|
162
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
163
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/offers/{jsonable_encoder(offer_id)}/activate",
|
|
164
|
+
method="POST",
|
|
165
|
+
params={
|
|
166
|
+
"supportedComponents": supported_components,
|
|
167
|
+
"include": include,
|
|
168
|
+
},
|
|
169
|
+
request_options=request_options,
|
|
170
|
+
)
|
|
171
|
+
try:
|
|
172
|
+
if 200 <= _response.status_code < 300:
|
|
173
|
+
_data = typing.cast(
|
|
174
|
+
ActivateOfferResponse,
|
|
175
|
+
parse_obj_as(
|
|
176
|
+
type_=ActivateOfferResponse, # type: ignore
|
|
177
|
+
object_=_response.json(),
|
|
178
|
+
),
|
|
179
|
+
)
|
|
180
|
+
return HttpResponse(response=_response, data=_data)
|
|
181
|
+
if _response.status_code == 401:
|
|
182
|
+
raise UnauthorizedError(
|
|
183
|
+
headers=dict(_response.headers),
|
|
184
|
+
body=typing.cast(
|
|
185
|
+
ErrorResponse,
|
|
186
|
+
parse_obj_as(
|
|
187
|
+
type_=ErrorResponse, # type: ignore
|
|
188
|
+
object_=_response.json(),
|
|
189
|
+
),
|
|
190
|
+
),
|
|
191
|
+
)
|
|
192
|
+
if _response.status_code == 500:
|
|
193
|
+
raise InternalServerError(
|
|
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
|
+
_response_json = _response.json()
|
|
215
|
+
except JSONDecodeError:
|
|
216
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
217
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
218
|
+
|
|
121
219
|
|
|
122
220
|
class AsyncRawAttributionsClient:
|
|
123
221
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -213,3 +311,98 @@ class AsyncRawAttributionsClient:
|
|
|
213
311
|
except JSONDecodeError:
|
|
214
312
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
215
313
|
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
314
|
+
|
|
315
|
+
async def activate(
|
|
316
|
+
self,
|
|
317
|
+
organization_id: OrganizationId,
|
|
318
|
+
user_id: UserId,
|
|
319
|
+
offer_id: str,
|
|
320
|
+
*,
|
|
321
|
+
supported_components: typing.Optional[typing.Union[ComponentType, typing.Sequence[ComponentType]]] = None,
|
|
322
|
+
include: typing.Optional[
|
|
323
|
+
typing.Union[ActivateOfferIncludeOption, typing.Sequence[ActivateOfferIncludeOption]]
|
|
324
|
+
] = None,
|
|
325
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
326
|
+
) -> AsyncHttpResponse[ActivateOfferResponse]:
|
|
327
|
+
"""
|
|
328
|
+
Record when a user activates an offer. Creates an attribution event with eventCode=ACTIVATE and medium=CTA.
|
|
329
|
+
Optionally include the offer data by passing `include=offer`.
|
|
330
|
+
|
|
331
|
+
Parameters
|
|
332
|
+
----------
|
|
333
|
+
organization_id : OrganizationId
|
|
334
|
+
|
|
335
|
+
user_id : UserId
|
|
336
|
+
|
|
337
|
+
offer_id : str
|
|
338
|
+
The unique identifier of the offer being activated
|
|
339
|
+
|
|
340
|
+
supported_components : typing.Optional[typing.Union[ComponentType, typing.Sequence[ComponentType]]]
|
|
341
|
+
UI component types to include in the offer response (when include=offer).
|
|
342
|
+
|
|
343
|
+
include : typing.Optional[typing.Union[ActivateOfferIncludeOption, typing.Sequence[ActivateOfferIncludeOption]]]
|
|
344
|
+
Related resources to include in the response. Allowed value is `offer`.
|
|
345
|
+
|
|
346
|
+
request_options : typing.Optional[RequestOptions]
|
|
347
|
+
Request-specific configuration.
|
|
348
|
+
|
|
349
|
+
Returns
|
|
350
|
+
-------
|
|
351
|
+
AsyncHttpResponse[ActivateOfferResponse]
|
|
352
|
+
"""
|
|
353
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
354
|
+
f"v2/issuers/{jsonable_encoder(organization_id)}/users/{jsonable_encoder(user_id)}/offers/{jsonable_encoder(offer_id)}/activate",
|
|
355
|
+
method="POST",
|
|
356
|
+
params={
|
|
357
|
+
"supportedComponents": supported_components,
|
|
358
|
+
"include": include,
|
|
359
|
+
},
|
|
360
|
+
request_options=request_options,
|
|
361
|
+
)
|
|
362
|
+
try:
|
|
363
|
+
if 200 <= _response.status_code < 300:
|
|
364
|
+
_data = typing.cast(
|
|
365
|
+
ActivateOfferResponse,
|
|
366
|
+
parse_obj_as(
|
|
367
|
+
type_=ActivateOfferResponse, # type: ignore
|
|
368
|
+
object_=_response.json(),
|
|
369
|
+
),
|
|
370
|
+
)
|
|
371
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
372
|
+
if _response.status_code == 401:
|
|
373
|
+
raise UnauthorizedError(
|
|
374
|
+
headers=dict(_response.headers),
|
|
375
|
+
body=typing.cast(
|
|
376
|
+
ErrorResponse,
|
|
377
|
+
parse_obj_as(
|
|
378
|
+
type_=ErrorResponse, # type: ignore
|
|
379
|
+
object_=_response.json(),
|
|
380
|
+
),
|
|
381
|
+
),
|
|
382
|
+
)
|
|
383
|
+
if _response.status_code == 500:
|
|
384
|
+
raise InternalServerError(
|
|
385
|
+
headers=dict(_response.headers),
|
|
386
|
+
body=typing.cast(
|
|
387
|
+
ErrorResponse,
|
|
388
|
+
parse_obj_as(
|
|
389
|
+
type_=ErrorResponse, # type: ignore
|
|
390
|
+
object_=_response.json(),
|
|
391
|
+
),
|
|
392
|
+
),
|
|
393
|
+
)
|
|
394
|
+
if _response.status_code == 400:
|
|
395
|
+
raise InvalidRequest(
|
|
396
|
+
headers=dict(_response.headers),
|
|
397
|
+
body=typing.cast(
|
|
398
|
+
ErrorResponse,
|
|
399
|
+
parse_obj_as(
|
|
400
|
+
type_=ErrorResponse, # type: ignore
|
|
401
|
+
object_=_response.json(),
|
|
402
|
+
),
|
|
403
|
+
),
|
|
404
|
+
)
|
|
405
|
+
_response_json = _response.json()
|
|
406
|
+
except JSONDecodeError:
|
|
407
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
408
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
@@ -6,6 +6,11 @@ import typing
|
|
|
6
6
|
from importlib import import_module
|
|
7
7
|
|
|
8
8
|
if typing.TYPE_CHECKING:
|
|
9
|
+
from .activate_offer_include_option import ActivateOfferIncludeOption
|
|
10
|
+
from .activate_offer_included import ActivateOfferIncluded
|
|
11
|
+
from .activate_offer_response import ActivateOfferResponse
|
|
12
|
+
from .activate_offer_response_attributes import ActivateOfferResponseAttributes
|
|
13
|
+
from .activate_offer_response_data import ActivateOfferResponseData
|
|
9
14
|
from .create_attribution_request_object import CreateAttributionRequestObject
|
|
10
15
|
from .create_attribution_request_union import (
|
|
11
16
|
CreateAttributionRequestUnion,
|
|
@@ -21,6 +26,11 @@ if typing.TYPE_CHECKING:
|
|
|
21
26
|
from .offer_attribution_request import OfferAttributionRequest
|
|
22
27
|
from .offer_medium import OfferMedium
|
|
23
28
|
_dynamic_imports: typing.Dict[str, str] = {
|
|
29
|
+
"ActivateOfferIncludeOption": ".activate_offer_include_option",
|
|
30
|
+
"ActivateOfferIncluded": ".activate_offer_included",
|
|
31
|
+
"ActivateOfferResponse": ".activate_offer_response",
|
|
32
|
+
"ActivateOfferResponseAttributes": ".activate_offer_response_attributes",
|
|
33
|
+
"ActivateOfferResponseData": ".activate_offer_response_data",
|
|
24
34
|
"CreateAttributionRequestObject": ".create_attribution_request_object",
|
|
25
35
|
"CreateAttributionRequestUnion": ".create_attribution_request_union",
|
|
26
36
|
"CreateAttributionRequestUnion_NotificationAttribution": ".create_attribution_request_union",
|
|
@@ -58,6 +68,11 @@ def __dir__():
|
|
|
58
68
|
|
|
59
69
|
|
|
60
70
|
__all__ = [
|
|
71
|
+
"ActivateOfferIncludeOption",
|
|
72
|
+
"ActivateOfferIncluded",
|
|
73
|
+
"ActivateOfferResponse",
|
|
74
|
+
"ActivateOfferResponseAttributes",
|
|
75
|
+
"ActivateOfferResponseData",
|
|
61
76
|
"CreateAttributionRequestObject",
|
|
62
77
|
"CreateAttributionRequestUnion",
|
|
63
78
|
"CreateAttributionRequestUnion_NotificationAttribution",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ...rewards.types.category_included import CategoryIncluded
|
|
6
|
+
from ...rewards.types.offer_data_union import OfferDataUnion
|
|
7
|
+
|
|
8
|
+
ActivateOfferIncluded = typing.Union[OfferDataUnion, CategoryIncluded]
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
from .activate_offer_included import ActivateOfferIncluded
|
|
8
|
+
from .activate_offer_response_data import ActivateOfferResponseData
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ActivateOfferResponse(UniversalBaseModel):
|
|
12
|
+
"""
|
|
13
|
+
Examples
|
|
14
|
+
--------
|
|
15
|
+
import datetime
|
|
16
|
+
|
|
17
|
+
from kard.users.attributions import (
|
|
18
|
+
ActivateOfferResponse,
|
|
19
|
+
ActivateOfferResponseAttributes,
|
|
20
|
+
ActivateOfferResponseData,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
ActivateOfferResponse(
|
|
24
|
+
data=ActivateOfferResponseData(
|
|
25
|
+
type="offerAttribution",
|
|
26
|
+
id="c94a93a7-beb9-4e58-960c-2c812f849398",
|
|
27
|
+
attributes=ActivateOfferResponseAttributes(
|
|
28
|
+
entity_id="offer-456",
|
|
29
|
+
event_code="ACTIVATE",
|
|
30
|
+
medium="CTA",
|
|
31
|
+
event_date=datetime.datetime.fromisoformat(
|
|
32
|
+
"2025-01-01 00:00:00+00:00",
|
|
33
|
+
),
|
|
34
|
+
),
|
|
35
|
+
),
|
|
36
|
+
)
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
data: ActivateOfferResponseData
|
|
40
|
+
included: typing.Optional[typing.List[ActivateOfferIncluded]] = None
|
|
41
|
+
|
|
42
|
+
if IS_PYDANTIC_V2:
|
|
43
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
44
|
+
else:
|
|
45
|
+
|
|
46
|
+
class Config:
|
|
47
|
+
frozen = True
|
|
48
|
+
smart_union = True
|
|
49
|
+
extra = pydantic.Extra.allow
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import datetime as dt
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
import pydantic
|
|
7
|
+
import typing_extensions
|
|
8
|
+
from ....core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
|
|
9
|
+
from ....core.serialization import FieldMetadata
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ActivateOfferResponseAttributes(UniversalBaseModel):
|
|
13
|
+
entity_id: typing_extensions.Annotated[str, FieldMetadata(alias="entityId")]
|
|
14
|
+
event_code: typing_extensions.Annotated[str, FieldMetadata(alias="eventCode")]
|
|
15
|
+
medium: str
|
|
16
|
+
event_date: typing_extensions.Annotated[dt.datetime, FieldMetadata(alias="eventDate")]
|
|
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
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
from .activate_offer_response_attributes import ActivateOfferResponseAttributes
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ActivateOfferResponseData(UniversalBaseModel):
|
|
11
|
+
type: str
|
|
12
|
+
id: str
|
|
13
|
+
attributes: ActivateOfferResponseAttributes
|
|
14
|
+
|
|
15
|
+
if IS_PYDANTIC_V2:
|
|
16
|
+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
17
|
+
else:
|
|
18
|
+
|
|
19
|
+
class Config:
|
|
20
|
+
frozen = True
|
|
21
|
+
smart_union = True
|
|
22
|
+
extra = pydantic.Extra.allow
|