mc5-api-client 1.0.16__py3-none-any.whl → 1.0.17__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.
- mc5_api_client/__init__.py +106 -1
- mc5_api_client/account.py +352 -0
- mc5_api_client/account_quick.py +246 -0
- mc5_api_client/alerts.py +336 -0
- mc5_api_client/alerts_quick.py +210 -0
- mc5_api_client/client.py +875 -34
- mc5_api_client/debug.py +259 -0
- mc5_api_client/federation.py +257 -0
- mc5_api_client/federation_quick.py +198 -0
- mc5_api_client/platform.py +109 -0
- mc5_api_client/simple_client.py +563 -19
- mc5_api_client/squad_battle.py +439 -0
- mc5_api_client/squad_battle_quick.py +223 -0
- mc5_api_client/telemetry.py +344 -0
- mc5_api_client/transfer.py +348 -0
- mc5_api_client/transfer_quick.py +280 -0
- {mc5_api_client-1.0.16.dist-info → mc5_api_client-1.0.17.dist-info}/METADATA +581 -7
- mc5_api_client-1.0.17.dist-info/RECORD +28 -0
- mc5_api_client-1.0.16.dist-info/RECORD +0 -15
- {mc5_api_client-1.0.16.dist-info → mc5_api_client-1.0.17.dist-info}/WHEEL +0 -0
- {mc5_api_client-1.0.16.dist-info → mc5_api_client-1.0.17.dist-info}/entry_points.txt +0 -0
- {mc5_api_client-1.0.16.dist-info → mc5_api_client-1.0.17.dist-info}/licenses/LICENSE +0 -0
- {mc5_api_client-1.0.16.dist-info → mc5_api_client-1.0.17.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ────────────[ CHIZOBA ]────────────────────────────
|
|
3
|
+
# | Email : chizoba2026@hotmail.com
|
|
4
|
+
# | File : transfer_quick.py
|
|
5
|
+
# | License | MIT License © 2026 Chizoba
|
|
6
|
+
# | Brief : Quick functions for account transfer and device linking
|
|
7
|
+
# ────────────────★─────────────────────────────────
|
|
8
|
+
|
|
9
|
+
from typing import Optional, Dict, Any
|
|
10
|
+
from .simple_client import SimpleMC5Client
|
|
11
|
+
from .telemetry import report_usage
|
|
12
|
+
from .debug import debug_function, debug_print
|
|
13
|
+
|
|
14
|
+
@debug_function
|
|
15
|
+
def quick_generate_transfer_code(username: str, password: str) -> Optional[Dict[str, Any]]:
|
|
16
|
+
"""
|
|
17
|
+
Quick function to generate a transfer code for account linking.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
username: MC5 username
|
|
21
|
+
password: MC5 password
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
Transfer code information or None if failed
|
|
25
|
+
"""
|
|
26
|
+
try:
|
|
27
|
+
with SimpleMC5Client(username, password) as client:
|
|
28
|
+
if client.connect():
|
|
29
|
+
transfer_info = client.client.generate_transfer_code()
|
|
30
|
+
|
|
31
|
+
if transfer_info.get("transfer_code"):
|
|
32
|
+
code = transfer_info["transfer_code"]
|
|
33
|
+
expiration = transfer_info["expiration"]
|
|
34
|
+
|
|
35
|
+
debug_print(f"✅ Transfer code generated: {code}", "success")
|
|
36
|
+
debug_print(f"⏰ Expires: {expiration}", "info")
|
|
37
|
+
debug_print("📱 Use this code on your new device to link your account", "info")
|
|
38
|
+
|
|
39
|
+
return transfer_info
|
|
40
|
+
else:
|
|
41
|
+
debug_print("❌ Failed to generate transfer code", "error")
|
|
42
|
+
return None
|
|
43
|
+
return None
|
|
44
|
+
except Exception as e:
|
|
45
|
+
debug_print(f"❌ Failed to generate transfer code: {e}", "error")
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
@debug_function
|
|
49
|
+
def quick_check_transfer_status(username: str, password: str) -> Optional[Dict[str, Any]]:
|
|
50
|
+
"""
|
|
51
|
+
Quick function to check transfer code status.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
username: MC5 username
|
|
55
|
+
password: MC5 password
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
Transfer code status or None if failed
|
|
59
|
+
"""
|
|
60
|
+
try:
|
|
61
|
+
with SimpleMC5Client(username, password) as client:
|
|
62
|
+
if client.connect():
|
|
63
|
+
status = client.client.get_transfer_code_info()
|
|
64
|
+
|
|
65
|
+
if status.get("has_active_code"):
|
|
66
|
+
code = status["transfer_code"]
|
|
67
|
+
time_remaining = status.get("time_remaining", {})
|
|
68
|
+
|
|
69
|
+
debug_print(f"✅ Active transfer code found: {code}", "success")
|
|
70
|
+
|
|
71
|
+
if time_remaining and not status.get("is_expired"):
|
|
72
|
+
debug_print(f"⏰ Time remaining: {time_remaining.get('formatted', 'Unknown')}", "info")
|
|
73
|
+
else:
|
|
74
|
+
debug_print("⚠️ Code has expired", "warning")
|
|
75
|
+
|
|
76
|
+
return status
|
|
77
|
+
else:
|
|
78
|
+
debug_print("ℹ️ No active transfer code found", "info")
|
|
79
|
+
return status
|
|
80
|
+
return None
|
|
81
|
+
except Exception as e:
|
|
82
|
+
debug_print(f"❌ Failed to check transfer status: {e}", "error")
|
|
83
|
+
return None
|
|
84
|
+
|
|
85
|
+
@debug_function
|
|
86
|
+
def quick_get_device_linking_guide(username: str, password: str) -> Optional[Dict[str, Any]]:
|
|
87
|
+
"""
|
|
88
|
+
Quick function to get complete device linking guide.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
username: MC5 username
|
|
92
|
+
password: MC5 password
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Device linking guide or None if failed
|
|
96
|
+
"""
|
|
97
|
+
try:
|
|
98
|
+
with SimpleMC5Client(username, password) as client:
|
|
99
|
+
if client.connect():
|
|
100
|
+
guide = client.client.get_device_linking_guide()
|
|
101
|
+
|
|
102
|
+
debug_print("📖 Device linking guide generated", "success")
|
|
103
|
+
|
|
104
|
+
# Show current code status
|
|
105
|
+
code_info = guide.get("current_code_info", {})
|
|
106
|
+
if code_info.get("has_active_code"):
|
|
107
|
+
debug_print(f"🔑 Current code: {code_info.get('transfer_code')}", "info")
|
|
108
|
+
debug_print(f"⏰ Expires: {code_info.get('expiration')}", "info")
|
|
109
|
+
else:
|
|
110
|
+
debug_print("ℹ️ No active code - generate one first", "info")
|
|
111
|
+
|
|
112
|
+
return guide
|
|
113
|
+
return None
|
|
114
|
+
except Exception as e:
|
|
115
|
+
debug_print(f"❌ Failed to get linking guide: {e}", "error")
|
|
116
|
+
return None
|
|
117
|
+
|
|
118
|
+
@debug_function
|
|
119
|
+
def quick_link_device_workflow(username: str, password: str) -> Optional[Dict[str, Any]]:
|
|
120
|
+
"""
|
|
121
|
+
Quick function for complete device linking workflow.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
username: MC5 username
|
|
125
|
+
password: MC5 password
|
|
126
|
+
|
|
127
|
+
Returns:
|
|
128
|
+
Complete workflow results or None if failed
|
|
129
|
+
"""
|
|
130
|
+
try:
|
|
131
|
+
with SimpleMC5Client(username, password) as client:
|
|
132
|
+
if client.connect():
|
|
133
|
+
debug_print("🔄 Starting device linking workflow", "info")
|
|
134
|
+
|
|
135
|
+
# Step 1: Check existing code
|
|
136
|
+
debug_print("📋 Step 1: Checking existing transfer code...")
|
|
137
|
+
status = client.client.get_transfer_code_info()
|
|
138
|
+
|
|
139
|
+
if status.get("has_active_code") and not status.get("is_expired"):
|
|
140
|
+
debug_print(f"✅ Found active code: {status['transfer_code']}", "success")
|
|
141
|
+
time_remaining = status.get("time_remaining", {})
|
|
142
|
+
if time_remaining:
|
|
143
|
+
debug_print(f"⏰ Time remaining: {time_remaining.get('formatted')}", "info")
|
|
144
|
+
|
|
145
|
+
workflow_result = {
|
|
146
|
+
"status": "existing_code",
|
|
147
|
+
"transfer_code": status["transfer_code"],
|
|
148
|
+
"expiration": status["expiration"],
|
|
149
|
+
"time_remaining": time_remaining,
|
|
150
|
+
"instructions": status["instructions"]
|
|
151
|
+
}
|
|
152
|
+
else:
|
|
153
|
+
# Step 2: Generate new code
|
|
154
|
+
debug_print("📋 Step 2: Generating new transfer code...")
|
|
155
|
+
transfer_info = client.client.generate_transfer_code()
|
|
156
|
+
|
|
157
|
+
if transfer_info.get("transfer_code"):
|
|
158
|
+
debug_print(f"✅ New code generated: {transfer_info['transfer_code']}", "success")
|
|
159
|
+
|
|
160
|
+
workflow_result = {
|
|
161
|
+
"status": "new_code",
|
|
162
|
+
"transfer_code": transfer_info["transfer_code"],
|
|
163
|
+
"expiration": transfer_info["expiration"],
|
|
164
|
+
"instructions": transfer_info["instructions"]
|
|
165
|
+
}
|
|
166
|
+
else:
|
|
167
|
+
debug_print("❌ Failed to generate new code", "error")
|
|
168
|
+
return None
|
|
169
|
+
|
|
170
|
+
# Step 3: Get linking guide
|
|
171
|
+
debug_print("📋 Step 3: Getting linking instructions...")
|
|
172
|
+
guide = client.client.get_device_linking_guide()
|
|
173
|
+
|
|
174
|
+
workflow_result.update({
|
|
175
|
+
"linking_guide": guide,
|
|
176
|
+
"steps": guide.get("steps", []),
|
|
177
|
+
"important_notes": guide.get("important_notes", [])
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
debug_print("✅ Device linking workflow completed", "success")
|
|
181
|
+
return workflow_result
|
|
182
|
+
return None
|
|
183
|
+
except Exception as e:
|
|
184
|
+
debug_print(f"❌ Failed to complete linking workflow: {e}", "error")
|
|
185
|
+
return None
|
|
186
|
+
|
|
187
|
+
@debug_function
|
|
188
|
+
def quick_validate_transfer_code(transfer_code: str) -> Optional[Dict[str, Any]]:
|
|
189
|
+
"""
|
|
190
|
+
Quick function to validate transfer code format.
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
transfer_code: Transfer code to validate
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
Validation result or None if failed
|
|
197
|
+
"""
|
|
198
|
+
try:
|
|
199
|
+
from .transfer import TransferMixin
|
|
200
|
+
|
|
201
|
+
# Create a temporary client instance for validation
|
|
202
|
+
client = TransferMixin()
|
|
203
|
+
client._token_data = {"access_token": "dummy"} # Set minimal token data
|
|
204
|
+
|
|
205
|
+
validation = client.validate_transfer_code_format(transfer_code)
|
|
206
|
+
|
|
207
|
+
if validation.get("valid"):
|
|
208
|
+
debug_print(f"✅ Transfer code format is valid", "success")
|
|
209
|
+
else:
|
|
210
|
+
debug_print(f"❌ Invalid transfer code: {validation.get('error')}", "error")
|
|
211
|
+
|
|
212
|
+
return validation
|
|
213
|
+
except Exception as e:
|
|
214
|
+
debug_print(f"❌ Failed to validate transfer code: {e}", "error")
|
|
215
|
+
return None
|
|
216
|
+
|
|
217
|
+
@debug_function
|
|
218
|
+
def quick_force_new_code(username: str, password: str) -> Optional[Dict[str, Any]]:
|
|
219
|
+
"""
|
|
220
|
+
Quick function to force generate a new transfer code.
|
|
221
|
+
|
|
222
|
+
Args:
|
|
223
|
+
username: MC5 username
|
|
224
|
+
password: MC5 password
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
New transfer code information or None if failed
|
|
228
|
+
"""
|
|
229
|
+
try:
|
|
230
|
+
with SimpleMC5Client(username, password) as client:
|
|
231
|
+
if client.connect():
|
|
232
|
+
debug_print("🔄 Forcing new transfer code generation...", "info")
|
|
233
|
+
|
|
234
|
+
result = client.client.generate_new_transfer_code()
|
|
235
|
+
|
|
236
|
+
if result.get("transfer_code"):
|
|
237
|
+
debug_print(f"✅ New transfer code: {result['transfer_code']}", "success")
|
|
238
|
+
debug_print(f"⏰ Expires: {result['expiration']}", "info")
|
|
239
|
+
debug_print("⚠️ This may have overridden any existing code", "warning")
|
|
240
|
+
|
|
241
|
+
return result
|
|
242
|
+
else:
|
|
243
|
+
debug_print("❌ Failed to force generate new code", "error")
|
|
244
|
+
return None
|
|
245
|
+
return None
|
|
246
|
+
except Exception as e:
|
|
247
|
+
debug_print(f"❌ Failed to force new code generation: {e}", "error")
|
|
248
|
+
return None
|
|
249
|
+
|
|
250
|
+
@debug_function
|
|
251
|
+
def quick_transfer_status_summary(username: str, password: str) -> Optional[str]:
|
|
252
|
+
"""
|
|
253
|
+
Quick function to get a human-readable transfer status summary.
|
|
254
|
+
|
|
255
|
+
Args:
|
|
256
|
+
username: MC5 username
|
|
257
|
+
password: MC5 password
|
|
258
|
+
|
|
259
|
+
Returns:
|
|
260
|
+
Human-readable status summary or None if failed
|
|
261
|
+
"""
|
|
262
|
+
try:
|
|
263
|
+
status = quick_check_transfer_status(username, password)
|
|
264
|
+
|
|
265
|
+
if status:
|
|
266
|
+
if status.get("has_active_code"):
|
|
267
|
+
if status.get("is_expired"):
|
|
268
|
+
return f"⚠️ Transfer code expired: {status.get('transfer_code')}"
|
|
269
|
+
else:
|
|
270
|
+
code = status.get("transfer_code")
|
|
271
|
+
time_remaining = status.get("time_remaining", {})
|
|
272
|
+
time_str = time_remaining.get('formatted', 'Unknown time')
|
|
273
|
+
return f"✅ Active code: {code} (expires in {time_str})"
|
|
274
|
+
else:
|
|
275
|
+
return "ℹ️ No active transfer code - generate one to link a device"
|
|
276
|
+
else:
|
|
277
|
+
return "❌ Failed to check transfer status"
|
|
278
|
+
except Exception as e:
|
|
279
|
+
debug_print(f"❌ Failed to get status summary: {e}", "error")
|
|
280
|
+
return None
|