celitech-sdk 1.0.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.
- celitech/__init__.py +2 -0
- celitech/hooks/__init__.py +0 -0
- celitech/hooks/hook.py +95 -0
- celitech/models/__init__.py +14 -0
- celitech/models/base.py +251 -0
- celitech/models/create_purchase_ok_response.py +85 -0
- celitech/models/create_purchase_request.py +54 -0
- celitech/models/edit_purchase_ok_response.py +41 -0
- celitech/models/edit_purchase_request.py +41 -0
- celitech/models/get_esim_device_ok_response.py +41 -0
- celitech/models/get_esim_history_ok_response.py +50 -0
- celitech/models/get_esim_mac_ok_response.py +39 -0
- celitech/models/get_esim_ok_response.py +43 -0
- celitech/models/get_purchase_consumption_ok_response.py +17 -0
- celitech/models/list_destinations_ok_response.py +38 -0
- celitech/models/list_packages_ok_response.py +61 -0
- celitech/models/list_purchases_ok_response.py +129 -0
- celitech/models/top_up_esim_ok_response.py +82 -0
- celitech/models/top_up_esim_request.py +49 -0
- celitech/models/utils/cast_models.py +81 -0
- celitech/models/utils/json_map.py +80 -0
- celitech/net/__init__.py +0 -0
- celitech/net/environment/__init__.py +1 -0
- celitech/net/environment/environment.py +11 -0
- celitech/net/headers/__init__.py +0 -0
- celitech/net/headers/base_header.py +9 -0
- celitech/net/request_chain/__init__.py +0 -0
- celitech/net/request_chain/handlers/__init__.py +0 -0
- celitech/net/request_chain/handlers/base_handler.py +39 -0
- celitech/net/request_chain/handlers/hook_handler.py +47 -0
- celitech/net/request_chain/handlers/http_handler.py +80 -0
- celitech/net/request_chain/handlers/retry_handler.py +65 -0
- celitech/net/request_chain/request_chain.py +57 -0
- celitech/net/transport/__init__.py +0 -0
- celitech/net/transport/request.py +89 -0
- celitech/net/transport/request_error.py +53 -0
- celitech/net/transport/response.py +57 -0
- celitech/net/transport/serializer.py +249 -0
- celitech/net/transport/utils.py +28 -0
- celitech/sdk.py +30 -0
- celitech/services/__init__.py +0 -0
- celitech/services/destinations.py +29 -0
- celitech/services/e_sim.py +121 -0
- celitech/services/packages.py +72 -0
- celitech/services/purchases.py +189 -0
- celitech/services/utils/base_service.py +63 -0
- celitech/services/utils/default_headers.py +57 -0
- celitech/services/utils/validator.py +170 -0
- celitech_sdk-1.0.0.dist-info/LICENSE +21 -0
- celitech_sdk-1.0.0.dist-info/METADATA +482 -0
- celitech_sdk-1.0.0.dist-info/RECORD +53 -0
- celitech_sdk-1.0.0.dist-info/WHEEL +5 -0
- celitech_sdk-1.0.0.dist-info/top_level.txt +1 -0
celitech/__init__.py
ADDED
|
File without changes
|
celitech/hooks/hook.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import time
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Request:
|
|
7
|
+
def __init__(self, method, url, headers, body=""):
|
|
8
|
+
self.method = method
|
|
9
|
+
self.url = url
|
|
10
|
+
self.headers = headers
|
|
11
|
+
self.body = body
|
|
12
|
+
|
|
13
|
+
def __str__(self):
|
|
14
|
+
return f"method={self.method}, url={self.url}, headers={self.headers}, body={self.body})"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Response:
|
|
18
|
+
def __init__(self, status, headers, body):
|
|
19
|
+
self.status = status
|
|
20
|
+
self.headers = headers
|
|
21
|
+
self.body = body
|
|
22
|
+
|
|
23
|
+
def __str__(self):
|
|
24
|
+
return "Response(status={}, headers={}, body={})".format(
|
|
25
|
+
self.status, self.headers, self.body
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class CustomHook:
|
|
30
|
+
|
|
31
|
+
def __init__(self):
|
|
32
|
+
self.CURRENT_TOKEN = None
|
|
33
|
+
self.CURRENT_EXPIRY = 0
|
|
34
|
+
|
|
35
|
+
def before_request(self, request: Request):
|
|
36
|
+
if request.url.endswith("/oauth/token"):
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
# Get the client_id and client_secret from environment variables
|
|
40
|
+
client_id = os.getenv("CLIENT_ID", "")
|
|
41
|
+
client_secret = os.getenv("CLIENT_SECRET", "")
|
|
42
|
+
|
|
43
|
+
if not client_id or not client_secret:
|
|
44
|
+
print("Missing CLIENT_ID and/or CLIENT_SECRET environment variables")
|
|
45
|
+
return
|
|
46
|
+
else:
|
|
47
|
+
# Check if CURRENT_TOKEN is missing or CURRENT_EXPIRY is in the past
|
|
48
|
+
if not self.CURRENT_TOKEN or self.CURRENT_EXPIRY < time.time() * 1000:
|
|
49
|
+
# Assuming Celitech class and its methods are defined appropriately
|
|
50
|
+
sdk = Celitech(environment=Environment.TOKEN_SERVER)
|
|
51
|
+
|
|
52
|
+
# Prepare the request payload for fetching a fresh OAuth token
|
|
53
|
+
input_data = {
|
|
54
|
+
"client_id": client_id,
|
|
55
|
+
"client_secret": client_secret,
|
|
56
|
+
"grant_type": "client_credentials",
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Fetch a fresh OAuth token
|
|
60
|
+
token_response = self.do_post(request, input_data, "/oauth2/token")
|
|
61
|
+
expires_in = token_response.get("expires_in")
|
|
62
|
+
access_token = token_response.get("access_token")
|
|
63
|
+
|
|
64
|
+
if not expires_in or not access_token:
|
|
65
|
+
print("There is an issue with getting the OAuth token")
|
|
66
|
+
return
|
|
67
|
+
|
|
68
|
+
self.CURRENT_EXPIRY = time.time() * 1000 + expires_in * 1000
|
|
69
|
+
self.CURRENT_TOKEN = access_token
|
|
70
|
+
|
|
71
|
+
# Set the Bearer token in the request header
|
|
72
|
+
authorization = f"Bearer {self.CURRENT_TOKEN}"
|
|
73
|
+
request.headers.update({"Authorization": authorization})
|
|
74
|
+
|
|
75
|
+
def do_post(self, request: Request, input_data: dict, url_endpoint: str):
|
|
76
|
+
full_url = "https://auth.celitech.net/oauth2/token"
|
|
77
|
+
|
|
78
|
+
try:
|
|
79
|
+
response = requests.post(
|
|
80
|
+
full_url,
|
|
81
|
+
data=input_data,
|
|
82
|
+
headers={"Content-type": "application/x-www-form-urlencoded"},
|
|
83
|
+
verify=True,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
return response.json() if response.ok else None
|
|
87
|
+
except Exception as error:
|
|
88
|
+
print("Error in posting the request:", error)
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
def after_response(self, request: Request, response: Response):
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
def on_error(self, error: Exception, request: Request, response: Response):
|
|
95
|
+
pass
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .list_destinations_ok_response import ListDestinationsOkResponse
|
|
2
|
+
from .list_packages_ok_response import ListPackagesOkResponse
|
|
3
|
+
from .list_purchases_ok_response import ListPurchasesOkResponse
|
|
4
|
+
from .create_purchase_request import CreatePurchaseRequest
|
|
5
|
+
from .create_purchase_ok_response import CreatePurchaseOkResponse
|
|
6
|
+
from .top_up_esim_request import TopUpEsimRequest
|
|
7
|
+
from .top_up_esim_ok_response import TopUpEsimOkResponse
|
|
8
|
+
from .edit_purchase_request import EditPurchaseRequest
|
|
9
|
+
from .edit_purchase_ok_response import EditPurchaseOkResponse
|
|
10
|
+
from .get_purchase_consumption_ok_response import GetPurchaseConsumptionOkResponse
|
|
11
|
+
from .get_esim_ok_response import GetEsimOkResponse
|
|
12
|
+
from .get_esim_device_ok_response import GetEsimDeviceOkResponse
|
|
13
|
+
from .get_esim_history_ok_response import GetEsimHistoryOkResponse
|
|
14
|
+
from .get_esim_mac_ok_response import GetEsimMacOkResponse
|
celitech/models/base.py
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import List, Union, get_origin, get_args
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BaseModel:
|
|
7
|
+
"""
|
|
8
|
+
A base class that most of the models in the SDK inherited from.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self):
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
def _pattern_matching(self, value: str, pattern: str, variable_name: str):
|
|
15
|
+
"""
|
|
16
|
+
Checks if a value matches a regex pattern and returns the value if there's a match.
|
|
17
|
+
|
|
18
|
+
:param value: The value to be checked.
|
|
19
|
+
:type value: str
|
|
20
|
+
:param pattern: The regex pattern.
|
|
21
|
+
:type pattern: str
|
|
22
|
+
:param variable_name: The variable name.
|
|
23
|
+
:type variable_name: str
|
|
24
|
+
:return: The value if it matches the pattern.
|
|
25
|
+
:rtype: str
|
|
26
|
+
:raises ValueError: If the value does not match the pattern.
|
|
27
|
+
"""
|
|
28
|
+
if value is None:
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
if re.match(r"{}".format(pattern), value):
|
|
32
|
+
return value
|
|
33
|
+
else:
|
|
34
|
+
raise ValueError(f"Invalid value for {variable_name}: must match {pattern}")
|
|
35
|
+
|
|
36
|
+
def _enum_matching(
|
|
37
|
+
self, value: Union[str, Enum], enum_values: List[str], variable_name: str
|
|
38
|
+
):
|
|
39
|
+
"""
|
|
40
|
+
Checks if a value (str or enum) matches the required enum values and returns the value if there's a match.
|
|
41
|
+
|
|
42
|
+
:param value: The value to be checked.
|
|
43
|
+
:type value: Union[str, Enum]
|
|
44
|
+
:param enum_values: The list of valid enum values.
|
|
45
|
+
:type enum_values: List[str]
|
|
46
|
+
:param variable_name: The variable name.
|
|
47
|
+
:type variable_name: str
|
|
48
|
+
:return: The value if it matches one of the enum values.
|
|
49
|
+
:rtype: Union[str, Enum]
|
|
50
|
+
:raises ValueError: If the value does not match any of the enum values.
|
|
51
|
+
"""
|
|
52
|
+
if value is None:
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
str_value = value.value if isinstance(value, Enum) else value
|
|
56
|
+
if str_value in enum_values:
|
|
57
|
+
return value
|
|
58
|
+
else:
|
|
59
|
+
raise ValueError(
|
|
60
|
+
f"Invalid value for {variable_name}: must match one of {enum_values}"
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def _define_object(self, input_data, input_class):
|
|
64
|
+
"""
|
|
65
|
+
Check if the input data is an instance of the input class and return the input data if it is.
|
|
66
|
+
Otherwise, return an instance of the input class.
|
|
67
|
+
|
|
68
|
+
:param input_data: The input data to be checked.
|
|
69
|
+
:param input_class: The class that the input data should be an instance of.
|
|
70
|
+
:return: The input data if it is an instance of input_class, otherwise an instance of input_class.
|
|
71
|
+
:rtype: object
|
|
72
|
+
"""
|
|
73
|
+
if input_data is None:
|
|
74
|
+
return None
|
|
75
|
+
elif isinstance(input_data, input_class):
|
|
76
|
+
return input_data
|
|
77
|
+
else:
|
|
78
|
+
return input_class._unmap(input_data)
|
|
79
|
+
|
|
80
|
+
def _define_list(self, input_data, list_class):
|
|
81
|
+
"""
|
|
82
|
+
Create a list of instances of a specified class from input data.
|
|
83
|
+
|
|
84
|
+
:param input_data: The input data to be transformed into a list of instances.
|
|
85
|
+
:param list_class: The class that each instance in the list should be an instance of.
|
|
86
|
+
:return: A list of instances of list_class.
|
|
87
|
+
:rtype: list
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
if input_data is None:
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
result = []
|
|
94
|
+
for item in input_data:
|
|
95
|
+
if hasattr(list_class, "__args__") and len(list_class.__args__) > 0:
|
|
96
|
+
class_list = self.__create_class_map(list_class)
|
|
97
|
+
OneOfBaseModel.class_list = class_list
|
|
98
|
+
result.append(OneOfBaseModel.return_one_of(item))
|
|
99
|
+
elif issubclass(list_class, Enum):
|
|
100
|
+
result.append(
|
|
101
|
+
self._enum_matching(item, list_class.list(), list_class.__name__)
|
|
102
|
+
)
|
|
103
|
+
elif isinstance(item, list_class):
|
|
104
|
+
result.append(item)
|
|
105
|
+
elif isinstance(item, dict):
|
|
106
|
+
result.append(list_class._unmap(item))
|
|
107
|
+
else:
|
|
108
|
+
result.append(list_class(item))
|
|
109
|
+
return result
|
|
110
|
+
|
|
111
|
+
def __create_class_map(self, union_type):
|
|
112
|
+
"""
|
|
113
|
+
Create a dictionary that maps class names to the actual classes in a Union type.
|
|
114
|
+
|
|
115
|
+
:param union_type: The Union type to create a class map for.
|
|
116
|
+
:return: A dictionary mapping class names to classes.
|
|
117
|
+
:rtype: dict
|
|
118
|
+
"""
|
|
119
|
+
class_map = {}
|
|
120
|
+
for arg in union_type.__args__:
|
|
121
|
+
if arg.__name__:
|
|
122
|
+
class_map[arg.__name__] = arg
|
|
123
|
+
return class_map
|
|
124
|
+
|
|
125
|
+
def _get_representation(self, level=0):
|
|
126
|
+
"""
|
|
127
|
+
Get a string representation of the model.
|
|
128
|
+
|
|
129
|
+
:param int level: The indentation level.
|
|
130
|
+
:return: A string representation of the model.
|
|
131
|
+
"""
|
|
132
|
+
indent = " " * level
|
|
133
|
+
representation_lines = []
|
|
134
|
+
|
|
135
|
+
for attr, value in vars(self).items():
|
|
136
|
+
if value is not None:
|
|
137
|
+
value_representation = (
|
|
138
|
+
value._get_representation(level + 1)
|
|
139
|
+
if hasattr(value, "_get_representation")
|
|
140
|
+
else repr(value)
|
|
141
|
+
)
|
|
142
|
+
representation_lines.append(
|
|
143
|
+
f"{indent} {attr}={value_representation}"
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
f"{self.__class__.__name__}(\n"
|
|
148
|
+
+ ",\n".join(representation_lines)
|
|
149
|
+
+ f"\n{indent})"
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
def __str__(self):
|
|
153
|
+
return self._get_representation()
|
|
154
|
+
|
|
155
|
+
def __repr__(self):
|
|
156
|
+
return self._get_representation()
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class OneOfBaseModel:
|
|
160
|
+
"""
|
|
161
|
+
A base class for handling 'oneOf' models where multiple class constructors are available,
|
|
162
|
+
and the appropriate one is determined based on the input data.
|
|
163
|
+
|
|
164
|
+
:ivar dict class_list: A dictionary mapping class names to their constructors.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
class_list = {}
|
|
168
|
+
|
|
169
|
+
@classmethod
|
|
170
|
+
def return_one_of(cls, input_data):
|
|
171
|
+
"""
|
|
172
|
+
Attempts to initialize an instance of one of the classes in the class_list
|
|
173
|
+
based on the provided input data.
|
|
174
|
+
|
|
175
|
+
:param input_data: Input data used for initialization.
|
|
176
|
+
:return: An instance of one of the classes specified.
|
|
177
|
+
:rtype: object
|
|
178
|
+
:raises ValueError: If no class can be initialized with the provided input data,
|
|
179
|
+
or if optional parameters don't match the input data.
|
|
180
|
+
"""
|
|
181
|
+
if input_data is None:
|
|
182
|
+
return None
|
|
183
|
+
|
|
184
|
+
if isinstance(input_data, (str, float, int, bool)):
|
|
185
|
+
return input_data
|
|
186
|
+
|
|
187
|
+
for class_constructor in cls.class_list.values():
|
|
188
|
+
try:
|
|
189
|
+
# Check if the class is a only a TypeHint
|
|
190
|
+
origin = get_origin(class_constructor)
|
|
191
|
+
if origin is not None and isinstance(input_data, list):
|
|
192
|
+
list_instance = cls._get_list_instance(
|
|
193
|
+
input_data, class_constructor, origin
|
|
194
|
+
)
|
|
195
|
+
if list_instance is not None:
|
|
196
|
+
return list_instance
|
|
197
|
+
else:
|
|
198
|
+
continue # Try the next class constructor
|
|
199
|
+
|
|
200
|
+
# Check if the input_data is already an instance of the class
|
|
201
|
+
if isinstance(input_data, class_constructor):
|
|
202
|
+
return input_data
|
|
203
|
+
|
|
204
|
+
# Check if the input_data is a dictionary that can be used to initialize the class
|
|
205
|
+
elif isinstance(input_data, dict):
|
|
206
|
+
instance = class_constructor._unmap(input_data)
|
|
207
|
+
if cls._check_params(input_data, instance):
|
|
208
|
+
return instance
|
|
209
|
+
except Exception:
|
|
210
|
+
pass
|
|
211
|
+
|
|
212
|
+
raise ValueError(
|
|
213
|
+
f"Input data must match one of the models: {list(cls.class_list.keys())}"
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
@classmethod
|
|
217
|
+
def _get_list_instance(cls, input_data, class_constructor, origin):
|
|
218
|
+
"""
|
|
219
|
+
Return the list of elements for a given class constructor and origin type.
|
|
220
|
+
|
|
221
|
+
:param input_data: The input data to check.
|
|
222
|
+
:param class_constructor: The constructor of the class to check against.
|
|
223
|
+
:param origin: The origin type to check against.
|
|
224
|
+
:return: The input data if all elements are instances of the type specified in the class_constructor,
|
|
225
|
+
or a new list with each item unmapped.
|
|
226
|
+
"""
|
|
227
|
+
args = get_args(class_constructor)
|
|
228
|
+
if isinstance(input_data, origin):
|
|
229
|
+
if args and len(args) == 1 and isinstance(input_data, list):
|
|
230
|
+
inner_type = args[0]
|
|
231
|
+
if all(isinstance(item, inner_type) for item in input_data):
|
|
232
|
+
return input_data
|
|
233
|
+
else:
|
|
234
|
+
return [inner_type._unmap(item) for item in input_data]
|
|
235
|
+
|
|
236
|
+
@classmethod
|
|
237
|
+
def _check_params(cls, raw_input, instance):
|
|
238
|
+
"""
|
|
239
|
+
Checks if the optional parameters in the instance match the keys in the input data,
|
|
240
|
+
ensuring compliance with one of the models.
|
|
241
|
+
|
|
242
|
+
:param dict raw_input: Input data used for initialization.
|
|
243
|
+
:param object instance: An instance of one of the classes specified in the 'oneOf' model.
|
|
244
|
+
:return: True if the optional parameters in the instance match the keys in the input data, False otherwise.
|
|
245
|
+
"""
|
|
246
|
+
input_values = {k: v for k, v in raw_input.items() if v is not None}.values()
|
|
247
|
+
instance_map = instance._map()
|
|
248
|
+
instance_values = {
|
|
249
|
+
k: v for k, v in instance_map.items() if v is not None
|
|
250
|
+
}.values()
|
|
251
|
+
return len(input_values) == len(instance_values)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from .utils.json_map import JsonMap
|
|
2
|
+
from .base import BaseModel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@JsonMap(
|
|
6
|
+
{
|
|
7
|
+
"id_": "id",
|
|
8
|
+
"package_id": "packageId",
|
|
9
|
+
"start_date": "startDate",
|
|
10
|
+
"end_date": "endDate",
|
|
11
|
+
"created_date": "createdDate",
|
|
12
|
+
"start_time": "startTime",
|
|
13
|
+
"end_time": "endTime",
|
|
14
|
+
}
|
|
15
|
+
)
|
|
16
|
+
class CreatePurchaseOkResponsePurchase(BaseModel):
|
|
17
|
+
"""CreatePurchaseOkResponsePurchase
|
|
18
|
+
|
|
19
|
+
:param id_: ID of the purchase, defaults to None
|
|
20
|
+
:type id_: str, optional
|
|
21
|
+
:param package_id: ID of the package, defaults to None
|
|
22
|
+
:type package_id: str, optional
|
|
23
|
+
:param start_date: Start date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ', defaults to None
|
|
24
|
+
:type start_date: str, optional
|
|
25
|
+
:param end_date: End date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ', defaults to None
|
|
26
|
+
:type end_date: str, optional
|
|
27
|
+
:param created_date: Creation date of the purchase in the format 'yyyy-MM-ddThh:mm:ssZZ', defaults to None
|
|
28
|
+
:type created_date: str, optional
|
|
29
|
+
:param start_time: Epoch value representing the start time of the package's validity, defaults to None
|
|
30
|
+
:type start_time: float, optional
|
|
31
|
+
:param end_time: Epoch value representing the end time of the package's validity, defaults to None
|
|
32
|
+
:type end_time: float, optional
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
id_: str = None,
|
|
38
|
+
package_id: str = None,
|
|
39
|
+
start_date: str = None,
|
|
40
|
+
end_date: str = None,
|
|
41
|
+
created_date: str = None,
|
|
42
|
+
start_time: float = None,
|
|
43
|
+
end_time: float = None,
|
|
44
|
+
):
|
|
45
|
+
self.id_ = id_
|
|
46
|
+
self.package_id = package_id
|
|
47
|
+
self.start_date = start_date
|
|
48
|
+
self.end_date = end_date
|
|
49
|
+
self.created_date = created_date
|
|
50
|
+
self.start_time = start_time
|
|
51
|
+
self.end_time = end_time
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@JsonMap({"activation_code": "activationCode"})
|
|
55
|
+
class CreatePurchaseOkResponseProfile(BaseModel):
|
|
56
|
+
"""CreatePurchaseOkResponseProfile
|
|
57
|
+
|
|
58
|
+
:param iccid: ID of the eSIM, defaults to None
|
|
59
|
+
:type iccid: str, optional
|
|
60
|
+
:param activation_code: QR Code of the eSIM as base64, defaults to None
|
|
61
|
+
:type activation_code: str, optional
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
def __init__(self, iccid: str = None, activation_code: str = None):
|
|
65
|
+
self.iccid = iccid
|
|
66
|
+
self.activation_code = activation_code
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@JsonMap({})
|
|
70
|
+
class CreatePurchaseOkResponse(BaseModel):
|
|
71
|
+
"""CreatePurchaseOkResponse
|
|
72
|
+
|
|
73
|
+
:param purchase: purchase, defaults to None
|
|
74
|
+
:type purchase: CreatePurchaseOkResponsePurchase, optional
|
|
75
|
+
:param profile: profile, defaults to None
|
|
76
|
+
:type profile: CreatePurchaseOkResponseProfile, optional
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
def __init__(
|
|
80
|
+
self,
|
|
81
|
+
purchase: CreatePurchaseOkResponsePurchase = None,
|
|
82
|
+
profile: CreatePurchaseOkResponseProfile = None,
|
|
83
|
+
):
|
|
84
|
+
self.purchase = self._define_object(purchase, CreatePurchaseOkResponsePurchase)
|
|
85
|
+
self.profile = self._define_object(profile, CreatePurchaseOkResponseProfile)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from .utils.json_map import JsonMap
|
|
2
|
+
from .base import BaseModel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@JsonMap(
|
|
6
|
+
{
|
|
7
|
+
"data_limit_in_gb": "dataLimitInGB",
|
|
8
|
+
"start_date": "startDate",
|
|
9
|
+
"end_date": "endDate",
|
|
10
|
+
"network_brand": "networkBrand",
|
|
11
|
+
"start_time": "startTime",
|
|
12
|
+
"end_time": "endTime",
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
class CreatePurchaseRequest(BaseModel):
|
|
16
|
+
"""CreatePurchaseRequest
|
|
17
|
+
|
|
18
|
+
:param destination: ISO representation of the package's destination
|
|
19
|
+
:type destination: str
|
|
20
|
+
:param data_limit_in_gb: Size of the package in GB. The available options are 1, 2, 3, 5, 8, 20GB
|
|
21
|
+
:type data_limit_in_gb: float
|
|
22
|
+
:param start_date: Start date of the package's validity in the format 'yyyy-MM-dd'. This date can be set to the current day or any day within the next 12 months.
|
|
23
|
+
:type start_date: str
|
|
24
|
+
:param end_date: End date of the package's validity in the format 'yyyy-MM-dd'. End date can be maximum 60 days after Start date.
|
|
25
|
+
:type end_date: str
|
|
26
|
+
:param email: Email address where the purchase confirmation email will be sent (including QR Code & activation steps), defaults to None
|
|
27
|
+
:type email: str, optional
|
|
28
|
+
:param network_brand: Customize the network brand of the issued eSIM. This parameter is accessible to platforms with Diamond tier and requires an alphanumeric string of up to 15 characters, defaults to None
|
|
29
|
+
:type network_brand: str, optional
|
|
30
|
+
:param start_time: Epoch value representing the start time of the package's validity. This timestamp can be set to the current time or any time within the next 12 months., defaults to None
|
|
31
|
+
:type start_time: float, optional
|
|
32
|
+
:param end_time: Epoch value representing the end time of the package's validity. End time can be maximum 60 days after Start time., defaults to None
|
|
33
|
+
:type end_time: float, optional
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
destination: str,
|
|
39
|
+
data_limit_in_gb: float,
|
|
40
|
+
start_date: str,
|
|
41
|
+
end_date: str,
|
|
42
|
+
email: str = None,
|
|
43
|
+
network_brand: str = None,
|
|
44
|
+
start_time: float = None,
|
|
45
|
+
end_time: float = None,
|
|
46
|
+
):
|
|
47
|
+
self.destination = destination
|
|
48
|
+
self.data_limit_in_gb = data_limit_in_gb
|
|
49
|
+
self.start_date = start_date
|
|
50
|
+
self.end_date = end_date
|
|
51
|
+
self.email = email
|
|
52
|
+
self.network_brand = network_brand
|
|
53
|
+
self.start_time = start_time
|
|
54
|
+
self.end_time = end_time
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from .utils.json_map import JsonMap
|
|
2
|
+
from .base import BaseModel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@JsonMap(
|
|
6
|
+
{
|
|
7
|
+
"purchase_id": "purchaseId",
|
|
8
|
+
"new_start_date": "newStartDate",
|
|
9
|
+
"new_end_date": "newEndDate",
|
|
10
|
+
"new_start_time": "newStartTime",
|
|
11
|
+
"new_end_time": "newEndTime",
|
|
12
|
+
}
|
|
13
|
+
)
|
|
14
|
+
class EditPurchaseOkResponse(BaseModel):
|
|
15
|
+
"""EditPurchaseOkResponse
|
|
16
|
+
|
|
17
|
+
:param purchase_id: ID of the purchase, defaults to None
|
|
18
|
+
:type purchase_id: str, optional
|
|
19
|
+
:param new_start_date: Start date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ', defaults to None
|
|
20
|
+
:type new_start_date: str, optional
|
|
21
|
+
:param new_end_date: End date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ', defaults to None
|
|
22
|
+
:type new_end_date: str, optional
|
|
23
|
+
:param new_start_time: Epoch value representing the new start time of the package's validity, defaults to None
|
|
24
|
+
:type new_start_time: float, optional
|
|
25
|
+
:param new_end_time: Epoch value representing the new end time of the package's validity, defaults to None
|
|
26
|
+
:type new_end_time: float, optional
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
purchase_id: str = None,
|
|
32
|
+
new_start_date: str = None,
|
|
33
|
+
new_end_date: str = None,
|
|
34
|
+
new_start_time: float = None,
|
|
35
|
+
new_end_time: float = None,
|
|
36
|
+
):
|
|
37
|
+
self.purchase_id = purchase_id
|
|
38
|
+
self.new_start_date = new_start_date
|
|
39
|
+
self.new_end_date = new_end_date
|
|
40
|
+
self.new_start_time = new_start_time
|
|
41
|
+
self.new_end_time = new_end_time
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from .utils.json_map import JsonMap
|
|
2
|
+
from .base import BaseModel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@JsonMap(
|
|
6
|
+
{
|
|
7
|
+
"purchase_id": "purchaseId",
|
|
8
|
+
"start_date": "startDate",
|
|
9
|
+
"end_date": "endDate",
|
|
10
|
+
"start_time": "startTime",
|
|
11
|
+
"end_time": "endTime",
|
|
12
|
+
}
|
|
13
|
+
)
|
|
14
|
+
class EditPurchaseRequest(BaseModel):
|
|
15
|
+
"""EditPurchaseRequest
|
|
16
|
+
|
|
17
|
+
:param purchase_id: ID of the purchase
|
|
18
|
+
:type purchase_id: str
|
|
19
|
+
:param start_date: Start date of the package's validity in the format 'yyyy-MM-dd'. This date can be set to the current day or any day within the next 12 months.
|
|
20
|
+
:type start_date: str
|
|
21
|
+
:param end_date: End date of the package's validity in the format 'yyyy-MM-dd'. End date can be maximum 60 days after Start date.
|
|
22
|
+
:type end_date: str
|
|
23
|
+
:param start_time: Epoch value representing the start time of the package's validity. This timestamp can be set to the current time or any time within the next 12 months., defaults to None
|
|
24
|
+
:type start_time: float, optional
|
|
25
|
+
:param end_time: Epoch value representing the end time of the package's validity. End time can be maximum 60 days after Start time., defaults to None
|
|
26
|
+
:type end_time: float, optional
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
purchase_id: str,
|
|
32
|
+
start_date: str,
|
|
33
|
+
end_date: str,
|
|
34
|
+
start_time: float = None,
|
|
35
|
+
end_time: float = None,
|
|
36
|
+
):
|
|
37
|
+
self.purchase_id = purchase_id
|
|
38
|
+
self.start_date = start_date
|
|
39
|
+
self.end_date = end_date
|
|
40
|
+
self.start_time = start_time
|
|
41
|
+
self.end_time = end_time
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from .utils.json_map import JsonMap
|
|
2
|
+
from .base import BaseModel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@JsonMap({"hardware_name": "hardwareName", "hardware_model": "hardwareModel"})
|
|
6
|
+
class Device(BaseModel):
|
|
7
|
+
"""Device
|
|
8
|
+
|
|
9
|
+
:param oem: Name of the OEM, defaults to None
|
|
10
|
+
:type oem: str, optional
|
|
11
|
+
:param hardware_name: Name of the Device, defaults to None
|
|
12
|
+
:type hardware_name: str, optional
|
|
13
|
+
:param hardware_model: Model of the Device, defaults to None
|
|
14
|
+
:type hardware_model: str, optional
|
|
15
|
+
:param eid: Serial Number of the eSIM, defaults to None
|
|
16
|
+
:type eid: str, optional
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
oem: str = None,
|
|
22
|
+
hardware_name: str = None,
|
|
23
|
+
hardware_model: str = None,
|
|
24
|
+
eid: str = None,
|
|
25
|
+
):
|
|
26
|
+
self.oem = oem
|
|
27
|
+
self.hardware_name = hardware_name
|
|
28
|
+
self.hardware_model = hardware_model
|
|
29
|
+
self.eid = eid
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@JsonMap({})
|
|
33
|
+
class GetEsimDeviceOkResponse(BaseModel):
|
|
34
|
+
"""GetEsimDeviceOkResponse
|
|
35
|
+
|
|
36
|
+
:param device: device, defaults to None
|
|
37
|
+
:type device: Device, optional
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(self, device: Device = None):
|
|
41
|
+
self.device = self._define_object(device, Device)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
from .utils.json_map import JsonMap
|
|
3
|
+
from .base import BaseModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@JsonMap({"status_date": "statusDate", "date_": "date"})
|
|
7
|
+
class History(BaseModel):
|
|
8
|
+
"""History
|
|
9
|
+
|
|
10
|
+
:param status: The status of the eSIM at a given time, possible values are 'RELEASED', 'DOWNLOADED', 'INSTALLED', 'ENABLED', 'DELETED', or 'ERROR', defaults to None
|
|
11
|
+
:type status: str, optional
|
|
12
|
+
:param status_date: The date when the eSIM status changed in the format 'yyyy-MM-ddThh:mm:ssZZ', defaults to None
|
|
13
|
+
:type status_date: str, optional
|
|
14
|
+
:param date_: Epoch value representing the date when the eSIM status changed, defaults to None
|
|
15
|
+
:type date_: float, optional
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self, status: str = None, status_date: str = None, date_: float = None
|
|
20
|
+
):
|
|
21
|
+
self.status = status
|
|
22
|
+
self.status_date = status_date
|
|
23
|
+
self.date_ = date_
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@JsonMap({})
|
|
27
|
+
class GetEsimHistoryOkResponseEsim(BaseModel):
|
|
28
|
+
"""GetEsimHistoryOkResponseEsim
|
|
29
|
+
|
|
30
|
+
:param iccid: ID of the eSIM, defaults to None
|
|
31
|
+
:type iccid: str, optional
|
|
32
|
+
:param history: history, defaults to None
|
|
33
|
+
:type history: List[History], optional
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, iccid: str = None, history: List[History] = None):
|
|
37
|
+
self.iccid = iccid
|
|
38
|
+
self.history = self._define_list(history, History)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@JsonMap({})
|
|
42
|
+
class GetEsimHistoryOkResponse(BaseModel):
|
|
43
|
+
"""GetEsimHistoryOkResponse
|
|
44
|
+
|
|
45
|
+
:param esim: esim, defaults to None
|
|
46
|
+
:type esim: GetEsimHistoryOkResponseEsim, optional
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
def __init__(self, esim: GetEsimHistoryOkResponseEsim = None):
|
|
50
|
+
self.esim = self._define_object(esim, GetEsimHistoryOkResponseEsim)
|