growsurf-python 0.0.2__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 (80) hide show
  1. growsurf/__init__.py +102 -0
  2. growsurf/_base_client.py +2153 -0
  3. growsurf/_client.py +484 -0
  4. growsurf/_compat.py +226 -0
  5. growsurf/_constants.py +14 -0
  6. growsurf/_exceptions.py +108 -0
  7. growsurf/_files.py +173 -0
  8. growsurf/_models.py +878 -0
  9. growsurf/_qs.py +149 -0
  10. growsurf/_resource.py +43 -0
  11. growsurf/_response.py +833 -0
  12. growsurf/_streaming.py +338 -0
  13. growsurf/_types.py +274 -0
  14. growsurf/_utils/__init__.py +64 -0
  15. growsurf/_utils/_compat.py +45 -0
  16. growsurf/_utils/_datetime_parse.py +136 -0
  17. growsurf/_utils/_json.py +35 -0
  18. growsurf/_utils/_logs.py +25 -0
  19. growsurf/_utils/_path.py +127 -0
  20. growsurf/_utils/_proxy.py +65 -0
  21. growsurf/_utils/_reflection.py +42 -0
  22. growsurf/_utils/_resources_proxy.py +24 -0
  23. growsurf/_utils/_streams.py +12 -0
  24. growsurf/_utils/_sync.py +58 -0
  25. growsurf/_utils/_transform.py +457 -0
  26. growsurf/_utils/_typing.py +156 -0
  27. growsurf/_utils/_utils.py +433 -0
  28. growsurf/_version.py +4 -0
  29. growsurf/lib/.keep +4 -0
  30. growsurf/py.typed +0 -0
  31. growsurf/resources/__init__.py +19 -0
  32. growsurf/resources/campaign/__init__.py +61 -0
  33. growsurf/resources/campaign/campaign.py +1126 -0
  34. growsurf/resources/campaign/commission.py +259 -0
  35. growsurf/resources/campaign/participant.py +1587 -0
  36. growsurf/resources/campaign/reward.py +355 -0
  37. growsurf/types/__init__.py +18 -0
  38. growsurf/types/campaign/__init__.py +35 -0
  39. growsurf/types/campaign/campaign.py +73 -0
  40. growsurf/types/campaign/commission_approve_response.py +9 -0
  41. growsurf/types/campaign/commission_delete_response.py +9 -0
  42. growsurf/types/campaign/fraud_risk_level.py +7 -0
  43. growsurf/types/campaign/participant.py +147 -0
  44. growsurf/types/campaign/participant_add_params.py +30 -0
  45. growsurf/types/campaign/participant_delete_response.py +9 -0
  46. growsurf/types/campaign/participant_list_commissions_params.py +22 -0
  47. growsurf/types/campaign/participant_list_payouts_params.py +22 -0
  48. growsurf/types/campaign/participant_list_referrals_params.py +43 -0
  49. growsurf/types/campaign/participant_list_rewards_params.py +19 -0
  50. growsurf/types/campaign/participant_list_rewards_response.py +18 -0
  51. growsurf/types/campaign/participant_record_transaction_params.py +60 -0
  52. growsurf/types/campaign/participant_record_transaction_response.py +37 -0
  53. growsurf/types/campaign/participant_reward.py +39 -0
  54. growsurf/types/campaign/participant_send_invites_params.py +20 -0
  55. growsurf/types/campaign/participant_send_invites_response.py +15 -0
  56. growsurf/types/campaign/participant_trigger_referral_response.py +13 -0
  57. growsurf/types/campaign/participant_update_params.py +34 -0
  58. growsurf/types/campaign/referral_source.py +7 -0
  59. growsurf/types/campaign/referral_status.py +7 -0
  60. growsurf/types/campaign/reward_approve_params.py +14 -0
  61. growsurf/types/campaign/reward_approve_response.py +9 -0
  62. growsurf/types/campaign/reward_delete_response.py +9 -0
  63. growsurf/types/campaign/reward_fulfill_response.py +9 -0
  64. growsurf/types/campaign_list_commissions_params.py +20 -0
  65. growsurf/types/campaign_list_leaderboard_params.py +36 -0
  66. growsurf/types/campaign_list_participants_params.py +17 -0
  67. growsurf/types/campaign_list_payouts_params.py +20 -0
  68. growsurf/types/campaign_list_referrals_params.py +41 -0
  69. growsurf/types/campaign_list_response.py +12 -0
  70. growsurf/types/campaign_retrieve_analytics_params.py +26 -0
  71. growsurf/types/campaign_retrieve_analytics_response.py +75 -0
  72. growsurf/types/commission_structure.py +62 -0
  73. growsurf/types/participant_commission_list.py +62 -0
  74. growsurf/types/participant_list.py +18 -0
  75. growsurf/types/participant_payout_list.py +50 -0
  76. growsurf/types/referral_list.py +40 -0
  77. growsurf_python-0.0.2.dist-info/METADATA +399 -0
  78. growsurf_python-0.0.2.dist-info/RECORD +80 -0
  79. growsurf_python-0.0.2.dist-info/WHEEL +4 -0
  80. growsurf_python-0.0.2.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,1587 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, Iterable, cast
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
11
+ from ..._utils import path_template, maybe_transform, async_maybe_transform
12
+ from ..._compat import cached_property
13
+ from ..._resource import SyncAPIResource, AsyncAPIResource
14
+ from ..._response import (
15
+ to_raw_response_wrapper,
16
+ to_streamed_response_wrapper,
17
+ async_to_raw_response_wrapper,
18
+ async_to_streamed_response_wrapper,
19
+ )
20
+ from ..._base_client import make_request_options
21
+ from ...types.campaign import (
22
+ ReferralStatus,
23
+ participant_add_params,
24
+ participant_update_params,
25
+ participant_list_payouts_params,
26
+ participant_list_rewards_params,
27
+ participant_send_invites_params,
28
+ participant_list_referrals_params,
29
+ participant_list_commissions_params,
30
+ participant_record_transaction_params,
31
+ )
32
+ from ...types.referral_list import ReferralList
33
+ from ...types.campaign.participant import Participant
34
+ from ...types.participant_payout_list import ParticipantPayoutList
35
+ from ...types.campaign.referral_status import ReferralStatus
36
+ from ...types.participant_commission_list import ParticipantCommissionList
37
+ from ...types.campaign.participant_delete_response import ParticipantDeleteResponse
38
+ from ...types.campaign.participant_list_rewards_response import ParticipantListRewardsResponse
39
+ from ...types.campaign.participant_send_invites_response import ParticipantSendInvitesResponse
40
+ from ...types.campaign.participant_trigger_referral_response import ParticipantTriggerReferralResponse
41
+ from ...types.campaign.participant_record_transaction_response import ParticipantRecordTransactionResponse
42
+
43
+ __all__ = ["ParticipantResource", "AsyncParticipantResource"]
44
+
45
+
46
+ class ParticipantResource(SyncAPIResource):
47
+ @cached_property
48
+ def with_raw_response(self) -> ParticipantResourceWithRawResponse:
49
+ """
50
+ This property can be used as a prefix for any HTTP method call to return
51
+ the raw response object instead of the parsed content.
52
+
53
+ For more information, see https://www.github.com/growsurf/growsurf-python#accessing-raw-response-data-eg-headers
54
+ """
55
+ return ParticipantResourceWithRawResponse(self)
56
+
57
+ @cached_property
58
+ def with_streaming_response(self) -> ParticipantResourceWithStreamingResponse:
59
+ """
60
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
61
+
62
+ For more information, see https://www.github.com/growsurf/growsurf-python#with_streaming_response
63
+ """
64
+ return ParticipantResourceWithStreamingResponse(self)
65
+
66
+ def retrieve(
67
+ self,
68
+ participant_id_or_email: str,
69
+ *,
70
+ id: str,
71
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
72
+ # The extra values given here take precedence over values defined on the client or passed to this method.
73
+ extra_headers: Headers | None = None,
74
+ extra_query: Query | None = None,
75
+ extra_body: Body | None = None,
76
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
77
+ ) -> Participant:
78
+ """
79
+ Retrieves a single participant by GrowSurf participant ID or email address.
80
+
81
+ Args:
82
+ extra_headers: Send extra headers
83
+
84
+ extra_query: Add additional query parameters to the request
85
+
86
+ extra_body: Add additional JSON properties to the request
87
+
88
+ timeout: Override the client-level default timeout for this request, in seconds
89
+ """
90
+ if not id:
91
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
92
+ if not participant_id_or_email:
93
+ raise ValueError(
94
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
95
+ )
96
+ return self._get(
97
+ path_template(
98
+ "/campaign/{id}/participant/{participant_id_or_email}",
99
+ id=id,
100
+ participant_id_or_email=participant_id_or_email,
101
+ ),
102
+ options=make_request_options(
103
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
104
+ ),
105
+ cast_to=Participant,
106
+ )
107
+
108
+ def update(
109
+ self,
110
+ participant_id_or_email: str,
111
+ *,
112
+ id: str,
113
+ email: str | Omit = omit,
114
+ first_name: str | Omit = omit,
115
+ last_name: str | Omit = omit,
116
+ metadata: Dict[str, object] | Omit = omit,
117
+ referral_status: Literal["CREDIT_PENDING", "CREDIT_AWARDED", "CREDIT_EXPIRED"] | Omit = omit,
118
+ referred_by: str | Omit = omit,
119
+ unsubscribed: bool | Omit = omit,
120
+ vanity_keys: SequenceNotStr[str] | Omit = omit,
121
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
122
+ # The extra values given here take precedence over values defined on the client or passed to this method.
123
+ extra_headers: Headers | None = None,
124
+ extra_query: Query | None = None,
125
+ extra_body: Body | None = None,
126
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
127
+ ) -> Participant:
128
+ """
129
+ Updates a participant by GrowSurf participant ID or email address.
130
+
131
+ Args:
132
+ metadata: Shallow custom metadata object.
133
+
134
+ extra_headers: Send extra headers
135
+
136
+ extra_query: Add additional query parameters to the request
137
+
138
+ extra_body: Add additional JSON properties to the request
139
+
140
+ timeout: Override the client-level default timeout for this request, in seconds
141
+ """
142
+ if not id:
143
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
144
+ if not participant_id_or_email:
145
+ raise ValueError(
146
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
147
+ )
148
+ return self._post(
149
+ path_template(
150
+ "/campaign/{id}/participant/{participant_id_or_email}",
151
+ id=id,
152
+ participant_id_or_email=participant_id_or_email,
153
+ ),
154
+ body=maybe_transform(
155
+ {
156
+ "email": email,
157
+ "first_name": first_name,
158
+ "last_name": last_name,
159
+ "metadata": metadata,
160
+ "referral_status": referral_status,
161
+ "referred_by": referred_by,
162
+ "unsubscribed": unsubscribed,
163
+ "vanity_keys": vanity_keys,
164
+ },
165
+ participant_update_params.ParticipantUpdateParams,
166
+ ),
167
+ options=make_request_options(
168
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
169
+ ),
170
+ cast_to=Participant,
171
+ )
172
+
173
+ def delete(
174
+ self,
175
+ participant_id_or_email: str,
176
+ *,
177
+ id: str,
178
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
179
+ # The extra values given here take precedence over values defined on the client or passed to this method.
180
+ extra_headers: Headers | None = None,
181
+ extra_query: Query | None = None,
182
+ extra_body: Body | None = None,
183
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
184
+ ) -> ParticipantDeleteResponse:
185
+ """
186
+ Removes a participant by GrowSurf participant ID or email address.
187
+
188
+ Args:
189
+ extra_headers: Send extra headers
190
+
191
+ extra_query: Add additional query parameters to the request
192
+
193
+ extra_body: Add additional JSON properties to the request
194
+
195
+ timeout: Override the client-level default timeout for this request, in seconds
196
+ """
197
+ if not id:
198
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
199
+ if not participant_id_or_email:
200
+ raise ValueError(
201
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
202
+ )
203
+ return self._delete(
204
+ path_template(
205
+ "/campaign/{id}/participant/{participant_id_or_email}",
206
+ id=id,
207
+ participant_id_or_email=participant_id_or_email,
208
+ ),
209
+ options=make_request_options(
210
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
211
+ ),
212
+ cast_to=ParticipantDeleteResponse,
213
+ )
214
+
215
+ def add(
216
+ self,
217
+ id: str,
218
+ *,
219
+ email: str,
220
+ fingerprint: str | Omit = omit,
221
+ first_name: str | Omit = omit,
222
+ ip_address: str | Omit = omit,
223
+ last_name: str | Omit = omit,
224
+ metadata: Dict[str, object] | Omit = omit,
225
+ referral_status: Literal["CREDIT_PENDING", "CREDIT_AWARDED"] | Omit = omit,
226
+ referred_by: str | Omit = omit,
227
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
228
+ # The extra values given here take precedence over values defined on the client or passed to this method.
229
+ extra_headers: Headers | None = None,
230
+ extra_query: Query | None = None,
231
+ extra_body: Body | None = None,
232
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
233
+ ) -> Participant:
234
+ """Adds a new participant to the program.
235
+
236
+ If the email already exists, the existing
237
+ participant is returned.
238
+
239
+ Args:
240
+ metadata: Shallow custom metadata object.
241
+
242
+ referred_by: Referrer participant ID or email address.
243
+
244
+ extra_headers: Send extra headers
245
+
246
+ extra_query: Add additional query parameters to the request
247
+
248
+ extra_body: Add additional JSON properties to the request
249
+
250
+ timeout: Override the client-level default timeout for this request, in seconds
251
+ """
252
+ if not id:
253
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
254
+ return self._post(
255
+ path_template("/campaign/{id}/participant", id=id),
256
+ body=maybe_transform(
257
+ {
258
+ "email": email,
259
+ "fingerprint": fingerprint,
260
+ "first_name": first_name,
261
+ "ip_address": ip_address,
262
+ "last_name": last_name,
263
+ "metadata": metadata,
264
+ "referral_status": referral_status,
265
+ "referred_by": referred_by,
266
+ },
267
+ participant_add_params.ParticipantAddParams,
268
+ ),
269
+ options=make_request_options(
270
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
271
+ ),
272
+ cast_to=Participant,
273
+ )
274
+
275
+ def list_commissions(
276
+ self,
277
+ participant_id_or_email: str,
278
+ *,
279
+ id: str,
280
+ limit: int | Omit = omit,
281
+ next_id: str | Omit = omit,
282
+ status: Literal["PENDING", "APPROVED", "PAID", "REVERSED", "DELETED"] | Omit = omit,
283
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
284
+ # The extra values given here take precedence over values defined on the client or passed to this method.
285
+ extra_headers: Headers | None = None,
286
+ extra_query: Query | None = None,
287
+ extra_body: Body | None = None,
288
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
289
+ ) -> ParticipantCommissionList:
290
+ """
291
+ Retrieves a paged list of commissions earned by a participant.
292
+
293
+ Args:
294
+ limit: Number of results to return. Maximum 100.
295
+
296
+ next_id: ID to start the next paged result set with.
297
+
298
+ status: Participant commission status.
299
+
300
+ extra_headers: Send extra headers
301
+
302
+ extra_query: Add additional query parameters to the request
303
+
304
+ extra_body: Add additional JSON properties to the request
305
+
306
+ timeout: Override the client-level default timeout for this request, in seconds
307
+ """
308
+ if not id:
309
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
310
+ if not participant_id_or_email:
311
+ raise ValueError(
312
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
313
+ )
314
+ return self._get(
315
+ path_template(
316
+ "/campaign/{id}/participant/{participant_id_or_email}/commissions",
317
+ id=id,
318
+ participant_id_or_email=participant_id_or_email,
319
+ ),
320
+ options=make_request_options(
321
+ extra_headers=extra_headers,
322
+ extra_query=extra_query,
323
+ extra_body=extra_body,
324
+ timeout=timeout,
325
+ query=maybe_transform(
326
+ {
327
+ "limit": limit,
328
+ "next_id": next_id,
329
+ "status": status,
330
+ },
331
+ participant_list_commissions_params.ParticipantListCommissionsParams,
332
+ ),
333
+ ),
334
+ cast_to=ParticipantCommissionList,
335
+ )
336
+
337
+ def list_payouts(
338
+ self,
339
+ participant_id_or_email: str,
340
+ *,
341
+ id: str,
342
+ limit: int | Omit = omit,
343
+ next_id: str | Omit = omit,
344
+ status: Literal["UPCOMING", "QUEUED", "ISSUED", "FAILED"] | Omit = omit,
345
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
346
+ # The extra values given here take precedence over values defined on the client or passed to this method.
347
+ extra_headers: Headers | None = None,
348
+ extra_query: Query | None = None,
349
+ extra_body: Body | None = None,
350
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
351
+ ) -> ParticipantPayoutList:
352
+ """
353
+ Retrieves a paged list of payouts that belong to a participant.
354
+
355
+ Args:
356
+ limit: Number of results to return. Maximum 100.
357
+
358
+ next_id: ID to start the next paged result set with.
359
+
360
+ status: Participant payout status.
361
+
362
+ extra_headers: Send extra headers
363
+
364
+ extra_query: Add additional query parameters to the request
365
+
366
+ extra_body: Add additional JSON properties to the request
367
+
368
+ timeout: Override the client-level default timeout for this request, in seconds
369
+ """
370
+ if not id:
371
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
372
+ if not participant_id_or_email:
373
+ raise ValueError(
374
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
375
+ )
376
+ return self._get(
377
+ path_template(
378
+ "/campaign/{id}/participant/{participant_id_or_email}/payouts",
379
+ id=id,
380
+ participant_id_or_email=participant_id_or_email,
381
+ ),
382
+ options=make_request_options(
383
+ extra_headers=extra_headers,
384
+ extra_query=extra_query,
385
+ extra_body=extra_body,
386
+ timeout=timeout,
387
+ query=maybe_transform(
388
+ {
389
+ "limit": limit,
390
+ "next_id": next_id,
391
+ "status": status,
392
+ },
393
+ participant_list_payouts_params.ParticipantListPayoutsParams,
394
+ ),
395
+ ),
396
+ cast_to=ParticipantPayoutList,
397
+ )
398
+
399
+ def list_referrals(
400
+ self,
401
+ participant_id_or_email: str,
402
+ *,
403
+ id: str,
404
+ desc: bool | Omit = omit,
405
+ email: str | Omit = omit,
406
+ first_name: str | Omit = omit,
407
+ last_name: str | Omit = omit,
408
+ limit: int | Omit = omit,
409
+ next_id: str | Omit = omit,
410
+ offset: int | Omit = omit,
411
+ referral_status: ReferralStatus | Omit = omit,
412
+ sort_by: Literal[
413
+ "updatedAt", "createdAt", "email", "firstName", "lastName", "referralStatus", "referralTriggeredAt"
414
+ ]
415
+ | Omit = omit,
416
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
417
+ # The extra values given here take precedence over values defined on the client or passed to this method.
418
+ extra_headers: Headers | None = None,
419
+ extra_query: Query | None = None,
420
+ extra_body: Body | None = None,
421
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
422
+ ) -> ReferralList:
423
+ """
424
+ Retrieves referrals and email invites made by a participant.
425
+
426
+ Args:
427
+ desc: Return results in descending order when true.
428
+
429
+ email: URL-encoded email value to filter referral results.
430
+
431
+ first_name: First name value to filter results.
432
+
433
+ last_name: Last name value to filter results.
434
+
435
+ limit: Number of results to return. Maximum 100.
436
+
437
+ next_id: ID to start the next paged result set with.
438
+
439
+ offset: Offset number used to skip through a result set.
440
+
441
+ sort_by: Field used to sort referral results.
442
+
443
+ extra_headers: Send extra headers
444
+
445
+ extra_query: Add additional query parameters to the request
446
+
447
+ extra_body: Add additional JSON properties to the request
448
+
449
+ timeout: Override the client-level default timeout for this request, in seconds
450
+ """
451
+ if not id:
452
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
453
+ if not participant_id_or_email:
454
+ raise ValueError(
455
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
456
+ )
457
+ return self._get(
458
+ path_template(
459
+ "/campaign/{id}/participant/{participant_id_or_email}/referrals",
460
+ id=id,
461
+ participant_id_or_email=participant_id_or_email,
462
+ ),
463
+ options=make_request_options(
464
+ extra_headers=extra_headers,
465
+ extra_query=extra_query,
466
+ extra_body=extra_body,
467
+ timeout=timeout,
468
+ query=maybe_transform(
469
+ {
470
+ "desc": desc,
471
+ "email": email,
472
+ "first_name": first_name,
473
+ "last_name": last_name,
474
+ "limit": limit,
475
+ "next_id": next_id,
476
+ "offset": offset,
477
+ "referral_status": referral_status,
478
+ "sort_by": sort_by,
479
+ },
480
+ participant_list_referrals_params.ParticipantListReferralsParams,
481
+ ),
482
+ ),
483
+ cast_to=ReferralList,
484
+ )
485
+
486
+ def list_rewards(
487
+ self,
488
+ participant_id_or_email: str,
489
+ *,
490
+ id: str,
491
+ limit: int | Omit = omit,
492
+ next_id: str | Omit = omit,
493
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
494
+ # The extra values given here take precedence over values defined on the client or passed to this method.
495
+ extra_headers: Headers | None = None,
496
+ extra_query: Query | None = None,
497
+ extra_body: Body | None = None,
498
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
499
+ ) -> ParticipantListRewardsResponse:
500
+ """
501
+ Retrieves a paged list of rewards earned by a participant.
502
+
503
+ Args:
504
+ limit: Number of results to return. Maximum 100.
505
+
506
+ next_id: ID to start the next paged result set with.
507
+
508
+ extra_headers: Send extra headers
509
+
510
+ extra_query: Add additional query parameters to the request
511
+
512
+ extra_body: Add additional JSON properties to the request
513
+
514
+ timeout: Override the client-level default timeout for this request, in seconds
515
+ """
516
+ if not id:
517
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
518
+ if not participant_id_or_email:
519
+ raise ValueError(
520
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
521
+ )
522
+ return self._get(
523
+ path_template(
524
+ "/campaign/{id}/participant/{participant_id_or_email}/rewards",
525
+ id=id,
526
+ participant_id_or_email=participant_id_or_email,
527
+ ),
528
+ options=make_request_options(
529
+ extra_headers=extra_headers,
530
+ extra_query=extra_query,
531
+ extra_body=extra_body,
532
+ timeout=timeout,
533
+ query=maybe_transform(
534
+ {
535
+ "limit": limit,
536
+ "next_id": next_id,
537
+ },
538
+ participant_list_rewards_params.ParticipantListRewardsParams,
539
+ ),
540
+ ),
541
+ cast_to=ParticipantListRewardsResponse,
542
+ )
543
+
544
+ def record_transaction(
545
+ self,
546
+ participant_id_or_email: str,
547
+ *,
548
+ id: str,
549
+ currency: str,
550
+ gross_amount: int,
551
+ amount_cash_net: int | Omit = omit,
552
+ amount_paid: int | Omit = omit,
553
+ charge_id: str | Omit = omit,
554
+ customer_id: str | Omit = omit,
555
+ description: str | Omit = omit,
556
+ external_id: str | Omit = omit,
557
+ invoice_id: str | Omit = omit,
558
+ invoice_subtotal_excluding_tax: int | Omit = omit,
559
+ invoice_total: int | Omit = omit,
560
+ invoice_total_excluding_tax: int | Omit = omit,
561
+ net_amount: int | Omit = omit,
562
+ order_id: str | Omit = omit,
563
+ paid_at: int | Omit = omit,
564
+ payment_id: str | Omit = omit,
565
+ payment_intent_id: str | Omit = omit,
566
+ subscription_id: str | Omit = omit,
567
+ tax_amount: int | Omit = omit,
568
+ total_tax_amount: int | Omit = omit,
569
+ total_tax_amounts: Iterable[Dict[str, object]] | Omit = omit,
570
+ total_taxes: Iterable[Dict[str, object]] | Omit = omit,
571
+ transaction_id: str | Omit = omit,
572
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
573
+ # The extra values given here take precedence over values defined on the client or passed to this method.
574
+ extra_headers: Headers | None = None,
575
+ extra_query: Query | None = None,
576
+ extra_body: Body | None = None,
577
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
578
+ ) -> ParticipantRecordTransactionResponse:
579
+ """
580
+ Records a sale made by a referred customer and generates affiliate commissions
581
+ for their referrer when applicable.
582
+
583
+ Args:
584
+ extra_headers: Send extra headers
585
+
586
+ extra_query: Add additional query parameters to the request
587
+
588
+ extra_body: Add additional JSON properties to the request
589
+
590
+ timeout: Override the client-level default timeout for this request, in seconds
591
+ """
592
+ if not id:
593
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
594
+ if not participant_id_or_email:
595
+ raise ValueError(
596
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
597
+ )
598
+ return cast(
599
+ ParticipantRecordTransactionResponse,
600
+ self._post(
601
+ path_template(
602
+ "/campaign/{id}/participant/{participant_id_or_email}/transaction",
603
+ id=id,
604
+ participant_id_or_email=participant_id_or_email,
605
+ ),
606
+ body=maybe_transform(
607
+ {
608
+ "currency": currency,
609
+ "gross_amount": gross_amount,
610
+ "amount_cash_net": amount_cash_net,
611
+ "amount_paid": amount_paid,
612
+ "charge_id": charge_id,
613
+ "customer_id": customer_id,
614
+ "description": description,
615
+ "external_id": external_id,
616
+ "invoice_id": invoice_id,
617
+ "invoice_subtotal_excluding_tax": invoice_subtotal_excluding_tax,
618
+ "invoice_total": invoice_total,
619
+ "invoice_total_excluding_tax": invoice_total_excluding_tax,
620
+ "net_amount": net_amount,
621
+ "order_id": order_id,
622
+ "paid_at": paid_at,
623
+ "payment_id": payment_id,
624
+ "payment_intent_id": payment_intent_id,
625
+ "subscription_id": subscription_id,
626
+ "tax_amount": tax_amount,
627
+ "total_tax_amount": total_tax_amount,
628
+ "total_tax_amounts": total_tax_amounts,
629
+ "total_taxes": total_taxes,
630
+ "transaction_id": transaction_id,
631
+ },
632
+ participant_record_transaction_params.ParticipantRecordTransactionParams,
633
+ ),
634
+ options=make_request_options(
635
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
636
+ ),
637
+ cast_to=cast(
638
+ Any, ParticipantRecordTransactionResponse
639
+ ), # Union types cannot be passed in as arguments in the type system
640
+ ),
641
+ )
642
+
643
+ def send_invites(
644
+ self,
645
+ participant_id_or_email: str,
646
+ *,
647
+ id: str,
648
+ email_addresses: SequenceNotStr[str],
649
+ message_text: str,
650
+ subject_text: str,
651
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
652
+ # The extra values given here take precedence over values defined on the client or passed to this method.
653
+ extra_headers: Headers | None = None,
654
+ extra_query: Query | None = None,
655
+ extra_body: Body | None = None,
656
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
657
+ ) -> ParticipantSendInvitesResponse:
658
+ """
659
+ Sends email invites on behalf of a participant to a list of email addresses.
660
+
661
+ Args:
662
+ extra_headers: Send extra headers
663
+
664
+ extra_query: Add additional query parameters to the request
665
+
666
+ extra_body: Add additional JSON properties to the request
667
+
668
+ timeout: Override the client-level default timeout for this request, in seconds
669
+ """
670
+ if not id:
671
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
672
+ if not participant_id_or_email:
673
+ raise ValueError(
674
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
675
+ )
676
+ return self._post(
677
+ path_template(
678
+ "/campaign/{id}/participant/{participant_id_or_email}/invites",
679
+ id=id,
680
+ participant_id_or_email=participant_id_or_email,
681
+ ),
682
+ body=maybe_transform(
683
+ {
684
+ "email_addresses": email_addresses,
685
+ "message_text": message_text,
686
+ "subject_text": subject_text,
687
+ },
688
+ participant_send_invites_params.ParticipantSendInvitesParams,
689
+ ),
690
+ options=make_request_options(
691
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
692
+ ),
693
+ cast_to=ParticipantSendInvitesResponse,
694
+ )
695
+
696
+ def trigger_referral(
697
+ self,
698
+ participant_id_or_email: str,
699
+ *,
700
+ id: str,
701
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
702
+ # The extra values given here take precedence over values defined on the client or passed to this method.
703
+ extra_headers: Headers | None = None,
704
+ extra_query: Query | None = None,
705
+ extra_body: Body | None = None,
706
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
707
+ ) -> ParticipantTriggerReferralResponse:
708
+ """
709
+ Triggers referral credit for an existing referred participant by GrowSurf
710
+ participant ID or email address.
711
+
712
+ Args:
713
+ extra_headers: Send extra headers
714
+
715
+ extra_query: Add additional query parameters to the request
716
+
717
+ extra_body: Add additional JSON properties to the request
718
+
719
+ timeout: Override the client-level default timeout for this request, in seconds
720
+ """
721
+ if not id:
722
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
723
+ if not participant_id_or_email:
724
+ raise ValueError(
725
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
726
+ )
727
+ return self._post(
728
+ path_template(
729
+ "/campaign/{id}/participant/{participant_id_or_email}/ref",
730
+ id=id,
731
+ participant_id_or_email=participant_id_or_email,
732
+ ),
733
+ options=make_request_options(
734
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
735
+ ),
736
+ cast_to=ParticipantTriggerReferralResponse,
737
+ )
738
+
739
+
740
+ class AsyncParticipantResource(AsyncAPIResource):
741
+ @cached_property
742
+ def with_raw_response(self) -> AsyncParticipantResourceWithRawResponse:
743
+ """
744
+ This property can be used as a prefix for any HTTP method call to return
745
+ the raw response object instead of the parsed content.
746
+
747
+ For more information, see https://www.github.com/growsurf/growsurf-python#accessing-raw-response-data-eg-headers
748
+ """
749
+ return AsyncParticipantResourceWithRawResponse(self)
750
+
751
+ @cached_property
752
+ def with_streaming_response(self) -> AsyncParticipantResourceWithStreamingResponse:
753
+ """
754
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
755
+
756
+ For more information, see https://www.github.com/growsurf/growsurf-python#with_streaming_response
757
+ """
758
+ return AsyncParticipantResourceWithStreamingResponse(self)
759
+
760
+ async def retrieve(
761
+ self,
762
+ participant_id_or_email: str,
763
+ *,
764
+ id: str,
765
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
766
+ # The extra values given here take precedence over values defined on the client or passed to this method.
767
+ extra_headers: Headers | None = None,
768
+ extra_query: Query | None = None,
769
+ extra_body: Body | None = None,
770
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
771
+ ) -> Participant:
772
+ """
773
+ Retrieves a single participant by GrowSurf participant ID or email address.
774
+
775
+ Args:
776
+ extra_headers: Send extra headers
777
+
778
+ extra_query: Add additional query parameters to the request
779
+
780
+ extra_body: Add additional JSON properties to the request
781
+
782
+ timeout: Override the client-level default timeout for this request, in seconds
783
+ """
784
+ if not id:
785
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
786
+ if not participant_id_or_email:
787
+ raise ValueError(
788
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
789
+ )
790
+ return await self._get(
791
+ path_template(
792
+ "/campaign/{id}/participant/{participant_id_or_email}",
793
+ id=id,
794
+ participant_id_or_email=participant_id_or_email,
795
+ ),
796
+ options=make_request_options(
797
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
798
+ ),
799
+ cast_to=Participant,
800
+ )
801
+
802
+ async def update(
803
+ self,
804
+ participant_id_or_email: str,
805
+ *,
806
+ id: str,
807
+ email: str | Omit = omit,
808
+ first_name: str | Omit = omit,
809
+ last_name: str | Omit = omit,
810
+ metadata: Dict[str, object] | Omit = omit,
811
+ referral_status: Literal["CREDIT_PENDING", "CREDIT_AWARDED", "CREDIT_EXPIRED"] | Omit = omit,
812
+ referred_by: str | Omit = omit,
813
+ unsubscribed: bool | Omit = omit,
814
+ vanity_keys: SequenceNotStr[str] | Omit = omit,
815
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
816
+ # The extra values given here take precedence over values defined on the client or passed to this method.
817
+ extra_headers: Headers | None = None,
818
+ extra_query: Query | None = None,
819
+ extra_body: Body | None = None,
820
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
821
+ ) -> Participant:
822
+ """
823
+ Updates a participant by GrowSurf participant ID or email address.
824
+
825
+ Args:
826
+ metadata: Shallow custom metadata object.
827
+
828
+ extra_headers: Send extra headers
829
+
830
+ extra_query: Add additional query parameters to the request
831
+
832
+ extra_body: Add additional JSON properties to the request
833
+
834
+ timeout: Override the client-level default timeout for this request, in seconds
835
+ """
836
+ if not id:
837
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
838
+ if not participant_id_or_email:
839
+ raise ValueError(
840
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
841
+ )
842
+ return await self._post(
843
+ path_template(
844
+ "/campaign/{id}/participant/{participant_id_or_email}",
845
+ id=id,
846
+ participant_id_or_email=participant_id_or_email,
847
+ ),
848
+ body=await async_maybe_transform(
849
+ {
850
+ "email": email,
851
+ "first_name": first_name,
852
+ "last_name": last_name,
853
+ "metadata": metadata,
854
+ "referral_status": referral_status,
855
+ "referred_by": referred_by,
856
+ "unsubscribed": unsubscribed,
857
+ "vanity_keys": vanity_keys,
858
+ },
859
+ participant_update_params.ParticipantUpdateParams,
860
+ ),
861
+ options=make_request_options(
862
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
863
+ ),
864
+ cast_to=Participant,
865
+ )
866
+
867
+ async def delete(
868
+ self,
869
+ participant_id_or_email: str,
870
+ *,
871
+ id: str,
872
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
873
+ # The extra values given here take precedence over values defined on the client or passed to this method.
874
+ extra_headers: Headers | None = None,
875
+ extra_query: Query | None = None,
876
+ extra_body: Body | None = None,
877
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
878
+ ) -> ParticipantDeleteResponse:
879
+ """
880
+ Removes a participant by GrowSurf participant ID or email address.
881
+
882
+ Args:
883
+ extra_headers: Send extra headers
884
+
885
+ extra_query: Add additional query parameters to the request
886
+
887
+ extra_body: Add additional JSON properties to the request
888
+
889
+ timeout: Override the client-level default timeout for this request, in seconds
890
+ """
891
+ if not id:
892
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
893
+ if not participant_id_or_email:
894
+ raise ValueError(
895
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
896
+ )
897
+ return await self._delete(
898
+ path_template(
899
+ "/campaign/{id}/participant/{participant_id_or_email}",
900
+ id=id,
901
+ participant_id_or_email=participant_id_or_email,
902
+ ),
903
+ options=make_request_options(
904
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
905
+ ),
906
+ cast_to=ParticipantDeleteResponse,
907
+ )
908
+
909
+ async def add(
910
+ self,
911
+ id: str,
912
+ *,
913
+ email: str,
914
+ fingerprint: str | Omit = omit,
915
+ first_name: str | Omit = omit,
916
+ ip_address: str | Omit = omit,
917
+ last_name: str | Omit = omit,
918
+ metadata: Dict[str, object] | Omit = omit,
919
+ referral_status: Literal["CREDIT_PENDING", "CREDIT_AWARDED"] | Omit = omit,
920
+ referred_by: str | Omit = omit,
921
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
922
+ # The extra values given here take precedence over values defined on the client or passed to this method.
923
+ extra_headers: Headers | None = None,
924
+ extra_query: Query | None = None,
925
+ extra_body: Body | None = None,
926
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
927
+ ) -> Participant:
928
+ """Adds a new participant to the program.
929
+
930
+ If the email already exists, the existing
931
+ participant is returned.
932
+
933
+ Args:
934
+ metadata: Shallow custom metadata object.
935
+
936
+ referred_by: Referrer participant ID or email address.
937
+
938
+ extra_headers: Send extra headers
939
+
940
+ extra_query: Add additional query parameters to the request
941
+
942
+ extra_body: Add additional JSON properties to the request
943
+
944
+ timeout: Override the client-level default timeout for this request, in seconds
945
+ """
946
+ if not id:
947
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
948
+ return await self._post(
949
+ path_template("/campaign/{id}/participant", id=id),
950
+ body=await async_maybe_transform(
951
+ {
952
+ "email": email,
953
+ "fingerprint": fingerprint,
954
+ "first_name": first_name,
955
+ "ip_address": ip_address,
956
+ "last_name": last_name,
957
+ "metadata": metadata,
958
+ "referral_status": referral_status,
959
+ "referred_by": referred_by,
960
+ },
961
+ participant_add_params.ParticipantAddParams,
962
+ ),
963
+ options=make_request_options(
964
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
965
+ ),
966
+ cast_to=Participant,
967
+ )
968
+
969
+ async def list_commissions(
970
+ self,
971
+ participant_id_or_email: str,
972
+ *,
973
+ id: str,
974
+ limit: int | Omit = omit,
975
+ next_id: str | Omit = omit,
976
+ status: Literal["PENDING", "APPROVED", "PAID", "REVERSED", "DELETED"] | Omit = omit,
977
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
978
+ # The extra values given here take precedence over values defined on the client or passed to this method.
979
+ extra_headers: Headers | None = None,
980
+ extra_query: Query | None = None,
981
+ extra_body: Body | None = None,
982
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
983
+ ) -> ParticipantCommissionList:
984
+ """
985
+ Retrieves a paged list of commissions earned by a participant.
986
+
987
+ Args:
988
+ limit: Number of results to return. Maximum 100.
989
+
990
+ next_id: ID to start the next paged result set with.
991
+
992
+ status: Participant commission status.
993
+
994
+ extra_headers: Send extra headers
995
+
996
+ extra_query: Add additional query parameters to the request
997
+
998
+ extra_body: Add additional JSON properties to the request
999
+
1000
+ timeout: Override the client-level default timeout for this request, in seconds
1001
+ """
1002
+ if not id:
1003
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1004
+ if not participant_id_or_email:
1005
+ raise ValueError(
1006
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
1007
+ )
1008
+ return await self._get(
1009
+ path_template(
1010
+ "/campaign/{id}/participant/{participant_id_or_email}/commissions",
1011
+ id=id,
1012
+ participant_id_or_email=participant_id_or_email,
1013
+ ),
1014
+ options=make_request_options(
1015
+ extra_headers=extra_headers,
1016
+ extra_query=extra_query,
1017
+ extra_body=extra_body,
1018
+ timeout=timeout,
1019
+ query=await async_maybe_transform(
1020
+ {
1021
+ "limit": limit,
1022
+ "next_id": next_id,
1023
+ "status": status,
1024
+ },
1025
+ participant_list_commissions_params.ParticipantListCommissionsParams,
1026
+ ),
1027
+ ),
1028
+ cast_to=ParticipantCommissionList,
1029
+ )
1030
+
1031
+ async def list_payouts(
1032
+ self,
1033
+ participant_id_or_email: str,
1034
+ *,
1035
+ id: str,
1036
+ limit: int | Omit = omit,
1037
+ next_id: str | Omit = omit,
1038
+ status: Literal["UPCOMING", "QUEUED", "ISSUED", "FAILED"] | Omit = omit,
1039
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1040
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1041
+ extra_headers: Headers | None = None,
1042
+ extra_query: Query | None = None,
1043
+ extra_body: Body | None = None,
1044
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1045
+ ) -> ParticipantPayoutList:
1046
+ """
1047
+ Retrieves a paged list of payouts that belong to a participant.
1048
+
1049
+ Args:
1050
+ limit: Number of results to return. Maximum 100.
1051
+
1052
+ next_id: ID to start the next paged result set with.
1053
+
1054
+ status: Participant payout status.
1055
+
1056
+ extra_headers: Send extra headers
1057
+
1058
+ extra_query: Add additional query parameters to the request
1059
+
1060
+ extra_body: Add additional JSON properties to the request
1061
+
1062
+ timeout: Override the client-level default timeout for this request, in seconds
1063
+ """
1064
+ if not id:
1065
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1066
+ if not participant_id_or_email:
1067
+ raise ValueError(
1068
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
1069
+ )
1070
+ return await self._get(
1071
+ path_template(
1072
+ "/campaign/{id}/participant/{participant_id_or_email}/payouts",
1073
+ id=id,
1074
+ participant_id_or_email=participant_id_or_email,
1075
+ ),
1076
+ options=make_request_options(
1077
+ extra_headers=extra_headers,
1078
+ extra_query=extra_query,
1079
+ extra_body=extra_body,
1080
+ timeout=timeout,
1081
+ query=await async_maybe_transform(
1082
+ {
1083
+ "limit": limit,
1084
+ "next_id": next_id,
1085
+ "status": status,
1086
+ },
1087
+ participant_list_payouts_params.ParticipantListPayoutsParams,
1088
+ ),
1089
+ ),
1090
+ cast_to=ParticipantPayoutList,
1091
+ )
1092
+
1093
+ async def list_referrals(
1094
+ self,
1095
+ participant_id_or_email: str,
1096
+ *,
1097
+ id: str,
1098
+ desc: bool | Omit = omit,
1099
+ email: str | Omit = omit,
1100
+ first_name: str | Omit = omit,
1101
+ last_name: str | Omit = omit,
1102
+ limit: int | Omit = omit,
1103
+ next_id: str | Omit = omit,
1104
+ offset: int | Omit = omit,
1105
+ referral_status: ReferralStatus | Omit = omit,
1106
+ sort_by: Literal[
1107
+ "updatedAt", "createdAt", "email", "firstName", "lastName", "referralStatus", "referralTriggeredAt"
1108
+ ]
1109
+ | Omit = omit,
1110
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1111
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1112
+ extra_headers: Headers | None = None,
1113
+ extra_query: Query | None = None,
1114
+ extra_body: Body | None = None,
1115
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1116
+ ) -> ReferralList:
1117
+ """
1118
+ Retrieves referrals and email invites made by a participant.
1119
+
1120
+ Args:
1121
+ desc: Return results in descending order when true.
1122
+
1123
+ email: URL-encoded email value to filter referral results.
1124
+
1125
+ first_name: First name value to filter results.
1126
+
1127
+ last_name: Last name value to filter results.
1128
+
1129
+ limit: Number of results to return. Maximum 100.
1130
+
1131
+ next_id: ID to start the next paged result set with.
1132
+
1133
+ offset: Offset number used to skip through a result set.
1134
+
1135
+ sort_by: Field used to sort referral results.
1136
+
1137
+ extra_headers: Send extra headers
1138
+
1139
+ extra_query: Add additional query parameters to the request
1140
+
1141
+ extra_body: Add additional JSON properties to the request
1142
+
1143
+ timeout: Override the client-level default timeout for this request, in seconds
1144
+ """
1145
+ if not id:
1146
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1147
+ if not participant_id_or_email:
1148
+ raise ValueError(
1149
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
1150
+ )
1151
+ return await self._get(
1152
+ path_template(
1153
+ "/campaign/{id}/participant/{participant_id_or_email}/referrals",
1154
+ id=id,
1155
+ participant_id_or_email=participant_id_or_email,
1156
+ ),
1157
+ options=make_request_options(
1158
+ extra_headers=extra_headers,
1159
+ extra_query=extra_query,
1160
+ extra_body=extra_body,
1161
+ timeout=timeout,
1162
+ query=await async_maybe_transform(
1163
+ {
1164
+ "desc": desc,
1165
+ "email": email,
1166
+ "first_name": first_name,
1167
+ "last_name": last_name,
1168
+ "limit": limit,
1169
+ "next_id": next_id,
1170
+ "offset": offset,
1171
+ "referral_status": referral_status,
1172
+ "sort_by": sort_by,
1173
+ },
1174
+ participant_list_referrals_params.ParticipantListReferralsParams,
1175
+ ),
1176
+ ),
1177
+ cast_to=ReferralList,
1178
+ )
1179
+
1180
+ async def list_rewards(
1181
+ self,
1182
+ participant_id_or_email: str,
1183
+ *,
1184
+ id: str,
1185
+ limit: int | Omit = omit,
1186
+ next_id: str | Omit = omit,
1187
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1188
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1189
+ extra_headers: Headers | None = None,
1190
+ extra_query: Query | None = None,
1191
+ extra_body: Body | None = None,
1192
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1193
+ ) -> ParticipantListRewardsResponse:
1194
+ """
1195
+ Retrieves a paged list of rewards earned by a participant.
1196
+
1197
+ Args:
1198
+ limit: Number of results to return. Maximum 100.
1199
+
1200
+ next_id: ID to start the next paged result set with.
1201
+
1202
+ extra_headers: Send extra headers
1203
+
1204
+ extra_query: Add additional query parameters to the request
1205
+
1206
+ extra_body: Add additional JSON properties to the request
1207
+
1208
+ timeout: Override the client-level default timeout for this request, in seconds
1209
+ """
1210
+ if not id:
1211
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1212
+ if not participant_id_or_email:
1213
+ raise ValueError(
1214
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
1215
+ )
1216
+ return await self._get(
1217
+ path_template(
1218
+ "/campaign/{id}/participant/{participant_id_or_email}/rewards",
1219
+ id=id,
1220
+ participant_id_or_email=participant_id_or_email,
1221
+ ),
1222
+ options=make_request_options(
1223
+ extra_headers=extra_headers,
1224
+ extra_query=extra_query,
1225
+ extra_body=extra_body,
1226
+ timeout=timeout,
1227
+ query=await async_maybe_transform(
1228
+ {
1229
+ "limit": limit,
1230
+ "next_id": next_id,
1231
+ },
1232
+ participant_list_rewards_params.ParticipantListRewardsParams,
1233
+ ),
1234
+ ),
1235
+ cast_to=ParticipantListRewardsResponse,
1236
+ )
1237
+
1238
+ async def record_transaction(
1239
+ self,
1240
+ participant_id_or_email: str,
1241
+ *,
1242
+ id: str,
1243
+ currency: str,
1244
+ gross_amount: int,
1245
+ amount_cash_net: int | Omit = omit,
1246
+ amount_paid: int | Omit = omit,
1247
+ charge_id: str | Omit = omit,
1248
+ customer_id: str | Omit = omit,
1249
+ description: str | Omit = omit,
1250
+ external_id: str | Omit = omit,
1251
+ invoice_id: str | Omit = omit,
1252
+ invoice_subtotal_excluding_tax: int | Omit = omit,
1253
+ invoice_total: int | Omit = omit,
1254
+ invoice_total_excluding_tax: int | Omit = omit,
1255
+ net_amount: int | Omit = omit,
1256
+ order_id: str | Omit = omit,
1257
+ paid_at: int | Omit = omit,
1258
+ payment_id: str | Omit = omit,
1259
+ payment_intent_id: str | Omit = omit,
1260
+ subscription_id: str | Omit = omit,
1261
+ tax_amount: int | Omit = omit,
1262
+ total_tax_amount: int | Omit = omit,
1263
+ total_tax_amounts: Iterable[Dict[str, object]] | Omit = omit,
1264
+ total_taxes: Iterable[Dict[str, object]] | Omit = omit,
1265
+ transaction_id: str | Omit = omit,
1266
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1267
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1268
+ extra_headers: Headers | None = None,
1269
+ extra_query: Query | None = None,
1270
+ extra_body: Body | None = None,
1271
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1272
+ ) -> ParticipantRecordTransactionResponse:
1273
+ """
1274
+ Records a sale made by a referred customer and generates affiliate commissions
1275
+ for their referrer when applicable.
1276
+
1277
+ Args:
1278
+ extra_headers: Send extra headers
1279
+
1280
+ extra_query: Add additional query parameters to the request
1281
+
1282
+ extra_body: Add additional JSON properties to the request
1283
+
1284
+ timeout: Override the client-level default timeout for this request, in seconds
1285
+ """
1286
+ if not id:
1287
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1288
+ if not participant_id_or_email:
1289
+ raise ValueError(
1290
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
1291
+ )
1292
+ return cast(
1293
+ ParticipantRecordTransactionResponse,
1294
+ await self._post(
1295
+ path_template(
1296
+ "/campaign/{id}/participant/{participant_id_or_email}/transaction",
1297
+ id=id,
1298
+ participant_id_or_email=participant_id_or_email,
1299
+ ),
1300
+ body=await async_maybe_transform(
1301
+ {
1302
+ "currency": currency,
1303
+ "gross_amount": gross_amount,
1304
+ "amount_cash_net": amount_cash_net,
1305
+ "amount_paid": amount_paid,
1306
+ "charge_id": charge_id,
1307
+ "customer_id": customer_id,
1308
+ "description": description,
1309
+ "external_id": external_id,
1310
+ "invoice_id": invoice_id,
1311
+ "invoice_subtotal_excluding_tax": invoice_subtotal_excluding_tax,
1312
+ "invoice_total": invoice_total,
1313
+ "invoice_total_excluding_tax": invoice_total_excluding_tax,
1314
+ "net_amount": net_amount,
1315
+ "order_id": order_id,
1316
+ "paid_at": paid_at,
1317
+ "payment_id": payment_id,
1318
+ "payment_intent_id": payment_intent_id,
1319
+ "subscription_id": subscription_id,
1320
+ "tax_amount": tax_amount,
1321
+ "total_tax_amount": total_tax_amount,
1322
+ "total_tax_amounts": total_tax_amounts,
1323
+ "total_taxes": total_taxes,
1324
+ "transaction_id": transaction_id,
1325
+ },
1326
+ participant_record_transaction_params.ParticipantRecordTransactionParams,
1327
+ ),
1328
+ options=make_request_options(
1329
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1330
+ ),
1331
+ cast_to=cast(
1332
+ Any, ParticipantRecordTransactionResponse
1333
+ ), # Union types cannot be passed in as arguments in the type system
1334
+ ),
1335
+ )
1336
+
1337
+ async def send_invites(
1338
+ self,
1339
+ participant_id_or_email: str,
1340
+ *,
1341
+ id: str,
1342
+ email_addresses: SequenceNotStr[str],
1343
+ message_text: str,
1344
+ subject_text: str,
1345
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1346
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1347
+ extra_headers: Headers | None = None,
1348
+ extra_query: Query | None = None,
1349
+ extra_body: Body | None = None,
1350
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1351
+ ) -> ParticipantSendInvitesResponse:
1352
+ """
1353
+ Sends email invites on behalf of a participant to a list of email addresses.
1354
+
1355
+ Args:
1356
+ extra_headers: Send extra headers
1357
+
1358
+ extra_query: Add additional query parameters to the request
1359
+
1360
+ extra_body: Add additional JSON properties to the request
1361
+
1362
+ timeout: Override the client-level default timeout for this request, in seconds
1363
+ """
1364
+ if not id:
1365
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1366
+ if not participant_id_or_email:
1367
+ raise ValueError(
1368
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
1369
+ )
1370
+ return await self._post(
1371
+ path_template(
1372
+ "/campaign/{id}/participant/{participant_id_or_email}/invites",
1373
+ id=id,
1374
+ participant_id_or_email=participant_id_or_email,
1375
+ ),
1376
+ body=await async_maybe_transform(
1377
+ {
1378
+ "email_addresses": email_addresses,
1379
+ "message_text": message_text,
1380
+ "subject_text": subject_text,
1381
+ },
1382
+ participant_send_invites_params.ParticipantSendInvitesParams,
1383
+ ),
1384
+ options=make_request_options(
1385
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1386
+ ),
1387
+ cast_to=ParticipantSendInvitesResponse,
1388
+ )
1389
+
1390
+ async def trigger_referral(
1391
+ self,
1392
+ participant_id_or_email: str,
1393
+ *,
1394
+ id: str,
1395
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1396
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1397
+ extra_headers: Headers | None = None,
1398
+ extra_query: Query | None = None,
1399
+ extra_body: Body | None = None,
1400
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1401
+ ) -> ParticipantTriggerReferralResponse:
1402
+ """
1403
+ Triggers referral credit for an existing referred participant by GrowSurf
1404
+ participant ID or email address.
1405
+
1406
+ Args:
1407
+ extra_headers: Send extra headers
1408
+
1409
+ extra_query: Add additional query parameters to the request
1410
+
1411
+ extra_body: Add additional JSON properties to the request
1412
+
1413
+ timeout: Override the client-level default timeout for this request, in seconds
1414
+ """
1415
+ if not id:
1416
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1417
+ if not participant_id_or_email:
1418
+ raise ValueError(
1419
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
1420
+ )
1421
+ return await self._post(
1422
+ path_template(
1423
+ "/campaign/{id}/participant/{participant_id_or_email}/ref",
1424
+ id=id,
1425
+ participant_id_or_email=participant_id_or_email,
1426
+ ),
1427
+ options=make_request_options(
1428
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1429
+ ),
1430
+ cast_to=ParticipantTriggerReferralResponse,
1431
+ )
1432
+
1433
+
1434
+ class ParticipantResourceWithRawResponse:
1435
+ def __init__(self, participant: ParticipantResource) -> None:
1436
+ self._participant = participant
1437
+
1438
+ self.retrieve = to_raw_response_wrapper(
1439
+ participant.retrieve,
1440
+ )
1441
+ self.update = to_raw_response_wrapper(
1442
+ participant.update,
1443
+ )
1444
+ self.delete = to_raw_response_wrapper(
1445
+ participant.delete,
1446
+ )
1447
+ self.add = to_raw_response_wrapper(
1448
+ participant.add,
1449
+ )
1450
+ self.list_commissions = to_raw_response_wrapper(
1451
+ participant.list_commissions,
1452
+ )
1453
+ self.list_payouts = to_raw_response_wrapper(
1454
+ participant.list_payouts,
1455
+ )
1456
+ self.list_referrals = to_raw_response_wrapper(
1457
+ participant.list_referrals,
1458
+ )
1459
+ self.list_rewards = to_raw_response_wrapper(
1460
+ participant.list_rewards,
1461
+ )
1462
+ self.record_transaction = to_raw_response_wrapper(
1463
+ participant.record_transaction,
1464
+ )
1465
+ self.send_invites = to_raw_response_wrapper(
1466
+ participant.send_invites,
1467
+ )
1468
+ self.trigger_referral = to_raw_response_wrapper(
1469
+ participant.trigger_referral,
1470
+ )
1471
+
1472
+
1473
+ class AsyncParticipantResourceWithRawResponse:
1474
+ def __init__(self, participant: AsyncParticipantResource) -> None:
1475
+ self._participant = participant
1476
+
1477
+ self.retrieve = async_to_raw_response_wrapper(
1478
+ participant.retrieve,
1479
+ )
1480
+ self.update = async_to_raw_response_wrapper(
1481
+ participant.update,
1482
+ )
1483
+ self.delete = async_to_raw_response_wrapper(
1484
+ participant.delete,
1485
+ )
1486
+ self.add = async_to_raw_response_wrapper(
1487
+ participant.add,
1488
+ )
1489
+ self.list_commissions = async_to_raw_response_wrapper(
1490
+ participant.list_commissions,
1491
+ )
1492
+ self.list_payouts = async_to_raw_response_wrapper(
1493
+ participant.list_payouts,
1494
+ )
1495
+ self.list_referrals = async_to_raw_response_wrapper(
1496
+ participant.list_referrals,
1497
+ )
1498
+ self.list_rewards = async_to_raw_response_wrapper(
1499
+ participant.list_rewards,
1500
+ )
1501
+ self.record_transaction = async_to_raw_response_wrapper(
1502
+ participant.record_transaction,
1503
+ )
1504
+ self.send_invites = async_to_raw_response_wrapper(
1505
+ participant.send_invites,
1506
+ )
1507
+ self.trigger_referral = async_to_raw_response_wrapper(
1508
+ participant.trigger_referral,
1509
+ )
1510
+
1511
+
1512
+ class ParticipantResourceWithStreamingResponse:
1513
+ def __init__(self, participant: ParticipantResource) -> None:
1514
+ self._participant = participant
1515
+
1516
+ self.retrieve = to_streamed_response_wrapper(
1517
+ participant.retrieve,
1518
+ )
1519
+ self.update = to_streamed_response_wrapper(
1520
+ participant.update,
1521
+ )
1522
+ self.delete = to_streamed_response_wrapper(
1523
+ participant.delete,
1524
+ )
1525
+ self.add = to_streamed_response_wrapper(
1526
+ participant.add,
1527
+ )
1528
+ self.list_commissions = to_streamed_response_wrapper(
1529
+ participant.list_commissions,
1530
+ )
1531
+ self.list_payouts = to_streamed_response_wrapper(
1532
+ participant.list_payouts,
1533
+ )
1534
+ self.list_referrals = to_streamed_response_wrapper(
1535
+ participant.list_referrals,
1536
+ )
1537
+ self.list_rewards = to_streamed_response_wrapper(
1538
+ participant.list_rewards,
1539
+ )
1540
+ self.record_transaction = to_streamed_response_wrapper(
1541
+ participant.record_transaction,
1542
+ )
1543
+ self.send_invites = to_streamed_response_wrapper(
1544
+ participant.send_invites,
1545
+ )
1546
+ self.trigger_referral = to_streamed_response_wrapper(
1547
+ participant.trigger_referral,
1548
+ )
1549
+
1550
+
1551
+ class AsyncParticipantResourceWithStreamingResponse:
1552
+ def __init__(self, participant: AsyncParticipantResource) -> None:
1553
+ self._participant = participant
1554
+
1555
+ self.retrieve = async_to_streamed_response_wrapper(
1556
+ participant.retrieve,
1557
+ )
1558
+ self.update = async_to_streamed_response_wrapper(
1559
+ participant.update,
1560
+ )
1561
+ self.delete = async_to_streamed_response_wrapper(
1562
+ participant.delete,
1563
+ )
1564
+ self.add = async_to_streamed_response_wrapper(
1565
+ participant.add,
1566
+ )
1567
+ self.list_commissions = async_to_streamed_response_wrapper(
1568
+ participant.list_commissions,
1569
+ )
1570
+ self.list_payouts = async_to_streamed_response_wrapper(
1571
+ participant.list_payouts,
1572
+ )
1573
+ self.list_referrals = async_to_streamed_response_wrapper(
1574
+ participant.list_referrals,
1575
+ )
1576
+ self.list_rewards = async_to_streamed_response_wrapper(
1577
+ participant.list_rewards,
1578
+ )
1579
+ self.record_transaction = async_to_streamed_response_wrapper(
1580
+ participant.record_transaction,
1581
+ )
1582
+ self.send_invites = async_to_streamed_response_wrapper(
1583
+ participant.send_invites,
1584
+ )
1585
+ self.trigger_referral = async_to_streamed_response_wrapper(
1586
+ participant.trigger_referral,
1587
+ )