Ejemplo n.º 1
0
    def serializer(envelope: Envelope):
        namespacedef_ = f'xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/" {namespace}'

        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        apply_namespaceprefix(envelope.Body.anytypeobjs_[0], prefix)

        return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 2
0
def _request_serializer(request: KnownTrackingRequest) -> str:
    return XP.export(
        request,
        name_="req:KnownTrackingRequest",
        namespacedef_=
        'xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com TrackingRequestKnown.xsd"',
    ).replace('schemaVersion="1."', 'schemaVersion="1.0"')
Ejemplo n.º 3
0
def _request_serializer(request: RouteRequest) -> str:
    namespacedef_ = (
        'xmlns:ns1="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
        ' xsi:schemaLocation="http://www.dhl.com routing-global-req.xsd"')

    return XP.export(request, namespacedef_=namespacedef_).replace(
        'schemaVersion="2."', 'schemaVersion="2.0"')
Ejemplo n.º 4
0
    def serialize(envelope: Envelope):
        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        envelope.Header.ns_prefix_ = envelope.ns_prefix_
        apply_namespaceprefix(envelope.Body.anytypeobjs_[0], "trk")
        apply_namespaceprefix(envelope.Header.anytypeobjs_[0], "upss")
        apply_namespaceprefix(envelope.Body.anytypeobjs_[0].Request, "common")

        return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 5
0
def _request_serializer(request: FedexRateRequest) -> str:
    namespacedef_ = 'xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:v26="http://fedex.com/ws/rate/v26"'

    envelope = create_envelope(body_content=request)
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0], "v26")

    return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 6
0
def _request_serializer(envelope: Envelope) -> str:
    namespacedef_ = 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://purolator.com/pws/datatypes/v1"'
    envelope.ns_prefix_ = "soap"
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    envelope.Header.ns_prefix_ = envelope.ns_prefix_
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0], "v1")
    apply_namespaceprefix(envelope.Header.anytypeobjs_[0], "v1")
    return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 7
0
def _request_serializer(request: ProcessShipmentRequest) -> str:
    namespacedef_ = 'xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v25="http://fedex.com/ws/ship/v25"'

    envelope = create_envelope(body_content=request)
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0], "v25")

    return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 8
0
def _request_serializer(request: PickupRequestDetails,
                        update: bool = False) -> str:
    return XP.export(
        request,
        name_=("pickup-request-update"
               if update else "pickup-request-details"),
        namespacedef_='xmlns="http://www.canadapost.ca/ws/pickuprequest"',
    )
Ejemplo n.º 9
0
def _request_serializer(request: DHLShipmentRequest) -> str:
    xml_str = (XP.export(
        request,
        name_="req:ShipmentRequest",
        namespacedef_=
        'xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd"',
    ).replace("<Image>b'", "<Image>").replace("'</Image>", "</Image>"))
    return xml_str
Ejemplo n.º 10
0
def _request_serializer(request: ModifyPURequest) -> str:
    xml_str = XP.export(
        request,
        name_="req:ModifyPURequest",
        namespacedef_='xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com modify-pickup-Global-req.xsd"',
    ).replace("dhlPickup:", "")

    xml_str = reformat_time("CloseTime", reformat_time("ReadyByTime", xml_str))
    return xml_str
Ejemplo n.º 11
0
def _request_serializer(request: CancelPickupRequest) -> str:
    envelope: Envelope = create_envelope(body_content=request)
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0], "v22")

    return XP.export(
        envelope,
        namespacedef_='xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v22="http://fedex.com/ws/pickup/v22"',
    )
Ejemplo n.º 12
0
def _request_serializer(request: DHLShipmentRequest) -> str:
    xml_str = XP.export(
        request,
        name_="req:ShipmentRequest",
        namespacedef_=
        'xsi:schemaLocation="http://www.dhl.com ship-val-global-req.xsd" xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"',
    ).replace('schemaVersion="10"', 'schemaVersion="10.0"')

    return xml_str
