client-side models to match server-side output
This commit is contained in:
parent
6982f46c37
commit
80415e2b28
3 changed files with 8 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ class HysteriaData(BaseModel):
|
||||||
hysteria2_host: str
|
hysteria2_host: str
|
||||||
server_ip: IPv4Address
|
server_ip: IPv4Address
|
||||||
location_country_code: str
|
location_country_code: str
|
||||||
location_city_code: int
|
location_city_code: str
|
||||||
operator_id: int
|
operator_id: int
|
||||||
# operator_name: str = None
|
# operator_name: str = None
|
||||||
operator_domain: str = None
|
operator_domain: str = None
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ def configure_singbox(
|
||||||
###################################
|
###################################
|
||||||
# SEND TO THE API
|
# SEND TO THE API
|
||||||
###################################
|
###################################
|
||||||
|
logger.info("getting config..")
|
||||||
config_results = post_operator_proxy(
|
config_results = post_operator_proxy(
|
||||||
billing_code=profile.subscription.billing_code,
|
billing_code=profile.subscription.billing_code,
|
||||||
protocol=protocol,
|
protocol=protocol,
|
||||||
|
|
@ -62,6 +63,8 @@ def configure_singbox(
|
||||||
if not config_results:
|
if not config_results:
|
||||||
return Result(valid=False, error_type=ResultError.INVALID_API_REPLY, message="Server-side API issue.")
|
return Result(valid=False, error_type=ResultError.INVALID_API_REPLY, message="Server-side API issue.")
|
||||||
|
|
||||||
|
print(f"config_results is {config_results}")
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# (SERVER CHOICES) PREP RAW DATA (PYDANTIC MODEL)
|
# (SERVER CHOICES) PREP RAW DATA (PYDANTIC MODEL)
|
||||||
###################################
|
###################################
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,9 @@ def create_invoice(
|
||||||
payload=submit_data,
|
payload=submit_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(f"api_response is {api_response.valid}")
|
||||||
|
print(f"api_response is {api_response.error_type}")
|
||||||
|
|
||||||
# Layer 1: API failure:
|
# Layer 1: API failure:
|
||||||
if not api_response.valid:
|
if not api_response.valid:
|
||||||
error_msg = f"API Error: {api_response.error_type} {api_response.message}"
|
error_msg = f"API Error: {api_response.error_type} {api_response.message}"
|
||||||
|
|
@ -84,7 +87,7 @@ def create_invoice(
|
||||||
|
|
||||||
# Layer 2: Server's Reply:
|
# Layer 2: Server's Reply:
|
||||||
raw_reply = api_response.data
|
raw_reply = api_response.data
|
||||||
print("validating the server reply.")
|
print(f"validating the server reply of {raw_reply}.")
|
||||||
server_reply = validate_model(ServerReply, raw_reply)
|
server_reply = validate_model(ServerReply, raw_reply)
|
||||||
|
|
||||||
if not server_reply:
|
if not server_reply:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue