def parse_shipment_response(
        response: Element,
        settings: Settings) -> Tuple[ShipmentDetails, List[Message]]:
    errors = parse_error_response(response, settings)
    details = _extract_details(response, settings)

    return details, errors
Exemple #2
0
def parse_pickup_response(
        response: dict,
        settings: Settings) -> Tuple[PickupDetails, List[Message]]:
    errors = parse_error_response(response, settings)
    details = None

    return details, errors
Exemple #3
0
def parse_tracking_response(
        response: Element,
        settings: Settings) -> Tuple[List[TrackingDetails], List[Message]]:
    tracks_info = response.xpath(".//*[local-name() = $name]",
                                 name="TrackInfo")
    details = [
        _extract_details(node, settings) for node in tracks_info if
        len(node.xpath(".//*[local-name() = $name]", name="TrackDetail")) > 0
    ]

    return details, parse_error_response(response, settings)
Exemple #4
0
def parse_pickup_cancel_response(response: dict, settings: Settings) -> Tuple[ConfirmationDetails, List[Message]]:
    errors = parse_error_response(response, settings)
    details = (
        ConfirmationDetails(
            carrier_id=settings.carrier_id,
            carrier_name=settings.carrier_name,
            success=True,
            operation="Pickup Cancel"
        )
        if not any(errors) else None
    )

    return details, errors
Exemple #5
0
def parse_shipment_cancel_response(
        response: Element,
        settings: Settings) -> Tuple[ConfirmationDetails, List[Message]]:
    errors: List[Message] = parse_error_response(response, settings)
    cancel_response = XP.to_object(eVSICancelResponse, response)

    if cancel_response.Status != "Cancelled":
        errors.append(
            Message(carrier_name=settings.carrier_name,
                    carrier_id=settings.carrier_id,
                    message=cancel_response.Reason,
                    code=cancel_response.Status))

    details = (ConfirmationDetails(
        carrier_id=settings.carrier_id,
        carrier_name=settings.carrier_name,
        operation="Shipment Cancel",
        success=True,
    ) if not any(errors) else None)

    return details, errors
Exemple #6
0
def parse_rate_response(response: Element, settings: Settings) -> Tuple[List[RateDetails], List[Message]]:
    quotes: List[RateDetails] = [
        _extract_details(package, settings)
        for package in response.xpath(".//*[local-name() = $name]", name="Service")
    ]
    return quotes, parse_error_response(response, settings)
def parse_rate_response(response: Element, settings: Settings) -> Tuple[List[RateDetails], List[Message]]:
    quotes: List[RateDetails] = [
        _extract_details(package, settings)
        for package in XP.find("Service", response)
    ]
    return quotes, parse_error_response(response, settings)