stigg-api-client-v2 0.579.8__py3-none-any.whl → 5.9.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.
- stigg/_edge_utils.py +58 -0
- stigg/client.py +97 -21
- stigg/generated/__init__.py +777 -44
- stigg/generated/apply_subscription.py +4 -12
- stigg/generated/archive_customer.py +2 -3
- stigg/generated/async_base_client.py +187 -29
- stigg/generated/async_client.py +3701 -587
- stigg/generated/base_client.py +144 -23
- stigg/generated/base_model.py +16 -47
- stigg/generated/cancel_subscription.py +2 -3
- stigg/generated/cancel_subscription_updates.py +1 -4
- stigg/generated/client.py +3703 -585
- stigg/generated/create_payment_session.py +20 -0
- stigg/generated/create_subscription.py +2 -3
- stigg/generated/delegate_subscription_to_customer.py +22 -0
- stigg/generated/detach_customer_payment_method.py +20 -0
- stigg/generated/enums.py +449 -7
- stigg/generated/estimate_subscription.py +2 -3
- stigg/generated/estimate_subscription_update.py +2 -3
- stigg/generated/exceptions.py +9 -5
- stigg/generated/fragments.py +1983 -788
- stigg/generated/get_active_subscriptions.py +2 -3
- stigg/generated/get_active_subscriptions_list.py +22 -0
- stigg/generated/get_checkout_state.py +2 -3
- stigg/generated/get_coupons.py +4 -5
- stigg/generated/get_credit_balance.py +20 -0
- stigg/generated/get_credit_grants.py +36 -0
- stigg/generated/get_credit_ledger.py +25 -0
- stigg/generated/get_credit_usage.py +18 -0
- stigg/generated/get_customer_by_id.py +2 -3
- stigg/generated/get_customer_portal_by_ref_id.py +2 -3
- stigg/generated/get_customer_statistics.py +22 -0
- stigg/generated/get_entitlement.py +2 -3
- stigg/generated/get_entitlements.py +2 -3
- stigg/generated/get_entitlements_state.py +31 -0
- stigg/generated/get_mock_paywall.py +3 -5
- stigg/generated/get_paywall.py +2 -3
- stigg/generated/get_products.py +4 -5
- stigg/generated/get_sdk_configuration.py +3 -3
- stigg/generated/get_subscription.py +18 -0
- stigg/generated/get_subscriptions.py +35 -0
- stigg/generated/get_usage_history.py +2 -3
- stigg/generated/get_usage_history_v_2.py +18 -0
- stigg/generated/grant_credits.py +20 -0
- stigg/generated/grant_promotional_entitlements.py +2 -3
- stigg/generated/grant_promotional_entitlements_group.py +24 -0
- stigg/generated/import_customer.py +2 -3
- stigg/generated/import_customer_bulk.py +1 -4
- stigg/generated/import_subscriptions_bulk.py +1 -4
- stigg/generated/input_types.py +3950 -1825
- stigg/generated/migrate_subscription_to_latest.py +2 -3
- stigg/generated/preview_next_invoice.py +20 -0
- stigg/generated/preview_subscription.py +2 -3
- stigg/generated/provision_customer.py +4 -22
- stigg/generated/provision_subscription.py +4 -15
- stigg/generated/report_entitlement_check_requested.py +1 -4
- stigg/generated/report_event.py +1 -4
- stigg/generated/report_usage.py +6 -13
- stigg/generated/report_usage_bulk.py +22 -0
- stigg/generated/revoke_promotional_entitlement.py +5 -4
- stigg/generated/revoke_promotional_entitlements_group.py +24 -0
- stigg/generated/transfer_subscription.py +2 -3
- stigg/generated/transfer_subscription_to_resource.py +22 -0
- stigg/generated/unarchive_customer.py +20 -0
- stigg/generated/unlink_promotional_entitlements_group.py +24 -0
- stigg/generated/update_customer.py +2 -3
- stigg/generated/update_subscription.py +2 -3
- stigg/generated/void_credit_grant.py +18 -0
- stigg_api_client_v2-5.9.0.dist-info/LICENSE +14 -0
- {stigg_api_client_v2-0.579.8.dist-info → stigg_api_client_v2-5.9.0.dist-info}/METADATA +5 -2
- stigg_api_client_v2-5.9.0.dist-info/RECORD +73 -0
- stigg/edge_utils.py +0 -28
- stigg/generated/scalars.py +0 -6
- stigg_api_client_v2-0.579.8.dist-info/RECORD +0 -51
- {stigg_api_client_v2-0.579.8.dist-info → stigg_api_client_v2-5.9.0.dist-info}/WHEEL +0 -0
stigg/generated/base_client.py
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# Generated by ariadne-codegen
|
|
1
|
+
# Generated by ariadne-codegen
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
|
-
from typing import Any, Dict, Optional, TypeVar, cast
|
|
4
|
+
from typing import IO, Any, Dict, List, Optional, Tuple, TypeVar, cast
|
|
5
5
|
|
|
6
6
|
import httpx
|
|
7
7
|
from pydantic import BaseModel
|
|
8
|
-
from
|
|
8
|
+
from pydantic_core import to_jsonable_python
|
|
9
9
|
|
|
10
|
-
from .base_model import UNSET
|
|
10
|
+
from .base_model import UNSET, Upload
|
|
11
11
|
from .exceptions import (
|
|
12
12
|
GraphQLClientGraphQLMultiError,
|
|
13
13
|
GraphQLClientHttpError,
|
|
14
|
-
|
|
14
|
+
GraphQLClientInvalidResponseError,
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
Self = TypeVar("Self", bound="BaseClient")
|
|
@@ -41,15 +41,32 @@ class BaseClient:
|
|
|
41
41
|
self.http_client.close()
|
|
42
42
|
|
|
43
43
|
def execute(
|
|
44
|
-
self,
|
|
44
|
+
self,
|
|
45
|
+
query: str,
|
|
46
|
+
operation_name: Optional[str] = None,
|
|
47
|
+
variables: Optional[Dict[str, Any]] = None,
|
|
48
|
+
**kwargs: Any,
|
|
45
49
|
) -> httpx.Response:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
processed_variables, files, files_map = self._process_variables(variables)
|
|
51
|
+
|
|
52
|
+
if files and files_map:
|
|
53
|
+
return self._execute_multipart(
|
|
54
|
+
query=query,
|
|
55
|
+
operation_name=operation_name,
|
|
56
|
+
variables=processed_variables,
|
|
57
|
+
files=files,
|
|
58
|
+
files_map=files_map,
|
|
59
|
+
**kwargs,
|
|
60
|
+
)
|
|
51
61
|
|
|
52
|
-
|
|
62
|
+
return self._execute_json(
|
|
63
|
+
query=query,
|
|
64
|
+
operation_name=operation_name,
|
|
65
|
+
variables=processed_variables,
|
|
66
|
+
**kwargs,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def get_data(self, response: httpx.Response) -> Dict[str, Any]:
|
|
53
70
|
if not response.is_success:
|
|
54
71
|
raise GraphQLClientHttpError(
|
|
55
72
|
status_code=response.status_code, response=response
|
|
@@ -58,12 +75,14 @@ class BaseClient:
|
|
|
58
75
|
try:
|
|
59
76
|
response_json = response.json()
|
|
60
77
|
except ValueError as exc:
|
|
61
|
-
raise
|
|
78
|
+
raise GraphQLClientInvalidResponseError(response=response) from exc
|
|
62
79
|
|
|
63
|
-
if (not isinstance(response_json, dict)) or (
|
|
64
|
-
|
|
80
|
+
if (not isinstance(response_json, dict)) or (
|
|
81
|
+
"data" not in response_json and "errors" not in response_json
|
|
82
|
+
):
|
|
83
|
+
raise GraphQLClientInvalidResponseError(response=response)
|
|
65
84
|
|
|
66
|
-
data = response_json
|
|
85
|
+
data = response_json.get("data")
|
|
67
86
|
errors = response_json.get("errors")
|
|
68
87
|
|
|
69
88
|
if errors:
|
|
@@ -71,14 +90,18 @@ class BaseClient:
|
|
|
71
90
|
errors_dicts=errors, data=data
|
|
72
91
|
)
|
|
73
92
|
|
|
74
|
-
return cast(
|
|
93
|
+
return cast(Dict[str, Any], data)
|
|
75
94
|
|
|
76
|
-
def
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
95
|
+
def _process_variables(
|
|
96
|
+
self, variables: Optional[Dict[str, Any]]
|
|
97
|
+
) -> Tuple[
|
|
98
|
+
Dict[str, Any], Dict[str, Tuple[str, IO[bytes], str]], Dict[str, List[str]]
|
|
99
|
+
]:
|
|
100
|
+
if not variables:
|
|
101
|
+
return {}, {}, {}
|
|
102
|
+
|
|
103
|
+
serializable_variables = self._convert_dict_to_json_serializable(variables)
|
|
104
|
+
return self._get_files_from_variables(serializable_variables)
|
|
82
105
|
|
|
83
106
|
def _convert_dict_to_json_serializable(
|
|
84
107
|
self, dict_: Dict[str, Any]
|
|
@@ -88,3 +111,101 @@ class BaseClient:
|
|
|
88
111
|
for key, value in dict_.items()
|
|
89
112
|
if value is not UNSET
|
|
90
113
|
}
|
|
114
|
+
|
|
115
|
+
def _convert_value(self, value: Any) -> Any:
|
|
116
|
+
if isinstance(value, BaseModel):
|
|
117
|
+
return value.model_dump(by_alias=True, exclude_unset=True)
|
|
118
|
+
if isinstance(value, list):
|
|
119
|
+
return [self._convert_value(item) for item in value]
|
|
120
|
+
return value
|
|
121
|
+
|
|
122
|
+
def _get_files_from_variables(
|
|
123
|
+
self, variables: Dict[str, Any]
|
|
124
|
+
) -> Tuple[
|
|
125
|
+
Dict[str, Any], Dict[str, Tuple[str, IO[bytes], str]], Dict[str, List[str]]
|
|
126
|
+
]:
|
|
127
|
+
files_map: Dict[str, List[str]] = {}
|
|
128
|
+
files_list: List[Upload] = []
|
|
129
|
+
|
|
130
|
+
def separate_files(path: str, obj: Any) -> Any:
|
|
131
|
+
if isinstance(obj, list):
|
|
132
|
+
nulled_list = []
|
|
133
|
+
for index, value in enumerate(obj):
|
|
134
|
+
value = separate_files(f"{path}.{index}", value)
|
|
135
|
+
nulled_list.append(value)
|
|
136
|
+
return nulled_list
|
|
137
|
+
|
|
138
|
+
if isinstance(obj, dict):
|
|
139
|
+
nulled_dict = {}
|
|
140
|
+
for key, value in obj.items():
|
|
141
|
+
value = separate_files(f"{path}.{key}", value)
|
|
142
|
+
nulled_dict[key] = value
|
|
143
|
+
return nulled_dict
|
|
144
|
+
|
|
145
|
+
if isinstance(obj, Upload):
|
|
146
|
+
if obj in files_list:
|
|
147
|
+
file_index = files_list.index(obj)
|
|
148
|
+
files_map[str(file_index)].append(path)
|
|
149
|
+
else:
|
|
150
|
+
file_index = len(files_list)
|
|
151
|
+
files_list.append(obj)
|
|
152
|
+
files_map[str(file_index)] = [path]
|
|
153
|
+
return None
|
|
154
|
+
|
|
155
|
+
return obj
|
|
156
|
+
|
|
157
|
+
nulled_variables = separate_files("variables", variables)
|
|
158
|
+
files: Dict[str, Tuple[str, IO[bytes], str]] = {
|
|
159
|
+
str(i): (file_.filename, cast(IO[bytes], file_.content), file_.content_type)
|
|
160
|
+
for i, file_ in enumerate(files_list)
|
|
161
|
+
}
|
|
162
|
+
return nulled_variables, files, files_map
|
|
163
|
+
|
|
164
|
+
def _execute_multipart(
|
|
165
|
+
self,
|
|
166
|
+
query: str,
|
|
167
|
+
operation_name: Optional[str],
|
|
168
|
+
variables: Dict[str, Any],
|
|
169
|
+
files: Dict[str, Tuple[str, IO[bytes], str]],
|
|
170
|
+
files_map: Dict[str, List[str]],
|
|
171
|
+
**kwargs: Any,
|
|
172
|
+
) -> httpx.Response:
|
|
173
|
+
data = {
|
|
174
|
+
"operations": json.dumps(
|
|
175
|
+
{
|
|
176
|
+
"query": query,
|
|
177
|
+
"operationName": operation_name,
|
|
178
|
+
"variables": variables,
|
|
179
|
+
},
|
|
180
|
+
default=to_jsonable_python,
|
|
181
|
+
),
|
|
182
|
+
"map": json.dumps(files_map, default=to_jsonable_python),
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return self.http_client.post(url=self.url, data=data, files=files, **kwargs)
|
|
186
|
+
|
|
187
|
+
def _execute_json(
|
|
188
|
+
self,
|
|
189
|
+
query: str,
|
|
190
|
+
operation_name: Optional[str],
|
|
191
|
+
variables: Dict[str, Any],
|
|
192
|
+
**kwargs: Any,
|
|
193
|
+
) -> httpx.Response:
|
|
194
|
+
headers: Dict[str, str] = {"Content-Type": "application/json"}
|
|
195
|
+
headers.update(kwargs.get("headers", {}))
|
|
196
|
+
|
|
197
|
+
merged_kwargs: Dict[str, Any] = kwargs.copy()
|
|
198
|
+
merged_kwargs["headers"] = headers
|
|
199
|
+
|
|
200
|
+
return self.http_client.post(
|
|
201
|
+
url=self.url,
|
|
202
|
+
content=json.dumps(
|
|
203
|
+
{
|
|
204
|
+
"query": query,
|
|
205
|
+
"operationName": operation_name,
|
|
206
|
+
"variables": variables,
|
|
207
|
+
},
|
|
208
|
+
default=to_jsonable_python,
|
|
209
|
+
),
|
|
210
|
+
**merged_kwargs,
|
|
211
|
+
)
|
stigg/generated/base_model.py
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
# Generated by ariadne-codegen
|
|
1
|
+
# Generated by ariadne-codegen
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from io import IOBase
|
|
4
4
|
|
|
5
|
-
from pydantic import BaseModel as PydanticBaseModel
|
|
6
|
-
from pydantic.class_validators import validator
|
|
7
|
-
from pydantic.fields import ModelField
|
|
8
|
-
|
|
9
|
-
from .scalars import SCALARS_PARSE_FUNCTIONS, SCALARS_SERIALIZE_FUNCTIONS
|
|
5
|
+
from pydantic import BaseModel as PydanticBaseModel, ConfigDict
|
|
10
6
|
|
|
11
7
|
|
|
12
8
|
class UnsetType:
|
|
@@ -18,43 +14,16 @@ UNSET = UnsetType()
|
|
|
18
14
|
|
|
19
15
|
|
|
20
16
|
class BaseModel(PydanticBaseModel):
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
validate_assignment
|
|
24
|
-
arbitrary_types_allowed
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
args = get_args(type_)
|
|
35
|
-
if origin is list and isinstance(value, list):
|
|
36
|
-
return [cls._parse_custom_scalar_value(item, args[0]) for item in value]
|
|
37
|
-
|
|
38
|
-
if origin is Union and type(None) in args:
|
|
39
|
-
sub_type: Any = list(filter(None, args))[0]
|
|
40
|
-
return cls._parse_custom_scalar_value(value, sub_type)
|
|
41
|
-
|
|
42
|
-
decode = SCALARS_PARSE_FUNCTIONS.get(type_)
|
|
43
|
-
if value and decode and callable(decode):
|
|
44
|
-
return decode(value)
|
|
45
|
-
|
|
46
|
-
return value
|
|
47
|
-
|
|
48
|
-
def dict(self, **kwargs: Any) -> Dict[str, Any]:
|
|
49
|
-
dict_ = super().dict(**kwargs)
|
|
50
|
-
return {key: self._serialize_value(value) for key, value in dict_.items()}
|
|
51
|
-
|
|
52
|
-
def _serialize_value(self, value: Any) -> Any:
|
|
53
|
-
serialize = SCALARS_SERIALIZE_FUNCTIONS.get(type(value))
|
|
54
|
-
if serialize and callable(serialize):
|
|
55
|
-
return serialize(value)
|
|
56
|
-
|
|
57
|
-
if isinstance(value, list):
|
|
58
|
-
return [self._serialize_value(item) for item in value]
|
|
59
|
-
|
|
60
|
-
return value
|
|
17
|
+
model_config = ConfigDict(
|
|
18
|
+
populate_by_name=True,
|
|
19
|
+
validate_assignment=True,
|
|
20
|
+
arbitrary_types_allowed=True,
|
|
21
|
+
protected_namespaces=(),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Upload:
|
|
26
|
+
def __init__(self, filename: str, content: IOBase, content_type: str):
|
|
27
|
+
self.filename = filename
|
|
28
|
+
self.content = content
|
|
29
|
+
self.content_type = content_type
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Generated by ariadne-codegen
|
|
1
|
+
# Generated by ariadne-codegen
|
|
2
2
|
# Source: operations.graphql
|
|
3
3
|
|
|
4
4
|
from pydantic import Field
|
|
@@ -17,5 +17,4 @@ class CancelSubscriptionCancelSubscription(SlimSubscriptionFragment):
|
|
|
17
17
|
pass
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
CancelSubscription.
|
|
21
|
-
CancelSubscriptionCancelSubscription.update_forward_refs()
|
|
20
|
+
CancelSubscription.model_rebuild()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Generated by ariadne-codegen
|
|
1
|
+
# Generated by ariadne-codegen
|
|
2
2
|
# Source: operations.graphql
|
|
3
3
|
|
|
4
4
|
from pydantic import Field
|
|
@@ -8,6 +8,3 @@ from .base_model import BaseModel
|
|
|
8
8
|
|
|
9
9
|
class CancelSubscriptionUpdates(BaseModel):
|
|
10
10
|
cancel_schedule: str = Field(alias="cancelSchedule")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CancelSubscriptionUpdates.update_forward_refs()
|