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,1126 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing_extensions import Literal
6
+
7
+ import httpx
8
+
9
+ from .reward import (
10
+ RewardResource,
11
+ AsyncRewardResource,
12
+ RewardResourceWithRawResponse,
13
+ AsyncRewardResourceWithRawResponse,
14
+ RewardResourceWithStreamingResponse,
15
+ AsyncRewardResourceWithStreamingResponse,
16
+ )
17
+ from ...types import (
18
+ campaign_list_payouts_params,
19
+ campaign_list_referrals_params,
20
+ campaign_list_commissions_params,
21
+ campaign_list_leaderboard_params,
22
+ campaign_list_participants_params,
23
+ campaign_retrieve_analytics_params,
24
+ )
25
+ from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
26
+ from ..._utils import path_template, maybe_transform, async_maybe_transform
27
+ from ..._compat import cached_property
28
+ from .commission import (
29
+ CommissionResource,
30
+ AsyncCommissionResource,
31
+ CommissionResourceWithRawResponse,
32
+ AsyncCommissionResourceWithRawResponse,
33
+ CommissionResourceWithStreamingResponse,
34
+ AsyncCommissionResourceWithStreamingResponse,
35
+ )
36
+ from ..._resource import SyncAPIResource, AsyncAPIResource
37
+ from ..._response import (
38
+ to_raw_response_wrapper,
39
+ to_streamed_response_wrapper,
40
+ async_to_raw_response_wrapper,
41
+ async_to_streamed_response_wrapper,
42
+ )
43
+ from .participant import (
44
+ ParticipantResource,
45
+ AsyncParticipantResource,
46
+ ParticipantResourceWithRawResponse,
47
+ AsyncParticipantResourceWithRawResponse,
48
+ ParticipantResourceWithStreamingResponse,
49
+ AsyncParticipantResourceWithStreamingResponse,
50
+ )
51
+ from ..._base_client import make_request_options
52
+ from ...types.campaign import ReferralStatus
53
+ from ...types.referral_list import ReferralList
54
+ from ...types.participant_list import ParticipantList
55
+ from ...types.campaign.campaign import Campaign
56
+ from ...types.campaign_list_response import CampaignListResponse
57
+ from ...types.participant_payout_list import ParticipantPayoutList
58
+ from ...types.campaign.referral_status import ReferralStatus
59
+ from ...types.participant_commission_list import ParticipantCommissionList
60
+ from ...types.campaign_retrieve_analytics_response import CampaignRetrieveAnalyticsResponse
61
+
62
+ __all__ = ["CampaignResource", "AsyncCampaignResource"]
63
+
64
+
65
+ class CampaignResource(SyncAPIResource):
66
+ @cached_property
67
+ def participant(self) -> ParticipantResource:
68
+ return ParticipantResource(self._client)
69
+
70
+ @cached_property
71
+ def reward(self) -> RewardResource:
72
+ """Participant reward retrieval and manual reward operations."""
73
+ return RewardResource(self._client)
74
+
75
+ @cached_property
76
+ def commission(self) -> CommissionResource:
77
+ """Affiliate transaction, commission, and payout operations."""
78
+ return CommissionResource(self._client)
79
+
80
+ @cached_property
81
+ def with_raw_response(self) -> CampaignResourceWithRawResponse:
82
+ """
83
+ This property can be used as a prefix for any HTTP method call to return
84
+ the raw response object instead of the parsed content.
85
+
86
+ For more information, see https://www.github.com/growsurf/growsurf-python#accessing-raw-response-data-eg-headers
87
+ """
88
+ return CampaignResourceWithRawResponse(self)
89
+
90
+ @cached_property
91
+ def with_streaming_response(self) -> CampaignResourceWithStreamingResponse:
92
+ """
93
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
94
+
95
+ For more information, see https://www.github.com/growsurf/growsurf-python#with_streaming_response
96
+ """
97
+ return CampaignResourceWithStreamingResponse(self)
98
+
99
+ def retrieve(
100
+ self,
101
+ id: str,
102
+ *,
103
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
104
+ # The extra values given here take precedence over values defined on the client or passed to this method.
105
+ extra_headers: Headers | None = None,
106
+ extra_query: Query | None = None,
107
+ extra_body: Body | None = None,
108
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
109
+ ) -> Campaign:
110
+ """
111
+ Retrieves a program for the given program ID.
112
+
113
+ Args:
114
+ extra_headers: Send extra headers
115
+
116
+ extra_query: Add additional query parameters to the request
117
+
118
+ extra_body: Add additional JSON properties to the request
119
+
120
+ timeout: Override the client-level default timeout for this request, in seconds
121
+ """
122
+ if not id:
123
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
124
+ return self._get(
125
+ path_template("/campaign/{id}", id=id),
126
+ options=make_request_options(
127
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
128
+ ),
129
+ cast_to=Campaign,
130
+ )
131
+
132
+ def list(
133
+ self,
134
+ *,
135
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
136
+ # The extra values given here take precedence over values defined on the client or passed to this method.
137
+ extra_headers: Headers | None = None,
138
+ extra_query: Query | None = None,
139
+ extra_body: Body | None = None,
140
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
141
+ ) -> CampaignListResponse:
142
+ """Retrieves a list of your programs. Deleted programs are not returned."""
143
+ return self._get(
144
+ "/campaigns",
145
+ options=make_request_options(
146
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
147
+ ),
148
+ cast_to=CampaignListResponse,
149
+ )
150
+
151
+ def list_commissions(
152
+ self,
153
+ id: str,
154
+ *,
155
+ limit: int | Omit = omit,
156
+ next_id: str | Omit = omit,
157
+ status: Literal["PENDING", "APPROVED", "PAID", "REVERSED", "DELETED"] | Omit = omit,
158
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
159
+ # The extra values given here take precedence over values defined on the client or passed to this method.
160
+ extra_headers: Headers | None = None,
161
+ extra_query: Query | None = None,
162
+ extra_body: Body | None = None,
163
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
164
+ ) -> ParticipantCommissionList:
165
+ """
166
+ Retrieves a paged list of all participant commissions in an affiliate program.
167
+
168
+ Args:
169
+ limit: Number of results to return. Maximum 100.
170
+
171
+ next_id: ID to start the next paged result set with.
172
+
173
+ status: Participant commission status.
174
+
175
+ extra_headers: Send extra headers
176
+
177
+ extra_query: Add additional query parameters to the request
178
+
179
+ extra_body: Add additional JSON properties to the request
180
+
181
+ timeout: Override the client-level default timeout for this request, in seconds
182
+ """
183
+ if not id:
184
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
185
+ return self._get(
186
+ path_template("/campaign/{id}/commissions", id=id),
187
+ options=make_request_options(
188
+ extra_headers=extra_headers,
189
+ extra_query=extra_query,
190
+ extra_body=extra_body,
191
+ timeout=timeout,
192
+ query=maybe_transform(
193
+ {
194
+ "limit": limit,
195
+ "next_id": next_id,
196
+ "status": status,
197
+ },
198
+ campaign_list_commissions_params.CampaignListCommissionsParams,
199
+ ),
200
+ ),
201
+ cast_to=ParticipantCommissionList,
202
+ )
203
+
204
+ def list_leaderboard(
205
+ self,
206
+ id: str,
207
+ *,
208
+ is_monthly: bool | Omit = omit,
209
+ leaderboard_type: Literal[
210
+ "ALL_TIME",
211
+ "CURRENT_MONTH",
212
+ "PREV_MONTH",
213
+ "TOTAL_IMPRESSION_COUNT",
214
+ "UNIQUE_IMPRESSION_COUNT",
215
+ "BY_COMMISSIONS",
216
+ "BY_REVENUE",
217
+ "BY_REFERRALS",
218
+ "BY_LEADS",
219
+ ]
220
+ | Omit = omit,
221
+ limit: int | Omit = omit,
222
+ next_id: str | Omit = omit,
223
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
224
+ # The extra values given here take precedence over values defined on the client or passed to this method.
225
+ extra_headers: Headers | None = None,
226
+ extra_query: Query | None = None,
227
+ extra_body: Body | None = None,
228
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
229
+ ) -> ParticipantList:
230
+ """
231
+ Retrieves participants in leaderboard order for the specified leaderboard type.
232
+
233
+ Args:
234
+ is_monthly: Deprecated. Use `leaderboardType=CURRENT_MONTH` instead.
235
+
236
+ leaderboard_type: Leaderboard ordering mode.
237
+
238
+ limit: Number of results to return. Maximum 100.
239
+
240
+ next_id: ID to start the next paged result set with.
241
+
242
+ extra_headers: Send extra headers
243
+
244
+ extra_query: Add additional query parameters to the request
245
+
246
+ extra_body: Add additional JSON properties to the request
247
+
248
+ timeout: Override the client-level default timeout for this request, in seconds
249
+ """
250
+ if not id:
251
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
252
+ return self._get(
253
+ path_template("/campaign/{id}/leaderboard", id=id),
254
+ options=make_request_options(
255
+ extra_headers=extra_headers,
256
+ extra_query=extra_query,
257
+ extra_body=extra_body,
258
+ timeout=timeout,
259
+ query=maybe_transform(
260
+ {
261
+ "is_monthly": is_monthly,
262
+ "leaderboard_type": leaderboard_type,
263
+ "limit": limit,
264
+ "next_id": next_id,
265
+ },
266
+ campaign_list_leaderboard_params.CampaignListLeaderboardParams,
267
+ ),
268
+ ),
269
+ cast_to=ParticipantList,
270
+ )
271
+
272
+ def list_participants(
273
+ self,
274
+ id: str,
275
+ *,
276
+ limit: int | Omit = omit,
277
+ next_id: str | Omit = omit,
278
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
279
+ # The extra values given here take precedence over values defined on the client or passed to this method.
280
+ extra_headers: Headers | None = None,
281
+ extra_query: Query | None = None,
282
+ extra_body: Body | None = None,
283
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
284
+ ) -> ParticipantList:
285
+ """
286
+ Retrieves a paged list of participants in a program.
287
+
288
+ Args:
289
+ limit: Number of results to return. Maximum 100.
290
+
291
+ next_id: ID to start the next paged result set with.
292
+
293
+ extra_headers: Send extra headers
294
+
295
+ extra_query: Add additional query parameters to the request
296
+
297
+ extra_body: Add additional JSON properties to the request
298
+
299
+ timeout: Override the client-level default timeout for this request, in seconds
300
+ """
301
+ if not id:
302
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
303
+ return self._get(
304
+ path_template("/campaign/{id}/participants", id=id),
305
+ options=make_request_options(
306
+ extra_headers=extra_headers,
307
+ extra_query=extra_query,
308
+ extra_body=extra_body,
309
+ timeout=timeout,
310
+ query=maybe_transform(
311
+ {
312
+ "limit": limit,
313
+ "next_id": next_id,
314
+ },
315
+ campaign_list_participants_params.CampaignListParticipantsParams,
316
+ ),
317
+ ),
318
+ cast_to=ParticipantList,
319
+ )
320
+
321
+ def list_payouts(
322
+ self,
323
+ id: str,
324
+ *,
325
+ limit: int | Omit = omit,
326
+ next_id: str | Omit = omit,
327
+ status: Literal["UPCOMING", "QUEUED", "ISSUED", "FAILED"] | Omit = omit,
328
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
329
+ # The extra values given here take precedence over values defined on the client or passed to this method.
330
+ extra_headers: Headers | None = None,
331
+ extra_query: Query | None = None,
332
+ extra_body: Body | None = None,
333
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
334
+ ) -> ParticipantPayoutList:
335
+ """
336
+ Retrieves a paged list of all participant payouts in an affiliate program.
337
+
338
+ Args:
339
+ limit: Number of results to return. Maximum 100.
340
+
341
+ next_id: ID to start the next paged result set with.
342
+
343
+ status: Participant payout status.
344
+
345
+ extra_headers: Send extra headers
346
+
347
+ extra_query: Add additional query parameters to the request
348
+
349
+ extra_body: Add additional JSON properties to the request
350
+
351
+ timeout: Override the client-level default timeout for this request, in seconds
352
+ """
353
+ if not id:
354
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
355
+ return self._get(
356
+ path_template("/campaign/{id}/payouts", id=id),
357
+ options=make_request_options(
358
+ extra_headers=extra_headers,
359
+ extra_query=extra_query,
360
+ extra_body=extra_body,
361
+ timeout=timeout,
362
+ query=maybe_transform(
363
+ {
364
+ "limit": limit,
365
+ "next_id": next_id,
366
+ "status": status,
367
+ },
368
+ campaign_list_payouts_params.CampaignListPayoutsParams,
369
+ ),
370
+ ),
371
+ cast_to=ParticipantPayoutList,
372
+ )
373
+
374
+ def list_referrals(
375
+ self,
376
+ id: str,
377
+ *,
378
+ desc: bool | Omit = omit,
379
+ email: str | Omit = omit,
380
+ first_name: str | Omit = omit,
381
+ last_name: str | Omit = omit,
382
+ limit: int | Omit = omit,
383
+ next_id: str | Omit = omit,
384
+ offset: int | Omit = omit,
385
+ referral_status: ReferralStatus | Omit = omit,
386
+ sort_by: Literal[
387
+ "updatedAt", "createdAt", "email", "firstName", "lastName", "referralStatus", "referralTriggeredAt"
388
+ ]
389
+ | Omit = omit,
390
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
391
+ # The extra values given here take precedence over values defined on the client or passed to this method.
392
+ extra_headers: Headers | None = None,
393
+ extra_query: Query | None = None,
394
+ extra_body: Body | None = None,
395
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
396
+ ) -> ReferralList:
397
+ """
398
+ Retrieves a list of all referrals and email invites made by participants in a
399
+ program.
400
+
401
+ Args:
402
+ desc: Return results in descending order when true.
403
+
404
+ email: URL-encoded email value to filter referral results.
405
+
406
+ first_name: First name value to filter results.
407
+
408
+ last_name: Last name value to filter results.
409
+
410
+ limit: Number of results to return. Maximum 100.
411
+
412
+ next_id: ID to start the next paged result set with.
413
+
414
+ offset: Offset number used to skip through a result set.
415
+
416
+ sort_by: Field used to sort referral results.
417
+
418
+ extra_headers: Send extra headers
419
+
420
+ extra_query: Add additional query parameters to the request
421
+
422
+ extra_body: Add additional JSON properties to the request
423
+
424
+ timeout: Override the client-level default timeout for this request, in seconds
425
+ """
426
+ if not id:
427
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
428
+ return self._get(
429
+ path_template("/campaign/{id}/referrals", id=id),
430
+ options=make_request_options(
431
+ extra_headers=extra_headers,
432
+ extra_query=extra_query,
433
+ extra_body=extra_body,
434
+ timeout=timeout,
435
+ query=maybe_transform(
436
+ {
437
+ "desc": desc,
438
+ "email": email,
439
+ "first_name": first_name,
440
+ "last_name": last_name,
441
+ "limit": limit,
442
+ "next_id": next_id,
443
+ "offset": offset,
444
+ "referral_status": referral_status,
445
+ "sort_by": sort_by,
446
+ },
447
+ campaign_list_referrals_params.CampaignListReferralsParams,
448
+ ),
449
+ ),
450
+ cast_to=ReferralList,
451
+ )
452
+
453
+ def retrieve_analytics(
454
+ self,
455
+ id: str,
456
+ *,
457
+ days: int | Omit = omit,
458
+ end_date: int | Omit = omit,
459
+ start_date: int | Omit = omit,
460
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
461
+ # The extra values given here take precedence over values defined on the client or passed to this method.
462
+ extra_headers: Headers | None = None,
463
+ extra_query: Query | None = None,
464
+ extra_body: Body | None = None,
465
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
466
+ ) -> CampaignRetrieveAnalyticsResponse:
467
+ """
468
+ Retrieves analytics for a program.
469
+
470
+ Args:
471
+ days: Last number of days to retrieve analytics for. Defaults to 365. Maximum 1825.
472
+
473
+ end_date: End date of the analytics timeframe as a Unix timestamp in milliseconds.
474
+ Required if `days` is not set.
475
+
476
+ start_date: Start date of the analytics timeframe as a Unix timestamp in milliseconds.
477
+ Required if `days` is not set.
478
+
479
+ extra_headers: Send extra headers
480
+
481
+ extra_query: Add additional query parameters to the request
482
+
483
+ extra_body: Add additional JSON properties to the request
484
+
485
+ timeout: Override the client-level default timeout for this request, in seconds
486
+ """
487
+ if not id:
488
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
489
+ return self._get(
490
+ path_template("/campaign/{id}/analytics", id=id),
491
+ options=make_request_options(
492
+ extra_headers=extra_headers,
493
+ extra_query=extra_query,
494
+ extra_body=extra_body,
495
+ timeout=timeout,
496
+ query=maybe_transform(
497
+ {
498
+ "days": days,
499
+ "end_date": end_date,
500
+ "start_date": start_date,
501
+ },
502
+ campaign_retrieve_analytics_params.CampaignRetrieveAnalyticsParams,
503
+ ),
504
+ ),
505
+ cast_to=CampaignRetrieveAnalyticsResponse,
506
+ )
507
+
508
+
509
+ class AsyncCampaignResource(AsyncAPIResource):
510
+ @cached_property
511
+ def participant(self) -> AsyncParticipantResource:
512
+ return AsyncParticipantResource(self._client)
513
+
514
+ @cached_property
515
+ def reward(self) -> AsyncRewardResource:
516
+ """Participant reward retrieval and manual reward operations."""
517
+ return AsyncRewardResource(self._client)
518
+
519
+ @cached_property
520
+ def commission(self) -> AsyncCommissionResource:
521
+ """Affiliate transaction, commission, and payout operations."""
522
+ return AsyncCommissionResource(self._client)
523
+
524
+ @cached_property
525
+ def with_raw_response(self) -> AsyncCampaignResourceWithRawResponse:
526
+ """
527
+ This property can be used as a prefix for any HTTP method call to return
528
+ the raw response object instead of the parsed content.
529
+
530
+ For more information, see https://www.github.com/growsurf/growsurf-python#accessing-raw-response-data-eg-headers
531
+ """
532
+ return AsyncCampaignResourceWithRawResponse(self)
533
+
534
+ @cached_property
535
+ def with_streaming_response(self) -> AsyncCampaignResourceWithStreamingResponse:
536
+ """
537
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
538
+
539
+ For more information, see https://www.github.com/growsurf/growsurf-python#with_streaming_response
540
+ """
541
+ return AsyncCampaignResourceWithStreamingResponse(self)
542
+
543
+ async def retrieve(
544
+ self,
545
+ id: str,
546
+ *,
547
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
548
+ # The extra values given here take precedence over values defined on the client or passed to this method.
549
+ extra_headers: Headers | None = None,
550
+ extra_query: Query | None = None,
551
+ extra_body: Body | None = None,
552
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
553
+ ) -> Campaign:
554
+ """
555
+ Retrieves a program for the given program ID.
556
+
557
+ Args:
558
+ extra_headers: Send extra headers
559
+
560
+ extra_query: Add additional query parameters to the request
561
+
562
+ extra_body: Add additional JSON properties to the request
563
+
564
+ timeout: Override the client-level default timeout for this request, in seconds
565
+ """
566
+ if not id:
567
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
568
+ return await self._get(
569
+ path_template("/campaign/{id}", id=id),
570
+ options=make_request_options(
571
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
572
+ ),
573
+ cast_to=Campaign,
574
+ )
575
+
576
+ async def list(
577
+ self,
578
+ *,
579
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
580
+ # The extra values given here take precedence over values defined on the client or passed to this method.
581
+ extra_headers: Headers | None = None,
582
+ extra_query: Query | None = None,
583
+ extra_body: Body | None = None,
584
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
585
+ ) -> CampaignListResponse:
586
+ """Retrieves a list of your programs. Deleted programs are not returned."""
587
+ return await self._get(
588
+ "/campaigns",
589
+ options=make_request_options(
590
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
591
+ ),
592
+ cast_to=CampaignListResponse,
593
+ )
594
+
595
+ async def list_commissions(
596
+ self,
597
+ id: str,
598
+ *,
599
+ limit: int | Omit = omit,
600
+ next_id: str | Omit = omit,
601
+ status: Literal["PENDING", "APPROVED", "PAID", "REVERSED", "DELETED"] | Omit = omit,
602
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
603
+ # The extra values given here take precedence over values defined on the client or passed to this method.
604
+ extra_headers: Headers | None = None,
605
+ extra_query: Query | None = None,
606
+ extra_body: Body | None = None,
607
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
608
+ ) -> ParticipantCommissionList:
609
+ """
610
+ Retrieves a paged list of all participant commissions in an affiliate program.
611
+
612
+ Args:
613
+ limit: Number of results to return. Maximum 100.
614
+
615
+ next_id: ID to start the next paged result set with.
616
+
617
+ status: Participant commission status.
618
+
619
+ extra_headers: Send extra headers
620
+
621
+ extra_query: Add additional query parameters to the request
622
+
623
+ extra_body: Add additional JSON properties to the request
624
+
625
+ timeout: Override the client-level default timeout for this request, in seconds
626
+ """
627
+ if not id:
628
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
629
+ return await self._get(
630
+ path_template("/campaign/{id}/commissions", id=id),
631
+ options=make_request_options(
632
+ extra_headers=extra_headers,
633
+ extra_query=extra_query,
634
+ extra_body=extra_body,
635
+ timeout=timeout,
636
+ query=await async_maybe_transform(
637
+ {
638
+ "limit": limit,
639
+ "next_id": next_id,
640
+ "status": status,
641
+ },
642
+ campaign_list_commissions_params.CampaignListCommissionsParams,
643
+ ),
644
+ ),
645
+ cast_to=ParticipantCommissionList,
646
+ )
647
+
648
+ async def list_leaderboard(
649
+ self,
650
+ id: str,
651
+ *,
652
+ is_monthly: bool | Omit = omit,
653
+ leaderboard_type: Literal[
654
+ "ALL_TIME",
655
+ "CURRENT_MONTH",
656
+ "PREV_MONTH",
657
+ "TOTAL_IMPRESSION_COUNT",
658
+ "UNIQUE_IMPRESSION_COUNT",
659
+ "BY_COMMISSIONS",
660
+ "BY_REVENUE",
661
+ "BY_REFERRALS",
662
+ "BY_LEADS",
663
+ ]
664
+ | Omit = omit,
665
+ limit: int | Omit = omit,
666
+ next_id: str | Omit = omit,
667
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
668
+ # The extra values given here take precedence over values defined on the client or passed to this method.
669
+ extra_headers: Headers | None = None,
670
+ extra_query: Query | None = None,
671
+ extra_body: Body | None = None,
672
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
673
+ ) -> ParticipantList:
674
+ """
675
+ Retrieves participants in leaderboard order for the specified leaderboard type.
676
+
677
+ Args:
678
+ is_monthly: Deprecated. Use `leaderboardType=CURRENT_MONTH` instead.
679
+
680
+ leaderboard_type: Leaderboard ordering mode.
681
+
682
+ limit: Number of results to return. Maximum 100.
683
+
684
+ next_id: ID to start the next paged result set with.
685
+
686
+ extra_headers: Send extra headers
687
+
688
+ extra_query: Add additional query parameters to the request
689
+
690
+ extra_body: Add additional JSON properties to the request
691
+
692
+ timeout: Override the client-level default timeout for this request, in seconds
693
+ """
694
+ if not id:
695
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
696
+ return await self._get(
697
+ path_template("/campaign/{id}/leaderboard", id=id),
698
+ options=make_request_options(
699
+ extra_headers=extra_headers,
700
+ extra_query=extra_query,
701
+ extra_body=extra_body,
702
+ timeout=timeout,
703
+ query=await async_maybe_transform(
704
+ {
705
+ "is_monthly": is_monthly,
706
+ "leaderboard_type": leaderboard_type,
707
+ "limit": limit,
708
+ "next_id": next_id,
709
+ },
710
+ campaign_list_leaderboard_params.CampaignListLeaderboardParams,
711
+ ),
712
+ ),
713
+ cast_to=ParticipantList,
714
+ )
715
+
716
+ async def list_participants(
717
+ self,
718
+ id: str,
719
+ *,
720
+ limit: int | Omit = omit,
721
+ next_id: str | Omit = omit,
722
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
723
+ # The extra values given here take precedence over values defined on the client or passed to this method.
724
+ extra_headers: Headers | None = None,
725
+ extra_query: Query | None = None,
726
+ extra_body: Body | None = None,
727
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
728
+ ) -> ParticipantList:
729
+ """
730
+ Retrieves a paged list of participants in a program.
731
+
732
+ Args:
733
+ limit: Number of results to return. Maximum 100.
734
+
735
+ next_id: ID to start the next paged result set with.
736
+
737
+ extra_headers: Send extra headers
738
+
739
+ extra_query: Add additional query parameters to the request
740
+
741
+ extra_body: Add additional JSON properties to the request
742
+
743
+ timeout: Override the client-level default timeout for this request, in seconds
744
+ """
745
+ if not id:
746
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
747
+ return await self._get(
748
+ path_template("/campaign/{id}/participants", id=id),
749
+ options=make_request_options(
750
+ extra_headers=extra_headers,
751
+ extra_query=extra_query,
752
+ extra_body=extra_body,
753
+ timeout=timeout,
754
+ query=await async_maybe_transform(
755
+ {
756
+ "limit": limit,
757
+ "next_id": next_id,
758
+ },
759
+ campaign_list_participants_params.CampaignListParticipantsParams,
760
+ ),
761
+ ),
762
+ cast_to=ParticipantList,
763
+ )
764
+
765
+ async def list_payouts(
766
+ self,
767
+ id: str,
768
+ *,
769
+ limit: int | Omit = omit,
770
+ next_id: str | Omit = omit,
771
+ status: Literal["UPCOMING", "QUEUED", "ISSUED", "FAILED"] | Omit = omit,
772
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
773
+ # The extra values given here take precedence over values defined on the client or passed to this method.
774
+ extra_headers: Headers | None = None,
775
+ extra_query: Query | None = None,
776
+ extra_body: Body | None = None,
777
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
778
+ ) -> ParticipantPayoutList:
779
+ """
780
+ Retrieves a paged list of all participant payouts in an affiliate program.
781
+
782
+ Args:
783
+ limit: Number of results to return. Maximum 100.
784
+
785
+ next_id: ID to start the next paged result set with.
786
+
787
+ status: Participant payout status.
788
+
789
+ extra_headers: Send extra headers
790
+
791
+ extra_query: Add additional query parameters to the request
792
+
793
+ extra_body: Add additional JSON properties to the request
794
+
795
+ timeout: Override the client-level default timeout for this request, in seconds
796
+ """
797
+ if not id:
798
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
799
+ return await self._get(
800
+ path_template("/campaign/{id}/payouts", id=id),
801
+ options=make_request_options(
802
+ extra_headers=extra_headers,
803
+ extra_query=extra_query,
804
+ extra_body=extra_body,
805
+ timeout=timeout,
806
+ query=await async_maybe_transform(
807
+ {
808
+ "limit": limit,
809
+ "next_id": next_id,
810
+ "status": status,
811
+ },
812
+ campaign_list_payouts_params.CampaignListPayoutsParams,
813
+ ),
814
+ ),
815
+ cast_to=ParticipantPayoutList,
816
+ )
817
+
818
+ async def list_referrals(
819
+ self,
820
+ id: str,
821
+ *,
822
+ desc: bool | Omit = omit,
823
+ email: str | Omit = omit,
824
+ first_name: str | Omit = omit,
825
+ last_name: str | Omit = omit,
826
+ limit: int | Omit = omit,
827
+ next_id: str | Omit = omit,
828
+ offset: int | Omit = omit,
829
+ referral_status: ReferralStatus | Omit = omit,
830
+ sort_by: Literal[
831
+ "updatedAt", "createdAt", "email", "firstName", "lastName", "referralStatus", "referralTriggeredAt"
832
+ ]
833
+ | Omit = omit,
834
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
835
+ # The extra values given here take precedence over values defined on the client or passed to this method.
836
+ extra_headers: Headers | None = None,
837
+ extra_query: Query | None = None,
838
+ extra_body: Body | None = None,
839
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
840
+ ) -> ReferralList:
841
+ """
842
+ Retrieves a list of all referrals and email invites made by participants in a
843
+ program.
844
+
845
+ Args:
846
+ desc: Return results in descending order when true.
847
+
848
+ email: URL-encoded email value to filter referral results.
849
+
850
+ first_name: First name value to filter results.
851
+
852
+ last_name: Last name value to filter results.
853
+
854
+ limit: Number of results to return. Maximum 100.
855
+
856
+ next_id: ID to start the next paged result set with.
857
+
858
+ offset: Offset number used to skip through a result set.
859
+
860
+ sort_by: Field used to sort referral results.
861
+
862
+ extra_headers: Send extra headers
863
+
864
+ extra_query: Add additional query parameters to the request
865
+
866
+ extra_body: Add additional JSON properties to the request
867
+
868
+ timeout: Override the client-level default timeout for this request, in seconds
869
+ """
870
+ if not id:
871
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
872
+ return await self._get(
873
+ path_template("/campaign/{id}/referrals", id=id),
874
+ options=make_request_options(
875
+ extra_headers=extra_headers,
876
+ extra_query=extra_query,
877
+ extra_body=extra_body,
878
+ timeout=timeout,
879
+ query=await async_maybe_transform(
880
+ {
881
+ "desc": desc,
882
+ "email": email,
883
+ "first_name": first_name,
884
+ "last_name": last_name,
885
+ "limit": limit,
886
+ "next_id": next_id,
887
+ "offset": offset,
888
+ "referral_status": referral_status,
889
+ "sort_by": sort_by,
890
+ },
891
+ campaign_list_referrals_params.CampaignListReferralsParams,
892
+ ),
893
+ ),
894
+ cast_to=ReferralList,
895
+ )
896
+
897
+ async def retrieve_analytics(
898
+ self,
899
+ id: str,
900
+ *,
901
+ days: int | Omit = omit,
902
+ end_date: int | Omit = omit,
903
+ start_date: int | Omit = omit,
904
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
905
+ # The extra values given here take precedence over values defined on the client or passed to this method.
906
+ extra_headers: Headers | None = None,
907
+ extra_query: Query | None = None,
908
+ extra_body: Body | None = None,
909
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
910
+ ) -> CampaignRetrieveAnalyticsResponse:
911
+ """
912
+ Retrieves analytics for a program.
913
+
914
+ Args:
915
+ days: Last number of days to retrieve analytics for. Defaults to 365. Maximum 1825.
916
+
917
+ end_date: End date of the analytics timeframe as a Unix timestamp in milliseconds.
918
+ Required if `days` is not set.
919
+
920
+ start_date: Start date of the analytics timeframe as a Unix timestamp in milliseconds.
921
+ Required if `days` is not set.
922
+
923
+ extra_headers: Send extra headers
924
+
925
+ extra_query: Add additional query parameters to the request
926
+
927
+ extra_body: Add additional JSON properties to the request
928
+
929
+ timeout: Override the client-level default timeout for this request, in seconds
930
+ """
931
+ if not id:
932
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
933
+ return await self._get(
934
+ path_template("/campaign/{id}/analytics", id=id),
935
+ options=make_request_options(
936
+ extra_headers=extra_headers,
937
+ extra_query=extra_query,
938
+ extra_body=extra_body,
939
+ timeout=timeout,
940
+ query=await async_maybe_transform(
941
+ {
942
+ "days": days,
943
+ "end_date": end_date,
944
+ "start_date": start_date,
945
+ },
946
+ campaign_retrieve_analytics_params.CampaignRetrieveAnalyticsParams,
947
+ ),
948
+ ),
949
+ cast_to=CampaignRetrieveAnalyticsResponse,
950
+ )
951
+
952
+
953
+ class CampaignResourceWithRawResponse:
954
+ def __init__(self, campaign: CampaignResource) -> None:
955
+ self._campaign = campaign
956
+
957
+ self.retrieve = to_raw_response_wrapper(
958
+ campaign.retrieve,
959
+ )
960
+ self.list = to_raw_response_wrapper(
961
+ campaign.list,
962
+ )
963
+ self.list_commissions = to_raw_response_wrapper(
964
+ campaign.list_commissions,
965
+ )
966
+ self.list_leaderboard = to_raw_response_wrapper(
967
+ campaign.list_leaderboard,
968
+ )
969
+ self.list_participants = to_raw_response_wrapper(
970
+ campaign.list_participants,
971
+ )
972
+ self.list_payouts = to_raw_response_wrapper(
973
+ campaign.list_payouts,
974
+ )
975
+ self.list_referrals = to_raw_response_wrapper(
976
+ campaign.list_referrals,
977
+ )
978
+ self.retrieve_analytics = to_raw_response_wrapper(
979
+ campaign.retrieve_analytics,
980
+ )
981
+
982
+ @cached_property
983
+ def participant(self) -> ParticipantResourceWithRawResponse:
984
+ return ParticipantResourceWithRawResponse(self._campaign.participant)
985
+
986
+ @cached_property
987
+ def reward(self) -> RewardResourceWithRawResponse:
988
+ """Participant reward retrieval and manual reward operations."""
989
+ return RewardResourceWithRawResponse(self._campaign.reward)
990
+
991
+ @cached_property
992
+ def commission(self) -> CommissionResourceWithRawResponse:
993
+ """Affiliate transaction, commission, and payout operations."""
994
+ return CommissionResourceWithRawResponse(self._campaign.commission)
995
+
996
+
997
+ class AsyncCampaignResourceWithRawResponse:
998
+ def __init__(self, campaign: AsyncCampaignResource) -> None:
999
+ self._campaign = campaign
1000
+
1001
+ self.retrieve = async_to_raw_response_wrapper(
1002
+ campaign.retrieve,
1003
+ )
1004
+ self.list = async_to_raw_response_wrapper(
1005
+ campaign.list,
1006
+ )
1007
+ self.list_commissions = async_to_raw_response_wrapper(
1008
+ campaign.list_commissions,
1009
+ )
1010
+ self.list_leaderboard = async_to_raw_response_wrapper(
1011
+ campaign.list_leaderboard,
1012
+ )
1013
+ self.list_participants = async_to_raw_response_wrapper(
1014
+ campaign.list_participants,
1015
+ )
1016
+ self.list_payouts = async_to_raw_response_wrapper(
1017
+ campaign.list_payouts,
1018
+ )
1019
+ self.list_referrals = async_to_raw_response_wrapper(
1020
+ campaign.list_referrals,
1021
+ )
1022
+ self.retrieve_analytics = async_to_raw_response_wrapper(
1023
+ campaign.retrieve_analytics,
1024
+ )
1025
+
1026
+ @cached_property
1027
+ def participant(self) -> AsyncParticipantResourceWithRawResponse:
1028
+ return AsyncParticipantResourceWithRawResponse(self._campaign.participant)
1029
+
1030
+ @cached_property
1031
+ def reward(self) -> AsyncRewardResourceWithRawResponse:
1032
+ """Participant reward retrieval and manual reward operations."""
1033
+ return AsyncRewardResourceWithRawResponse(self._campaign.reward)
1034
+
1035
+ @cached_property
1036
+ def commission(self) -> AsyncCommissionResourceWithRawResponse:
1037
+ """Affiliate transaction, commission, and payout operations."""
1038
+ return AsyncCommissionResourceWithRawResponse(self._campaign.commission)
1039
+
1040
+
1041
+ class CampaignResourceWithStreamingResponse:
1042
+ def __init__(self, campaign: CampaignResource) -> None:
1043
+ self._campaign = campaign
1044
+
1045
+ self.retrieve = to_streamed_response_wrapper(
1046
+ campaign.retrieve,
1047
+ )
1048
+ self.list = to_streamed_response_wrapper(
1049
+ campaign.list,
1050
+ )
1051
+ self.list_commissions = to_streamed_response_wrapper(
1052
+ campaign.list_commissions,
1053
+ )
1054
+ self.list_leaderboard = to_streamed_response_wrapper(
1055
+ campaign.list_leaderboard,
1056
+ )
1057
+ self.list_participants = to_streamed_response_wrapper(
1058
+ campaign.list_participants,
1059
+ )
1060
+ self.list_payouts = to_streamed_response_wrapper(
1061
+ campaign.list_payouts,
1062
+ )
1063
+ self.list_referrals = to_streamed_response_wrapper(
1064
+ campaign.list_referrals,
1065
+ )
1066
+ self.retrieve_analytics = to_streamed_response_wrapper(
1067
+ campaign.retrieve_analytics,
1068
+ )
1069
+
1070
+ @cached_property
1071
+ def participant(self) -> ParticipantResourceWithStreamingResponse:
1072
+ return ParticipantResourceWithStreamingResponse(self._campaign.participant)
1073
+
1074
+ @cached_property
1075
+ def reward(self) -> RewardResourceWithStreamingResponse:
1076
+ """Participant reward retrieval and manual reward operations."""
1077
+ return RewardResourceWithStreamingResponse(self._campaign.reward)
1078
+
1079
+ @cached_property
1080
+ def commission(self) -> CommissionResourceWithStreamingResponse:
1081
+ """Affiliate transaction, commission, and payout operations."""
1082
+ return CommissionResourceWithStreamingResponse(self._campaign.commission)
1083
+
1084
+
1085
+ class AsyncCampaignResourceWithStreamingResponse:
1086
+ def __init__(self, campaign: AsyncCampaignResource) -> None:
1087
+ self._campaign = campaign
1088
+
1089
+ self.retrieve = async_to_streamed_response_wrapper(
1090
+ campaign.retrieve,
1091
+ )
1092
+ self.list = async_to_streamed_response_wrapper(
1093
+ campaign.list,
1094
+ )
1095
+ self.list_commissions = async_to_streamed_response_wrapper(
1096
+ campaign.list_commissions,
1097
+ )
1098
+ self.list_leaderboard = async_to_streamed_response_wrapper(
1099
+ campaign.list_leaderboard,
1100
+ )
1101
+ self.list_participants = async_to_streamed_response_wrapper(
1102
+ campaign.list_participants,
1103
+ )
1104
+ self.list_payouts = async_to_streamed_response_wrapper(
1105
+ campaign.list_payouts,
1106
+ )
1107
+ self.list_referrals = async_to_streamed_response_wrapper(
1108
+ campaign.list_referrals,
1109
+ )
1110
+ self.retrieve_analytics = async_to_streamed_response_wrapper(
1111
+ campaign.retrieve_analytics,
1112
+ )
1113
+
1114
+ @cached_property
1115
+ def participant(self) -> AsyncParticipantResourceWithStreamingResponse:
1116
+ return AsyncParticipantResourceWithStreamingResponse(self._campaign.participant)
1117
+
1118
+ @cached_property
1119
+ def reward(self) -> AsyncRewardResourceWithStreamingResponse:
1120
+ """Participant reward retrieval and manual reward operations."""
1121
+ return AsyncRewardResourceWithStreamingResponse(self._campaign.reward)
1122
+
1123
+ @cached_property
1124
+ def commission(self) -> AsyncCommissionResourceWithStreamingResponse:
1125
+ """Affiliate transaction, commission, and payout operations."""
1126
+ return AsyncCommissionResourceWithStreamingResponse(self._campaign.commission)