growsurf-python 0.0.2__py3-none-any.whl → 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
growsurf/_files.py CHANGED
@@ -99,7 +99,7 @@ async def async_to_httpx_files(files: RequestFiles | None) -> HttpxRequestFiles
99
99
  elif is_sequence_t(files):
100
100
  files = [(key, await _async_transform_file(file)) for key, file in files]
101
101
  else:
102
- raise TypeError("Unexpected file type input {type(files)}, expected mapping or sequence")
102
+ raise TypeError(f"Unexpected file type input {type(files)}, expected mapping or sequence")
103
103
 
104
104
  return files
105
105
 
growsurf/_models.py CHANGED
@@ -25,7 +25,9 @@ from typing_extensions import (
25
25
  ClassVar,
26
26
  Protocol,
27
27
  Required,
28
+ Annotated,
28
29
  ParamSpec,
30
+ TypeAlias,
29
31
  TypedDict,
30
32
  TypeGuard,
31
33
  final,
@@ -79,7 +81,15 @@ from ._compat import (
79
81
  from ._constants import RAW_RESPONSE_HEADER
80
82
 
81
83
  if TYPE_CHECKING:
84
+ from pydantic import GetCoreSchemaHandler, ValidatorFunctionWrapHandler
85
+ from pydantic_core import CoreSchema, core_schema
82
86
  from pydantic_core.core_schema import ModelField, ModelSchema, LiteralSchema, ModelFieldsSchema
87
+ else:
88
+ try:
89
+ from pydantic_core import CoreSchema, core_schema
90
+ except ImportError:
91
+ CoreSchema = None
92
+ core_schema = None
83
93
 
84
94
  __all__ = ["BaseModel", "GenericModel"]
85
95
 
@@ -396,6 +406,76 @@ class BaseModel(pydantic.BaseModel):
396
406
  )
397
407
 
398
408
 
409
+ class _EagerIterable(list[_T], Generic[_T]):
410
+ """
411
+ Accepts any Iterable[T] input (including generators), consumes it
412
+ eagerly, and validates all items upfront.
413
+
414
+ Validation preserves the original container type where possible
415
+ (e.g. a set[T] stays a set[T]). Serialization (model_dump / JSON)
416
+ always emits a list — round-tripping through model_dump() will not
417
+ restore the original container type.
418
+ """
419
+
420
+ @classmethod
421
+ def __get_pydantic_core_schema__(
422
+ cls,
423
+ source_type: Any,
424
+ handler: GetCoreSchemaHandler,
425
+ ) -> CoreSchema:
426
+ (item_type,) = get_args(source_type) or (Any,)
427
+ item_schema: CoreSchema = handler.generate_schema(item_type)
428
+ list_of_items_schema: CoreSchema = core_schema.list_schema(item_schema)
429
+
430
+ return core_schema.no_info_wrap_validator_function(
431
+ cls._validate,
432
+ list_of_items_schema,
433
+ serialization=core_schema.plain_serializer_function_ser_schema(
434
+ cls._serialize,
435
+ info_arg=False,
436
+ ),
437
+ )
438
+
439
+ @staticmethod
440
+ def _validate(v: Iterable[_T], handler: "ValidatorFunctionWrapHandler") -> Any:
441
+ original_type: type[Any] = type(v)
442
+
443
+ # Normalize to list so list_schema can validate each item
444
+ if isinstance(v, list):
445
+ items: list[_T] = v
446
+ else:
447
+ try:
448
+ items = list(v)
449
+ except TypeError as e:
450
+ raise TypeError("Value is not iterable") from e
451
+
452
+ # Validate items against the inner schema
453
+ validated: list[_T] = handler(items)
454
+
455
+ # Reconstruct original container type
456
+ if original_type is list:
457
+ return validated
458
+ # str(list) produces the list's repr, not a string built from items,
459
+ # so skip reconstruction for str and its subclasses.
460
+ if issubclass(original_type, str):
461
+ return validated
462
+ try:
463
+ return original_type(validated)
464
+ except (TypeError, ValueError):
465
+ # If the type cannot be reconstructed, just return the validated list
466
+ return validated
467
+
468
+ @staticmethod
469
+ def _serialize(v: Iterable[_T]) -> list[_T]:
470
+ """Always serialize as a list so Pydantic's JSON encoder is happy."""
471
+ if isinstance(v, list):
472
+ return v
473
+ return list(v)
474
+
475
+
476
+ EagerIterable: TypeAlias = Annotated[Iterable[_T], _EagerIterable]
477
+
478
+
399
479
  def _construct_field(value: object, field: FieldInfo, key: str) -> object:
400
480
  if value is None:
401
481
  return field_get_default(field)
growsurf/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "growsurf"
4
- __version__ = "0.0.2" # x-release-please-version
4
+ __version__ = "0.1.0" # x-release-please-version
@@ -39,6 +39,7 @@ from ...types.campaign.participant_list_rewards_response import ParticipantListR
39
39
  from ...types.campaign.participant_send_invites_response import ParticipantSendInvitesResponse
40
40
  from ...types.campaign.participant_trigger_referral_response import ParticipantTriggerReferralResponse
41
41
  from ...types.campaign.participant_record_transaction_response import ParticipantRecordTransactionResponse
42
+ from ...types.campaign.participant_create_mobile_token_response import ParticipantCreateMobileTokenResponse
42
43
 
43
44
  __all__ = ["ParticipantResource", "AsyncParticipantResource"]
44
45
 
@@ -272,6 +273,50 @@ class ParticipantResource(SyncAPIResource):
272
273
  cast_to=Participant,
273
274
  )