Ejemplo n.º 13
0
def _request_serializer(request: CancelPURequest) -> str:
    xml_str = XP.export(
        request,
        name_="req:CancelPURequest",
        namespacedef_=
        'xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com cancel-pickup-global-req.xsd"',
    )

    xml_str = reformat_time("CancelTime", xml_str)
    return xml_str
Ejemplo n.º 14
0
def standard_request_serializer(envelope: Envelope, version: str = "v2") -> str:
    namespacedef_ = f'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:{version}="http://purolator.com/pws/datatypes/{version}"'
    envelope.ns_prefix_ = "soap"
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    envelope.Header.ns_prefix_ = envelope.ns_prefix_
    [
        apply_namespaceprefix(node, version)
        for node in (envelope.Body.anytypeobjs_ + envelope.Header.anytypeobjs_)
    ]
    return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 15
0
def _request_serializer(request: DCTRequest) -> str:
    namespacedef_ = ('xmlns:p="http://www.dhl.com" '
                     'xmlns:p1="http://www.dhl.com/datatypes" '
                     'xmlns:p2="http://www.dhl.com/DCTRequestdatatypes" '
                     'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
                     'xsi:schemaLocation="http://www.dhl.com DCT-req.xsd "')
    return XP.export(
        request,
        name_="p:DCTRequest",
        namespacedef_=namespacedef_,
    ).replace('schemaVersion="2."', 'schemaVersion="2.0"')
Ejemplo n.º 16
0
def _request_serializer(request: BookPURequest) -> str:
    xml_str = XP.export(
        request,
        name_="req:BookPURequest",
        namespacedef_=
        'xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com book-pickup-global-req_EA.xsd"',
    ).replace("dhlPickup:", "").replace('schemaVersion="3"',
                                        'schemaVersion="3.0"')

    xml_str = reformat_time("CloseTime", reformat_time("ReadyByTime", xml_str))
    return xml_str
Ejemplo n.º 17
0
def default_request_serializer(envelope: Envelope) -> str:
    namespace_ = (
        ' xmlns:soap="http://www.w3.org/2003/05/soap-envelope"'
        ' xmlns:ws="http://ws.onlinerating.canshipws.canpar.com"'
        ' xmlns="http://ws.dto.canshipws.canpar.com/xsd"'
        ' xmlns:xsd1="http://dto.canshipws.canpar.com/xsd"'
    )
    envelope.ns_prefix_ = 'soapenv'
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    envelope.Body.anytypeobjs_[0].ns_prefix_ = "ws"
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0].request, "")
    envelope.Body.anytypeobjs_[0].request.ns_prefix_ = "ws"

    return XP.export(envelope, namespacedef_=namespace_)
Ejemplo n.º 18
0
def _request_serializer(envelope: Envelope) -> str:
    namespace_ = (
        'xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/" '
        'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
        'xmlns:upss="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0" '
        'xmlns:wsf="http://www.ups.com/schema/wsf" '
        'xmlns:common="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0" '
        'xmlns:rate="http://www.ups.com/XMLSchema/XOLTWS/FreightRate/v1.0"')
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    envelope.Header.ns_prefix_ = envelope.ns_prefix_
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0], "rate")
    apply_namespaceprefix(envelope.Header.anytypeobjs_[0], "upss")
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0].Request, "common")

    return XP.export(envelope, namespacedef_=namespace_)
Ejemplo n.º 19
0
    def serializer(envelope: Envelope):
        namespace_ = (
            ' xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"'
            ' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
            ' xmlns:upss="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0"'
            ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
            ' xmlns:common="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0"'
            f" {namespace}")
        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        envelope.Header.ns_prefix_ = envelope.ns_prefix_
        apply_namespaceprefix(envelope.Body.anytypeobjs_[0], prefix)
        apply_namespaceprefix(envelope.Header.anytypeobjs_[0], "upss")
        apply_namespaceprefix(envelope.Body.anytypeobjs_[0].Request, "common")

        return XP.export(envelope, namespacedef_=namespace_)
