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
growsurf/_qs.py ADDED
@@ -0,0 +1,149 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, List, Tuple, Union, Mapping, TypeVar
4
+ from urllib.parse import parse_qs, urlencode
5
+ from typing_extensions import get_args
6
+
7
+ from ._types import NotGiven, ArrayFormat, NestedFormat, not_given
8
+ from ._utils import flatten
9
+
10
+ _T = TypeVar("_T")
11
+
12
+ PrimitiveData = Union[str, int, float, bool, None]
13
+ # this should be Data = Union[PrimitiveData, "List[Data]", "Tuple[Data]", "Mapping[str, Data]"]
14
+ # https://github.com/microsoft/pyright/issues/3555
15
+ Data = Union[PrimitiveData, List[Any], Tuple[Any], "Mapping[str, Any]"]
16
+ Params = Mapping[str, Data]
17
+
18
+
19
+ class Querystring:
20
+ array_format: ArrayFormat
21
+ nested_format: NestedFormat
22
+
23
+ def __init__(
24
+ self,
25
+ *,
26
+ array_format: ArrayFormat = "repeat",
27
+ nested_format: NestedFormat = "brackets",
28
+ ) -> None:
29
+ self.array_format = array_format
30
+ self.nested_format = nested_format
31
+
32
+ def parse(self, query: str) -> Mapping[str, object]:
33
+ # Note: custom format syntax is not supported yet
34
+ return parse_qs(query)
35
+
36
+ def stringify(
37
+ self,
38
+ params: Params,
39
+ *,
40
+ array_format: ArrayFormat | NotGiven = not_given,
41
+ nested_format: NestedFormat | NotGiven = not_given,
42
+ ) -> str:
43
+ return urlencode(
44
+ self.stringify_items(
45
+ params,
46
+ array_format=array_format,
47
+ nested_format=nested_format,
48
+ )
49
+ )
50
+
51
+ def stringify_items(
52
+ self,
53
+ params: Params,
54
+ *,
55
+ array_format: ArrayFormat | NotGiven = not_given,
56
+ nested_format: NestedFormat | NotGiven = not_given,
57
+ ) -> list[tuple[str, str]]:
58
+ opts = Options(
59
+ qs=self,
60
+ array_format=array_format,
61
+ nested_format=nested_format,
62
+ )
63
+ return flatten([self._stringify_item(key, value, opts) for key, value in params.items()])
64
+
65
+ def _stringify_item(
66
+ self,
67
+ key: str,
68
+ value: Data,
69
+ opts: Options,
70
+ ) -> list[tuple[str, str]]:
71
+ if isinstance(value, Mapping):
72
+ items: list[tuple[str, str]] = []
73
+ nested_format = opts.nested_format
74
+ for subkey, subvalue in value.items():
75
+ items.extend(
76
+ self._stringify_item(
77
+ # TODO: error if unknown format
78
+ f"{key}.{subkey}" if nested_format == "dots" else f"{key}[{subkey}]",
79
+ subvalue,
80
+ opts,
81
+ )
82
+ )
83
+ return items
84
+
85
+ if isinstance(value, (list, tuple)):
86
+ array_format = opts.array_format
87
+ if array_format == "comma":
88
+ return [
89
+ (
90
+ key,
91
+ ",".join(self._primitive_value_to_str(item) for item in value if item is not None),
92
+ ),
93
+ ]
94
+ elif array_format == "repeat":
95
+ items = []
96
+ for item in value:
97
+ items.extend(self._stringify_item(key, item, opts))
98
+ return items
99
+ elif array_format == "indices":
100
+ items = []
101
+ for i, item in enumerate(value):
102
+ items.extend(self._stringify_item(f"{key}[{i}]", item, opts))
103
+ return items
104
+ elif array_format == "brackets":
105
+ items = []
106
+ key = key + "[]"
107
+ for item in value:
108
+ items.extend(self._stringify_item(key, item, opts))
109
+ return items
110
+ else:
111
+ raise NotImplementedError(
112
+ f"Unknown array_format value: {array_format}, choose from {', '.join(get_args(ArrayFormat))}"
113
+ )
114
+
115
+ serialised = self._primitive_value_to_str(value)
116
+ if not serialised:
117
+ return []
118
+ return [(key, serialised)]
119
+
120
+ def _primitive_value_to_str(self, value: PrimitiveData) -> str:
121
+ # copied from httpx
122
+ if value is True:
123
+ return "true"
124
+ elif value is False:
125
+ return "false"
126
+ elif value is None:
127
+ return ""
128
+ return str(value)
129
+
130
+
131
+ _qs = Querystring()
132
+ parse = _qs.parse
133
+ stringify = _qs.stringify
134
+ stringify_items = _qs.stringify_items
135
+
136
+
137
+ class Options:
138
+ array_format: ArrayFormat
139
+ nested_format: NestedFormat
140
+
141
+ def __init__(
142
+ self,
143
+ qs: Querystring = _qs,
144
+ *,
145
+ array_format: ArrayFormat | NotGiven = not_given,
146
+ nested_format: NestedFormat | NotGiven = not_given,
147
+ ) -> None:
148
+ self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format
149
+ self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format
growsurf/_resource.py ADDED
@@ -0,0 +1,43 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import time
6
+ from typing import TYPE_CHECKING
7
+
8
+ import anyio
9
+
10
+ if TYPE_CHECKING:
11
+ from ._client import Growsurf, AsyncGrowsurf
12
+
13
+
14
+ class SyncAPIResource:
15
+ _client: Growsurf
16
+
17
+ def __init__(self, client: Growsurf) -> None:
18
+ self._client = client
19
+ self._get = client.get
20
+ self._post = client.post
21
+ self._patch = client.patch
22
+ self._put = client.put
23
+ self._delete = client.delete
24
+ self._get_api_list = client.get_api_list
25
+
26
+ def _sleep(self, seconds: float) -> None:
27
+ time.sleep(seconds)
28
+
29
+
30
+ class AsyncAPIResource:
31
+ _client: AsyncGrowsurf
32
+
33
+ def __init__(self, client: AsyncGrowsurf) -> None:
34
+ self._client = client
35
+ self._get = client.get
36
+ self._post = client.post
37
+ self._patch = client.patch
38
+ self._put = client.put
39
+ self._delete = client.delete
40
+ self._get_api_list = client.get_api_list
41
+
42
+ async def _sleep(self, seconds: float) -> None:
43
+ await anyio.sleep(seconds)