274
275
 
276
+ def create_mobile_token(
277
+ self,
278
+ participant_id_or_email: str,
279
+ *,
280
+ id: str,
281
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
282
+ # The extra values given here take precedence over values defined on the client or passed to this method.
283
+ extra_headers: Headers | None = None,
284
+ extra_query: Query | None = None,
285
+ extra_body: Body | None = None,
286
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
287
+ ) -> ParticipantCreateMobileTokenResponse:
288
+ """Creates a participant-scoped token for GrowSurf mobile SDK participant
289
+ endpoints.
290
+
291
+ The program must have mobile SDK access enabled.
292
+
293
+ Args:
294
+ extra_headers: Send extra headers
295
+
296
+ extra_query: Add additional query parameters to the request
297
+
298
+ extra_body: Add additional JSON properties to the request
299
+
300
+ timeout: Override the client-level default timeout for this request, in seconds
301
+ """
302
+ if not id:
303
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
304
+ if not participant_id_or_email:
305
+ raise ValueError(
306
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
307
+ )
308
+ return self._post(
309
+ path_template(
310
+ "/campaign/{id}/participant/{participant_id_or_email}/mobile-token",
311
+ id=id,
312
+ participant_id_or_email=participant_id_or_email,
313
+ ),
314
+ options=make_request_options(
315
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
316
+ ),
317
+ cast_to=ParticipantCreateMobileTokenResponse,
318
+ )
319
+
275
320
  def list_commissions(
276
321
  self,
277
322
  participant_id_or_email: str,
@@ -966,6 +1011,50 @@ class AsyncParticipantResource(AsyncAPIResource):
966
1011
  cast_to=Participant,
967
1012
  )
968
1013
 
