Esempio n. 1
0
def parse_track_response(
        response: Element,
        settings: Settings) -> Tuple[List[TrackingDetails], List[Message]]:
    track_details = response.xpath(".//*[local-name() = $name]",
                                   name="Shipment")
    tracking: List[TrackingDetails] = [
        _extract_tracking(node, settings) for node in track_details
    ]
    return tracking, parse_error_response(response, settings)
Esempio n. 2
0
def parse_freight_rate_response(
        response: Element,
        settings: Settings) -> Tuple[List[RateDetails], List[Message]]:
    rate_reply = response.xpath(".//*[local-name() = $name]",
                                name="FreightRateResponse")
    rates: List[RateDetails] = [
        _extract_freight_rate(detail_node, settings)
        for detail_node in rate_reply
    ]
    return rates, parse_error_response(response, settings)
Esempio n. 3
0
def parse_shipment_response(
        response: Element,
        settings: Settings) -> Tuple[ShipmentDetails, List[Message]]:
    details = next(
        iter(
            response.xpath(".//*[local-name() = $name]",
                           name="ShipmentResults")), None)
    shipment = _extract_shipment(details,
                                 settings) if details is not None else None
    return shipment, parse_error_response(response, settings)
Esempio n. 4
0
def parse_freight_ship_response(
    response: Element, settings: Settings
) -> Tuple[ShipmentDetails, List[Message]]:
    details = response.xpath(".//*[local-name() = $name]", name="FreightShipResponse")
    shipment = _extract_shipment(details[0], settings) if len(details) > 0 else None
    return shipment, parse_error_response(response, settings)
Esempio n. 5
0
def parse_rate_response(
    response: Element, settings: Settings
) -> Tuple[List[RateDetails], List[Message]]:
    rate_reply = response.xpath(".//*[local-name() = $name]", name="RatedShipment")
    rates: List[RateDetails] = reduce(_extract_package_rate(settings), rate_reply, [])
    return rates, parse_error_response(response, settings)