dub 0.32.0__py3-none-any.whl → 0.34.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.
Files changed (70) hide show
  1. dub/_version.py +3 -3
  2. dub/analytics.py +6 -4
  3. dub/basesdk.py +6 -0
  4. dub/commissions.py +12 -8
  5. dub/customers.py +24 -313
  6. dub/domains.py +34 -26
  7. dub/embed_tokens.py +6 -4
  8. dub/events.py +6 -4
  9. dub/folders.py +24 -20
  10. dub/links.py +58 -54
  11. dub/models/components/__init__.py +81 -149
  12. dub/models/components/analyticstopurls.py +2 -2
  13. dub/models/components/leadcreatedevent.py +15 -14
  14. dub/models/components/linkclickedevent.py +19 -18
  15. dub/models/components/linkerrorschema.py +12 -12
  16. dub/models/components/linkschema.py +9 -3
  17. dub/models/components/linktagschema.py +3 -3
  18. dub/models/components/linktagschemaoutput.py +38 -0
  19. dub/models/components/linkwebhookevent.py +15 -16
  20. dub/models/components/partnerapplicationsubmittedevent.py +269 -0
  21. dub/models/components/partnerenrolledevent.py +68 -8
  22. dub/models/components/salecreatedevent.py +15 -14
  23. dub/models/components/webhookevent.py +6 -0
  24. dub/models/components/workspaceschema.py +6 -0
  25. dub/models/operations/__init__.py +147 -57
  26. dub/models/operations/banpartner.py +83 -0
  27. dub/models/operations/createpartner.py +68 -59
  28. dub/models/operations/createpartnerlink.py +0 -51
  29. dub/models/operations/createreferralsembedtoken.py +0 -51
  30. dub/models/operations/getcustomers.py +18 -0
  31. dub/models/operations/getlinkinfo.py +0 -2
  32. dub/models/operations/getlinks.py +2 -2
  33. dub/models/operations/getlinkscount.py +2 -2
  34. dub/models/operations/getqrcode.py +1 -1
  35. dub/models/operations/listcommissions.py +13 -2
  36. dub/models/operations/listdomains.py +1 -1
  37. dub/models/operations/listevents.py +2026 -21
  38. dub/models/operations/listpartners.py +75 -8
  39. dub/models/operations/retrieveanalytics.py +28 -5
  40. dub/models/operations/retrievelinks.py +44 -9
  41. dub/models/operations/retrievepartneranalytics.py +51 -11
  42. dub/models/operations/tracklead.py +4 -4
  43. dub/models/operations/updatecommission.py +7 -2
  44. dub/models/operations/updatecustomer.py +23 -11
  45. dub/models/operations/updatelink.py +0 -2
  46. dub/models/operations/updateworkspace.py +3 -3
  47. dub/models/operations/upsertpartnerlink.py +0 -51
  48. dub/partners.py +316 -24
  49. dub/qr_codes.py +4 -2
  50. dub/tags.py +24 -20
  51. dub/track.py +12 -16
  52. dub/types/basemodel.py +41 -3
  53. dub/utils/__init__.py +0 -3
  54. dub/utils/enums.py +60 -0
  55. dub/utils/forms.py +21 -10
  56. dub/utils/queryparams.py +14 -2
  57. dub/utils/requestbodies.py +3 -3
  58. dub/utils/retries.py +69 -5
  59. dub/utils/serializers.py +0 -20
  60. dub/utils/unmarshal_json_response.py +15 -1
  61. dub/workspaces.py +12 -16
  62. {dub-0.32.0.dist-info → dub-0.34.0.dist-info}/METADATA +15 -33
  63. {dub-0.32.0.dist-info → dub-0.34.0.dist-info}/RECORD +65 -67
  64. dub/models/components/clickevent.py +0 -556
  65. dub/models/components/continentcode.py +0 -16
  66. dub/models/components/leadevent.py +0 -680
  67. dub/models/components/saleevent.py +0 -779
  68. dub/models/operations/createcustomer.py +0 -382
  69. {dub-0.32.0.dist-info → dub-0.34.0.dist-info}/WHEEL +0 -0
  70. {dub-0.32.0.dist-info → dub-0.34.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,779 +0,0 @@
1
- """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
-
3
- from __future__ import annotations
4
- from .linktagschema import LinkTagSchema, LinkTagSchemaTypedDict
5
- from dub.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
6
- from enum import Enum
7
- import pydantic
8
- from pydantic import model_serializer
9
- from typing import Any, Dict, List, Optional
10
- from typing_extensions import Annotated, NotRequired, TypedDict
11
-
12
-
13
- class SaleEventEvent(str, Enum):
14
- SALE = "sale"
15
-
16
-
17
- class PaymentProcessor(str, Enum):
18
- r"""The payment processor via which the sale was made."""
19
-
20
- STRIPE = "stripe"
21
- SHOPIFY = "shopify"
22
- POLAR = "polar"
23
- PADDLE = "paddle"
24
- REVENUECAT = "revenuecat"
25
- CUSTOM = "custom"
26
-
27
-
28
- class SaleTypedDict(TypedDict):
29
- amount: int
30
- r"""The amount of the sale in cents (for all two-decimal currencies). If the sale is in a zero-decimal currency, pass the full integer value (e.g. `1437` JPY). Learn more: https://d.to/currency"""
31
- invoice_id: NotRequired[Nullable[str]]
32
- r"""The invoice ID of the sale. Can be used as a idempotency key – only one sale event can be recorded for a given invoice ID."""
33
- payment_processor: NotRequired[PaymentProcessor]
34
- r"""The payment processor via which the sale was made."""
35
-
36
-
37
- class Sale(BaseModel):
38
- amount: int
39
- r"""The amount of the sale in cents (for all two-decimal currencies). If the sale is in a zero-decimal currency, pass the full integer value (e.g. `1437` JPY). Learn more: https://d.to/currency"""
40
-
41
- invoice_id: Annotated[OptionalNullable[str], pydantic.Field(alias="invoiceId")] = (
42
- None
43
- )
44
- r"""The invoice ID of the sale. Can be used as a idempotency key – only one sale event can be recorded for a given invoice ID."""
45
-
46
- payment_processor: Annotated[
47
- Optional[PaymentProcessor], pydantic.Field(alias="paymentProcessor")
48
- ] = PaymentProcessor.CUSTOM
49
- r"""The payment processor via which the sale was made."""
50
-
51
- @model_serializer(mode="wrap")
52
- def serialize_model(self, handler):
53
- optional_fields = ["invoiceId", "paymentProcessor"]
54
- nullable_fields = ["invoiceId"]
55
- null_default_fields = ["invoiceId"]
56
-
57
- serialized = handler(self)
58
-
59
- m = {}
60
-
61
- for n, f in type(self).model_fields.items():
62
- k = f.alias or n
63
- val = serialized.get(k)
64
- serialized.pop(k, None)
65
-
66
- optional_nullable = k in optional_fields and k in nullable_fields
67
- is_set = (
68
- self.__pydantic_fields_set__.intersection({n})
69
- or k in null_default_fields
70
- ) # pylint: disable=no-member
71
-
72
- if val is not None and val != UNSET_SENTINEL:
73
- m[k] = val
74
- elif val != UNSET_SENTINEL and (
75
- not k in optional_fields or (optional_nullable and is_set)
76
- ):
77
- m[k] = val
78
-
79
- return m
80
-
81
-
82
- class SaleEventTestVariantsTypedDict(TypedDict):
83
- url: str
84
- percentage: float
85
-
86
-
87
- class SaleEventTestVariants(BaseModel):
88
- url: str
89
-
90
- percentage: float
91
-
92
-
93
- class SaleEventLinkTypedDict(TypedDict):
94
- id: str
95
- r"""The unique ID of the short link."""
96
- domain: str
97
- r"""The domain of the short link. If not provided, the primary domain for the workspace will be used (or `dub.sh` if the workspace has no domains)."""
98
- key: str
99
- r"""The short link slug. If not provided, a random 7-character slug will be generated."""
100
- url: str
101
- track_conversion: bool
102
- external_id: Nullable[str]
103
- r"""The ID of the link in your database. If set, it can be used to identify the link in future API requests (must be prefixed with 'ext_' when passed as a query parameter). This key is unique across your workspace."""
104
- tenant_id: Nullable[str]
105
- r"""The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant."""
106
- program_id: Nullable[str]
107
- r"""The ID of the program the short link is associated with."""
108
- partner_id: Nullable[str]
109
- r"""The ID of the partner the short link is associated with."""
110
- archived: bool
111
- expires_at: str
112
- expired_url: Nullable[str]
113
- password: Nullable[str]
114
- r"""The password required to access the destination URL of the short link."""
115
- proxy: bool
116
- title: Nullable[str]
117
- r"""The title of the short link. Will be used for Custom Link Previews if `proxy` is true."""
118
- description: Nullable[str]
119
- r"""The description of the short link. Will be used for Custom Link Previews if `proxy` is true."""
120
- image: Nullable[str]
121
- r"""The image of the short link. Will be used for Custom Link Previews if `proxy` is true."""
122
- video: Nullable[str]
123
- r"""The custom link preview video (og:video). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og"""
124
- rewrite: bool
125
- do_index: bool
126
- ios: Nullable[str]
127
- r"""The iOS destination URL for the short link for iOS device targeting."""
128
- android: Nullable[str]
129
- r"""The Android destination URL for the short link for Android device targeting."""
130
- geo: Nullable[Dict[str, str]]
131
- r"""Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. See https://d.to/geo for more information."""
132
- public_stats: bool
133
- tags: Nullable[List[LinkTagSchemaTypedDict]]
134
- r"""The tags assigned to the short link."""
135
- folder_id: Nullable[str]
136
- r"""The unique ID of the folder assigned to the short link."""
137
- webhook_ids: List[str]
138
- r"""The IDs of the webhooks that the short link is associated with."""
139
- comments: Nullable[str]
140
- r"""The comments for the short link."""
141
- short_link: str
142
- r"""The full URL of the short link, including the https protocol (e.g. `https://dub.sh/try`)."""
143
- qr_code: str
144
- r"""The full URL of the QR code for the short link (e.g. `https://api.dub.co/qr?url=https://dub.sh/try`)."""
145
- utm_source: Nullable[str]
146
- r"""The UTM source of the short link."""
147
- utm_medium: Nullable[str]
148
- r"""The UTM medium of the short link."""
149
- utm_campaign: Nullable[str]
150
- r"""The UTM campaign of the short link."""
151
- utm_term: Nullable[str]
152
- r"""The UTM term of the short link."""
153
- utm_content: Nullable[str]
154
- r"""The UTM content of the short link."""
155
- test_started_at: Nullable[str]
156
- test_completed_at: Nullable[str]
157
- user_id: Nullable[str]
158
- workspace_id: str
159
- r"""The workspace ID of the short link."""
160
- last_clicked: str
161
- created_at: str
162
- updated_at: str
163
- tag_id: Nullable[str]
164
- r"""Deprecated: Use `tags` instead. The unique ID of the tag assigned to the short link."""
165
- project_id: str
166
- r"""Deprecated: Use `workspaceId` instead. The project ID of the short link."""
167
- test_variants: NotRequired[Nullable[List[SaleEventTestVariantsTypedDict]]]
168
- r"""An array of A/B test URLs and the percentage of traffic to send to each URL."""
169
- clicks: NotRequired[float]
170
- r"""The number of clicks on the short link."""
171
- leads: NotRequired[float]
172
- r"""The number of leads the short link has generated."""
173
- conversions: NotRequired[float]
174
- r"""The number of leads that converted to paying customers."""
175
- sales: NotRequired[float]
176
- r"""The total number of sales (includes recurring sales) generated by the short link."""
177
- sale_amount: NotRequired[float]
178
- r"""The total dollar value of sales (in cents) generated by the short link."""
179
-
180
-
181
- class SaleEventLink(BaseModel):
182
- id: str
183
- r"""The unique ID of the short link."""
184
-
185
- domain: str
186
- r"""The domain of the short link. If not provided, the primary domain for the workspace will be used (or `dub.sh` if the workspace has no domains)."""
187
-
188
- key: str
189
- r"""The short link slug. If not provided, a random 7-character slug will be generated."""
190
-
191
- url: str
192
-
193
- track_conversion: Annotated[bool, pydantic.Field(alias="trackConversion")]
194
-
195
- external_id: Annotated[Nullable[str], pydantic.Field(alias="externalId")]
196
- r"""The ID of the link in your database. If set, it can be used to identify the link in future API requests (must be prefixed with 'ext_' when passed as a query parameter). This key is unique across your workspace."""
197
-
198
- tenant_id: Annotated[Nullable[str], pydantic.Field(alias="tenantId")]
199
- r"""The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant."""
200
-
201
- program_id: Annotated[Nullable[str], pydantic.Field(alias="programId")]
202
- r"""The ID of the program the short link is associated with."""
203
-
204
- partner_id: Annotated[Nullable[str], pydantic.Field(alias="partnerId")]
205
- r"""The ID of the partner the short link is associated with."""
206
-
207
- archived: bool
208
-
209
- expires_at: Annotated[str, pydantic.Field(alias="expiresAt")]
210
-
211
- expired_url: Annotated[Nullable[str], pydantic.Field(alias="expiredUrl")]
212
-
213
- password: Nullable[str]
214
- r"""The password required to access the destination URL of the short link."""
215
-
216
- proxy: bool
217
-
218
- title: Nullable[str]
219
- r"""The title of the short link. Will be used for Custom Link Previews if `proxy` is true."""
220
-
221
- description: Nullable[str]
222
- r"""The description of the short link. Will be used for Custom Link Previews if `proxy` is true."""
223
-
224
- image: Nullable[str]
225
- r"""The image of the short link. Will be used for Custom Link Previews if `proxy` is true."""
226
-
227
- video: Nullable[str]
228
- r"""The custom link preview video (og:video). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og"""
229
-
230
- rewrite: bool
231
-
232
- do_index: Annotated[bool, pydantic.Field(alias="doIndex")]
233
-
234
- ios: Nullable[str]
235
- r"""The iOS destination URL for the short link for iOS device targeting."""
236
-
237
- android: Nullable[str]
238
- r"""The Android destination URL for the short link for Android device targeting."""
239
-
240
- geo: Nullable[Dict[str, str]]
241
- r"""Geo targeting information for the short link in JSON format `{[COUNTRY]: https://example.com }`. See https://d.to/geo for more information."""
242
-
243
- public_stats: Annotated[bool, pydantic.Field(alias="publicStats")]
244
-
245
- tags: Nullable[List[LinkTagSchema]]
246
- r"""The tags assigned to the short link."""
247
-
248
- folder_id: Annotated[Nullable[str], pydantic.Field(alias="folderId")]
249
- r"""The unique ID of the folder assigned to the short link."""
250
-
251
- webhook_ids: Annotated[List[str], pydantic.Field(alias="webhookIds")]
252
- r"""The IDs of the webhooks that the short link is associated with."""
253
-
254
- comments: Nullable[str]
255
- r"""The comments for the short link."""
256
-
257
- short_link: Annotated[str, pydantic.Field(alias="shortLink")]
258
- r"""The full URL of the short link, including the https protocol (e.g. `https://dub.sh/try`)."""
259
-
260
- qr_code: Annotated[str, pydantic.Field(alias="qrCode")]
261
- r"""The full URL of the QR code for the short link (e.g. `https://api.dub.co/qr?url=https://dub.sh/try`)."""
262
-
263
- utm_source: Nullable[str]
264
- r"""The UTM source of the short link."""
265
-
266
- utm_medium: Nullable[str]
267
- r"""The UTM medium of the short link."""
268
-
269
- utm_campaign: Nullable[str]
270
- r"""The UTM campaign of the short link."""
271
-
272
- utm_term: Nullable[str]
273
- r"""The UTM term of the short link."""
274
-
275
- utm_content: Nullable[str]
276
- r"""The UTM content of the short link."""
277
-
278
- test_started_at: Annotated[Nullable[str], pydantic.Field(alias="testStartedAt")]
279
-
280
- test_completed_at: Annotated[Nullable[str], pydantic.Field(alias="testCompletedAt")]
281
-
282
- user_id: Annotated[Nullable[str], pydantic.Field(alias="userId")]
283
-
284
- workspace_id: Annotated[str, pydantic.Field(alias="workspaceId")]
285
- r"""The workspace ID of the short link."""
286
-
287
- last_clicked: Annotated[str, pydantic.Field(alias="lastClicked")]
288
-
289
- created_at: Annotated[str, pydantic.Field(alias="createdAt")]
290
-
291
- updated_at: Annotated[str, pydantic.Field(alias="updatedAt")]
292
-
293
- tag_id: Annotated[
294
- Nullable[str],
295
- pydantic.Field(
296
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible.",
297
- alias="tagId",
298
- ),
299
- ]
300
- r"""Deprecated: Use `tags` instead. The unique ID of the tag assigned to the short link."""
301
-
302
- project_id: Annotated[
303
- str,
304
- pydantic.Field(
305
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible.",
306
- alias="projectId",
307
- ),
308
- ]
309
- r"""Deprecated: Use `workspaceId` instead. The project ID of the short link."""
310
-
311
- test_variants: Annotated[
312
- OptionalNullable[List[SaleEventTestVariants]],
313
- pydantic.Field(alias="testVariants"),
314
- ] = UNSET
315
- r"""An array of A/B test URLs and the percentage of traffic to send to each URL."""
316
-
317
- clicks: Optional[float] = 0
318
- r"""The number of clicks on the short link."""
319
-
320
- leads: Optional[float] = 0
321
- r"""The number of leads the short link has generated."""
322
-
323
- conversions: Optional[float] = 0
324
- r"""The number of leads that converted to paying customers."""
325
-
326
- sales: Optional[float] = 0
327
- r"""The total number of sales (includes recurring sales) generated by the short link."""
328
-
329
- sale_amount: Annotated[Optional[float], pydantic.Field(alias="saleAmount")] = 0
330
- r"""The total dollar value of sales (in cents) generated by the short link."""
331
-
332
- @model_serializer(mode="wrap")
333
- def serialize_model(self, handler):
334
- optional_fields = [
335
- "testVariants",
336
- "clicks",
337
- "leads",
338
- "conversions",
339
- "sales",
340
- "saleAmount",
341
- ]
342
- nullable_fields = [
343
- "externalId",
344
- "tenantId",
345
- "programId",
346
- "partnerId",
347
- "expiredUrl",
348
- "password",
349
- "title",
350
- "description",
351
- "image",
352
- "video",
353
- "ios",
354
- "android",
355
- "geo",
356
- "tags",
357
- "folderId",
358
- "comments",
359
- "utm_source",
360
- "utm_medium",
361
- "utm_campaign",
362
- "utm_term",
363
- "utm_content",
364
- "testVariants",
365
- "testStartedAt",
366
- "testCompletedAt",
367
- "userId",
368
- "tagId",
369
- ]
370
- null_default_fields = []
371
-
372
- serialized = handler(self)
373
-
374
- m = {}
375
-
376
- for n, f in type(self).model_fields.items():
377
- k = f.alias or n
378
- val = serialized.get(k)
379
- serialized.pop(k, None)
380
-
381
- optional_nullable = k in optional_fields and k in nullable_fields
382
- is_set = (
383
- self.__pydantic_fields_set__.intersection({n})
384
- or k in null_default_fields
385
- ) # pylint: disable=no-member
386
-
387
- if val is not None and val != UNSET_SENTINEL:
388
- m[k] = val
389
- elif val != UNSET_SENTINEL and (
390
- not k in optional_fields or (optional_nullable and is_set)
391
- ):
392
- m[k] = val
393
-
394
- return m
395
-
396
-
397
- class SaleEventClickTypedDict(TypedDict):
398
- id: str
399
- timestamp: str
400
- url: str
401
- country: str
402
- city: str
403
- region: str
404
- continent: str
405
- device: str
406
- browser: str
407
- os: str
408
- referer: str
409
- referer_url: str
410
- qr: bool
411
- ip: str
412
- trigger: NotRequired[Nullable[str]]
413
-
414
-
415
- class SaleEventClick(BaseModel):
416
- id: str
417
-
418
- timestamp: str
419
-
420
- url: str
421
-
422
- country: str
423
-
424
- city: str
425
-
426
- region: str
427
-
428
- continent: str
429
-
430
- device: str
431
-
432
- browser: str
433
-
434
- os: str
435
-
436
- referer: str
437
-
438
- referer_url: Annotated[str, pydantic.Field(alias="refererUrl")]
439
-
440
- qr: bool
441
-
442
- ip: str
443
-
444
- trigger: OptionalNullable[str] = UNSET
445
-
446
- @model_serializer(mode="wrap")
447
- def serialize_model(self, handler):
448
- optional_fields = ["trigger"]
449
- nullable_fields = ["trigger"]
450
- null_default_fields = []
451
-
452
- serialized = handler(self)
453
-
454
- m = {}
455
-
456
- for n, f in type(self).model_fields.items():
457
- k = f.alias or n
458
- val = serialized.get(k)
459
- serialized.pop(k, None)
460
-
461
- optional_nullable = k in optional_fields and k in nullable_fields
462
- is_set = (
463
- self.__pydantic_fields_set__.intersection({n})
464
- or k in null_default_fields
465
- ) # pylint: disable=no-member
466
-
467
- if val is not None and val != UNSET_SENTINEL:
468
- m[k] = val
469
- elif val != UNSET_SENTINEL and (
470
- not k in optional_fields or (optional_nullable and is_set)
471
- ):
472
- m[k] = val
473
-
474
- return m
475
-
476
-
477
- class SaleEventCustomerTypedDict(TypedDict):
478
- id: str
479
- r"""The unique ID of the customer. You may use either the customer's `id` on Dub (obtained via `/customers` endpoint) or their `externalId` (unique ID within your system, prefixed with `ext_`, e.g. `ext_123`)."""
480
- external_id: str
481
- r"""Unique identifier for the customer in the client's app."""
482
- name: str
483
- r"""Name of the customer."""
484
- created_at: str
485
- r"""The date the customer was created."""
486
- email: NotRequired[Nullable[str]]
487
- r"""Email of the customer."""
488
- avatar: NotRequired[Nullable[str]]
489
- r"""Avatar URL of the customer."""
490
- country: NotRequired[Nullable[str]]
491
- r"""Country of the customer."""
492
- sales: NotRequired[Nullable[float]]
493
- r"""Total number of sales for the customer."""
494
- sale_amount: NotRequired[Nullable[float]]
495
- r"""Total amount of sales for the customer."""
496
-
497
-
498
- class SaleEventCustomer(BaseModel):
499
- id: str
500
- r"""The unique ID of the customer. You may use either the customer's `id` on Dub (obtained via `/customers` endpoint) or their `externalId` (unique ID within your system, prefixed with `ext_`, e.g. `ext_123`)."""
501
-
502
- external_id: Annotated[str, pydantic.Field(alias="externalId")]
503
- r"""Unique identifier for the customer in the client's app."""
504
-
505
- name: str
506
- r"""Name of the customer."""
507
-
508
- created_at: Annotated[str, pydantic.Field(alias="createdAt")]
509
- r"""The date the customer was created."""
510
-
511
- email: OptionalNullable[str] = UNSET
512
- r"""Email of the customer."""
513
-
514
- avatar: OptionalNullable[str] = UNSET
515
- r"""Avatar URL of the customer."""
516
-
517
- country: OptionalNullable[str] = UNSET
518
- r"""Country of the customer."""
519
-
520
- sales: OptionalNullable[float] = UNSET
521
- r"""Total number of sales for the customer."""
522
-
523
- sale_amount: Annotated[
524
- OptionalNullable[float], pydantic.Field(alias="saleAmount")
525
- ] = UNSET
526
- r"""Total amount of sales for the customer."""
527
-
528
- @model_serializer(mode="wrap")
529
- def serialize_model(self, handler):
530
- optional_fields = ["email", "avatar", "country", "sales", "saleAmount"]
531
- nullable_fields = ["email", "avatar", "country", "sales", "saleAmount"]
532
- null_default_fields = []
533
-
534
- serialized = handler(self)
535
-
536
- m = {}
537
-
538
- for n, f in type(self).model_fields.items():
539
- k = f.alias or n
540
- val = serialized.get(k)
541
- serialized.pop(k, None)
542
-
543
- optional_nullable = k in optional_fields and k in nullable_fields
544
- is_set = (
545
- self.__pydantic_fields_set__.intersection({n})
546
- or k in null_default_fields
547
- ) # pylint: disable=no-member
548
-
549
- if val is not None and val != UNSET_SENTINEL:
550
- m[k] = val
551
- elif val != UNSET_SENTINEL and (
552
- not k in optional_fields or (optional_nullable and is_set)
553
- ):
554
- m[k] = val
555
-
556
- return m
557
-
558
-
559
- class SaleEventTypedDict(TypedDict):
560
- event: SaleEventEvent
561
- timestamp: str
562
- event_id: str
563
- event_name: str
564
- sale: SaleTypedDict
565
- link: SaleEventLinkTypedDict
566
- click: SaleEventClickTypedDict
567
- customer: SaleEventCustomerTypedDict
568
- sale_amount: float
569
- r"""Deprecated: Use `sale.amount` instead."""
570
- invoice_id: str
571
- r"""Deprecated: Use `sale.invoiceId` instead."""
572
- payment_processor: str
573
- r"""Deprecated: Use `sale.paymentProcessor` instead."""
574
- click_id: str
575
- r"""Deprecated: Use `click.id` instead."""
576
- link_id: str
577
- r"""Deprecated: Use `link.id` instead."""
578
- domain: str
579
- r"""Deprecated: Use `link.domain` instead."""
580
- key: str
581
- r"""Deprecated: Use `link.key` instead."""
582
- url: str
583
- r"""Deprecated: Use `click.url` instead."""
584
- continent: str
585
- r"""Deprecated: Use `click.continent` instead."""
586
- country: str
587
- r"""Deprecated: Use `click.country` instead."""
588
- city: str
589
- r"""Deprecated: Use `click.city` instead."""
590
- device: str
591
- r"""Deprecated: Use `click.device` instead."""
592
- browser: str
593
- r"""Deprecated: Use `click.browser` instead."""
594
- os: str
595
- r"""Deprecated: Use `click.os` instead."""
596
- qr: float
597
- r"""Deprecated: Use `click.qr` instead."""
598
- ip: str
599
- r"""Deprecated: Use `click.ip` instead."""
600
- metadata: NotRequired[Nullable[Any]]
601
-
602
-
603
- class SaleEvent(BaseModel):
604
- event: SaleEventEvent
605
-
606
- timestamp: str
607
-
608
- event_id: Annotated[str, pydantic.Field(alias="eventId")]
609
-
610
- event_name: Annotated[str, pydantic.Field(alias="eventName")]
611
-
612
- sale: Sale
613
-
614
- link: SaleEventLink
615
-
616
- click: SaleEventClick
617
-
618
- customer: SaleEventCustomer
619
-
620
- sale_amount: Annotated[
621
- float,
622
- pydantic.Field(
623
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible.",
624
- alias="saleAmount",
625
- ),
626
- ]
627
- r"""Deprecated: Use `sale.amount` instead."""
628
-
629
- invoice_id: Annotated[
630
- str,
631
- pydantic.Field(
632
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
633
- ),
634
- ]
635
- r"""Deprecated: Use `sale.invoiceId` instead."""
636
-
637
- payment_processor: Annotated[
638
- str,
639
- pydantic.Field(
640
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
641
- ),
642
- ]
643
- r"""Deprecated: Use `sale.paymentProcessor` instead."""
644
-
645
- click_id: Annotated[
646
- str,
647
- pydantic.Field(
648
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
649
- ),
650
- ]
651
- r"""Deprecated: Use `click.id` instead."""
652
-
653
- link_id: Annotated[
654
- str,
655
- pydantic.Field(
656
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
657
- ),
658
- ]
659
- r"""Deprecated: Use `link.id` instead."""
660
-
661
- domain: Annotated[
662
- str,
663
- pydantic.Field(
664
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
665
- ),
666
- ]
667
- r"""Deprecated: Use `link.domain` instead."""
668
-
669
- key: Annotated[
670
- str,
671
- pydantic.Field(
672
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
673
- ),
674
- ]
675
- r"""Deprecated: Use `link.key` instead."""
676
-
677
- url: Annotated[
678
- str,
679
- pydantic.Field(
680
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
681
- ),
682
- ]
683
- r"""Deprecated: Use `click.url` instead."""
684
-
685
- continent: Annotated[
686
- str,
687
- pydantic.Field(
688
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
689
- ),
690
- ]
691
- r"""Deprecated: Use `click.continent` instead."""
692
-
693
- country: Annotated[
694
- str,
695
- pydantic.Field(
696
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
697
- ),
698
- ]
699
- r"""Deprecated: Use `click.country` instead."""
700
-
701
- city: Annotated[
702
- str,
703
- pydantic.Field(
704
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
705
- ),
706
- ]
707
- r"""Deprecated: Use `click.city` instead."""
708
-
709
- device: Annotated[
710
- str,
711
- pydantic.Field(
712
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
713
- ),
714
- ]
715
- r"""Deprecated: Use `click.device` instead."""
716
-
717
- browser: Annotated[
718
- str,
719
- pydantic.Field(
720
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
721
- ),
722
- ]
723
- r"""Deprecated: Use `click.browser` instead."""
724
-
725
- os: Annotated[
726
- str,
727
- pydantic.Field(
728
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
729
- ),
730
- ]
731
- r"""Deprecated: Use `click.os` instead."""
732
-
733
- qr: Annotated[
734
- float,
735
- pydantic.Field(
736
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
737
- ),
738
- ]
739
- r"""Deprecated: Use `click.qr` instead."""
740
-
741
- ip: Annotated[
742
- str,
743
- pydantic.Field(
744
- deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
745
- ),
746
- ]
747
- r"""Deprecated: Use `click.ip` instead."""
748
-
749
- metadata: OptionalNullable[Any] = UNSET
750
-
751
- @model_serializer(mode="wrap")
752
- def serialize_model(self, handler):
753
- optional_fields = ["metadata"]
754
- nullable_fields = ["metadata"]
755
- null_default_fields = []
756
-
757
- serialized = handler(self)
758
-
759
- m = {}
760
-
761
- for n, f in type(self).model_fields.items():
762
- k = f.alias or n
763
- val = serialized.get(k)
764
- serialized.pop(k, None)
765
-
766
- optional_nullable = k in optional_fields and k in nullable_fields
767
- is_set = (
768
- self.__pydantic_fields_set__.intersection({n})
769
- or k in null_default_fields
770
- ) # pylint: disable=no-member
771
-
772
- if val is not None and val != UNSET_SENTINEL:
773
- m[k] = val
774
- elif val != UNSET_SENTINEL and (
775
- not k in optional_fields or (optional_nullable and is_set)
776
- ):
777
- m[k] = val
778
-
779
- return m