Ejemplo n.º 20
0
def _request_serializer(envelope: Envelope) -> str:
    namespace_ = """
        xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:upss="http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:common="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0"
        xmlns:rate="http://www.ups.com/XMLSchema/XOLTWS/Rate/v1.1"
    """.replace(" ", "").replace("\n", " ")
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    envelope.Header.ns_prefix_ = envelope.ns_prefix_
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0], "rate")
    apply_namespaceprefix(envelope.Header.anytypeobjs_[0], "upss")
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0].Request, "common")

    return XP.export(envelope, namespacedef_=namespace_)
Ejemplo n.º 21
0
    def serialize(envelope: Envelope, special_prefixes: dict = {}) -> str:
        namespacedef_ = (
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            'xmlns: xsd="http://www.w3.org/2001/XMLSchema" '
            'xmlns: soap12="http://www.w3.org/2003/05/soap-envelope"')
        envelope.ns_prefix_ = "soap12"
        envelope.Header = Header()
        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        envelope.Header.ns_prefix_ = envelope.ns_prefix_

        prefixes = special_prefixes

        for node in (envelope.Body.anytypeobjs_ +
                     envelope.Header.anytypeobjs_):
            apply_namespaceprefix(node, "", prefixes)

        return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 22
0
    def standard_request_serializer(
            envelope: Envelope, version: str = "v1", extra_namespace: str = "", special_prefixes: dict = None) -> str:

        namespacedef_ = (
            f'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" '
            f'xmlns:{version}="http://ws.aramex.net/ShippingAPI/{version}/" '
            f'{extra_namespace}'
        )
        envelope.ns_prefix_ = "soap"
        envelope.Header = Header()
        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        envelope.Header.ns_prefix_ = envelope.ns_prefix_

        for node in (envelope.Body.anytypeobjs_ + envelope.Header.anytypeobjs_):
            apply_namespaceprefix(node, version, special_prefixes)

        return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 23
0
    def serialize(envelope: Envelope,
                  default_prefix: str = "ws",
                  extra_namespace: str = "",
                  special_prefixes: dict = None) -> str:

        namespacedef_ = (
            'xmlns:soap="http://www.w3.org/2003/05/soap-envelope" '
            ' xmlns:ws="http://ws.onlinerating.canshipws.canpar.com"'
            ' xmlns:xsd="http://ws.dto.canshipws.canpar.com/xsd"'
            f' {extra_namespace}')
        envelope.ns_prefix_ = "soap"
        envelope.Header = Header()
        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        envelope.Header.ns_prefix_ = envelope.ns_prefix_

        prefixes = {**(special_prefixes or {}), 'request_children': 'xsd'}

        for node in (envelope.Body.anytypeobjs_ +
                     envelope.Header.anytypeobjs_):
            apply_namespaceprefix(node, default_prefix, prefixes)

        return XP.export(envelope, namespacedef_=namespacedef_)
Ejemplo n.º 24
0
def _request_serializer(request: mailing_scenario) -> str:
    return XP.export(
        request,
        namespacedef_='xmlns="http://www.canadapost.ca/ws/ship/rate-v4"')
Ejemplo n.º 25
0
def _request_serializer(request: UPSAddressValidationRequest) -> str:

    return XP.export(request, namespacedef_='xml:lang="en-US"')
Ejemplo n.º 26
0
def standard_request_serializer(request) -> str:
    return XP.export(request,
                     namespacedef_='xmlns="http://www.eshipper.net/XMLSchema"')
Ejemplo n.º 27
0
def _request_serializer(request: TrackFieldRequest) -> str:
    return XP.export(request)
Ejemplo n.º 28
0
def standard_request_serializer(element) -> str:
    return XP.export(element, namespacedef_='xmlns="http://www.freightcom.net/XMLSchema"')
Ejemplo n.º 29
0
def _request_serializer(request: ShipmentType) -> str:
    return XP.export(
        request,
        name_="shipment",
        namespacedef_='xmlns="http://www.canadapost.ca/ws/shipment-v8"',
    )
Ejemplo n.º 30
0
def _request_serializer(request: NonContractShipmentType) -> str:
    return XP.export(
        request,
        name_="non-contract-shipment",
        namespacedef_='xmlns="http://www.canadapost.ca/ws/ncshipment-v4"',
    )