Beispiel #1
0
    def fetch(args: Union[TrackingRequest, dict]) -> IRequestFrom:
        payload = (args if isinstance(args, TrackingRequest) else
                   TrackingRequest(**args))

        def action(gateway: Gateway) -> IDeserialize:
            request: Serializable = gateway.mapper.create_tracking_request(
                payload)
            response: Deserializable = gateway.proxy.get_tracking(request)

            @fail_safe(gateway)
            def deserialize():
                return gateway.mapper.parse_tracking_response(response)

            return IDeserialize(deserialize)

        return IRequestFrom(action)
Beispiel #2
0
    def fetch(args: Union[TrackingRequest, dict]) -> IRequestFrom:
        """Fetch tracking statuses and details from a carrier
        
        Args:
            args (Union[TrackingRequest, dict]): the tracking request payload

        Returns:
            IRequestFrom: a lazy request dataclass instance
        """
        logger.debug(f"track a shipment. payload: {DP.jsonify(args)}")
        payload = args if isinstance(args, TrackingRequest) else TrackingRequest(**args)

        def action(gateway: Gateway) -> IDeserialize:
            request: Serializable = gateway.mapper.create_tracking_request(payload)
            response: Deserializable = gateway.proxy.get_tracking(request)

            @fail_safe(gateway)
            def deserialize():
                return gateway.mapper.parse_tracking_response(response)

            return IDeserialize(deserialize)

        return IRequestFrom(action)
Beispiel #3
0
 def setUp(self):
     self.maxDiff = None
     self.TrackingRequest = TrackingRequest(
         tracking_numbers=TRACKING_PAYLOAD)
Beispiel #4
0
 def setUp(self):
     self.maxDiff = None
     self.TrackingRequest = TrackingRequest(
         tracking_numbers=TrackingRequestPayload)
Beispiel #5
0
 def setUp(self):
     self.maxDiff = None
     self.TrackRequest = TrackingRequest(tracking_numbers=["794887075005"])