Exemplo n.º 1
0
    def schedule(args: Union[PickupRequest, dict]) -> IRequestFrom:
        """Schedule a pickup for one or many shipments
        
        Args:
            args (Union[TrackingRequest, dict]): the pickup schedule request payload

        Returns:
            IRequestWith: a lazy request dataclass instance
        """
        logger.debug(f"book a pickup. payload: {DP.jsonify(args)}")
        payload = args if isinstance(args, PickupRequest) else PickupRequest(
            **args)

        def action(gateway: Gateway):
            request: Serializable = gateway.mapper.create_pickup_request(
                payload)
            response: Deserializable = gateway.proxy.schedule_pickup(request)

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

            return IDeserialize(deserialize)

        return IRequestFrom(action)
Exemplo n.º 2
0
    def book(args: Union[PickupRequest, dict]):
        payload = args if isinstance(args, PickupRequest) else PickupRequest(
            **args)

        def action(gateway: Gateway):
            request: Serializable = gateway.mapper.create_pickup_request(
                payload)
            response: Deserializable = gateway.proxy.request_pickup(request)

            def deserialize():
                return gateway.mapper.parse_pickup_response(response)

            return IDeserialize(deserialize)

        return IRequestWith(action)
Exemplo n.º 3
0
    def book(args: Union[PickupRequest, dict]):
        logger.debug(f'book a pickup. payload: {jsonify(args)}')
        payload = args if isinstance(args, PickupRequest) else PickupRequest(
            **args)

        def action(gateway: Gateway):
            request: Serializable = gateway.mapper.create_pickup_request(
                payload)
            response: Deserializable = gateway.proxy.request_pickup(request)

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

            return IDeserialize(deserialize)

        return IRequestWith(action)
Exemplo n.º 4
0
 def setUp(self):
     self.maxDiff = None
     self.PickupRequest = PickupRequest(**pickup_data)
     self.PickupUpdateRequest = PickupUpdateRequest(**pickup_update_data)
     self.PickupCancelRequest = PickupCancelRequest(**pickup_cancel_data)
Exemplo n.º 5
0
 def setUp(self):
     self.maxDiff = None
     self.BookPURequest = PickupRequest(**book_pickup_payload)
     self.ModifyPURequest = PickupUpdateRequest(**modification_data)
     self.CancelPURequest = PickupCancelRequest(**cancellation_data)