Добавлен провайдер доставки CSE: SOAP-адаптер (Calc + SaveDocuments), маршрутизация init-payment по провайдеру, обобщение tariff_code до строки, география CSE в cities_map
Deploy / deploy (push) Failing after 52s
Deploy / deploy (push) Failing after 52s
This commit is contained in:
@@ -22,7 +22,7 @@ def map_cdek_response(payload: dict[str, Any]) -> list[DeliveryPrice]:
|
||||
def map_cdek_response_for_tariff_code(
|
||||
payload: dict[str, Any],
|
||||
*,
|
||||
tariff_code: int,
|
||||
tariff_code: str,
|
||||
) -> DeliveryPrice | None:
|
||||
tariff_codes = payload.get("tariff_codes")
|
||||
if not isinstance(tariff_codes, list):
|
||||
@@ -84,19 +84,17 @@ def _get_tariffs(payload: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
return tariffs
|
||||
|
||||
|
||||
def _tariff_code_matches(value: object, expected_tariff_code: int) -> bool:
|
||||
if isinstance(value, bool) or value is None:
|
||||
return False
|
||||
try:
|
||||
return int(value) == expected_tariff_code
|
||||
except (TypeError, ValueError):
|
||||
def _tariff_code_matches(value: object, expected_tariff_code: str) -> bool:
|
||||
extracted = _extract_tariff_code(value)
|
||||
if extracted is None:
|
||||
return False
|
||||
return extracted == expected_tariff_code
|
||||
|
||||
|
||||
def _extract_tariff_code(value: object) -> int | None:
|
||||
def _extract_tariff_code(value: object) -> str | None:
|
||||
if isinstance(value, bool) or value is None:
|
||||
return None
|
||||
try:
|
||||
return int(value)
|
||||
return str(int(value))
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
@@ -48,7 +48,7 @@ def map_cdek_order_request(
|
||||
payload: dict[str, Any] = {
|
||||
"number": order_uuid,
|
||||
"type": 2,
|
||||
"tariff_code": request.system_data.tariff.tariff_code,
|
||||
"tariff_code": _to_cdek_tariff_code(request.system_data.tariff.tariff_code),
|
||||
"print": _CDEK_WAYBILL_PRINT_TYPE,
|
||||
"sender": _map_party(request.sender_contact),
|
||||
"recipient": _map_party(request.receiver_contact),
|
||||
@@ -61,6 +61,15 @@ def map_cdek_order_request(
|
||||
return payload
|
||||
|
||||
|
||||
def _to_cdek_tariff_code(tariff_code: str) -> int:
|
||||
try:
|
||||
return int(tariff_code)
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise CDEKOrderMappingError(
|
||||
f"CDEK tariff_code must be numeric: {tariff_code!r}."
|
||||
) from exc
|
||||
|
||||
|
||||
def map_cdek_order_response(payload: dict[str, Any]) -> CDEKOrderRegistrationResult:
|
||||
entity = payload.get("entity")
|
||||
if not isinstance(entity, dict):
|
||||
|
||||
Reference in New Issue
Block a user