1014
+ async def create_mobile_token(
1015
+ self,
1016
+ participant_id_or_email: str,
1017
+ *,
1018
+ id: str,
1019
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1020
+ # The extra values given here take precedence over values defined on the client or passed to this method.
1021
+ extra_headers: Headers | None = None,
1022
+ extra_query: Query | None = None,
1023
+ extra_body: Body | None = None,
1024
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1025
+ ) -> ParticipantCreateMobileTokenResponse:
1026
+ """Creates a participant-scoped token for GrowSurf mobile SDK participant
1027
+ endpoints.
1028
+
1029
+ The program must have mobile SDK access enabled.
1030
+
1031
+ Args:
1032
+ extra_headers: Send extra headers
1033
+
1034
+ extra_query: Add additional query parameters to the request
1035
+
1036
+ extra_body: Add additional JSON properties to the request
1037
+
1038
+ timeout: Override the client-level default timeout for this request, in seconds
1039
+ """
1040
+ if not id:
1041
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
1042
+ if not participant_id_or_email:
1043
+ raise ValueError(
1044
+ f"Expected a non-empty value for `participant_id_or_email` but received {participant_id_or_email!r}"
1045
+ )
1046
+ return await self._post(
1047
+ path_template(
1048
+ "/campaign/{id}/participant/{participant_id_or_email}/mobile-token",
1049
+ id=id,
1050
+ participant_id_or_email=participant_id_or_email,
1051
+ ),
1052
+ options=make_request_options(
1053
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
1054
+ ),
1055
+ cast_to=ParticipantCreateMobileTokenResponse,
1056
+ )
1057
+
969
1058
  async def list_commissions(
970
1059
  self,
971
1060
  participant_id_or_email: str,
@@ -1447,6 +1536,9 @@ class ParticipantResourceWithRawResponse:
1447
1536
  self.add = to_raw_response_wrapper(
1448
1537
  participant.add,
1449
1538
  )
1539
+ self.create_mobile_token = to_raw_response_wrapper(
1540
+ participant.create_mobile_token,
1541
+ )
1450
1542
  self.list_commissions = to_raw_response_wrapper(
1451
1543
  participant.list_commissions,
1452
1544
  )
@@ -1486,6 +1578,9 @@ class AsyncParticipantResourceWithRawResponse:
1486
1578
  self.add = async_to_raw_response_wrapper(
1487
1579
  participant.add,
1488
1580
  )
1581
+ self.create_mobile_token = async_to_raw_response_wrapper(
1582
+ participant.create_mobile_token,
1583
+ )
1489
1584
  self.list_commissions = async_to_raw_response_wrapper(
1490
1585
  participant.list_commissions,
1491
1586
  )
@@ -1525,6 +1620,9 @@ class ParticipantResourceWithStreamingResponse:
1525
1620
  self.add = to_streamed_response_wrapper(
1526
1621
  participant.add,
1527
1622
  )
1623
+ self.create_mobile_token = to_streamed_response_wrapper(
1624
+ participant.create_mobile_token,
1625
+ )
1528
1626
  self.list_commissions = to_streamed_response_wrapper(
1529
1627
  participant.list_commissions,
1530
1628
  )
@@ -1564,6 +1662,9 @@ class AsyncParticipantResourceWithStreamingResponse:
1564
1662
  self.add = async_to_streamed_response_wrapper(
1565
1663
  participant.add,
1566
1664
  )
1665
+ self.create_mobile_token = async_to_streamed_response_wrapper(
1666
+ participant.create_mobile_token,
1667
+ )
1567
1668
  self.list_commissions = async_to_streamed_response_wrapper(
1568
1669
  participant.list_commissions,
1569
1670
  )
@@ -33,3 +33,6 @@ from .participant_trigger_referral_response import (
33
33
  from .participant_record_transaction_response import (
34
34
  ParticipantRecordTransactionResponse as ParticipantRecordTransactionResponse,
35
35
  )
36
+ from .participant_create_mobile_token_response import (
37
+ ParticipantCreateMobileTokenResponse as ParticipantCreateMobileTokenResponse,
38
+ )
@@ -0,0 +1,15 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from pydantic import Field as FieldInfo
4
+
5
+ from ..._models import BaseModel
6
+
7
+ __all__ = ["ParticipantCreateMobileTokenResponse"]
8
+
9
+
10
+ class ParticipantCreateMobileTokenResponse(BaseModel):
11
+ expires_in: int = FieldInfo(alias="expiresIn")
12
+ """Token lifetime in seconds."""
13
+
14
+ participant_token: str = FieldInfo(alias="participantToken")
15
+ """Participant-scoped bearer token for GrowSurf mobile SDK participant endpoints."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: growsurf-python
3
- Version: 0.0.2
3
+ Version: 0.1.0
4
4
  Summary: The official Python library for the growsurf API
5
5
  Project-URL: Homepage, https://github.com/growsurf/growsurf-python
6
6
  Project-URL: Repository, https://github.com/growsurf/growsurf-python
@@ -4,14 +4,14 @@ growsurf/_client.py,sha256=Iu6ABJ4B21yJ0QRE0RwjEJbFQN2wdc3d3JXY5J7kUqw,17638
4
4
  growsurf/_compat.py,sha256=_9guQfzYnL3DNtudX5W7T2cdSskx89B5AFfhPQDxMUk,6811
5
5
  growsurf/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
6
6
  growsurf/_exceptions.py,sha256=3bEzw4WDc3VYTMnwkiOucauRjS8Vhr3L0Qb02P0ZKaE,3224
7
- growsurf/_files.py,sha256=GsGgJfC6PEiO0d4ItFBMQlBrK8LLNpTaBdHa7T3EMDE,5452
8
- growsurf/_models.py,sha256=tYTwrY0cUy4ED2Z5fUEl2JegX-yVTYHxr-pv5DjjEYQ,32269
7
+ growsurf/_files.py,sha256=SVYqNE1L-wYm1GciyF95BCJGC1gsWAqvXvSyos-_rNo,5453
8
+ growsurf/_models.py,sha256=s_NXt8o1OMGsQilB4EliLxkFGZCWdrSiy5HJ0T2NZEo,35012
9
9
  growsurf/_qs.py,sha256=ZSfQv6arGBBoWlcy60zK1zmPE2Ije0i8kzKdnoxWUjU,4833
10
10
  growsurf/_resource.py,sha256=oeDA0FL2ottIchoUi86M_8eUqmtrGQLYTgfKYEzrsWg,1112
11
11
  growsurf/_response.py,sha256=RTZ8t27W4S6ExkCjzCg4HbcDUTCdOMgiheiMAuAxgu4,28937
12
12
  growsurf/_streaming.py,sha256=9aJ_V6JtddntWCon2Cq_MOLMnySnhc7wuqeZx7sUtKU,10558
13
13
  growsurf/_types.py,sha256=r8hAVihrutiLUToaJhSDys9T9sMc8BMy2qUrr3W_8Wo,7751
14
- growsurf/_version.py,sha256=4Sru0Bqk98PXjpRL1QFG7tmJWNpQhO20HB8OW031gek,160
14
+ growsurf/_version.py,sha256=1YB5RjbPw4Mk7vcoe4ToN0ismIbh1P7vP2iPuCXhZbs,160
15
15
  growsurf/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  growsurf/_utils/__init__.py,sha256=nQq-iFa5YxTaWySaLigatew5rHgTR0M75FNYm4mrO1s,2313
17
17
  growsurf/_utils/_compat.py,sha256=33246eDcl3pwL6kWsEhVuT4Akrd8gZEW9LPTm465ohk,1231
@@ -32,7 +32,7 @@ growsurf/resources/__init__.py,sha256=xfEkuLlMZ7ZMm_bcpbd5XKNGLBo9xEvNVGX6EHH0g-
32
32
  growsurf/resources/campaign/__init__.py,sha256=3k4V-N7TZLU1xJunA-760I62BQ1elIddwlLf_OtWQUQ,2045
33
33
  growsurf/resources/campaign/campaign.py,sha256=4r9je07cVILuvR0uxXnB1HlVr-G-u2Pt5HLdcOGKsWQ,43126
34
34
  growsurf/resources/campaign/commission.py,sha256=K5HmznRM7nO-VNiP2Jy1rIeW63rAx1Aa2M9DEJ9dB2I,10294
35
- growsurf/resources/campaign/participant.py,sha256=OTrmsJs8HtQUe3WQ5uuWj5-SoTPeNTY1duBQDT7oF6Q,63882
35
+ growsurf/resources/campaign/participant.py,sha256=3U7wNhTy48-HjMdmiMGg8EL_G8U5uNsH8OQVqXX56Zg,68164
36
36
  growsurf/resources/campaign/reward.py,sha256=AVPDhttbglDXnZE4onrCvf6Br6PdAohVV9WJgF7DsjY,14034
37
37
  growsurf/types/__init__.py,sha256=dVCfznQhh_l796cd1s584hjxXqILBQ49CWFp51dcNHA,1391
38
38
  growsurf/types/campaign_list_commissions_params.py,sha256=5T8SWE63fWyMglJP_EnK5AG8OVQIbE0rf5jNcvc8tn8,622
@@ -48,13 +48,14 @@ growsurf/types/participant_commission_list.py,sha256=79Eb8Wyic557dBERHiDpgjvYqC4
48
48
  growsurf/types/participant_list.py,sha256=5oety8iTXx5anr0W5wAjzCAIMPkQLPeVIc2TNuRbrMY,430
49
49
  growsurf/types/participant_payout_list.py,sha256=xO4_EwJAVA5B5opldd7S3X5O6WeAsejgpbVtQ_oacwQ,1419
50
50
  growsurf/types/referral_list.py,sha256=SOU3s0cjeQLhbZVbeGoeCprVyrPTk-tvmMBMV25uG1o,969
51
- growsurf/types/campaign/__init__.py,sha256=5QXEoVqNvARl_R8iRAILUVariVEN9Lno41tNHEKIC8E,2436
51
+ growsurf/types/campaign/__init__.py,sha256=bPWw1pegsnKubl4k9DDEzN_IMlTRqKUOVa__kbmA6QY,2576
52
52
  growsurf/types/campaign/campaign.py,sha256=JuiQhipggLIZatBvdmVZVYW5YkLabGHqhZ03rdJ9g-Q,2293
53
53
  growsurf/types/campaign/commission_approve_response.py,sha256=fcM2IM6qyqkne4aFPbYcJlfbO3P2fZsJQcBxdsB3BaE,225
54
54
  growsurf/types/campaign/commission_delete_response.py,sha256=psVQ1Yqh9j20kvg76LrRtXIa5cy0CVSWzKaZk9IvGKU,223
55
55
  growsurf/types/campaign/fraud_risk_level.py,sha256=e14xAEYtKH6gGnkJ9-sr81GZ2UY-zDQ6TZKCkBJLagw,228
56
56
  growsurf/types/campaign/participant.py,sha256=E6Hwr275wt5l0I-YdhUWXV1-J47vfXJJY-elrAMLgzg,5205
57
57
  growsurf/types/campaign/participant_add_params.py,sha256=wAbyxqdDZIqK0HDuuLwyjuQGAAdEICdVHySumv3VF5k,892
58
+ growsurf/types/campaign/participant_create_mobile_token_response.py,sha256=asUJXjAeA699qrr14BA2hv5TrSMsZqmz0MGoU18E1NU,513
58
59
  growsurf/types/campaign/participant_delete_response.py,sha256=qXghOQ04cS3jZh3oHZYr_iXzlanjELyeN5I4kUfFfRM,225
59
60
  growsurf/types/campaign/participant_list_commissions_params.py,sha256=4Cxa7rETQYmp71mR4wIzymfPYv2UV3vCzmQvv5iik1c,662
60
61
  growsurf/types/campaign/participant_list_payouts_params.py,sha256=AbadljbUZvMgc7cEDvDXpIg3n0nM1x4t2vZgTD-w69A,638
@@ -74,7 +75,7 @@ growsurf/types/campaign/reward_approve_params.py,sha256=IbGDBmEWgmtQQpmYaMg_navf
74
75
  growsurf/types/campaign/reward_approve_response.py,sha256=AID7RxcX5_BGxssHn6vR-pGOB_PK-xQhUBNk-ZkNkgI,217
75
76
  growsurf/types/campaign/reward_delete_response.py,sha256=YGOQ8GQEEN1HDzOT2pU30Q98UNM-s-U4VkTqMewNe5M,215
76
77
  growsurf/types/campaign/reward_fulfill_response.py,sha256=KlimtB3q-3djYMlRzshAxEyU_IVACOesNECbTeU574E,217
77
- growsurf_python-0.0.2.dist-info/METADATA,sha256=7juFQN5dTN5RrKtzDiZAEHhNxA2_r1_hDWhV9VDStYs,13597
78
- growsurf_python-0.0.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
79
- growsurf_python-0.0.2.dist-info/licenses/LICENSE,sha256=kTHLVE-ra1gtTxcn395uFqcOzcErebE-mDdPNW7b8OU,11338
80
- growsurf_python-0.0.2.dist-info/RECORD,,
78
+ growsurf_python-0.1.0.dist-info/METADATA,sha256=IiSfcoYAt0BQhGwS4DbmGAV_6WcpDORYFr1KuWrTNRg,13597
79
+ growsurf_python-0.1.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
80
+ growsurf_python-0.1.0.dist-info/licenses/LICENSE,sha256=kTHLVE-ra1gtTxcn395uFqcOzcErebE-mDdPNW7b8OU,11338
81
+ growsurf_python-0.1.0.dist-info/RECORD,,