Example #1
0
def parse_tracking_response(
        response,
        settings: Settings) -> Tuple[List[TrackingDetails], List[Message]]:
    details = []  # retrieve details from `response`
    tracking_details = [
        _extract_detail(detail, settings) for detail in details
    ]

    return tracking_details, parse_error_response(response, settings)
Example #2
0
def parse_address_validation_response(
        response,
        settings: Settings) -> Tuple[AddressValidationDetails, List[Message]]:
    successful = True  # retrieve success status from `response`
    validation_details = AddressValidationDetails(
        carrier_id=settings.carrier_id,
        carrier_name=settings.carrier_name,
        success=successful) if successful else None

    return validation_details, parse_error_response(response, settings)
Example #3
0
def parse_pickup_cancel_response(
        response, settings) -> Tuple[ConfirmationDetails, List[Message]]:
    successful = True  # retrieve success status from `response`
    cancellation = (ConfirmationDetails(
        carrier_name=settings.carrier_name,
        carrier_id=settings.carrier_id,
        success=successful,
        operation="Cancel Pickup",
    ) if successful else None)

    return cancellation, parse_error_response(response, settings)
Example #4
0
def parse_pickup_response(
        response, settings: Settings) -> Tuple[PickupDetails, List[Message]]:
    pickup = _extract_detail(response, settings)
    return pickup, parse_error_response(response, settings)
Example #5
0
def parse_shipment_response(
        response, settings: Settings) -> Tuple[ShipmentDetails, List[Message]]:
    shipment = _extract_detail(response, settings)
    return shipment, parse_error_response(response, settings)