diff --git a/modules/connectors/freightcom/generate b/modules/connectors/freightcom/generate index 37e3143e15..2f09af4468 100755 --- a/modules/connectors/freightcom/generate +++ b/modules/connectors/freightcom/generate @@ -1,12 +1,21 @@ -SCHEMAS=./vendor/schemas +SCHEMAS=./schemas LIB_MODULES=./karrio/schemas/freightcom +echo `pwd` find "${LIB_MODULES}" -name "*.py" -exec rm -r {} \; touch "${LIB_MODULES}/__init__.py" -generateDS --no-namespace-defs -o "${LIB_MODULES}/quote_request.py" $SCHEMAS/quote_request.xsd -generateDS --no-namespace-defs -o "${LIB_MODULES}/quote_reply.py" $SCHEMAS/quote_reply.xsd -generateDS --no-namespace-defs -o "${LIB_MODULES}/shipping_request.py" $SCHEMAS/shipping_request.xsd -generateDS --no-namespace-defs -o "${LIB_MODULES}/shipping_reply.py" $SCHEMAS/shipping_reply.xsd -generateDS --no-namespace-defs -o "${LIB_MODULES}/error.py" $SCHEMAS/error.xsd -generateDS --no-namespace-defs -o "${LIB_MODULES}/shipment_cancel_request.py" $SCHEMAS/shipment_cancel_request.xsd -generateDS --no-namespace-defs -o "${LIB_MODULES}/shipment_cancel_reply.py" $SCHEMAS/shipment_cancel_reply.xsd +quicktype() { + echo "Generating $1..." + docker run -it --rm --name quicktype -v $PWD:/app -e SCHEMAS=/app/schemas -e LIB_MODULES=/app/karrio/schemas/freightcom \ + karrio/tools /quicktype/script/quicktype --no-uuids --no-date-times --no-enums --src-lang json --lang jstruct \ + --all-properties-optional --type-as-suffix $@ +} + + +quicktype --src="${SCHEMAS}/rate_request.json" --out="${LIB_MODULES}/rate_request.py" +quicktype --src="${SCHEMAS}/rate_response.json" --out="${LIB_MODULES}/rate_response.py" +quicktype --src="${SCHEMAS}/error_response.json" --out="${LIB_MODULES}/error_response.py" +quicktype --src="${SCHEMAS}/shipping_request.json" --out="${LIB_MODULES}/shipping_request.py" +quicktype --src="${SCHEMAS}/shipping_response.json" --out="${LIB_MODULES}/shipping_response.py" +quicktype --src="${SCHEMAS}/pickup_request.json" --out="${LIB_MODULES}/pickup_request.py" +quicktype --src="${SCHEMAS}/tracking_response.json" --out="${LIB_MODULES}/tracking_response.py" diff --git a/modules/connectors/freightcom/karrio/mappers/freightcom/__init__.py b/modules/connectors/freightcom/karrio/mappers/freightcom/__init__.py index 14b08c02b5..e2193a7312 100644 --- a/modules/connectors/freightcom/karrio/mappers/freightcom/__init__.py +++ b/modules/connectors/freightcom/karrio/mappers/freightcom/__init__.py @@ -17,5 +17,5 @@ # Data Units options=units.ShippingOption, services=units.ShippingService, - hub_carriers=units.CARRIER_IDS, + connection_configs = units.ConnectionConfig, ) diff --git a/modules/connectors/freightcom/karrio/mappers/freightcom/mapper.py b/modules/connectors/freightcom/karrio/mappers/freightcom/mapper.py index 6637368a4f..b583e1ec0f 100644 --- a/modules/connectors/freightcom/karrio/mappers/freightcom/mapper.py +++ b/modules/connectors/freightcom/karrio/mappers/freightcom/mapper.py @@ -2,23 +2,8 @@ from karrio.api.mapper import Mapper as BaseMapper from karrio.mappers.freightcom.settings import Settings from karrio.core.utils.serializable import Deserializable, Serializable -from karrio.core.models import ( - RateRequest, - ShipmentRequest, - ShipmentDetails, - RateDetails, - Message, - ShipmentCancelRequest, - ConfirmationDetails, -) -from karrio.providers.freightcom import ( - parse_quote_reply, - quote_request, - parse_shipping_reply, - shipping_request, - shipment_cancel_request, - parse_shipment_cancel_reply, -) +import karrio.core.models as models +import karrio.providers.freightcom as provider class Mapper(BaseMapper): @@ -26,30 +11,30 @@ class Mapper(BaseMapper): # Request Mappers - def create_rate_request(self, payload: RateRequest) -> Serializable: - return quote_request(payload, self.settings) + def create_rate_request(self, payload: models.RateRequest) -> Serializable: + return provider.rate_request(payload, self.settings) - def create_shipment_request(self, payload: ShipmentRequest) -> Serializable: - return shipping_request(payload, self.settings) + def create_shipment_request(self, payload: models.ShipmentRequest) -> Serializable: + return provider.shipment_request(payload, self.settings) def create_cancel_shipment_request( - self, payload: ShipmentCancelRequest + self, payload: models.ShipmentCancelRequest ) -> Serializable: - return shipment_cancel_request(payload, self.settings) + return provider.shipment_cancel_request(payload, self.settings) # Response Parsers def parse_rate_response( self, response: Deserializable - ) -> Tuple[List[RateDetails], List[Message]]: - return parse_quote_reply(response, self.settings) + ) -> Tuple[List[models.RateDetails], List[models.Message]]: + return provider.parse_rate_response(response, self.settings) def parse_shipment_response( self, response: Deserializable - ) -> Tuple[ShipmentDetails, List[Message]]: - return parse_shipping_reply(response, self.settings) + ) -> Tuple[models.ShipmentDetails, List[models.Message]]: + return provider.parse_shipment_response(response, self.settings) def parse_cancel_shipment_response( self, response: Deserializable - ) -> Tuple[ConfirmationDetails, List[Message]]: - return parse_shipment_cancel_reply(response, self.settings) + ) -> Tuple[models.ConfirmationDetails, List[models.Message]]: + return provider.parse_shipment_cancel_response(response, self.settings) diff --git a/modules/connectors/freightcom/karrio/mappers/freightcom/proxy.py b/modules/connectors/freightcom/karrio/mappers/freightcom/proxy.py index 98d619d83e..3d680f8b40 100644 --- a/modules/connectors/freightcom/karrio/mappers/freightcom/proxy.py +++ b/modules/connectors/freightcom/karrio/mappers/freightcom/proxy.py @@ -1,38 +1,106 @@ -from karrio.core.utils import request as http, XP -from karrio.api.proxy import Proxy as BaseProxy +"""Karrio Freightcom client proxy.""" + +import time +import karrio.lib as lib +import karrio.api.proxy as proxy from karrio.mappers.freightcom.settings import Settings -from karrio.core.utils.serializable import Serializable, Deserializable +MAX_RETRIES = 10 +POLL_INTERVAL = 2 # seconds -class Proxy(BaseProxy): +class Proxy(proxy.Proxy): settings: Settings - def get_rates(self, request: Serializable) -> Deserializable: - response = http( - url=self.settings.server_url, - data=request.serialize(), - trace=self.trace_as("xml"), - method="POST", - headers={"Content-Type": "application/xml"}, + def get_rates(self, request: lib.Serializable) -> lib.Deserializable: + # Step 1: Submit rate request and get quote ID + response = self._send_request( + path="/rate", request=lib.Serializable(request.value, lib.to_json) + ) + + rate_id = lib.to_dict(response).get('request_id') + if not rate_id: + return lib.Deserializable(response, lib.to_dict) + + # Step 2: Poll for rate results + for _ in range(MAX_RETRIES): + status_res = self._send_request( + path=f"/rate/{rate_id}", + method="GET" + ) + + status = lib.to_dict(status_res).get('status', {}).get('done', False) + + if status: # Quote is complete + return lib.Deserializable(status_res, lib.to_dict) + + time.sleep(POLL_INTERVAL) + + # If we exceed max retries + return lib.Deserializable({ + 'message': 'Rate calculation timed out' + }, lib.to_dict) + + def create_shipment(self, request: lib.Serializable) -> lib.Deserializable: + + response = self._send_request( + path="/shipment", request=lib.Serializable(request.value, lib.to_json) + ) + + shipment_id = lib.to_dict(response).get('id') + if not shipment_id: + return lib.Deserializable(response, lib.to_dict) + + + # Step 2: retry because api return empty bytes if done to fast + time.sleep(1) + for _ in range(MAX_RETRIES): + + shipment_response = self._send_request(path=f"/shipment/{shipment_id}", method="GET") + shipment_res = lib.failsafe(lambda :lib.to_dict(shipment_response)) or lib.decode(shipment_response) + + if shipment_res: # is complete + return lib.Deserializable(shipment_res, lib.to_dict, request.ctx) + + time.sleep(POLL_INTERVAL) + + # If we exceed max retries + return lib.Deserializable({ + 'message': 'timed out' + }, lib.to_dict) + + + def get_tracking(self, request: lib.Serializable) -> lib.Deserializable[str]: + response = self._send_request(path=f"/shipment/{request.serialize()}/tracking-events") + + return lib.Deserializable(response, lib.to_dict) + + def _get_payments_methods(self) -> lib.Deserializable[str]: + response = self._send_request( + path="/finance/payment-methods", + method="GET" ) - return Deserializable(response, XP.to_xml) - - def create_shipment(self, request: Serializable) -> Deserializable: - response = http( - url=self.settings.server_url, - data=request.serialize(), - trace=self.trace_as("xml"), - method="POST", - headers={"Content-Type": "application/xml"}, + return lib.Deserializable(response, lib.to_dict) + + def cancel_shipment(self, request: lib.Serializable) -> lib.Deserializable: + response = self._send_request( + path=f"/shipment/{request.serialize()}", method="DELETE" ) - return Deserializable(response, XP.to_xml) - - def cancel_shipment(self, request: Serializable) -> Deserializable: - response = http( - url=self.settings.server_url, - data=request.serialize(), - trace=self.trace_as("xml"), - method="POST", - headers={"Content-Type": "application/xml"}, + return lib.Deserializable(response if any(response) else "{}", lib.to_dict) + + def _send_request( + self, path: str, request: lib.Serializable = None, method: str = "POST" + ) -> str: + + data: dict = dict(data=request.serialize()) if request is not None else dict() + return lib.request( + **{ + "url": f"{self.settings.server_url}{path}", + "trace": self.trace_as("json"), + "method": method, + "headers": { + "Content-Type": "application/json", + "Authorization": self.settings.api_key, + }, + **data, + } ) - return Deserializable(response, XP.to_xml) diff --git a/modules/connectors/freightcom/karrio/mappers/freightcom/settings.py b/modules/connectors/freightcom/karrio/mappers/freightcom/settings.py index 42e611cbbd..85509f5dc7 100644 --- a/modules/connectors/freightcom/karrio/mappers/freightcom/settings.py +++ b/modules/connectors/freightcom/karrio/mappers/freightcom/settings.py @@ -1,16 +1,16 @@ """Karrio freightcom connection settings.""" import attr -from karrio.providers.freightcom.utils import Settings as BaseSettings +import karrio.providers.freightcom.utils as provider_utils @attr.s(auto_attribs=True) -class Settings(BaseSettings): +class Settings(provider_utils.Settings): """Freightcom connection settings.""" + #carrier specific API connection properties here + api_key: str - username: str - password: str - + # generic properties id: str = None test_mode: bool = False carrier_id: str = "freightcom" diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/__init__.py b/modules/connectors/freightcom/karrio/providers/freightcom/__init__.py index a9b021054c..1f6e3f4dbe 100644 --- a/modules/connectors/freightcom/karrio/providers/freightcom/__init__.py +++ b/modules/connectors/freightcom/karrio/providers/freightcom/__init__.py @@ -1,6 +1,13 @@ -from karrio.providers.freightcom.quote import parse_quote_reply, quote_request -from karrio.providers.freightcom.shipping import ( - parse_shipping_reply, - shipping_request, + +from karrio.providers.freightcom.rate import parse_rate_response, rate_request +from karrio.providers.freightcom.shipment import ( + parse_shipment_response, + shipment_request, + parse_shipment_cancel_response, + shipment_cancel_request, ) -from karrio.providers.freightcom.void_shipment import shipment_cancel_request, parse_shipment_cancel_reply + +# from karrio.providers.eshipper.tracking import ( +# parse_tracking_response, +# tracking_request, +# ) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/error.py b/modules/connectors/freightcom/karrio/providers/freightcom/error.py index 923739e78d..acc0222409 100644 --- a/modules/connectors/freightcom/karrio/providers/freightcom/error.py +++ b/modules/connectors/freightcom/karrio/providers/freightcom/error.py @@ -1,40 +1,29 @@ -from typing import List -from karrio.schemas.freightcom.error import ErrorType -from karrio.schemas.freightcom.quote_reply import CarrierErrorMessageType -from karrio.core.models import Message -from karrio.core.utils import Element, XP -from karrio.providers.freightcom.utils import Settings +import typing +import karrio.core.models as models +import karrio.providers.freightcom.utils as provider_utils +def parse_error_response( + response: dict, + settings: provider_utils.Settings, + **kwargs, +) -> typing.List[models.Message]: + responses = response if isinstance(response, list) else [response] -def parse_error_response(response: Element, settings: Settings) -> List[Message]: - errors = XP.find("Error", response, ErrorType) - carrier_errors = XP.find("CarrierErrorMessage", response, CarrierErrorMessageType) + errors = [ + *[_ for _ in responses if _.get("message")], + ] return [ - *[_extract_error(er, settings) for er in errors if er.Message != ""], - *[ - _extract_carrier_error(er, settings) - for er in carrier_errors - if er.errorMessage0 != "" - ], + models.Message( + carrier_id=settings.carrier_id, + carrier_name=settings.carrier_name, + message=error.get("message"), + details={ + **kwargs, + **(error.get('data', {})) + }, + ) + for error in errors ] -def _extract_carrier_error( - error: CarrierErrorMessageType, settings: Settings -) -> Message: - return Message( - code="CarrierErrorMessage", - carrier_name=settings.carrier_name, - carrier_id=settings.carrier_id, - message=error.errorMessage0, - ) - - -def _extract_error(error: ErrorType, settings: Settings) -> Message: - return Message( - code="Error", - carrier_name=settings.carrier_name, - carrier_id=settings.carrier_id, - message=error.Message, - ) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/metadata.json b/modules/connectors/freightcom/karrio/providers/freightcom/metadata.json new file mode 100644 index 0000000000..1fe4acbeee --- /dev/null +++ b/modules/connectors/freightcom/karrio/providers/freightcom/metadata.json @@ -0,0 +1,4671 @@ +{ + "PROD_SERVICES": [ + { + "id": "dhatttransfreightserviceinc-558.standard", + "carrier_name": "DHATT TRANSFREIGHT SERVICE INC.", + "service_name": "Standard" + }, + { + "id": "kelownaexpressfreightinc-570.standard", + "carrier_name": "Kelowna Express Freight Inc.", + "service_name": "Standard" + }, + { + "id": "metrofreightwaysltd-610.standard", + "carrier_name": "METRO FREIGHTWAYS LTD.", + "service_name": "Standard" + }, + { + "id": "scottfreight-190.standard", + "carrier_name": "Scott Freight", + "service_name": "Standard" + }, + { + "id": "tforcefreight-575.standard", + "carrier_name": "TForce Freight", + "service_name": "Standard" + }, + { + "id": "vkdeliverylinehaulltd-499.standard", + "carrier_name": "VK DELIVERY/LINEHAUL LTD", + "service_name": "Standard" + }, + { + "id": "customcourierco-469.standard", + "carrier_name": "Custom Courier Co.", + "service_name": "Standard" + }, + { + "id": "ecotransinc-396.standard", + "carrier_name": "ECOTRANS INC", + "service_name": "Standard" + }, + { + "id": "fedex.economy", + "carrier_name": "FedEx Freight", + "service_name": "Economy" + }, + { + "id": "fedex.standard", + "carrier_name": "FedEx Freight", + "service_name": "Priority" + }, + { + "id": "gtagsm-540.standard", + "carrier_name": "G.T.A GSM", + "service_name": "Standard" + }, + { + "id": "kindersleytransportusa-551.standard", + "carrier_name": "Kindersley Transport | USA", + "service_name": "Standard" + }, + { + "id": "lodestarlogistics-446.standard", + "carrier_name": "LODESTAR LOGISTICS", + "service_name": "Standard" + }, + { + "id": "loomis-express.express-0900", + "carrier_name": "Loomis", + "service_name": "Express 9:00" + }, + { + "id": "loomis-express.express-1200", + "carrier_name": "Loomis", + "service_name": "Express 12:00" + }, + { + "id": "loomis-express.express-1800", + "carrier_name": "Loomis", + "service_name": "Express 18:00" + }, + { + "id": "loomis-express.ground", + "carrier_name": "Loomis", + "service_name": "Ground" + }, + { + "id": "mrflatbedstransportinc-284.standard", + "carrier_name": "Mr Flatbeds Transport Inc", + "service_name": "Standard" + }, + { + "id": "bisontransport-278.standard", + "carrier_name": "Bison Transport", + "service_name": "Standard" + }, + { + "id": "canpar.ground", + "carrier_name": "Canpar", + "service_name": "Ground" + }, + { + "id": "canpar.international", + "carrier_name": "Canpar", + "service_name": "International" + }, + { + "id": "canpar.overnight", + "carrier_name": "Canpar", + "service_name": "Overnight" + }, + { + "id": "canpar.overnight-letter", + "carrier_name": "Canpar", + "service_name": "Overnight Letter" + }, + { + "id": "canpar.overnight-pak", + "carrier_name": "Canpar", + "service_name": "Overnight Pak" + }, + { + "id": "canpar.select", + "carrier_name": "Canpar", + "service_name": "Select" + }, + { + "id": "canpar.select-letter", + "carrier_name": "Canpar", + "service_name": "Select Letter" + }, + { + "id": "canpar.select-pak", + "carrier_name": "Canpar", + "service_name": "Select Pak" + }, + { + "id": "canpar.select-usa", + "carrier_name": "Canpar", + "service_name": "Select U.S.A." + }, + { + "id": "canpar.usa", + "carrier_name": "Canpar", + "service_name": "U.S.A." + }, + { + "id": "canpar.usa-Letter", + "carrier_name": "Canpar", + "service_name": "U.S.A. Letter" + }, + { + "id": "canpar.usa-pak", + "carrier_name": "Canpar", + "service_name": "U.S.A. Pak" + }, + { + "id": "csa.standard", + "carrier_name": "CSA", + "service_name": "Standard" + }, + { + "id": "ettransportgroup-337.standard", + "carrier_name": "ET Transport Group", + "service_name": "Standard" + }, + { + "id": "guardiumlogisticsltd-608.standard", + "carrier_name": "Guardium Logistics Ltd.", + "service_name": "Standard" + }, + { + "id": "keltictransportation-465.standard", + "carrier_name": "Keltic Transportation", + "service_name": "Standard" + }, + { + "id": "kjlxpressinc-583.standard", + "carrier_name": "KJL Xpress Inc.", + "service_name": "Standard" + }, + { + "id": "newpennmotorexpress-445.standard", + "carrier_name": "New Penn Motor Express", + "service_name": "Standard" + }, + { + "id": "bridgepointlogisticsltd-524.standard", + "carrier_name": "BRIDGEPOINT LOGISTICS LTD", + "service_name": "Standard" + }, + { + "id": "canadapost.domestic", + "carrier_name": "Canada Post", + "service_name": "Domestic" + }, + { + "id": "canadapost.expedited-parcel", + "carrier_name": "Canada Post", + "service_name": "Expedited Parcel" + }, + { + "id": "canadapost.expedited-parcel-usa", + "carrier_name": "Canada Post", + "service_name": "Expedited Parcel USA" + }, + { + "id": "canadapost.international", + "carrier_name": "Canada Post", + "service_name": "International" + }, + { + "id": "canadapost.international-parcel-air", + "carrier_name": "Canada Post", + "service_name": "International Parcel Air" + }, + { + "id": "canadapost.international-parcel-surface", + "carrier_name": "Canada Post", + "service_name": "International Parcel Surface" + }, + { + "id": "canadapost.priority", + "carrier_name": "Canada Post", + "service_name": "Priority" + }, + { + "id": "canadapost.priority-ww-envelope-international", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide envelope INT’L" + }, + { + "id": "canadapost.priority-ww-envelope-usa", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide envelope USA" + }, + { + "id": "canadapost.priority-ww-pak-international", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide pak INT’L" + }, + { + "id": "canadapost.priority-ww-pak-usa", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide pak USA" + }, + { + "id": "canadapost.priority-ww-parcel-international", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide parcel INT’L" + }, + { + "id": "canadapost.priority-ww-parcel-usa", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide parcel USA" + }, + { + "id": "canadapost.regular-parcel", + "carrier_name": "Canada Post", + "service_name": "Regular Parcel" + }, + { + "id": "canadapost.small-packet-international-air", + "carrier_name": "Canada Post", + "service_name": "Small Packet International Air" + }, + { + "id": "canadapost.small-packet-international-surface", + "carrier_name": "Canada Post", + "service_name": "Small Packet International Surface" + }, + { + "id": "canadapost.small-packet-usa-air", + "carrier_name": "Canada Post", + "service_name": "Small Packet USA Air" + }, + { + "id": "canadapost.tracked-packet-international", + "carrier_name": "Canada Post", + "service_name": "Tracked Packet - International" + }, + { + "id": "canadapost.tracked-packet-usa", + "carrier_name": "Canada Post", + "service_name": "Tracked Packet USA" + }, + { + "id": "canadapost.xpresspost", + "carrier_name": "Canada Post", + "service_name": "Xpresspost" + }, + { + "id": "canadapost.xpresspost-international", + "carrier_name": "Canada Post", + "service_name": "Xpresspost International" + }, + { + "id": "canadapost.xpresspost-usa", + "carrier_name": "Canada Post", + "service_name": "Xpresspost USA" + }, + { + "id": "gardewine.standard", + "carrier_name": "Gardewine", + "service_name": "Standard" + }, + { + "id": "giantleaftruckinginc-556.standard", + "carrier_name": "GIANT LEAF TRUCKING INC.", + "service_name": "Standard" + }, + { + "id": "purolatorfreight.standard", + "carrier_name": "Purolator Freight", + "service_name": "Standard" + }, + { + "id": "swyft.nextday", + "carrier_name": "Swyft", + "service_name": "Next Day" + }, + { + "id": "swyft.sameday", + "carrier_name": "Swyft", + "service_name": "Same Day" + }, + { + "id": "usps.ground-advantage", + "carrier_name": "USPS", + "service_name": "Ground Advantage" + }, + { + "id": "usps.priority-mail", + "carrier_name": "USPS", + "service_name": "Priority Mail" + }, + { + "id": "usps.priority-mail-express", + "carrier_name": "USPS", + "service_name": "Priority Mail Express" + }, + { + "id": "xwestcarriersinc-547.standard", + "carrier_name": "X West Carriers Inc", + "service_name": "Standard" + }, + { + "id": "paulsfreightline-400.standard", + "carrier_name": "PAULS FREIGHTLINE", + "service_name": "Standard" + }, + { + "id": "ppgroadlinesinc-250.standard", + "carrier_name": "PPG ROADLINES INC.", + "service_name": "Standard" + }, + { + "id": "transportgilleslavigne-592.standard", + "carrier_name": "Transport Gilles Lavigne", + "service_name": "Standard" + }, + { + "id": "xpologistics-265.standard", + "carrier_name": "XPO Logistics", + "service_name": "Standard" + }, + { + "id": "upscourier-162.standard", + "carrier_name": "UPS Courier", + "service_name": "Standard" + }, + { + "id": "94222528qubecincdbagroupefmj-626.standard", + "carrier_name": "9422-2528 Québec Inc. DBA Groupe FMJ", + "service_name": "Standard" + }, + { + "id": "one.standard", + "carrier_name": "ONE Transportation", + "service_name": "Standard" + }, + { + "id": "readygotransportinc-435.standard", + "carrier_name": "READY GO TRANSPORT INC.", + "service_name": "Standard" + }, + { + "id": "streetkingtransportationltd-557.standard", + "carrier_name": "STREET KING TRANSPORTATION LTD", + "service_name": "Standard" + }, + { + "id": "martinroytransport-310.standard", + "carrier_name": "Martin Roy Transport", + "service_name": "Standard" + }, + { + "id": "sameday.2-man-delivery-to-entrance", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Entrance - 2 Person" + }, + { + "id": "sameday.2-man-delivery-to-room-of-choice", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Room of Choice - 2 Person" + }, + { + "id": "sameday.2-man-delivery-to-room-of-choice-with-debris-removal", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Two-person delivery to room of choice with debris removal" + }, + { + "id": "sameday.dayr-ecom-urgent-pac", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "eCommerce Urgent Pak" + }, + { + "id": "sameday.delivery-to-entrance", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Entrance" + }, + { + "id": "sameday.delivery-to-room-of-choice", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Room of Choice" + }, + { + "id": "sameday.delivery-to-room-of-choice-with-debris-removal", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Room of Choice with Debris Removal" + }, + { + "id": "sameday.ground-daynross-road", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Ground - Road" + }, + { + "id": "sameday.next-day-before-5pm", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Next Day Delivery by 5 PM" + }, + { + "id": "sameday.next-day-before-9am", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Next Day Delivery by 9 AM" + }, + { + "id": "sameday.next-day-delivery-before-noon", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Next Day Delivery Before Noon" + }, + { + "id": "searcytrucking-462.standard", + "carrier_name": "Searcy Trucking", + "service_name": "Standard" + }, + { + "id": "transkidinc-453.standard", + "carrier_name": "Transkid Inc", + "service_name": "Standard" + }, + { + "id": "amatransinc-251.standard", + "carrier_name": "AMA Trans Inc", + "service_name": "Standard" + }, + { + "id": "checkercourier-276.standard", + "carrier_name": "Checker Courier", + "service_name": "Standard" + }, + { + "id": "empiretransportltd-413.standard", + "carrier_name": "EMPIRE TRANSPORT LTD", + "service_name": "Standard" + }, + { + "id": "flashtransport-388.standard", + "carrier_name": "Flash Transport", + "service_name": "Standard" + }, + { + "id": "wce.standard", + "carrier_name": "WCE", + "service_name": "Intermodal" + }, + { + "id": "xpoglobalforwardinginc-416.standard", + "carrier_name": "XPO GLOBAL FORWARDING INC", + "service_name": "Standard" + }, + { + "id": "kjstransport-623.standard", + "carrier_name": "KJS Transport", + "service_name": "Standard" + }, + { + "id": "ltlexpressfreight-459.standard", + "carrier_name": "LTL EXPRESS FREIGHT", + "service_name": "Standard" + }, + { + "id": "overland.standard", + "carrier_name": "Overland", + "service_name": "Standard" + }, + { + "id": "dbgtrucking-132.standard", + "carrier_name": "DBG TRUCKING ", + "service_name": "Standard" + }, + { + "id": "dhillondhillontransportltd-528.standard", + "carrier_name": "Dhillon & Dhillon Transport Ltd.", + "service_name": "Standard" + }, + { + "id": "freightboy-565.standard", + "carrier_name": "FREIGHT BOY", + "service_name": "Standard" + }, + { + "id": "highrisetransport-545.standard", + "carrier_name": "HIGH RISE TRANSPORT", + "service_name": "Standard" + }, + { + "id": "yrcfreight-330.standard", + "carrier_name": "YRC Freight", + "service_name": "Standard" + }, + { + "id": "caledoncouriers-294.standard", + "carrier_name": "Caledon Couriers", + "service_name": "Standard" + }, + { + "id": "proactivetransportcoproactivesupplycahinsolutionsinc-471.standard", + "carrier_name": "PROACTIVE TRANSPORT C/O PROACTIVE SUPPLYCAHIN SOLUTIONS INC.", + "service_name": "Standard" + }, + { + "id": "roadtrainexpress-433.standard", + "carrier_name": "ROAD TRAIN EXPRESS ", + "service_name": "Standard" + }, + { + "id": "sablemarcoinc-509.standard", + "carrier_name": "Sable Marco inc.", + "service_name": "Standard" + }, + { + "id": "here2therefreightmanagementinc-629.standard", + "carrier_name": "Here 2 There Freight Management Inc", + "service_name": "Standard" + }, + { + "id": "thompsonemergencyfreightsystems-277.standard", + "carrier_name": "Thompson Emergency Freight Systems", + "service_name": "Standard" + }, + { + "id": "dhl-ecomm.packet-international", + "carrier_name": "DHL eCommerce", + "service_name": "Package International" + }, + { + "id": "dhl-ecomm.parcel-expedited", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel Expedited" + }, + { + "id": "dhl-ecomm.parcel-expedited-max", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel Expedited Max" + }, + { + "id": "dhl-ecomm.parcel-ground", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel Ground" + }, + { + "id": "dhl-ecomm.parcel-international-direct", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel International Direct" + }, + { + "id": "dhl-ecomm.parcel-international-direct-priority", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel International Direct Priority" + }, + { + "id": "dhl-ecomm.parcel-international-direct-standard", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel International Direct Standard" + }, + { + "id": "dhl-ecomm.parcel-international-standard", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel International Standard" + }, + { + "id": "excel-transport.standard", + "carrier_name": "Excel Transportation", + "service_name": "Standard" + }, + { + "id": "newpenn.standard", + "carrier_name": "New Penn", + "service_name": "Standard" + }, + { + "id": "bettertrucks.ddu", + "carrier_name": "Better Trucks", + "service_name": "DDU" + }, + { + "id": "bettertrucks.express", + "carrier_name": "Better Trucks", + "service_name": "Express" + }, + { + "id": "bettertrucks.next_day", + "carrier_name": "Better Trucks", + "service_name": "Next Day" + }, + { + "id": "bettertrucks.same_day", + "carrier_name": "Better Trucks", + "service_name": "Same Day" + }, + { + "id": "boxknight.next-day", + "carrier_name": "BoxKnight", + "service_name": "Next Day" + }, + { + "id": "boxknight.sameday", + "carrier_name": "BoxKnight", + "service_name": "Same Day" + }, + { + "id": "cranestransport-555.standard", + "carrier_name": "CRANES TRANSPORT", + "service_name": "Standard" + }, + { + "id": "daynross.cs", + "carrier_name": "Day & Ross", + "service_name": "CS" + }, + { + "id": "daynross.domestic-standard", + "carrier_name": "Day & Ross", + "service_name": "Domestic Standard" + }, + { + "id": "daynross.transborder-standard", + "carrier_name": "Day & Ross", + "service_name": "Transborder Standard" + }, + { + "id": "loadsafecrossborderfreightinc-493.standard", + "carrier_name": "LOADSAFE CROSSBORDER FREIGHT INC.", + "service_name": "Standard" + }, + { + "id": "maritimeontario-267.standard", + "carrier_name": "Maritime-Ontario", + "service_name": "Standard" + }, + { + "id": "saiamotorfreightinc-139.standard", + "carrier_name": "Saia Motor Freight Inc", + "service_name": "Standard" + }, + { + "id": "speedytransport-153.standard", + "carrier_name": "Speedy Transport", + "service_name": "Standard" + }, + { + "id": "bakshbroscartageinc-485.standard", + "carrier_name": "BAKSH BROS. CARTAGE INC", + "service_name": "Standard" + }, + { + "id": "estesexpresslines-274.standard", + "carrier_name": "ESTES Express Lines", + "service_name": "Standard" + }, + { + "id": "highenergytransportinc-533.standard", + "carrier_name": "High Energy Transport Inc", + "service_name": "Standard" + }, + { + "id": "kriskaytrucklinesinc-443.standard", + "carrier_name": "Kris Kay Truck Lines Inc", + "service_name": "Standard" + }, + { + "id": "rollsright-245.standard", + "carrier_name": "Rolls Right", + "service_name": "Standard" + }, + { + "id": "sunshinecoastlogisticsinc-614.standard", + "carrier_name": "Sunshine Coast Logistics Inc", + "service_name": "Standard" + }, + { + "id": "uppaltransportltddbabluewatertrucking-615.standard", + "carrier_name": "Uppal Transport Ltd dba Bluewater Trucking", + "service_name": "Standard" + }, + { + "id": "dayrossfreightrl-529.standard", + "carrier_name": "Day & Ross Freight | R+L", + "service_name": "Standard" + }, + { + "id": "fgmtrucklines-235.standard", + "carrier_name": "FGM Trucklines", + "service_name": "Standard" + }, + { + "id": "kdrtrucklinesinc-627.standard", + "carrier_name": "KDR Trucklines Inc", + "service_name": "Standard" + }, + { + "id": "psrlogisticsinc-506.standard", + "carrier_name": "PSR LOGISTICS INC.", + "service_name": "Standard" + }, + { + "id": "northplusgroupofcompanies-568.standard", + "carrier_name": "NORTH PLUS GROUP OF COMPANIES", + "service_name": "Standard" + }, + { + "id": "swiftdeliverysystems-268.standard", + "carrier_name": "Swift Delivery Systems", + "service_name": "Standard" + }, + { + "id": "vitran.maxx", + "carrier_name": "Vitran", + "service_name": "Maxx" + }, + { + "id": "vitran.priority", + "carrier_name": "Vitran", + "service_name": "Priority" + }, + { + "id": "vitran.regular", + "carrier_name": "Vitran", + "service_name": "Regular" + }, + { + "id": "fastnflowlogistics-487.standard", + "carrier_name": "FAST N FLOW LOGISTICS", + "service_name": "Standard" + }, + { + "id": "fpifreightpartnersinternationalinc-458.standard", + "carrier_name": "FPI - FREIGHT PARTNERS INTERNATIONAL INC.", + "service_name": "Standard" + }, + { + "id": "gsm.air-skip", + "carrier_name": "GTA GSM", + "service_name": "AirSkip" + }, + { + "id": "gsm.air-skip-plus", + "carrier_name": "GTA GSM", + "service_name": "AirSkip+" + }, + { + "id": "gsm.armed-secure-air", + "carrier_name": "GTA GSM", + "service_name": "Armed Secure Air" + }, + { + "id": "gsm.armed-secure-ground", + "carrier_name": "GTA GSM", + "service_name": "Armed Secure Ground" + }, + { + "id": "gsm.ground", + "carrier_name": "GTA GSM", + "service_name": "Ground" + }, + { + "id": "gsm.secure-air", + "carrier_name": "GTA GSM", + "service_name": "Secure Air" + }, + { + "id": "gsm.secure-ground", + "carrier_name": "GTA GSM", + "service_name": "Secure Ground" + }, + { + "id": "gsm.zone-skip", + "carrier_name": "GTA GSM", + "service_name": "ZoneSkip" + }, + { + "id": "gsm.zone-skip-plus", + "carrier_name": "GTA GSM", + "service_name": "ZoneSkip+" + }, + { + "id": "mcarthurexpress-503.standard", + "carrier_name": "Mcarthur Express", + "service_name": "Standard" + }, + { + "id": "himmatpuralogisticsinc-473.standard", + "carrier_name": "HIMMATPURA LOGISTICS INC", + "service_name": "Standard" + }, + { + "id": "proformanceintermodalinc-489.standard", + "carrier_name": "Pro-Formance Intermodal Inc.", + "service_name": "Standard" + }, + { + "id": "whistlercourier-621.standard", + "carrier_name": "Whistler Courier", + "service_name": "Standard" + }, + { + "id": "armourtransportationsystems-562.standard", + "carrier_name": "Armour Transportation Systems", + "service_name": "Standard" + }, + { + "id": "fastfrategroup-498.standard", + "carrier_name": "Fastfrate Group", + "service_name": "Standard" + }, + { + "id": "glotransports-530.standard", + "carrier_name": "GLO TRANSPORTS", + "service_name": "Standard" + }, + { + "id": "gsdirect-292.standard", + "carrier_name": "G&S Direct", + "service_name": "Standard" + }, + { + "id": "gls.ground", + "carrier_name": "GLS", + "service_name": "Ground" + }, + { + "id": "lighthousetransportationinc-619.standard", + "carrier_name": "LIGHTHOUSE TRANSPORTATION INC.", + "service_name": "Standard" + }, + { + "id": "pbtransport-507.standard", + "carrier_name": "P&B TRANSPORT", + "service_name": "Standard" + }, + { + "id": "servicestarfreightways-441.standard", + "carrier_name": "ServiceStar Freightways", + "service_name": "Standard" + }, + { + "id": "tforcefreight.tforcefreight-guarnteed", + "carrier_name": "TForceFreight", + "service_name": "TForceFreight Guaranteed" + }, + { + "id": "tforcefreight.tforcefreight-ltl", + "carrier_name": "TForceFreight", + "service_name": "TForceFreight LTL" + }, + { + "id": "tforcefreight.tforcefreight-standard", + "carrier_name": "TForceFreight", + "service_name": "TForceFreight Standard" + }, + { + "id": "zipcourier-468.standard", + "carrier_name": "Zip Courier", + "service_name": "Standard" + }, + { + "id": "cmwexpress-537.standard", + "carrier_name": "CMW Express", + "service_name": "Standard" + }, + { + "id": "ktslogisticsinc-620.standard", + "carrier_name": "KTS LOGISTICS INC", + "service_name": "Standard" + }, + { + "id": "raymanmotorfreight-357.standard", + "carrier_name": "Rayman Motor Freight", + "service_name": "Standard" + }, + { + "id": "safeloadtransportltd-510.standard", + "carrier_name": "SAFE LOAD TRANSPORT LTD. ", + "service_name": "Standard" + }, + { + "id": "milyardgroupinc-391.standard", + "carrier_name": "Milyard Group Inc.", + "service_name": "Standard" + }, + { + "id": "minimax.standard", + "carrier_name": "Minimax", + "service_name": "Standard" + }, + { + "id": "suretrackgroup-369.standard", + "carrier_name": "SureTrack Group", + "service_name": "Standard" + }, + { + "id": "ctmatransport-535.standard", + "carrier_name": "CTMA Transport", + "service_name": "Standard" + }, + { + "id": "kawarthacourier-425.standard", + "carrier_name": "Kawartha Courier", + "service_name": "Standard" + }, + { + "id": "kepatransportinc-516.standard", + "carrier_name": "KEPA Transport Inc", + "service_name": "Standard" + }, + { + "id": "kindersley-freight.domestic-expedited", + "carrier_name": "Kindersley Transport", + "service_name": "Domestic Expedited" + }, + { + "id": "kindersley-freight.domestic-rail", + "carrier_name": "Kindersley Transport", + "service_name": "Domestic Rail" + }, + { + "id": "kindersley-freight.domestic-road", + "carrier_name": "Kindersley Transport", + "service_name": "Domestic Road" + }, + { + "id": "kindersley-freight.transborder", + "carrier_name": "Kindersley Transport", + "service_name": "Transborder" + }, + { + "id": "boeingtruckinginc-593.standard", + "carrier_name": "Boeing Trucking Inc. ", + "service_name": "Standard" + }, + { + "id": "freightcom-134.standard", + "carrier_name": "Freightcom", + "service_name": "Standard" + }, + { + "id": "groupemorneau-599.standard", + "carrier_name": "Groupe Morneau", + "service_name": "Standard" + }, + { + "id": "xpofreightbrokerage-280.standard", + "carrier_name": "XPO Freight Brokerage", + "service_name": "Standard" + }, + { + "id": "aalfatransportationcorporation-596.standard", + "carrier_name": "A ALFA TRANSPORTATION CORPORATION", + "service_name": "Standard" + }, + { + "id": "barriedirecttransportation-428.standard", + "carrier_name": "Barrie Direct Transportation ", + "service_name": "Standard" + }, + { + "id": "fastfrate.express", + "carrier_name": "Fastfrate", + "service_name": "Express" + }, + { + "id": "fastfrate.standard", + "carrier_name": "Fastfrate", + "service_name": "Standard" + }, + { + "id": "flatouttransportation-566.standard", + "carrier_name": "Flat Out Transportation", + "service_name": "Standard" + }, + { + "id": "reddaway.guaranteed-3pm", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 3:30 PM" + }, + { + "id": "reddaway.guaranteed-9am", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 9 AM" + }, + { + "id": "reddaway.guaranteed-noon", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 12:00 PM (noon)" + }, + { + "id": "reddaway.guaranteed-weekend", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Weekend" + }, + { + "id": "reddaway.guarenteed-9am", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 9 AM" + }, + { + "id": "reddaway.guarenteed-noon", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 12:00 PM (noon)" + }, + { + "id": "reddaway.interline", + "carrier_name": "Reddaway", + "service_name": "Interline Delivery" + }, + { + "id": "reddaway.multi-hour-window", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Window - Multi-Hour Window" + }, + { + "id": "reddaway.regional-delivery", + "carrier_name": "Reddaway", + "service_name": "Regional Delivery" + }, + { + "id": "reddaway.single-hour-window", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Window - Single-hour Window" + }, + { + "id": "reddaway.single-or-multi-day", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Window - Single or Multi-day Window" + }, + { + "id": "reddaway.standard", + "carrier_name": "Reddaway", + "service_name": "Standard" + }, + { + "id": "urbanvalleytransport-526.standard", + "carrier_name": "Urban Valley Transport ", + "service_name": "Standard" + }, + { + "id": "xrpexpress-618.standard", + "carrier_name": "XRP Express", + "service_name": "Standard" + }, + { + "id": "actionforcetransportltd-363.standard", + "carrier_name": "Action Force Transport Ltd", + "service_name": "Standard" + }, + { + "id": "airpro-255.standard", + "carrier_name": "Air Pro", + "service_name": "Standard" + }, + { + "id": "asslafreightinc-588.standard", + "carrier_name": "ASSLA FREIGHT INC.", + "service_name": "Standard" + }, + { + "id": "dhlexpress.domestic-express", + "carrier_name": "DHL Express", + "service_name": "Domestic Express" + }, + { + "id": "dhlexpress.domestic-express1030am", + "carrier_name": "DHL Express", + "service_name": "Domestic Express 10:30" + }, + { + "id": "dhlexpress.domestic-express9am", + "carrier_name": "DHL Express", + "service_name": "Domestic Express 9:00" + }, + { + "id": "dhlexpress.economy-select", + "carrier_name": "DHL Express", + "service_name": "Economy Select" + }, + { + "id": "dhlexpress.express-easy", + "carrier_name": "DHL Express", + "service_name": "Express Easy" + }, + { + "id": "dhlexpress.express-worldwide", + "carrier_name": "DHL Express", + "service_name": "Express Worldwide" + }, + { + "id": "dhlexpress.express1030am", + "carrier_name": "DHL Express", + "service_name": "Express 10:30" + }, + { + "id": "dhlexpress.express12pm", + "carrier_name": "DHL Express", + "service_name": "Express 12:00" + }, + { + "id": "dhlexpress.express9am", + "carrier_name": "DHL Express", + "service_name": "Express 9:00" + }, + { + "id": "intelcom.standard", + "carrier_name": "Intelcom", + "service_name": "Standard" + }, + { + "id": "jardinetransport-217.standard", + "carrier_name": "JARDINE TRANSPORT", + "service_name": "Standard" + }, + { + "id": "sutcocontractingltddbasutcotransportationspecialist-552.standard", + "carrier_name": "SUTCO CONTRACTING LTD./DBA SUTCO TRANSPORTATION SPECIALIST", + "service_name": "Standard" + }, + { + "id": "whistler99courier-621.standard", + "carrier_name": "Whistler 99 Courier", + "service_name": "Standard" + }, + { + "id": "apps.intermodal", + "carrier_name": "APPS", + "service_name": "Intermodal" + }, + { + "id": "apps.standard", + "carrier_name": "APPS", + "service_name": "Standard" + }, + { + "id": "dbgtrucking-527.standard", + "carrier_name": "DBG TRUCKING ", + "service_name": "Standard" + }, + { + "id": "deliverytechinc-442.standard", + "carrier_name": "Delivery Tech Inc", + "service_name": "Standard" + }, + { + "id": "hiway.standard", + "carrier_name": "Hi-Way9", + "service_name": "Standard" + }, + { + "id": "speedxtransport-319.standard", + "carrier_name": "SpeedX Transport", + "service_name": "Standard" + }, + { + "id": "alldaystransportltd-449.standard", + "carrier_name": "ALL DAYS TRANSPORT LTD", + "service_name": "Standard" + }, + { + "id": "dhlexpress-230.standard", + "carrier_name": "DHL Express", + "service_name": "Standard" + }, + { + "id": "freightcomfulfilment-429.standard", + "carrier_name": "Freightcom Fulfilment", + "service_name": "Standard" + }, + { + "id": "makfreightlinesltd-422.standard", + "carrier_name": "MAK FREIGHT LINES LTD", + "service_name": "Standard" + }, + { + "id": "nationex.standard", + "carrier_name": "Nationex", + "service_name": "Standard" + }, + { + "id": "pacemarathon-611.standard", + "carrier_name": "Pace Marathon", + "service_name": "Standard" + }, + { + "id": "transprofreightsystemsltd-394.standard", + "carrier_name": "Transpro Freight Systems Ltd", + "service_name": "Standard" + }, + { + "id": "diamonddelivery-275.standard", + "carrier_name": "Diamond Delivery", + "service_name": "Standard" + }, + { + "id": "driverdirect-586.standard", + "carrier_name": "Driver Direct", + "service_name": "Standard" + }, + { + "id": "inetexpress-521.standard", + "carrier_name": "I-Net Express", + "service_name": "Standard" + }, + { + "id": "morneau.standard", + "carrier_name": "Morneau Transport", + "service_name": "Standard" + }, + { + "id": "wtmlogisticsltd-579.standard", + "carrier_name": "WTM LOGISTICS LTD.", + "service_name": "Standard" + }, + { + "id": "ab-courier.canada-1030am", + "carrier_name": "A&B Courier", + "service_name": "Canada 10:30am" + }, + { + "id": "ab-courier.canada-930am", + "carrier_name": "A&B Courier", + "service_name": "Canada 9:30am" + }, + { + "id": "ab-courier.canada-ground", + "carrier_name": "A&B Courier", + "service_name": "Canada Ground" + }, + { + "id": "ab-courier.canada-overnight", + "carrier_name": "A&B Courier", + "service_name": "Canada Overnight" + }, + { + "id": "ab-courier.direct", + "carrier_name": "A&B Courier", + "service_name": "Direct" + }, + { + "id": "ab-courier.four-hour", + "carrier_name": "A&B Courier", + "service_name": "Four Hour" + }, + { + "id": "ab-courier.rush", + "carrier_name": "A&B Courier", + "service_name": "Rush" + }, + { + "id": "ab-courier.sameday", + "carrier_name": "A&B Courier", + "service_name": "Sameday" + }, + { + "id": "ab-courier.usa-ground", + "carrier_name": "A&B Courier", + "service_name": "USA Ground" + }, + { + "id": "daytonfreight-581.standard", + "carrier_name": "Dayton Freight", + "service_name": "Standard" + }, + { + "id": "mtslogisticsint-307.standard", + "carrier_name": "MTS Logistics Int.", + "service_name": "Standard" + }, + { + "id": "quikxtransportationinc-490.standard", + "carrier_name": "Quik X Transportation Inc.", + "service_name": "Standard" + }, + { + "id": "sabbystransportinc-574.standard", + "carrier_name": "Sabby?s Transport Inc ", + "service_name": "Standard" + }, + { + "id": "spring-gds.spring-direct", + "carrier_name": "Spring GDS", + "service_name": "Spring Direct" + }, + { + "id": "spring-gds.spring-gateway-parcel", + "carrier_name": "Spring GDS", + "service_name": "Spring Gateway Parcel" + }, + { + "id": "spring-gds.spring-packet-plus", + "carrier_name": "Spring GDS", + "service_name": "Spring Packet Plus Registered" + }, + { + "id": "spring-gds.spring-packet-tracked", + "carrier_name": "Spring GDS", + "service_name": "Spring Packet Tracked" + }, + { + "id": "spring-gds.spring-packet-untracked", + "carrier_name": "Spring GDS", + "service_name": "Spring Packet Untracked" + }, + { + "id": "lplogisticsinc-622.standard", + "carrier_name": "LP Logistics Inc", + "service_name": "Standard" + }, + { + "id": "pctransport-256.standard", + "carrier_name": "PC Transport", + "service_name": "Standard" + }, + { + "id": "peaktransport-497.standard", + "carrier_name": "PEAK TRANSPORT", + "service_name": "Standard" + }, + { + "id": "polaristransportation-188.standard", + "carrier_name": "Polaris Transportation ", + "service_name": "Standard" + }, + { + "id": "uts-470.standard", + "carrier_name": "UTS ", + "service_name": "Standard" + }, + { + "id": "dhillonsnationalservices-531.standard", + "carrier_name": "DHILLON'S NATIONAL SERVICES", + "service_name": "Standard" + }, + { + "id": "gryphontransportationinc-563.standard", + "carrier_name": "GRYPHON TRANSPORTATION INC.", + "service_name": "Standard" + }, + { + "id": "holmesfreight-346.standard", + "carrier_name": "Holmes Freight", + "service_name": "Standard" + }, + { + "id": "transporttransramexpressinc-370.standard", + "carrier_name": "Transport Transram Express Inc", + "service_name": "Standard" + }, + { + "id": "overlandwestfreightlines-253.standard", + "carrier_name": "Overland West Freight Lines", + "service_name": "Standard" + }, + { + "id": "cbstealthexpressinc-520.standard", + "carrier_name": "C.B. Stealth Express Inc.", + "service_name": "Standard" + }, + { + "id": "geowavelogistics-604.standard", + "carrier_name": "Geo Wave Logistics", + "service_name": "Standard" + }, + { + "id": "heartlandtransportltd-624.standard", + "carrier_name": "Heartland Transport Ltd.", + "service_name": "Standard" + }, + { + "id": "kindersley-courier.standard", + "carrier_name": "Kindersley Transport", + "service_name": "Standard" + }, + { + "id": "diamondtransportlogistics-477.standard", + "carrier_name": "Diamond Transport Logistics", + "service_name": "Standard" + }, + { + "id": "maritime.dry", + "carrier_name": "Maritime", + "service_name": "Dry" + }, + { + "id": "maritime.frozen", + "carrier_name": "Maritime", + "service_name": "Reefer" + }, + { + "id": "maritime.heat", + "carrier_name": "Maritime", + "service_name": "Heat" + }, + { + "id": "proactiftransportinc-460.standard", + "carrier_name": "ProActif Transport Inc.", + "service_name": "Standard" + }, + { + "id": "rightservicerightchoicetransportationandwarehouse-578.standard", + "carrier_name": "RIGHT SERVICE RIGHT CHOICE TRANSPORTATION AND WAREHOUSE", + "service_name": "Standard" + }, + { + "id": "averittexpress-576.standard", + "carrier_name": "Averitt Express", + "service_name": "Standard" + }, + { + "id": "bitzertruckingltd-591.standard", + "carrier_name": "Bitzer Trucking Ltd", + "service_name": "Standard" + }, + { + "id": "cctcanada-211.standard", + "carrier_name": "CCT Canada", + "service_name": "Standard" + }, + { + "id": "centraltransport-427.standard", + "carrier_name": "Central Transport", + "service_name": "Standard" + }, + { + "id": "saraixpresstruckinginc-336.standard", + "carrier_name": "SARAI XPRESS TRUCKING INC", + "service_name": "Standard" + }, + { + "id": "onroutefreightservicesinc-598.standard", + "carrier_name": "ONROUTE FREIGHT SERVICES INC.", + "service_name": "Standard" + }, + { + "id": "ontargettransportation-283.standard", + "carrier_name": "On Target Transportation", + "service_name": "Standard" + }, + { + "id": "sunstarhaulersinc-590.standard", + "carrier_name": "SUNSTAR HAULERS INC.", + "service_name": "Standard" + }, + { + "id": "transportecononord-495.standard", + "carrier_name": "Transport Econo Nord", + "service_name": "Standard" + }, + { + "id": "allspeed-432.standard", + "carrier_name": "All Speed", + "service_name": "Standard" + }, + { + "id": "canedatransport-189.standard", + "carrier_name": "Caneda Transport", + "service_name": "Standard" + }, + { + "id": "globaltranslogisticsltd-464.standard", + "carrier_name": "GLOBAL TRANS & LOGISTICS LTD", + "service_name": "Standard" + }, + { + "id": "holland.guaranteed-330-pm", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed by 3:30 PM" + }, + { + "id": "holland.guaranteed-9-am", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed by 9:00 AM" + }, + { + "id": "holland.guaranteed-day", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed Day" + }, + { + "id": "holland.guaranteed-hour", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed Hour" + }, + { + "id": "holland.guaranteed-multi-hour", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed Multi Hour" + }, + { + "id": "holland.guaranteed-noon", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed by Noon" + }, + { + "id": "holland.guaranteed-weekend", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed Weekend" + }, + { + "id": "holland.inter-regional", + "carrier_name": "Holland Freight", + "service_name": "Inter-Regional" + }, + { + "id": "holland.interline", + "carrier_name": "Holland Freight", + "service_name": "Interline" + }, + { + "id": "holland.regional", + "carrier_name": "Holland Freight", + "service_name": "Regional" + }, + { + "id": "westerncanadaexpress-259.standard", + "carrier_name": "Western Canada Express", + "service_name": "Standard" + }, + { + "id": "roadlinkxpress-553.standard", + "carrier_name": "ROAD LINK XPRESS", + "service_name": "Standard" + }, + { + "id": "stishehwaztransportinc-597.standard", + "carrier_name": "STI - Shehwaz Transport Inc.", + "service_name": "Standard" + }, + { + "id": "jbfexpress-430.standard", + "carrier_name": "JBF Express", + "service_name": "Standard" + }, + { + "id": "mjexpress-377.standard", + "carrier_name": "MJ Express", + "service_name": "Standard" + }, + { + "id": "pdfreight-612.standard", + "carrier_name": "PD Freight", + "service_name": "Standard" + }, + { + "id": "riserstransportinc-523.standard", + "carrier_name": "RISERS TRANSPORT INC.", + "service_name": "Standard" + }, + { + "id": "greenwaycarriers-475.standard", + "carrier_name": "GREENWAY CARRIERS ", + "service_name": "Standard" + }, + { + "id": "kimberlytransportltd-327.standard", + "carrier_name": "Kimberly Transport Ltd", + "service_name": "Standard" + }, + { + "id": "kindersleytransport-263.standard", + "carrier_name": "Kindersley Transport", + "service_name": "Standard" + }, + { + "id": "southeasternfreightlines-573.standard", + "carrier_name": "Southeastern Freight Lines", + "service_name": "Standard" + }, + { + "id": "dayton-freight.standard", + "carrier_name": "Dayton Freight", + "service_name": "Standard" + }, + { + "id": "otxlogisticscanadaltd-414.standard", + "carrier_name": "OTX Logistics Canada Ltd", + "service_name": "Standard" + }, + { + "id": "overlandfreightinternational-534.standard", + "carrier_name": "Overland Freight International", + "service_name": "Standard" + }, + { + "id": "westtransautoinc-367.standard", + "carrier_name": "WestTransAuto Inc.", + "service_name": "Standard" + }, + { + "id": "hollandmotorfreight-371.standard", + "carrier_name": "Holland Motor Freight", + "service_name": "Standard" + }, + { + "id": "lowfreightratecaltd-406.standard", + "carrier_name": "LOW FREIGHT RATE.CA LTD", + "service_name": "Standard" + }, + { + "id": "precisiontrucklines-410.standard", + "carrier_name": "PRECISION TRUCK LINES", + "service_name": "Standard" + }, + { + "id": "sewaenterpriseltd-405.standard", + "carrier_name": "SEWA ENTERPRISE LTD", + "service_name": "Standard" + }, + { + "id": "ab-courier-ltl.ltl-direct", + "carrier_name": "A&B Courier", + "service_name": "Direct (Pallet)" + }, + { + "id": "ab-courier-ltl.ltl-rush", + "carrier_name": "A&B Courier", + "service_name": "Rush (Pallet)" + }, + { + "id": "ab-courier-ltl.ltl-sameday", + "carrier_name": "A&B Courier", + "service_name": "Sameday (Pallet)" + }, + { + "id": "bmptransport-318.standard", + "carrier_name": "BMP Transport", + "service_name": "Standard" + }, + { + "id": "courrierplus-494.standard", + "carrier_name": "Courrier Plus", + "service_name": "Standard" + }, + { + "id": "fedexground-426.standard", + "carrier_name": "FedEx Ground", + "service_name": "Standard" + }, + { + "id": "mototransportation-264.standard", + "carrier_name": "Moto Transportation", + "service_name": "Standard" + }, + { + "id": "acecourier-519.standard", + "carrier_name": "ACE Courier", + "service_name": "Standard" + }, + { + "id": "caneda-189.standard", + "carrier_name": "Caneda", + "service_name": "Standard" + }, + { + "id": "expotrans-518.standard", + "carrier_name": "EXPOTRANS", + "service_name": "Standard" + }, + { + "id": "frontlinecarriersystemsinc-496.standard", + "carrier_name": "Frontline Carrier Systems Inc.", + "service_name": "Standard" + }, + { + "id": "frontlinefreight-492.standard", + "carrier_name": "Frontline Freight", + "service_name": "Standard" + }, + { + "id": "nishantransportinc-423.standard", + "carrier_name": "NISHAN TRANSPORT INC.", + "service_name": "Standard" + }, + { + "id": "transamcarriersinc-482.standard", + "carrier_name": "TRANSAM CARRIERS INC", + "service_name": "Standard" + }, + { + "id": "aarontruckingltd-513.standard", + "carrier_name": "AARON TRUCKING LTD", + "service_name": "Standard" + }, + { + "id": "apexmotorexpress-258.standard", + "carrier_name": "Apex Motor Express", + "service_name": "Standard" + }, + { + "id": "comox.standard", + "carrier_name": "Comox Pacific Express", + "service_name": "Standard" + }, + { + "id": "fleet-optics.standard", + "carrier_name": "Fleet Optics", + "service_name": "Standard" + }, + { + "id": "garrymercertrucking-452.standard", + "carrier_name": "Garry Mercer Trucking", + "service_name": "Standard" + }, + { + "id": "hnmlogisticsinc-436.standard", + "carrier_name": "HNM LOGISTICS INC.", + "service_name": "Standard" + }, + { + "id": "smartexpressltd-488.standard", + "carrier_name": "s.m.a.r.t. Express Ltd.", + "service_name": "Standard" + }, + { + "id": "aaacooper-594.standard", + "carrier_name": "AAA Cooper", + "service_name": "Standard" + }, + { + "id": "abcourier-480.standard", + "carrier_name": "A&B Courier", + "service_name": "Standard" + }, + { + "id": "cretransport-287.standard", + "carrier_name": "CRE Transport", + "service_name": "Standard" + }, + { + "id": "fedexexpress-272.standard", + "carrier_name": "FedEx Express", + "service_name": "Standard" + }, + { + "id": "rangefreightwaysltd-448.standard", + "carrier_name": "Range Freightways Ltd.", + "service_name": "Standard" + }, + { + "id": "recalltransportservicesinc-609.standard", + "carrier_name": "Recall Transport Services Inc.", + "service_name": "Standard" + }, + { + "id": "saraixpresstruckinginc-379.standard", + "carrier_name": "Sarai Xpress Trucking Inc", + "service_name": "Standard" + }, + { + "id": "trans2-293.standard", + "carrier_name": "Trans2", + "service_name": "Standard" + }, + { + "id": "coastlineexpress-536.standard", + "carrier_name": "Coastline Express", + "service_name": "Standard" + }, + { + "id": "d4logisticsinc-505.standard", + "carrier_name": "D4 LOGISTICS INC.", + "service_name": "Standard" + }, + { + "id": "exceltransportation-328.standard", + "carrier_name": "Excel Transportation", + "service_name": "Standard" + }, + { + "id": "purolatorcourier.express", + "carrier_name": "Purolator", + "service_name": "Express" + }, + { + "id": "purolatorcourier.express-box", + "carrier_name": "Purolator", + "service_name": "Express Box" + }, + { + "id": "purolatorcourier.express-box-international", + "carrier_name": "Purolator", + "service_name": "Express Box International" + }, + { + "id": "purolatorcourier.express-box1030am", + "carrier_name": "Purolator", + "service_name": "Express Box 10:30 AM" + }, + { + "id": "purolatorcourier.express-box9am", + "carrier_name": "Purolator", + "service_name": "Express Box 9 AM" + }, + { + "id": "purolatorcourier.express-boxUS", + "carrier_name": "Purolator", + "service_name": "Express Box U.S." + }, + { + "id": "purolatorcourier.express-envelope", + "carrier_name": "Purolator", + "service_name": "Express Envelope" + }, + { + "id": "purolatorcourier.express-envelope-international", + "carrier_name": "Purolator", + "service_name": "Express Envelope International" + }, + { + "id": "purolatorcourier.express-envelope-us", + "carrier_name": "Purolator", + "service_name": "Express Envelope U.S." + }, + { + "id": "purolatorcourier.express-envelope1030am", + "carrier_name": "Purolator", + "service_name": "Express Envelope 10:30 AM" + }, + { + "id": "purolatorcourier.express-envelope9am", + "carrier_name": "Purolator", + "service_name": "Express Envelope 9 AM" + }, + { + "id": "purolatorcourier.express-international", + "carrier_name": "Purolator", + "service_name": "Express International" + }, + { + "id": "purolatorcourier.express-pack", + "carrier_name": "Purolator", + "service_name": "Express Pack" + }, + { + "id": "purolatorcourier.express-pack-international", + "carrier_name": "Purolator", + "service_name": "Express Pack International" + }, + { + "id": "purolatorcourier.express-pack-us", + "carrier_name": "Purolator", + "service_name": "Express Pack U.S." + }, + { + "id": "purolatorcourier.express-pack1030am", + "carrier_name": "Purolator", + "service_name": "Express Pack 10:30 AM" + }, + { + "id": "purolatorcourier.express-pack9am", + "carrier_name": "Purolator", + "service_name": "Express Pack 9 AM" + }, + { + "id": "purolatorcourier.express-us", + "carrier_name": "Purolator", + "service_name": "Express U.S." + }, + { + "id": "purolatorcourier.express-us-1030am", + "carrier_name": "Purolator", + "service_name": "Express U.S. 10:30 AM" + }, + { + "id": "purolatorcourier.express-us-9am", + "carrier_name": "Purolator", + "service_name": "Express U.S. 9 AM" + }, + { + "id": "purolatorcourier.express-us-box1030AM", + "carrier_name": "Purolator", + "service_name": "Express U.S. Box 10:30 AM" + }, + { + "id": "purolatorcourier.express-us-box9AM", + "carrier_name": "Purolator", + "service_name": "Express U.S. Box 9 AM" + }, + { + "id": "purolatorcourier.express-us-envelope1030am", + "carrier_name": "Purolator", + "service_name": "Express U.S. Envelope 10:30 AM" + }, + { + "id": "purolatorcourier.express-us-envelope9am", + "carrier_name": "Purolator", + "service_name": "Express U.S. Envelope 9 AM" + }, + { + "id": "purolatorcourier.express-us-pack1030am", + "carrier_name": "Purolator", + "service_name": "Express U.S. Pack 10:30 AM" + }, + { + "id": "purolatorcourier.express-us-pack9am", + "carrier_name": "Purolator", + "service_name": "Express U.S. Pack 9 AM" + }, + { + "id": "purolatorcourier.express1030AM", + "carrier_name": "Purolator", + "service_name": "Express 10:30 AM" + }, + { + "id": "purolatorcourier.express9AM", + "carrier_name": "Purolator", + "service_name": "Express 9 AM" + }, + { + "id": "purolatorcourier.ground", + "carrier_name": "Purolator", + "service_name": "Ground" + }, + { + "id": "purolatorcourier.ground-us", + "carrier_name": "Purolator", + "service_name": "Ground U.S." + }, + { + "id": "purolatorcourier.standard", + "carrier_name": "Purolator", + "service_name": "Standard" + }, + { + "id": "a1delivery-514.standard", + "carrier_name": "A-1 Delivery", + "service_name": "Standard" + }, + { + "id": "fedex-courier.2-day", + "carrier_name": "FedEx Courier", + "service_name": "2-Day" + }, + { + "id": "fedex-courier.2-day-a-m", + "carrier_name": "FedEx Courier", + "service_name": "2-Day AM" + }, + { + "id": "fedex-courier.express-saver", + "carrier_name": "FedEx Courier", + "service_name": "Express Saver" + }, + { + "id": "fedex-courier.first-overnight", + "carrier_name": "FedEx Courier", + "service_name": "First Overnight" + }, + { + "id": "fedex-courier.ground", + "carrier_name": "FedEx Courier", + "service_name": "Ground" + }, + { + "id": "fedex-courier.international-connect-plus", + "carrier_name": "FedEx Courier", + "service_name": "International Connect Plus" + }, + { + "id": "fedex-courier.international-economy", + "carrier_name": "FedEx Courier", + "service_name": "International Economy" + }, + { + "id": "fedex-courier.international-ground", + "carrier_name": "FedEx Courier", + "service_name": "International Ground" + }, + { + "id": "fedex-courier.international-priority", + "carrier_name": "FedEx Courier", + "service_name": "International Priority" + }, + { + "id": "fedex-courier.international-priority-express", + "carrier_name": "FedEx Courier", + "service_name": "International Priority Express" + }, + { + "id": "fedex-courier.overnight", + "carrier_name": "FedEx Courier", + "service_name": "Overnight" + }, + { + "id": "fedex-courier.priority-overnight", + "carrier_name": "FedEx Courier", + "service_name": "Priority Overnight" + }, + { + "id": "fedex-courier.same-day", + "carrier_name": "FedEx Courier", + "service_name": "Same Day" + }, + { + "id": "spadytransportltd-384.standard", + "carrier_name": "SPADY TRANSPORT LTD", + "service_name": "Standard" + }, + { + "id": "tstapi.intermodal", + "carrier_name": "TST", + "service_name": "Intermodal" + }, + { + "id": "tstapi.standard", + "carrier_name": "TST", + "service_name": "Standard" + }, + { + "id": "spanalaska-544.standard", + "carrier_name": "Span Alaska", + "service_name": "Standard" + }, + { + "id": "sunshinelogistics-321.standard", + "carrier_name": "Sunshine Logistics", + "service_name": "Standard" + }, + { + "id": "yellowlogistics-525.standard", + "carrier_name": "Yellow Logistics", + "service_name": "Standard" + }, + { + "id": "abffreight-455.standard", + "carrier_name": "ABF Freight", + "service_name": "Standard" + }, + { + "id": "fastexact-585.standard", + "carrier_name": "Fast Exact", + "service_name": "Standard" + }, + { + "id": "gardewinegroupinc-424.standard", + "carrier_name": "Gardewine Group Inc.", + "service_name": "Standard" + }, + { + "id": "saia.standard", + "carrier_name": "Saia Motor Freight", + "service_name": "Standard" + }, + { + "id": "roadridertransportltd-417.standard", + "carrier_name": "ROAD RIDER Transport Ltd", + "service_name": "Standard" + }, + { + "id": "cct.expedited", + "carrier_name": "CCT", + "service_name": "Expedited" + }, + { + "id": "cct.intermodal", + "carrier_name": "CCT", + "service_name": "Intermodal" + }, + { + "id": "dependablehawaiianexpress-567.standard", + "carrier_name": "Dependable Hawaiian Express", + "service_name": "Standard" + }, + { + "id": "interpacifictransport-457.standard", + "carrier_name": "Inter-Pacific Transport", + "service_name": "Standard" + }, + { + "id": "oneforfreight-481.standard", + "carrier_name": "ONE For Freight", + "service_name": "Standard" + }, + { + "id": "seawayexpress-431.standard", + "carrier_name": "Seaway Express", + "service_name": "Standard" + }, + { + "id": "allpointsfreightinc-546.standard", + "carrier_name": "ALL POINTS FREIGHT INC.", + "service_name": "Standard" + }, + { + "id": "groupelafrance-434.standard", + "carrier_name": "Groupe Lafrance", + "service_name": "Standard" + }, + { + "id": "hiltontransportation-317.standard", + "carrier_name": "Hilton Transportation", + "service_name": "Standard" + }, + { + "id": "locomoteexpress-538.standard", + "carrier_name": "Locomote Express", + "service_name": "Standard" + }, + { + "id": "sendr-603.standard", + "carrier_name": "SENDR", + "service_name": "Standard" + }, + { + "id": "airinuitcargo-539.standard", + "carrier_name": "Air Inuit Cargo", + "service_name": "Standard" + }, + { + "id": "cmttransportinc-628.standard", + "carrier_name": "C M T TRANSPORT INC.", + "service_name": "Standard" + }, + { + "id": "galaxyfreightline-221.standard", + "carrier_name": "Galaxy Freightline", + "service_name": "Standard" + }, + { + "id": "purolatorfreight-577.standard", + "carrier_name": "Purolator Freight", + "service_name": "Standard" + }, + { + "id": "mcdispatch-467.standard", + "carrier_name": "MC Dispatch", + "service_name": "Standard" + }, + { + "id": "midlandtransport-437.standard", + "carrier_name": "Midland Transport", + "service_name": "Standard" + }, + { + "id": "dukesfreightservices-617.standard", + "carrier_name": "Dukes Freight Services", + "service_name": "Standard" + }, + { + "id": "frontiersupplychainsolutions-451.standard", + "carrier_name": "Frontier Supply Chain Solutions", + "service_name": "Standard" + }, + { + "id": "gls-freight.ground", + "carrier_name": "GLS Freight", + "service_name": "Ground" + }, + { + "id": "loadkingtransportinc-385.standard", + "carrier_name": "LOAD KING TRANSPORT INC", + "service_name": "Standard" + }, + { + "id": "dayrossfreightcanada-559.standard", + "carrier_name": "Day & Ross Freight | Canada", + "service_name": "Standard" + }, + { + "id": "gillcologistics-601.standard", + "carrier_name": "Gillco Logistics", + "service_name": "Standard" + }, + { + "id": "reddaway-402.standard", + "carrier_name": "Reddaway", + "service_name": "Standard" + }, + { + "id": "xpo.standard", + "carrier_name": "XPO", + "service_name": "Standard" + }, + { + "id": "lodextransportltd-572.standard", + "carrier_name": "LODEX TRANSPORT LTD", + "service_name": "Standard" + }, + { + "id": "moto.standard", + "carrier_name": "Moto Transportation Services Corp", + "service_name": "Standard" + }, + { + "id": "schneidernational-501.standard", + "carrier_name": "Schneider National", + "service_name": "Standard" + }, + { + "id": "glsfreight-186.standard", + "carrier_name": "GLS Freight", + "service_name": "Standard" + }, + { + "id": "loadlandlogisticsinc-607.standard", + "carrier_name": "LOAD LAND LOGISTICS INC.", + "service_name": "Standard" + }, + { + "id": "pacificcoastexpress-373.standard", + "carrier_name": "Pacific Coast Express", + "service_name": "Standard" + }, + { + "id": "purolatorcourier-401.standard", + "carrier_name": "Purolator Courier", + "service_name": "Standard" + }, + { + "id": "albrighttruckinginc-454.standard", + "carrier_name": "Albright Trucking Inc.", + "service_name": "Standard" + }, + { + "id": "beyondtransportation-285.standard", + "carrier_name": "Beyond Transportation", + "service_name": "Standard" + }, + { + "id": "dinkaenterprises-630.standard", + "carrier_name": "DINKA Enterprises", + "service_name": "Standard" + }, + { + "id": "gls-us.am-select-8a-12p", + "carrier_name": "GLS US", + "service_name": "AM Select 8a-12p" + }, + { + "id": "gls-us.early-priority-overnight", + "carrier_name": "GLS US", + "service_name": "Early Priority Overnight" + }, + { + "id": "gls-us.early-saturday-delivery", + "carrier_name": "GLS US", + "service_name": "Early Saturday Delivery" + }, + { + "id": "gls-us.evening-select-4p-8p", + "carrier_name": "GLS US", + "service_name": "Evening Select 4p-8p" + }, + { + "id": "gls-us.gls-ground", + "carrier_name": "GLS US", + "service_name": "GLS Ground" + }, + { + "id": "gls-us.noon-priority-overnight-sds–saturday-delivery", + "carrier_name": "GLS US", + "service_name": "Noon Priority Overnight SDS – Saturday Delivery" + }, + { + "id": "gls-us.pm-select-12p-4p", + "carrier_name": "GLS US", + "service_name": "PM Select 12p-4p" + }, + { + "id": "gls-us.priority-overnight", + "carrier_name": "GLS US", + "service_name": "Priority Overnight" + }, + { + "id": "gls-us.saturday-delivery", + "carrier_name": "GLS US", + "service_name": "Saturday Delivery" + }, + { + "id": "wsbellcartage-584.standard", + "carrier_name": "W.S. Bell Cartage", + "service_name": "Standard" + }, + { + "id": "manitoulintransport-440.standard", + "carrier_name": "Manitoulin Transport", + "service_name": "Standard" + }, + { + "id": "arbaztransportincdbakrgtransport-415.standard", + "carrier_name": "ARBAZ TRANSPORT INC. DBA KRG TRANSPORT", + "service_name": "Standard" + }, + { + "id": "garantlogisticsltd-548.standard", + "carrier_name": "GARANT LOGISTICS LTD", + "service_name": "Standard" + }, + { + "id": "highlightmotorgroup-542.standard", + "carrier_name": "HIGHLIGHT MOTOR GROUP", + "service_name": "Standard" + }, + { + "id": "kaynortransport-508.standard", + "carrier_name": "KAYNOR TRANSPORT", + "service_name": "Standard" + }, + { + "id": "rpmtransit-356.standard", + "carrier_name": "RPM Transit", + "service_name": "Standard" + }, + { + "id": "bestbaylogistics-532.standard", + "carrier_name": "BEST BAY LOGISTICS", + "service_name": "Standard" + }, + { + "id": "csatransportation-191.standard", + "carrier_name": "CSA Transportation", + "service_name": "Standard" + }, + { + "id": "himmatlogistics-587.standard", + "carrier_name": "HIMMAT LOGISTICS", + "service_name": "Standard" + }, + { + "id": "pacificnorthwestfreightsytems-560.standard", + "carrier_name": "Pacific Northwest Freight Sytems", + "service_name": "Standard" + }, + { + "id": "bowlinggreenlogistics-466.standard", + "carrier_name": "BOWLING GREEN LOGISTICS", + "service_name": "Standard" + }, + { + "id": "eknaamshippingcorp-512.standard", + "carrier_name": "EK NAAM SHIPPING CORP.", + "service_name": "Standard" + }, + { + "id": "frontline.standard", + "carrier_name": "Frontline", + "service_name": "Standard" + }, + { + "id": "jmtransitinc-439.standard", + "carrier_name": "J.M. Transit Inc.", + "service_name": "Standard" + }, + { + "id": "midland.econoline", + "carrier_name": "MidLand Transport", + "service_name": "Econo Line" + }, + { + "id": "midland.standard", + "carrier_name": "MidLand Transport", + "service_name": "Standard" + }, + { + "id": "mjexpress-380.standard", + "carrier_name": "MJ Express", + "service_name": "Standard" + }, + { + "id": "robusttransportservicesltd-479.standard", + "carrier_name": "ROBUST TRANSPORT SERVICES LTD", + "service_name": "Standard" + }, + { + "id": "aonetransport2007ltd-625.standard", + "carrier_name": "A-One Transport (2007) Ltd.", + "service_name": "Standard" + }, + { + "id": "atlaslogistics-262.standard", + "carrier_name": "Atlas Logistics", + "service_name": "Standard" + }, + { + "id": "gurshanlogistics-486.standard", + "carrier_name": "Gurshan Logistics", + "service_name": "Standard" + }, + { + "id": "jdtransportltd-456.standard", + "carrier_name": "J.D.TRANSPORT LTD", + "service_name": "Standard" + }, + { + "id": "rollsright.standard", + "carrier_name": "Rollsright", + "service_name": "Standard" + }, + { + "id": "speedy.standard", + "carrier_name": "Speedy", + "service_name": "Standard" + }, + { + "id": "ettransport-337.standard", + "carrier_name": "E.T. Transport", + "service_name": "Standard" + }, + { + "id": "fedexfreight-154.standard", + "carrier_name": "FedEx Freight", + "service_name": "Standard" + }, + { + "id": "tstcfexpresscanada-282.standard", + "carrier_name": "TST-CF Express | Canada", + "service_name": "Standard" + }, + { + "id": "suntransportationsystems-476.standard", + "carrier_name": "Sun Transportation Systems", + "service_name": "Standard" + }, + { + "id": "universallogisticssolution-517.standard", + "carrier_name": "UNIVERSAL LOGISTICS SOLUTION", + "service_name": "Standard" + }, + { + "id": "apex.standard", + "carrier_name": "Apex", + "service_name": "Standard" + }, + { + "id": "dayrossfreightcanada-133.standard", + "carrier_name": "Day & Ross Freight | Canada", + "service_name": "Standard" + }, + { + "id": "indocanadiancarriers-386.standard", + "carrier_name": "Indo Canadian Carriers", + "service_name": "Standard" + }, + { + "id": "stitransport-250.standard", + "carrier_name": "STI Transport", + "service_name": "Standard" + }, + { + "id": "stallion.apc-priority-worldwide", + "carrier_name": "Stallion", + "service_name": "APC Priority Worldwide" + }, + { + "id": "stallion.apc-priority-worldwide-tracked", + "carrier_name": "Stallion", + "service_name": "APC Priority Worldwide Tracked" + }, + { + "id": "stallion.economy-usa", + "carrier_name": "Stallion", + "service_name": "Stallion Economy USA" + }, + { + "id": "stallion.express", + "carrier_name": "Stallion", + "service_name": "Stallion Express" + }, + { + "id": "stallion.usps-express-mail", + "carrier_name": "Stallion", + "service_name": "USPS Express Mail" + }, + { + "id": "stallion.usps-first-class-mail", + "carrier_name": "Stallion", + "service_name": "USPS First Class Mail" + }, + { + "id": "stallion.usps-library-mail", + "carrier_name": "Stallion", + "service_name": "USPS Library Mail" + }, + { + "id": "stallion.usps-media-mail", + "carrier_name": "Stallion", + "service_name": "USPS Media Mail" + }, + { + "id": "stallion.usps-parcel-select-ground", + "carrier_name": "Stallion", + "service_name": "USPS Parcel Select Ground" + }, + { + "id": "stallion.usps-priority-mail", + "carrier_name": "Stallion", + "service_name": "USPS Priority Mail" + }, + { + "id": "stallion.usps-priority-mail-express", + "carrier_name": "Stallion", + "service_name": "USPS Priority Mail Express" + }, + { + "id": "transkid.standard", + "carrier_name": "Transkid", + "service_name": "Standard" + }, + { + "id": "versacold-438.standard", + "carrier_name": "VersaCold", + "service_name": "Standard" + }, + { + "id": "vttranssolutionsinc-472.standard", + "carrier_name": "VT TRANS SOLUTIONS INC", + "service_name": "Standard" + }, + { + "id": "bestwaycartage-355.standard", + "carrier_name": "BestWay Cartage", + "service_name": "Standard" + }, + { + "id": "commanderwesttrucking-582.standard", + "carrier_name": "Commander West Trucking", + "service_name": "Standard" + }, + { + "id": "roundthelakesmotorexpress-233.standard", + "carrier_name": "Round the Lakes Motor Express", + "service_name": "Standard" + }, + { + "id": "trafalgarsupplyco-511.standard", + "carrier_name": "Trafalgar Supply Co. ", + "service_name": "Standard" + }, + { + "id": "sunburytransportlimited-478.standard", + "carrier_name": "SUNBURY TRANSPORT LIMITED", + "service_name": "Standard" + }, + { + "id": "winniefreight-549.standard", + "carrier_name": "Winnie Freight", + "service_name": "Standard" + }, + { + "id": "gladiatorriggs-483.standard", + "carrier_name": "GLADIATOR RIGGS", + "service_name": "Standard" + }, + { + "id": "hewingstransportationinc-515.standard", + "carrier_name": "Hewings Transportation Inc.", + "service_name": "Standard" + }, + { + "id": "kbdtransportation-420.standard", + "carrier_name": "KBD TRANSPORTATION ", + "service_name": "Standard" + }, + { + "id": "mopallet.standard", + "carrier_name": "Maritime ", + "service_name": "Pallet Program" + }, + { + "id": "transcomax-504.standard", + "carrier_name": "TranscoMAX", + "service_name": "Standard" + }, + { + "id": "uniteddhillontrucklinesudtl-600.standard", + "carrier_name": "UNITED DHILLON TRUCK LINES (UDTL)", + "service_name": "Standard" + }, + { + "id": "atripcodeliveryservice-279.standard", + "carrier_name": "Atripco Delivery Service", + "service_name": "Standard" + }, + { + "id": "interloadtruckserviceltd-569.standard", + "carrier_name": "INTERLOAD TRUCK SERVICE LTD.", + "service_name": "Standard" + }, + { + "id": "kindersley.expedited", + "carrier_name": "Kindersley", + "service_name": "Expedited" + }, + { + "id": "kindersley.intermodal", + "carrier_name": "Kindersley", + "service_name": "Intermodal" + }, + { + "id": "kindersley.standard", + "carrier_name": "Kindersley", + "service_name": "Regular" + }, + { + "id": "polarisweb.standard", + "carrier_name": "Polaris FPP", + "service_name": "Pallet Program" + }, + { + "id": "alainnormandtransportinc-595.standard", + "carrier_name": "ALAIN NORMAND TRANSPORT INC.", + "service_name": "Standard" + }, + { + "id": "ariesgloballogisticsinc-135.standard", + "carrier_name": "Aries Global Logistics Inc", + "service_name": "Standard" + }, + { + "id": "dhillontransport-550.standard", + "carrier_name": "Dhillon Transport", + "service_name": "Standard" + }, + { + "id": "springcreekcarriersinc-291.standard", + "carrier_name": "Spring Creek Carriers Inc", + "service_name": "Standard" + }, + { + "id": "ilclogistics-315.standard", + "carrier_name": "ILC Logistics", + "service_name": "Standard" + }, + { + "id": "transontarioexpress-248.standard", + "carrier_name": "Trans-Ontario Express", + "service_name": "Standard" + }, + { + "id": "yrc.accelerated", + "carrier_name": "YRC", + "service_name": "Accelerated" + }, + { + "id": "yrc.freight-canada-to-us", + "carrier_name": "YRC", + "service_name": "Canada to US" + }, + { + "id": "yrc.freight-dedicated-equipment", + "carrier_name": "YRC", + "service_name": "Dedicated Equipment" + }, + { + "id": "yrc.standard", + "carrier_name": "YRC", + "service_name": "Standard" + }, + { + "id": "yrc.time-critical-by-5pm", + "carrier_name": "YRC", + "service_name": "Critical by 5 PM" + }, + { + "id": "yrc.time-critical-by-afternoon", + "carrier_name": "YRC", + "service_name": "Critical by Afternoon" + }, + { + "id": "yrc.time-critical-fastest-ground", + "carrier_name": "YRC", + "service_name": "Critical Fastest Ground" + }, + { + "id": "yrc.time-critical-hour-window", + "carrier_name": "YRC", + "service_name": "Critical Hour Window" + }, + { + "id": "b2bfreightwayinc-605.standard", + "carrier_name": "B2B Freightway Inc.", + "service_name": "Standard" + }, + { + "id": "caribootruckterminalsltd-616.standard", + "carrier_name": "Cariboo Truck Terminals Ltd", + "service_name": "Standard" + }, + { + "id": "eximlogisticsinc-421.standard", + "carrier_name": "ExIm Logistics Inc.", + "service_name": "Standard" + }, + { + "id": "ics.ground", + "carrier_name": "ICS", + "service_name": "Ground" + }, + { + "id": "ics.next-day", + "carrier_name": "ICS", + "service_name": "Next day" + }, + { + "id": "tstcfexpresssaia-185.standard", + "carrier_name": "TST-CF Express | SAIA", + "service_name": "Standard" + }, + { + "id": "comoxpacificexpress-257.standard", + "carrier_name": "Comox Pacific Express", + "service_name": "Standard" + }, + { + "id": "galaxyfreightlineinc-183.standard", + "carrier_name": "Galaxy Freightline Inc", + "service_name": "Standard" + }, + { + "id": "samoyedtransport-602.standard", + "carrier_name": "Samoyed Transport", + "service_name": "Standard" + }, + { + "id": "sprinterdeliveryltd-522.standard", + "carrier_name": "Sprinter Delivery Ltd.", + "service_name": "Standard" + }, + { + "id": "gtboltoninc-491.standard", + "carrier_name": "G.T. BOLTON INC.", + "service_name": "Standard" + }, + { + "id": "polarisdirect.standard", + "carrier_name": "Polaris", + "service_name": "Direct" + }, + { + "id": "ups.3day-select", + "carrier_name": "UPS", + "service_name": "3 Day Select" + }, + { + "id": "ups.expedited", + "carrier_name": "UPS", + "service_name": "Expedited" + }, + { + "id": "ups.express", + "carrier_name": "UPS", + "service_name": "Express" + }, + { + "id": "ups.express-early", + "carrier_name": "UPS", + "service_name": "Express Early" + }, + { + "id": "ups.express-saver", + "carrier_name": "UPS", + "service_name": "Express Saver" + }, + { + "id": "ups.ground", + "carrier_name": "UPS", + "service_name": "Ground" + }, + { + "id": "ups.standard", + "carrier_name": "UPS", + "service_name": "Standard" + }, + { + "id": "ups.worldwide-expedited", + "carrier_name": "UPS", + "service_name": "Worldwide Expedited" + }, + { + "id": "ups.worldwide-express", + "carrier_name": "UPS", + "service_name": "Worldwide Express" + }, + { + "id": "ups.worldwide-express-plus", + "carrier_name": "UPS", + "service_name": "Worldwide Express Plus" + }, + { + "id": "ups.worldwide-express-saver", + "carrier_name": "UPS", + "service_name": "Worldwide Express Saver" + }, + { + "id": "argustransportcanada-463.standard", + "carrier_name": "ARGUS Transport Canada", + "service_name": "Standard" + }, + { + "id": "crosscountryfreightsolutions-571.standard", + "carrier_name": "CrossCountry Freight Solutions", + "service_name": "Standard" + }, + { + "id": "geysertransportltd-606.standard", + "carrier_name": "Geyser Transport Ltd", + "service_name": "Standard" + }, + { + "id": "greysertransportltd-606.standard", + "carrier_name": "Greyser Transport Ltd", + "service_name": "Standard" + }, + { + "id": "steelestransportationgroup-580.standard", + "carrier_name": "Steele's Transportation Group", + "service_name": "Standard" + }, + { + "id": "titantranslineinc-450.standard", + "carrier_name": "Titan Transline Inc.", + "service_name": "Standard" + }, + { + "id": "2stopdelivery-393.standard", + "carrier_name": "2 STOP DELIVERY", + "service_name": "Standard" + }, + { + "id": "aduiepyleinc-589.standard", + "carrier_name": "A Duie Pyle, Inc", + "service_name": "Standard" + }, + { + "id": "centralislanddistributors-554.standard", + "carrier_name": "Central Island Distributors", + "service_name": "Standard" + }, + { + "id": "minimaxexpress-418.standard", + "carrier_name": "Minimax Express", + "service_name": "Standard" + }, + { + "id": "dayrosscommerce-266.standard", + "carrier_name": "Day & Ross Commerce", + "service_name": "Standard" + }, + { + "id": "highlightmotorgroup-500.standard", + "carrier_name": "HIGHLIGHT MOTOR GROUP", + "service_name": "Standard" + }, + { + "id": "internordtransportation-461.standard", + "carrier_name": "Inter-Nord Transportation", + "service_name": "Standard" + }, + { + "id": "westmancourier-419.standard", + "carrier_name": "Westman Courier", + "service_name": "Standard" + } + ], + "DEV_SERVICES": [ + { + "id": "kindersley-freight.domestic-expedited", + "carrier_name": "Kindersley Transport", + "service_name": "Domestic Expedited" + }, + { + "id": "kindersley-freight.domestic-rail", + "carrier_name": "Kindersley Transport", + "service_name": "Domestic Rail" + }, + { + "id": "kindersley-freight.domestic-road", + "carrier_name": "Kindersley Transport", + "service_name": "Domestic Road" + }, + { + "id": "kindersley-freight.transborder", + "carrier_name": "Kindersley Transport", + "service_name": "Transborder" + }, + { + "id": "newpennmotorexpress-445.standard", + "carrier_name": "New Penn Motor Express", + "service_name": "Standard" + }, + { + "id": "a10cD2MfJjiOCcRejjgv3cHMyRcRBhE3.standard", + "carrier_name": "Bill's Spot Carrier", + "service_name": "Standard" + }, + { + "id": "apps.intermodal", + "carrier_name": "APPS", + "service_name": "Intermodal" + }, + { + "id": "apps.standard", + "carrier_name": "APPS", + "service_name": "Standard" + }, + { + "id": "dayrosscommerce-266.standard", + "carrier_name": "Day & Ross Commerce", + "service_name": "Standard" + }, + { + "id": "fedex-courier.2-day", + "carrier_name": "FedEx Courier", + "service_name": "2-Day" + }, + { + "id": "fedex-courier.2-day-a-m", + "carrier_name": "FedEx Courier", + "service_name": "2-Day AM" + }, + { + "id": "fedex-courier.express-saver", + "carrier_name": "FedEx Courier", + "service_name": "Express Saver" + }, + { + "id": "fedex-courier.first-overnight", + "carrier_name": "FedEx Courier", + "service_name": "First Overnight" + }, + { + "id": "fedex-courier.ground", + "carrier_name": "FedEx Courier", + "service_name": "Ground" + }, + { + "id": "fedex-courier.international-connect-plus", + "carrier_name": "FedEx Courier", + "service_name": "International Connect Plus" + }, + { + "id": "fedex-courier.international-economy", + "carrier_name": "FedEx Courier", + "service_name": "International Economy" + }, + { + "id": "fedex-courier.international-ground", + "carrier_name": "FedEx Courier", + "service_name": "International Ground" + }, + { + "id": "fedex-courier.international-priority", + "carrier_name": "FedEx Courier", + "service_name": "International Priority" + }, + { + "id": "fedex-courier.international-priority-express", + "carrier_name": "FedEx Courier", + "service_name": "International Priority Express" + }, + { + "id": "fedex-courier.overnight", + "carrier_name": "FedEx Courier", + "service_name": "Overnight" + }, + { + "id": "fedex-courier.priority-overnight", + "carrier_name": "FedEx Courier", + "service_name": "Priority Overnight" + }, + { + "id": "fedex-courier.same-day", + "carrier_name": "FedEx Courier", + "service_name": "Same Day" + }, + { + "id": "fedexfreight-154.standard", + "carrier_name": "FedEx Freight", + "service_name": "Standard" + }, + { + "id": "gsm.air-skip", + "carrier_name": "GTA GSM", + "service_name": "AirSkip" + }, + { + "id": "gsm.air-skip-eco", + "carrier_name": "GTA GSM", + "service_name": "AirSkipEco" + }, + { + "id": "gsm.air-skip-plus", + "carrier_name": "GTA GSM", + "service_name": "AirSkip+" + }, + { + "id": "gsm.armed-secure-air", + "carrier_name": "GTA GSM", + "service_name": "Armed Secure Air" + }, + { + "id": "gsm.armed-secure-ground", + "carrier_name": "GTA GSM", + "service_name": "Armed Secure Ground" + }, + { + "id": "gsm.ground", + "carrier_name": "GTA GSM", + "service_name": "Ground" + }, + { + "id": "gsm.secure-air", + "carrier_name": "GTA GSM", + "service_name": "Secure Air" + }, + { + "id": "gsm.secure-ground", + "carrier_name": "GTA GSM", + "service_name": "Secure Ground" + }, + { + "id": "gsm.zone-skip", + "carrier_name": "GTA GSM", + "service_name": "ZoneSkip" + }, + { + "id": "gsm.zone-skip-plus", + "carrier_name": "GTA GSM", + "service_name": "ZoneSkip+" + }, + { + "id": "dhlexpress.domestic-express", + "carrier_name": "DHL Express", + "service_name": "Domestic Express" + }, + { + "id": "dhlexpress.domestic-express1030am", + "carrier_name": "DHL Express", + "service_name": "Domestic Express 10:30" + }, + { + "id": "dhlexpress.domestic-express9am", + "carrier_name": "DHL Express", + "service_name": "Domestic Express 9:00" + }, + { + "id": "dhlexpress.economy-select", + "carrier_name": "DHL Express", + "service_name": "Economy Select" + }, + { + "id": "dhlexpress.express-easy", + "carrier_name": "DHL Express", + "service_name": "Express Easy" + }, + { + "id": "dhlexpress.express-worldwide", + "carrier_name": "DHL Express", + "service_name": "Express Worldwide" + }, + { + "id": "dhlexpress.express1030am", + "carrier_name": "DHL Express", + "service_name": "Express 10:30" + }, + { + "id": "dhlexpress.express12pm", + "carrier_name": "DHL Express", + "service_name": "Express 12:00" + }, + { + "id": "dhlexpress.express9am", + "carrier_name": "DHL Express", + "service_name": "Express 9:00" + }, + { + "id": "nin.next-day", + "carrier_name": "NIN", + "service_name": "Next Day" + }, + { + "id": "nin.same-day", + "carrier_name": "NIN", + "service_name": "Same Day" + }, + { + "id": "one.standard", + "carrier_name": "ONE Transportation", + "service_name": "Standard" + }, + { + "id": "rollsright.standard", + "carrier_name": "Rollsright", + "service_name": "Standard" + }, + { + "id": "stallion.apc-priority-worldwide", + "carrier_name": "Stallion", + "service_name": "APC Priority Worldwide" + }, + { + "id": "stallion.apc-priority-worldwide-tracked", + "carrier_name": "Stallion", + "service_name": "APC Priority Worldwide Tracked" + }, + { + "id": "stallion.economy-usa", + "carrier_name": "Stallion", + "service_name": "Stallion Economy USA" + }, + { + "id": "stallion.express", + "carrier_name": "Stallion", + "service_name": "Stallion Express" + }, + { + "id": "stallion.usps-express-mail", + "carrier_name": "Stallion", + "service_name": "USPS Express Mail" + }, + { + "id": "stallion.usps-first-class-mail", + "carrier_name": "Stallion", + "service_name": "USPS First Class Mail" + }, + { + "id": "stallion.usps-library-mail", + "carrier_name": "Stallion", + "service_name": "USPS Library Mail" + }, + { + "id": "stallion.usps-media-mail", + "carrier_name": "Stallion", + "service_name": "USPS Media Mail" + }, + { + "id": "stallion.usps-parcel-select-ground", + "carrier_name": "Stallion", + "service_name": "USPS Parcel Select Ground" + }, + { + "id": "stallion.usps-priority-mail", + "carrier_name": "Stallion", + "service_name": "USPS Priority Mail" + }, + { + "id": "stallion.usps-priority-mail-express", + "carrier_name": "Stallion", + "service_name": "USPS Priority Mail Express" + }, + { + "id": "wuPUFbL2xJpG1vd4jHDl0vaXiXZ99WO4.standard", + "carrier_name": "test manager add", + "service_name": "Standard" + }, + { + "id": "apexmotorexpress-258.standard", + "carrier_name": "Apex Motor Express", + "service_name": "Standard" + }, + { + "id": "bettertrucks.ddu", + "carrier_name": "Better Trucks", + "service_name": "DDU" + }, + { + "id": "bettertrucks.express", + "carrier_name": "Better Trucks", + "service_name": "Express" + }, + { + "id": "bettertrucks.next_day", + "carrier_name": "Better Trucks", + "service_name": "Next Day" + }, + { + "id": "bettertrucks.same_day", + "carrier_name": "Better Trucks", + "service_name": "Same Day" + }, + { + "id": "IQ1rjQyWY8EflOBKVyqGM1syqer1O65V.standard", + "carrier_name": "Carrier Ben", + "service_name": "Standard" + }, + { + "id": "kindersley.expedited", + "carrier_name": "Kindersley", + "service_name": "Expedited" + }, + { + "id": "kindersley.intermodal", + "carrier_name": "Kindersley", + "service_name": "Intermodal" + }, + { + "id": "kindersley.standard", + "carrier_name": "Kindersley", + "service_name": "Regular" + }, + { + "id": "speedy.standard", + "carrier_name": "Speedy", + "service_name": "Standard" + }, + { + "id": "vitran.maxx", + "carrier_name": "Vitran", + "service_name": "Maxx" + }, + { + "id": "vitran.priority", + "carrier_name": "Vitran", + "service_name": "Priority" + }, + { + "id": "vitran.regular", + "carrier_name": "Vitran", + "service_name": "Regular" + }, + { + "id": "c5itKPJ6v6s4cmHEhjMDbbp9XD5lKoPR.standard", + "carrier_name": "Bill's Truck Shop", + "service_name": "Standard" + }, + { + "id": "caledoncouriers-294.standard", + "carrier_name": "Caledon Couriers", + "service_name": "Standard" + }, + { + "id": "dayton-freight.standard", + "carrier_name": "Dayton Freight", + "service_name": "Standard" + }, + { + "id": "dj9Lv4FUhkBIG7tdKiWh4n3U2lP2Drc5.standard", + "carrier_name": "testNewCarrierGar", + "service_name": "Standard" + }, + { + "id": "hiway.standard", + "carrier_name": "Hi-Way9", + "service_name": "Standard" + }, + { + "id": "boxknight.next-day", + "carrier_name": "BoxKnight", + "service_name": "Next Day" + }, + { + "id": "boxknight.sameday", + "carrier_name": "BoxKnight", + "service_name": "Same Day" + }, + { + "id": "cct.expedited", + "carrier_name": "CCT", + "service_name": "Expedited" + }, + { + "id": "cct.intermodal", + "carrier_name": "CCT", + "service_name": "Intermodal" + }, + { + "id": "peglobal-511.standard", + "carrier_name": "PE Global", + "service_name": "Standard" + }, + { + "id": "polarisdirect.standard", + "carrier_name": "Polaris", + "service_name": "Direct" + }, + { + "id": "billatransport-203.standard", + "carrier_name": "Billa Transport", + "service_name": "Standard" + }, + { + "id": "purolatorfreight-151.standard", + "carrier_name": "Purolator Freight ", + "service_name": "Standard" + }, + { + "id": "wce.standard", + "carrier_name": "WCE", + "service_name": "Intermodal" + }, + { + "id": "ajWA9sU9dV6U6oSB5GrokBvlzfV2RRf7.standard", + "carrier_name": "Garima-test", + "service_name": "Standard" + }, + { + "id": "c19h151C0I4Sdnp3Mqt0jRLxjTcNtksA.standard", + "carrier_name": "BinduCarrier", + "service_name": "Standard" + }, + { + "id": "FzXhDtSYDgMYP97Zi28GgU4j8QNXBllS.standard", + "carrier_name": "Apex-SPOT", + "service_name": "Standard" + }, + { + "id": "holland.guaranteed-330-pm", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed by 3:30 PM" + }, + { + "id": "holland.guaranteed-9-am", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed by 9:00 AM" + }, + { + "id": "holland.guaranteed-day", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed Day" + }, + { + "id": "holland.guaranteed-hour", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed Hour" + }, + { + "id": "holland.guaranteed-multi-hour", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed Multi Hour" + }, + { + "id": "holland.guaranteed-noon", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed by Noon" + }, + { + "id": "holland.guaranteed-weekend", + "carrier_name": "Holland Freight", + "service_name": "Guaranteed Weekend" + }, + { + "id": "holland.inter-regional", + "carrier_name": "Holland Freight", + "service_name": "Inter-Regional" + }, + { + "id": "holland.interline", + "carrier_name": "Holland Freight", + "service_name": "Interline" + }, + { + "id": "holland.regional", + "carrier_name": "Holland Freight", + "service_name": "Regional" + }, + { + "id": "LfT69HBpfJrjS9wv0tkFVylVxcMwWIVt.standard", + "carrier_name": "test create 2", + "service_name": "Standard" + }, + { + "id": "mopallet.standard", + "carrier_name": "Maritime ", + "service_name": "Pallet Program" + }, + { + "id": "bgxtransportation-361.standard", + "carrier_name": "BGX Transportation", + "service_name": "Standard" + }, + { + "id": "ei8AJgRFI3Xslob8UmFawLq71jhlKyZX.standard", + "carrier_name": "Service Test", + "service_name": "Standard" + }, + { + "id": "vankam.standard", + "carrier_name": "Vankam", + "service_name": "Standard" + }, + { + "id": "AbqB0FuehDpOtTxHzhhEvBs8CRJ44Z2I.standard", + "carrier_name": "Manager Carrier", + "service_name": "Standard" + }, + { + "id": "bbWZeWwm92b0eyQBYnRNT5PUJb7vslCY.standard", + "carrier_name": "1Manager", + "service_name": "Standard" + }, + { + "id": "dhl-ecomm.packet-international", + "carrier_name": "DHL eCommerce", + "service_name": "Package International" + }, + { + "id": "dhl-ecomm.parcel-expedited", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel Expedited" + }, + { + "id": "dhl-ecomm.parcel-expedited-max", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel Expedited Max" + }, + { + "id": "dhl-ecomm.parcel-ground", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel Ground" + }, + { + "id": "dhl-ecomm.parcel-international-direct", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel International Direct" + }, + { + "id": "dhl-ecomm.parcel-international-direct-priority", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel International Direct Priority" + }, + { + "id": "dhl-ecomm.parcel-international-direct-standard", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel International Direct Standard" + }, + { + "id": "dhl-ecomm.parcel-international-standard", + "carrier_name": "DHL eCommerce", + "service_name": "Parcel International Standard" + }, + { + "id": "saia.standard", + "carrier_name": "Saia Motor Freight", + "service_name": "Standard" + }, + { + "id": "Mg5oX7RWPCrENCdFkqaijO3NI0qKLFPt.standard", + "carrier_name": "2garima", + "service_name": "Standard" + }, + { + "id": "moto.standard", + "carrier_name": "Moto Transportation Services Corp", + "service_name": "Standard" + }, + { + "id": "2vlSmNNDnF6OWQFjUTFPlwLpTv0RkgXp.standard", + "carrier_name": "New Carrier1", + "service_name": "Standard" + }, + { + "id": "6D24l95xtm4jFC550GYo0tLEBrjgavVS.standard", + "carrier_name": "Admin Added carrier", + "service_name": "Standard" + }, + { + "id": "ab-courier.canada-1030am", + "carrier_name": "A&B Courier", + "service_name": "Canada 10:30am" + }, + { + "id": "ab-courier.canada-930am", + "carrier_name": "A&B Courier", + "service_name": "Canada 9:30am" + }, + { + "id": "ab-courier.canada-ground", + "carrier_name": "A&B Courier", + "service_name": "Canada Ground" + }, + { + "id": "ab-courier.canada-overnight", + "carrier_name": "A&B Courier", + "service_name": "Canada Overnight" + }, + { + "id": "ab-courier.direct", + "carrier_name": "A&B Courier", + "service_name": "Direct" + }, + { + "id": "ab-courier.four-hour", + "carrier_name": "A&B Courier", + "service_name": "Four Hour" + }, + { + "id": "ab-courier.rush", + "carrier_name": "A&B Courier", + "service_name": "Rush" + }, + { + "id": "ab-courier.sameday", + "carrier_name": "A&B Courier", + "service_name": "Sameday" + }, + { + "id": "ab-courier.usa-ground", + "carrier_name": "A&B Courier", + "service_name": "USA Ground" + }, + { + "id": "daynross.cs", + "carrier_name": "Day & Ross", + "service_name": "CS" + }, + { + "id": "daynross.domestic-standard", + "carrier_name": "Day & Ross", + "service_name": "Domestic Standard" + }, + { + "id": "daynross.transborder-standard", + "carrier_name": "Day & Ross", + "service_name": "Transborder Standard" + }, + { + "id": "dayrossrlc-132.standard", + "carrier_name": "Day & Ross RLC", + "service_name": "Standard" + }, + { + "id": "LtViz90ze09z34gcXmBbnFhSSqvvO6h5.standard", + "carrier_name": "FastfrateTest", + "service_name": "Standard" + }, + { + "id": "B6lmGiW6bT5uYz0ceJwoqduC0QRf51cr.standard", + "carrier_name": "1NewDinesh", + "service_name": "Standard" + }, + { + "id": "fedex.economy", + "carrier_name": "FedEx Freight", + "service_name": "Economy" + }, + { + "id": "fedex.standard", + "carrier_name": "FedEx Freight", + "service_name": "Priority" + }, + { + "id": "VwSa0UuckhcLkEzVoCSkhPJoTygfzeIk.standard", + "carrier_name": "Insurance Testing Carrier", + "service_name": "Standard" + }, + { + "id": "YlhNxO31X2UtvtKauwVLdIo4skgYEtDi.standard", + "carrier_name": "Dino Trucking Inc", + "service_name": "Standard" + }, + { + "id": "anq7q2st2UWtnj2WPWqXtgIgaUa4AZF4.standard", + "carrier_name": "Air lines ", + "service_name": "Standard" + }, + { + "id": "dhlcanada-230.standard", + "carrier_name": "DHL CANADA", + "service_name": "Standard" + }, + { + "id": "fedexexpress-272.standard", + "carrier_name": "FedEx Express", + "service_name": "Standard" + }, + { + "id": "KQfppq3g1UUR3BabBSUvQko4MWDUPnul.standard", + "carrier_name": "FC Carrier", + "service_name": "Standard" + }, + { + "id": "speedytransport-153.standard", + "carrier_name": "Speedy Transport", + "service_name": "Standard" + }, + { + "id": "tstapi.intermodal", + "carrier_name": "TST", + "service_name": "Intermodal" + }, + { + "id": "tstapi.standard", + "carrier_name": "TST", + "service_name": "Standard" + }, + { + "id": "ab-courier-ltl.ltl-direct", + "carrier_name": "A&B Courier", + "service_name": "Direct (Pallet)" + }, + { + "id": "ab-courier-ltl.ltl-rush", + "carrier_name": "A&B Courier", + "service_name": "Rush (Pallet)" + }, + { + "id": "ab-courier-ltl.ltl-sameday", + "carrier_name": "A&B Courier", + "service_name": "Sameday (Pallet)" + }, + { + "id": "accordtransportation-176.standard", + "carrier_name": "Accord Transportation", + "service_name": "Standard" + }, + { + "id": "am0cHEYPS0pZbXDbVXUM6opDv3c4YyxP.standard", + "carrier_name": "testGar", + "service_name": "Standard" + }, + { + "id": "purolatorcourier-401.standard", + "carrier_name": "Purolator Courier", + "service_name": "Standard" + }, + { + "id": "swyft.nextday", + "carrier_name": "Swyft", + "service_name": "Next Day" + }, + { + "id": "swyft.sameday", + "carrier_name": "Swyft", + "service_name": "Same Day" + }, + { + "id": "upscourier-162.standard", + "carrier_name": "UPS Courier", + "service_name": "Standard" + }, + { + "id": "2ya9w4n9GgNbqWlBgKcWro3WYkm0SI2d.standard", + "carrier_name": "SD Carrier", + "service_name": "Standard" + }, + { + "id": "csa.standard", + "carrier_name": "CSA", + "service_name": "Standard" + }, + { + "id": "newpenn.standard", + "carrier_name": "New Penn", + "service_name": "Standard" + }, + { + "id": "spring-gds.spring-direct", + "carrier_name": "Spring GDS", + "service_name": "Spring Direct" + }, + { + "id": "spring-gds.spring-gateway-parcel", + "carrier_name": "Spring GDS", + "service_name": "Spring Gateway Parcel" + }, + { + "id": "spring-gds.spring-packet-plus", + "carrier_name": "Spring GDS", + "service_name": "Spring Packet Plus Registered" + }, + { + "id": "spring-gds.spring-packet-tracked", + "carrier_name": "Spring GDS", + "service_name": "Spring Packet Tracked" + }, + { + "id": "spring-gds.spring-packet-untracked", + "carrier_name": "Spring GDS", + "service_name": "Spring Packet Untracked" + }, + { + "id": "TXbrc3AuAEXSJ9uQnT40gRG0zk41qTml.standard", + "carrier_name": "1Dinesh carrier", + "service_name": "Standard" + }, + { + "id": "6AS1YHCOu0JmUMnb0kEHBAS1blnvdi3C.standard", + "carrier_name": "SushmaCarrier", + "service_name": "Standard" + }, + { + "id": "gls-us.am-select-8a-12p", + "carrier_name": "GLS US", + "service_name": "AM Select 8a-12p" + }, + { + "id": "gls-us.early-priority-overnight", + "carrier_name": "GLS US", + "service_name": "Early Priority Overnight" + }, + { + "id": "gls-us.early-saturday-delivery", + "carrier_name": "GLS US", + "service_name": "Early Saturday Delivery" + }, + { + "id": "gls-us.evening-select-4p-8p", + "carrier_name": "GLS US", + "service_name": "Evening Select 4p-8p" + }, + { + "id": "gls-us.gls-ground", + "carrier_name": "GLS US", + "service_name": "GLS Ground" + }, + { + "id": "gls-us.noon-priority-overnight-sds–saturday-delivery", + "carrier_name": "GLS US", + "service_name": "Noon Priority Overnight SDS – Saturday Delivery" + }, + { + "id": "gls-us.pm-select-12p-4p", + "carrier_name": "GLS US", + "service_name": "PM Select 12p-4p" + }, + { + "id": "gls-us.priority-overnight", + "carrier_name": "GLS US", + "service_name": "Priority Overnight" + }, + { + "id": "gls-us.saturday-delivery", + "carrier_name": "GLS US", + "service_name": "Saturday Delivery" + }, + { + "id": "6XTleMYOSAZrdGo5dkg0AB2FS3E35oMF.standard", + "carrier_name": "Show Demo", + "service_name": "Standard" + }, + { + "id": "abcourier-480.standard", + "carrier_name": "A&B Courier (Manual)", + "service_name": "Standard" + }, + { + "id": "allspeed-432.standard", + "carrier_name": "All Speed", + "service_name": "Standard" + }, + { + "id": "KqwXT5YZbXOvt0PXziMUxkj3J6V1pTsQ.standard", + "carrier_name": "SushmaCarrier", + "service_name": "Standard" + }, + { + "id": "sameday.2-man-delivery-to-entrance", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Entrance - 2 Person" + }, + { + "id": "sameday.2-man-delivery-to-room-of-choice", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Room of Choice - 2 Person" + }, + { + "id": "sameday.2-man-delivery-to-room-of-choice-with-debris-removal", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Two-person delivery to room of choice with debris removal" + }, + { + "id": "sameday.dayr-ecom-urgent-pac", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "eCommerce Urgent Pak" + }, + { + "id": "sameday.delivery-to-entrance", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Entrance" + }, + { + "id": "sameday.delivery-to-room-of-choice", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Room of Choice" + }, + { + "id": "sameday.delivery-to-room-of-choice-with-debris-removal", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Delivery to Room of Choice with Debris Removal" + }, + { + "id": "sameday.ground-daynross-road", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Ground - Road" + }, + { + "id": "sameday.next-day-before-5pm", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Next Day Delivery by 5 PM" + }, + { + "id": "sameday.next-day-before-9am", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Next Day Delivery by 9 AM" + }, + { + "id": "sameday.next-day-delivery-before-noon", + "carrier_name": "Day & Ross Commerce Solutions", + "service_name": "Next Day Delivery Before Noon" + }, + { + "id": "transkid.standard", + "carrier_name": "Transkid", + "service_name": "Standard" + }, + { + "id": "37SyVWjCgJxqehNHTdBaFhz1MQxKK0Vd.standard", + "carrier_name": "2New Spot carrier", + "service_name": "Standard" + }, + { + "id": "atlantistransport-347.standard", + "carrier_name": "Atlantis Transport", + "service_name": "Standard" + }, + { + "id": "excel-transport.standard", + "carrier_name": "Excel Transportation", + "service_name": "Standard" + }, + { + "id": "fleet-optics.standard", + "carrier_name": "Fleet Optics", + "service_name": "Standard" + }, + { + "id": "gardewine.standard", + "carrier_name": "Gardewine", + "service_name": "Standard" + }, + { + "id": "ics.ground", + "carrier_name": "ICS", + "service_name": "Ground" + }, + { + "id": "ics.next-day", + "carrier_name": "ICS", + "service_name": "Next day" + }, + { + "id": "usps.first-class", + "carrier_name": "USPS", + "service_name": "First Class" + }, + { + "id": "usps.ground-advantage", + "carrier_name": "USPS", + "service_name": "Ground Advantage" + }, + { + "id": "usps.parcel-select-ground", + "carrier_name": "USPS", + "service_name": "Parcel Select Ground" + }, + { + "id": "usps.priority-mail", + "carrier_name": "USPS", + "service_name": "Priority Mail" + }, + { + "id": "usps.priority-mail-express", + "carrier_name": "USPS", + "service_name": "Priority Mail Express" + }, + { + "id": "ups.3day-select", + "carrier_name": "UPS", + "service_name": "3 Day Select" + }, + { + "id": "ups.expedited", + "carrier_name": "UPS", + "service_name": "Expedited" + }, + { + "id": "ups.express", + "carrier_name": "UPS", + "service_name": "Express" + }, + { + "id": "ups.express-early", + "carrier_name": "UPS", + "service_name": "Express Early" + }, + { + "id": "ups.express-saver", + "carrier_name": "UPS", + "service_name": "Express Saver" + }, + { + "id": "ups.ground", + "carrier_name": "UPS", + "service_name": "Ground" + }, + { + "id": "ups.standard", + "carrier_name": "UPS", + "service_name": "Standard" + }, + { + "id": "ups.worldwide-expedited", + "carrier_name": "UPS", + "service_name": "Worldwide Expedited" + }, + { + "id": "ups.worldwide-express", + "carrier_name": "UPS", + "service_name": "Worldwide Express" + }, + { + "id": "ups.worldwide-express-plus", + "carrier_name": "UPS", + "service_name": "Worldwide Express Plus" + }, + { + "id": "ups.worldwide-express-saver", + "carrier_name": "UPS", + "service_name": "Worldwide Express Saver" + }, + { + "id": "airpro-255.standard", + "carrier_name": "Air Pro", + "service_name": "Standard" + }, + { + "id": "apex.standard", + "carrier_name": "Apex", + "service_name": "Standard" + }, + { + "id": "frontline.standard", + "carrier_name": "Frontline", + "service_name": "Standard" + }, + { + "id": "nationex.standard", + "carrier_name": "Nationex", + "service_name": "Standard" + }, + { + "id": "qM4cPFVXO20tNUz8fuU2bZCd6s0a6oKE.standard", + "carrier_name": "GL Freight", + "service_name": "Standard" + }, + { + "id": "swiftdeliverysystems-268.standard", + "carrier_name": "Swift Delivery Systems", + "service_name": "Standard" + }, + { + "id": "comox.standard", + "carrier_name": "Comox Pacific Express", + "service_name": "Standard" + }, + { + "id": "h9d2M32kjQDeB0GldPN0AMYvhuEXI45c.standard", + "carrier_name": "New2New carrier ", + "service_name": "Standard" + }, + { + "id": "maritime.dry", + "carrier_name": "Maritime", + "service_name": "Dry" + }, + { + "id": "maritime.frozen", + "carrier_name": "Maritime", + "service_name": "Reefer" + }, + { + "id": "maritime.heat", + "carrier_name": "Maritime", + "service_name": "Heat" + }, + { + "id": "overland.standard", + "carrier_name": "Overland", + "service_name": "Standard" + }, + { + "id": "manitoulintransport-440.standard", + "carrier_name": "Manitoulin Transport", + "service_name": "Standard" + }, + { + "id": "tforcefreight.tforcefreight-guarnteed", + "carrier_name": "TForceFreight", + "service_name": "TForceFreight Guaranteed" + }, + { + "id": "tforcefreight.tforcefreight-ltl", + "carrier_name": "TForceFreight", + "service_name": "TForceFreight LTL" + }, + { + "id": "tforcefreight.tforcefreight-standard", + "carrier_name": "TForceFreight", + "service_name": "TForceFreight Standard" + }, + { + "id": "V44U22d1DwvXrhpvW7UtPrZ4GQQ6x6Hb.standard", + "carrier_name": "11Manager Carriers", + "service_name": "Standard" + }, + { + "id": "yrc.accelerated", + "carrier_name": "YRC", + "service_name": "Accelerated" + }, + { + "id": "yrc.freight-canada-to-us", + "carrier_name": "YRC", + "service_name": "Canada to US" + }, + { + "id": "yrc.freight-dedicated-equipment", + "carrier_name": "YRC", + "service_name": "Dedicated Equipment" + }, + { + "id": "yrc.standard", + "carrier_name": "YRC", + "service_name": "Standard" + }, + { + "id": "yrc.time-critical-by-5pm", + "carrier_name": "YRC", + "service_name": "Critical by 5 PM" + }, + { + "id": "yrc.time-critical-by-afternoon", + "carrier_name": "YRC", + "service_name": "Critical by Afternoon" + }, + { + "id": "yrc.time-critical-fastest-ground", + "carrier_name": "YRC", + "service_name": "Critical Fastest Ground" + }, + { + "id": "yrc.time-critical-hour-window", + "carrier_name": "YRC", + "service_name": "Critical Hour Window" + }, + { + "id": "Zs8TafpKGZ0fx9utJ42E4ZFyLtoRUmzE.standard", + "carrier_name": "BinduTestCarrier", + "service_name": "Standard" + }, + { + "id": "abffreight-455.standard", + "carrier_name": "ABF Freight", + "service_name": "Standard" + }, + { + "id": "dayrosscdn-133.standard", + "carrier_name": "Day & Ross CDN", + "service_name": "Standard" + }, + { + "id": "gMS33dZBLDmtyw0ileP8b0wxytNPUNEe.standard", + "carrier_name": "SPOT Polaris", + "service_name": "Standard" + }, + { + "id": "intelcom.standard", + "carrier_name": "Intelcom", + "service_name": "Standard" + }, + { + "id": "maritimeontario-267.standard", + "carrier_name": "Maritime-Ontario", + "service_name": "Standard" + }, + { + "id": "minimax.standard", + "carrier_name": "Minimax", + "service_name": "Standard" + }, + { + "id": "allmodes-147.standard", + "carrier_name": "All Modes", + "service_name": "Standard" + }, + { + "id": "gls-freight.ground", + "carrier_name": "GLS Freight", + "service_name": "Ground" + }, + { + "id": "kindersley-courier.standard", + "carrier_name": "Kindersley Transport", + "service_name": "Standard" + }, + { + "id": "LfuLpu4OaMgNiVnBFYbNUXxiAyY66z3m.standard", + "carrier_name": "Joshuas super advanced and not sketchy at all spot carrier", + "service_name": "Standard" + }, + { + "id": "midland.econoline", + "carrier_name": "MidLand Transport", + "service_name": "Econo Line" + }, + { + "id": "midland.reefer", + "carrier_name": "MidLand Transport", + "service_name": "Reefer" + }, + { + "id": "midland.standard", + "carrier_name": "MidLand Transport", + "service_name": "Standard" + }, + { + "id": "TKzEkXVCaQIkGU0SqHyix6Lujv1YiCaR.standard", + "carrier_name": "Test carrier", + "service_name": "Standard" + }, + { + "id": "1lFVuiEgI85Be3BmNH9Jc8QKe5DEDVs0.standard", + "carrier_name": "vicky", + "service_name": "Standard" + }, + { + "id": "gY2Ah4O53ACmkb6D75rHLg6eMfzpsIpw.standard", + "carrier_name": "Flex transport", + "service_name": "Standard" + }, + { + "id": "morneau.standard", + "carrier_name": "Morneau Transport", + "service_name": "Standard" + }, + { + "id": "4TBSrW3F8aUzohICK0A0XH2mk25Aipdx.standard", + "carrier_name": "Bill Cartage", + "service_name": "Standard" + }, + { + "id": "nishantransportinc-423.standard", + "carrier_name": "NISHAN TRANSPORT INC.", + "service_name": "Standard" + }, + { + "id": "xpologistics-265.standard", + "carrier_name": "XPO Logistics", + "service_name": "Standard" + }, + { + "id": "Fqrdds8xTJcw2gopMEKjgdNR0jTkxxVm.standard", + "carrier_name": "gartest2Carrier", + "service_name": "Standard" + }, + { + "id": "mBbc7RwNE6CPvx22XiDZ50kdsC2fLNEF.standard", + "carrier_name": "CSS Carrier", + "service_name": "Standard" + }, + { + "id": "courrierplus-494.standard", + "carrier_name": "Courrier Plus", + "service_name": "Standard" + }, + { + "id": "loomis-express.express-0900", + "carrier_name": "Loomis", + "service_name": "Express 9:00" + }, + { + "id": "loomis-express.express-1200", + "carrier_name": "Loomis", + "service_name": "Express 12:00" + }, + { + "id": "loomis-express.express-1800", + "carrier_name": "Loomis", + "service_name": "Express 18:00" + }, + { + "id": "loomis-express.ground", + "carrier_name": "Loomis", + "service_name": "Ground" + }, + { + "id": "purolatorfreight.standard", + "carrier_name": "Purolator Freight", + "service_name": "Standard" + }, + { + "id": "csatransportation-191.standard", + "carrier_name": "CSA Transportation", + "service_name": "Standard" + }, + { + "id": "XiX2uCQlUYTCn4Mi5z3APT4Mi2Xn2x3a.standard", + "carrier_name": "New GLS Freight", + "service_name": "Standard" + }, + { + "id": "fastfrate.express", + "carrier_name": "Fastfrate", + "service_name": "Express" + }, + { + "id": "fastfrate.standard", + "carrier_name": "Fastfrate", + "service_name": "Standard" + }, + { + "id": "martinroytransport-310.standard", + "carrier_name": "Martin Roy Transport", + "service_name": "Standard" + }, + { + "id": "reddaway.guaranteed-3pm", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 3:30 PM" + }, + { + "id": "reddaway.guaranteed-9am", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 9 AM" + }, + { + "id": "reddaway.guaranteed-noon", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 12:00 PM (noon)" + }, + { + "id": "reddaway.guaranteed-weekend", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Weekend" + }, + { + "id": "reddaway.guarenteed-9am", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 9 AM" + }, + { + "id": "reddaway.guarenteed-noon", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Delivery Before 12:00 PM (noon)" + }, + { + "id": "reddaway.interline", + "carrier_name": "Reddaway", + "service_name": "Interline Delivery" + }, + { + "id": "reddaway.multi-hour-window", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Window - Multi-Hour Window" + }, + { + "id": "reddaway.regional-delivery", + "carrier_name": "Reddaway", + "service_name": "Regional Delivery" + }, + { + "id": "reddaway.single-hour-window", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Window - Single-hour Window" + }, + { + "id": "reddaway.single-or-multi-day", + "carrier_name": "Reddaway", + "service_name": "Guaranteed Window - Single or Multi-day Window" + }, + { + "id": "reddaway.standard", + "carrier_name": "Reddaway", + "service_name": "Standard" + }, + { + "id": "xpo.standard", + "carrier_name": "XPO", + "service_name": "Standard" + }, + { + "id": "yrcfreight-330.standard", + "carrier_name": "YRC Freight", + "service_name": "Standard" + }, + { + "id": "amatransinc-251.standard", + "carrier_name": "AMA Trans Inc", + "service_name": "Standard" + }, + { + "id": "canadapost.domestic", + "carrier_name": "Canada Post", + "service_name": "Domestic" + }, + { + "id": "canadapost.expedited-parcel", + "carrier_name": "Canada Post", + "service_name": "Expedited Parcel" + }, + { + "id": "canadapost.expedited-parcel-usa", + "carrier_name": "Canada Post", + "service_name": "Expedited Parcel USA" + }, + { + "id": "canadapost.international", + "carrier_name": "Canada Post", + "service_name": "International" + }, + { + "id": "canadapost.international-parcel-air", + "carrier_name": "Canada Post", + "service_name": "International Parcel Air" + }, + { + "id": "canadapost.international-parcel-surface", + "carrier_name": "Canada Post", + "service_name": "International Parcel Surface" + }, + { + "id": "canadapost.priority", + "carrier_name": "Canada Post", + "service_name": "Priority" + }, + { + "id": "canadapost.priority-ww-envelope-international", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide envelope INT’L" + }, + { + "id": "canadapost.priority-ww-envelope-usa", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide envelope USA" + }, + { + "id": "canadapost.priority-ww-pak-international", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide pak INT’L" + }, + { + "id": "canadapost.priority-ww-pak-usa", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide pak USA" + }, + { + "id": "canadapost.priority-ww-parcel-international", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide parcel INT’L" + }, + { + "id": "canadapost.priority-ww-parcel-usa", + "carrier_name": "Canada Post", + "service_name": "Priority Worldwide parcel USA" + }, + { + "id": "canadapost.regular-parcel", + "carrier_name": "Canada Post", + "service_name": "Regular Parcel" + }, + { + "id": "canadapost.small-packet-international-air", + "carrier_name": "Canada Post", + "service_name": "Small Packet International Air" + }, + { + "id": "canadapost.small-packet-international-surface", + "carrier_name": "Canada Post", + "service_name": "Small Packet International Surface" + }, + { + "id": "canadapost.small-packet-usa-air", + "carrier_name": "Canada Post", + "service_name": "Small Packet USA Air" + }, + { + "id": "canadapost.tracked-packet-international", + "carrier_name": "Canada Post", + "service_name": "Tracked Packet - International" + }, + { + "id": "canadapost.tracked-packet-usa", + "carrier_name": "Canada Post", + "service_name": "Tracked Packet USA" + }, + { + "id": "canadapost.xpresspost", + "carrier_name": "Canada Post", + "service_name": "Xpresspost" + }, + { + "id": "canadapost.xpresspost-international", + "carrier_name": "Canada Post", + "service_name": "Xpresspost International" + }, + { + "id": "canadapost.xpresspost-usa", + "carrier_name": "Canada Post", + "service_name": "Xpresspost USA" + }, + { + "id": "canpar.ground", + "carrier_name": "Canpar", + "service_name": "Ground" + }, + { + "id": "canpar.international", + "carrier_name": "Canpar", + "service_name": "International" + }, + { + "id": "canpar.overnight", + "carrier_name": "Canpar", + "service_name": "Overnight" + }, + { + "id": "canpar.overnight-letter", + "carrier_name": "Canpar", + "service_name": "Overnight Letter" + }, + { + "id": "canpar.overnight-pak", + "carrier_name": "Canpar", + "service_name": "Overnight Pak" + }, + { + "id": "canpar.select", + "carrier_name": "Canpar", + "service_name": "Select" + }, + { + "id": "canpar.select-letter", + "carrier_name": "Canpar", + "service_name": "Select Letter" + }, + { + "id": "canpar.select-pak", + "carrier_name": "Canpar", + "service_name": "Select Pak" + }, + { + "id": "canpar.select-usa", + "carrier_name": "Canpar", + "service_name": "Select U.S.A." + }, + { + "id": "canpar.usa", + "carrier_name": "Canpar", + "service_name": "U.S.A." + }, + { + "id": "canpar.usa-Letter", + "carrier_name": "Canpar", + "service_name": "U.S.A. Letter" + }, + { + "id": "canpar.usa-pak", + "carrier_name": "Canpar", + "service_name": "U.S.A. Pak" + }, + { + "id": "gls.ground", + "carrier_name": "GLS", + "service_name": "Ground" + }, + { + "id": "QzGk6Gz9BPcw0v7zsJcIaTAAXd6X7732.standard", + "carrier_name": "BinduTestCarrier2", + "service_name": "Standard" + }, + { + "id": "w2oXoP88bl44DA3Y4hft8dZoLFDp3KFX.standard", + "carrier_name": "Carrier Sonu", + "service_name": "Standard" + }, + { + "id": "e5966ZlRusUUM61sXUM1QQx0Td17iIan.standard", + "carrier_name": "Dolphin Carrier", + "service_name": "Standard" + }, + { + "id": "polarisweb.standard", + "carrier_name": "Polaris FPP", + "service_name": "Pallet Program" + }, + { + "id": "purolatorcourier.express", + "carrier_name": "Purolator", + "service_name": "Express" + }, + { + "id": "purolatorcourier.express-box", + "carrier_name": "Purolator", + "service_name": "Express Box" + }, + { + "id": "purolatorcourier.express-box-international", + "carrier_name": "Purolator", + "service_name": "Express Box International" + }, + { + "id": "purolatorcourier.express-box1030am", + "carrier_name": "Purolator", + "service_name": "Express Box 10:30 AM" + }, + { + "id": "purolatorcourier.express-box9am", + "carrier_name": "Purolator", + "service_name": "Express Box 9 AM" + }, + { + "id": "purolatorcourier.express-boxUS", + "carrier_name": "Purolator", + "service_name": "Express Box U.S." + }, + { + "id": "purolatorcourier.express-envelope", + "carrier_name": "Purolator", + "service_name": "Express Envelope" + }, + { + "id": "purolatorcourier.express-envelope-international", + "carrier_name": "Purolator", + "service_name": "Express Envelope International" + }, + { + "id": "purolatorcourier.express-envelope-us", + "carrier_name": "Purolator", + "service_name": "Express Envelope U.S." + }, + { + "id": "purolatorcourier.express-envelope1030am", + "carrier_name": "Purolator", + "service_name": "Express Envelope 10:30 AM" + }, + { + "id": "purolatorcourier.express-envelope9am", + "carrier_name": "Purolator", + "service_name": "Express Envelope 9 AM" + }, + { + "id": "purolatorcourier.express-international", + "carrier_name": "Purolator", + "service_name": "Express International" + }, + { + "id": "purolatorcourier.express-pack", + "carrier_name": "Purolator", + "service_name": "Express Pack" + }, + { + "id": "purolatorcourier.express-pack-international", + "carrier_name": "Purolator", + "service_name": "Express Pack International" + }, + { + "id": "purolatorcourier.express-pack-us", + "carrier_name": "Purolator", + "service_name": "Express Pack U.S." + }, + { + "id": "purolatorcourier.express-pack1030am", + "carrier_name": "Purolator", + "service_name": "Express Pack 10:30 AM" + }, + { + "id": "purolatorcourier.express-pack9am", + "carrier_name": "Purolator", + "service_name": "Express Pack 9 AM" + }, + { + "id": "purolatorcourier.express-us", + "carrier_name": "Purolator", + "service_name": "Express U.S." + }, + { + "id": "purolatorcourier.express-us-1030am", + "carrier_name": "Purolator", + "service_name": "Express U.S. 10:30 AM" + }, + { + "id": "purolatorcourier.express-us-9am", + "carrier_name": "Purolator", + "service_name": "Express U.S. 9 AM" + }, + { + "id": "purolatorcourier.express-us-box1030AM", + "carrier_name": "Purolator", + "service_name": "Express U.S. Box 10:30 AM" + }, + { + "id": "purolatorcourier.express-us-box9AM", + "carrier_name": "Purolator", + "service_name": "Express U.S. Box 9 AM" + }, + { + "id": "purolatorcourier.express-us-envelope1030am", + "carrier_name": "Purolator", + "service_name": "Express U.S. Envelope 10:30 AM" + }, + { + "id": "purolatorcourier.express-us-envelope9am", + "carrier_name": "Purolator", + "service_name": "Express U.S. Envelope 9 AM" + }, + { + "id": "purolatorcourier.express-us-pack1030am", + "carrier_name": "Purolator", + "service_name": "Express U.S. Pack 10:30 AM" + }, + { + "id": "purolatorcourier.express-us-pack9am", + "carrier_name": "Purolator", + "service_name": "Express U.S. Pack 9 AM" + }, + { + "id": "purolatorcourier.express1030AM", + "carrier_name": "Purolator", + "service_name": "Express 10:30 AM" + }, + { + "id": "purolatorcourier.express9AM", + "carrier_name": "Purolator", + "service_name": "Express 9 AM" + }, + { + "id": "purolatorcourier.ground", + "carrier_name": "Purolator", + "service_name": "Ground" + }, + { + "id": "purolatorcourier.ground-us", + "carrier_name": "Purolator", + "service_name": "Ground U.S." + }, + { + "id": "purolatorcourier.standard", + "carrier_name": "Purolator", + "service_name": "Standard" + } + ] +} diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/quote.py b/modules/connectors/freightcom/karrio/providers/freightcom/quote.py deleted file mode 100644 index 7704989149..0000000000 --- a/modules/connectors/freightcom/karrio/providers/freightcom/quote.py +++ /dev/null @@ -1,179 +0,0 @@ -from karrio.schemas.freightcom.quote_request import ( - Freightcom, - QuoteRequestType, - FromType, - ToType, - PackagesType, - PackageType, -) -from karrio.schemas.freightcom.quote_reply import QuoteType - -import typing -import karrio.lib as lib -import karrio.core.models as models -import karrio.providers.freightcom.error as provider_error -import karrio.providers.freightcom.units as provider_units -import karrio.providers.freightcom.utils as provider_utils - - -def parse_quote_reply( - _response: lib.Deserializable[lib.Element], settings: provider_utils.Settings -) -> typing.Tuple[typing.List[models.RateDetails], typing.List[models.Message]]: - response = _response.deserialize() - estimates = lib.find_element("Quote", response) - - return ( - [_extract_rate(node, settings) for node in estimates], - provider_error.parse_error_response(response, settings), - ) - - -def _extract_rate( - node: lib.Element, - settings: provider_utils.Settings, -) -> models.RateDetails: - quote = lib.to_object(QuoteType, node) - rate_provider, service, service_name = provider_units.ShippingService.info( - quote.serviceId, - quote.carrierId, - quote.serviceName, - quote.carrierName, - ) - charges = [ - ("Base charge", quote.baseCharge), - ("Fuel surcharge", quote.fuelSurcharge), - *((surcharge.name, surcharge.amount) for surcharge in quote.Surcharge), - ] - - return models.RateDetails( - carrier_name=settings.carrier_name, - carrier_id=settings.carrier_id, - currency=quote.currency, - service=service, - total_charge=lib.to_decimal(quote.totalCharge), - transit_days=quote.transitDays, - extra_charges=[ - models.ChargeDetails( - name=name, - currency="CAD", - amount=lib.to_decimal(amount), - ) - for name, amount in charges - if amount - ], - meta=dict(rate_provider=rate_provider, service_name=service_name), - ) - - -def quote_request( - payload: models.RateRequest, - settings: provider_utils.Settings, -) -> lib.Serializable: - shipper = lib.to_address(payload.shipper) - recipient = lib.to_address(payload.recipient) - packages = lib.to_packages( - payload.parcels, - package_option_type=provider_units.ShippingOption, - required=["weight", "height", "width", "length"], - ) - options = lib.to_shipping_options( - payload.options, - package_options=packages.options, - initializer=provider_units.shipping_options_initializer, - ) - packaging_type = provider_units.FreightPackagingType[ - packages.package_type or "small_box" - ].value - packaging = ( - "Pallet" - if packaging_type in [provider_units.FreightPackagingType.pallet.value] - else "Package" - ) - service = ( - lib.to_services(payload.services, provider_units.ShippingService).first - or provider_units.ShippingService.freightcom_all - ) - - request = Freightcom( - username=settings.username, - password=settings.password, - version="3.1.0", - QuoteRequest=QuoteRequestType( - saturdayPickupRequired=options.freightcom_saturday_pickup_required.state, - homelandSecurity=options.freightcom_homeland_security.state, - pierCharge=None, - exhibitionConventionSite=options.freightcom_exhibition_convention_site.state, - militaryBaseDelivery=options.freightcom_military_base_delivery.state, - customsIn_bondFreight=options.freightcom_customs_in_bond_freight.state, - limitedAccess=options.freightcom_limited_access.state, - excessLength=options.freightcom_excess_length.state, - tailgatePickup=options.freightcom_tailgate_pickup.state, - residentialPickup=options.freightcom_residential_pickup.state, - crossBorderFee=None, - notifyRecipient=options.freightcom_notify_recipient.state, - singleShipment=options.freightcom_single_shipment.state, - tailgateDelivery=options.freightcom_tailgate_delivery.state, - residentialDelivery=options.freightcom_residential_delivery.state, - insuranceType=options.insurance.state is not None, - scheduledShipDate=None, - insideDelivery=options.freightcom_inside_delivery.state, - isSaturdayService=options.freightcom_is_saturday_service.state, - dangerousGoodsType=options.freightcom_dangerous_goods_type.state, - serviceId=service.value, - stackable=options.freightcom_stackable.state, - From=FromType( - id=None, - company=shipper.company_name or " ", - instructions=None, - email=shipper.email, - attention=shipper.person_name, - phone=shipper.phone_number, - tailgateRequired=None, - residential=shipper.residential, - address1=shipper.street, - address2=lib.text(shipper.address_line2), - city=shipper.city, - state=shipper.state_code, - zip=shipper.postal_code, - country=shipper.country_code, - ), - To=ToType( - id=None, - company=recipient.company_name or " ", - notifyRecipient=None, - instructions=None, - email=recipient.email, - attention=recipient.person_name, - phone=recipient.phone_number, - tailgateRequired=None, - residential=recipient.residential, - address1=recipient.street, - address2=lib.text(recipient.address_line2), - city=recipient.city, - state=recipient.state_code, - zip=recipient.postal_code, - country=recipient.country_code, - ), - COD=None, - Packages=PackagesType( - Package=[ - PackageType( - length=provider_utils.ceil(package.length.IN), - width=provider_utils.ceil(package.width.IN), - height=provider_utils.ceil(package.height.IN), - weight=provider_utils.ceil(package.weight.LB), - type_=packaging_type, - freightClass=package.parcel.freight_class, - nmfcCode=None, - insuranceAmount=package.options.insurance.state, - codAmount=package.options.cash_on_delivery.state, - description=package.parcel.description, - ) - for package in packages - ], - type_=packaging, - ), - ), - ) - - return lib.Serializable(request, provider_utils.standard_request_serializer) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/rate.py b/modules/connectors/freightcom/karrio/providers/freightcom/rate.py new file mode 100644 index 0000000000..755f37e485 --- /dev/null +++ b/modules/connectors/freightcom/karrio/providers/freightcom/rate.py @@ -0,0 +1,204 @@ +import karrio.schemas.freightcom.rate_request as freightcom +import karrio.schemas.freightcom.rate_response as rating +import typing +import datetime +import karrio.lib as lib +import karrio.core.models as models +import karrio.providers.freightcom.error as error +import karrio.providers.freightcom.utils as provider_utils +import karrio.providers.freightcom.units as provider_units + + +def parse_rate_response( + _response: lib.Deserializable[dict], + settings: provider_utils.Settings, +) -> typing.Tuple[typing.List[models.RateDetails], typing.List[models.Message]]: + response = _response.deserialize() + + messages = error.parse_error_response(response, settings) + rates = [_extract_details(rate, settings) for rate in response.get("rates", [])] + + return rates, messages + + +def _extract_details( + data: dict, + settings: provider_utils.Settings, +) -> models.RateDetails: + rate = lib.to_object(rating.RateType, data) + + service = provider_units.ShippingService.map( + rate.service_id, + ) + courier = provider_units.ShippingCourier.find(rate.service_id) + + charges = [ + ("Base charge", rate.base.value, rate.base.currency), + *((surcharge.type, surcharge.amount.value, surcharge.amount.currency) for surcharge in rate.surcharges), + *((tax.type, tax.amount.value, tax.amount.currency) for tax in rate.taxes), + ] + + return models.RateDetails( + carrier_id=settings.carrier_id, + carrier_name=settings.carrier_name, + service=service.name_or_key, + total_charge=lib.to_money(int(rate.total.value) / 100), + currency=rate.total.currency, + transit_days=lib.to_int(rate.transit_time_days), + extra_charges=[ + models.ChargeDetails( + name=name, + currency=currency, + amount=lib.to_money(int(amount) / 100), + ) + for name, amount, currency in charges + if charges + ], + meta=dict( + rate_provider=courier.name_or_key, + service_name=service.name_or_key + ) + ) + + +def rate_request( + payload: models.RateRequest, + settings: provider_utils.Settings, +) -> lib.Serializable: + shipper = lib.to_address(payload.shipper) + recipient = lib.to_address(payload.recipient) + packages = lib.to_packages(payload.parcels) + options = lib.to_shipping_options( + payload.options, + package_options=packages.options, + ) + + packaging_type = provider_units.PackagingType.map(packages.package_type or "small_box").value + ship_datetime = lib.to_next_business_datetime( + options.shipping_date.state or datetime.datetime.now(), + current_format="%Y-%m-%dT%H:%M", + ) + + request = freightcom.RateRequestType( + services=[provider_units.ShippingService.map(service).value_or_key for service in payload.services], + excluded_services=[], + details=freightcom.DetailsType( + origin=freightcom.DestinationType( + name=shipper.company_name or shipper.person_name, + address=freightcom.AddressType( + address_line_1=shipper.address_line1, + address_line_2=shipper.address_line2, + city=shipper.city, + region=shipper.state_code, + country=shipper.country_code, + postal_code=shipper.postal_code, + ), + residential=shipper.residential is True, + contact_name=shipper.person_name if shipper.company_name else "", + phone_number=freightcom.PhoneNumberType( + number=shipper.phone_number, + ) if shipper.phone_number else None, + email_addresses=lib.join(shipper.email), + ), + destination=freightcom.DestinationType( + name=recipient.company_name or recipient.person_name, + address=freightcom.AddressType( + address_line_1=recipient.address_line1, + address_line_2=recipient.address_line2, + city=recipient.city, + region=recipient.state_code, + country=recipient.country_code, + postal_code=recipient.postal_code, + ), + residential=recipient.residential is True, + contact_name=recipient.person_name, + phone_number=freightcom.PhoneNumberType( + number=recipient.phone_number + ) if recipient.phone_number else None, + email_addresses=lib.join(recipient.email), + ready_at=freightcom.ReadyType( + hour=ship_datetime.hour, + minute=0 + ), + ready_until=freightcom.ReadyType( + hour=17, + minute=0 + ), + receives_email_updates=options.email_notification.state, + signature_requirement="required" if options.signature_confirmation.state else "not-required" + ), + expected_ship_date=freightcom.ExpectedShipDateType( + year=ship_datetime.year, + month=ship_datetime.month, + day=ship_datetime.day, + ), + packaging_type=packaging_type, + packaging_properties=( + freightcom.PackagingPropertiesType( + pallet_type="ltl" if packaging_type == "pallet" else None, + has_stackable_pallets=options.stackable.state if packaging_type == "pallet" else None, + dangerous_goods=options.dangerous_goods.state, + dangerous_goods_details=freightcom.DangerousGoodsDetailsType( + packaging_group=options.dangerous_goods_group.state, + goods_class=options.dangerous_goods_class.state, + ) if options.dangerous_goods.state else None, + pallets=[ + freightcom.PalletType( + measurements=freightcom.PackageMeasurementsType( + weight=freightcom.WeightType( + unit="kg", + value=parcel.weight.KG + ), + cuboid=freightcom.CuboidType( + unit="cm", + l=parcel.length.CM, + w=parcel.width.CM, + h=parcel.height.CM + ) + ), + description=parcel.description, + freight_class=options.freight_class.state, + ) for parcel in packages + ] if packaging_type == "pallet" else [], + packages=[ + freightcom.PackageType( + measurements=freightcom.PackageMeasurementsType( + weight=freightcom.WeightType( + unit="kg", + value=parcel.weight.KG + ), + cuboid=freightcom.CuboidType( + unit="cm", + l=parcel.length.CM, + w=parcel.width.CM, + h=parcel.height.CM + ) + ), + description=parcel.description, + ) for parcel in packages + ] if packaging_type == "package" else [], + courierpaks=[ + freightcom.CourierpakType( + measurements=freightcom.CourierpakMeasurementsType( + weight=freightcom.WeightType( + unit="kg", + value=parcel.weight.KG + ), + ), + description=parcel.description, + ) for parcel in packages + ] if packaging_type == "courier-pak" else [], + insurance=freightcom.InsuranceType( + type='carrier', + total_cost=freightcom.TotalCostType( + currency=options.currency.state or "CAD", + value=lib.to_int(options.insurance.state) + ) + ) if options.insurance.state else None, + pallet_service_details=freightcom.PalletServiceDetailsType() if packaging_type == "pallet" else None, + ) + ), + reference_codes=[payload.reference] if any(payload.reference or "") else [] + ) + ) + return lib.Serializable(request, lib.to_dict) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/shipment/__init__.py b/modules/connectors/freightcom/karrio/providers/freightcom/shipment/__init__.py new file mode 100644 index 0000000000..9b68164657 --- /dev/null +++ b/modules/connectors/freightcom/karrio/providers/freightcom/shipment/__init__.py @@ -0,0 +1,9 @@ + +from karrio.providers.freightcom.shipment.create import ( + parse_shipment_response, + shipment_request, +) +from karrio.providers.freightcom.shipment.cancel import ( + parse_shipment_cancel_response, + shipment_cancel_request, +) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/shipment/cancel.py b/modules/connectors/freightcom/karrio/providers/freightcom/shipment/cancel.py new file mode 100644 index 0000000000..f30a6a83a2 --- /dev/null +++ b/modules/connectors/freightcom/karrio/providers/freightcom/shipment/cancel.py @@ -0,0 +1,30 @@ + +import typing +import karrio.lib as lib +import karrio.core.models as models +import karrio.providers.freightcom.error as error +import karrio.providers.freightcom.utils as provider_utils + + +def parse_shipment_cancel_response( + _response: lib.Deserializable[dict], + settings: provider_utils.Settings, +) -> typing.Tuple[models.ConfirmationDetails, typing.List[models.Message]]: + response = _response.deserialize() + messages = error.parse_error_response(response, settings) + success = not any(messages) + + confirmation = ( + models.ConfirmationDetails( + carrier_id=settings.carrier_id, + carrier_name=settings.carrier_name, + operation="Cancel Shipment", + success=success, + ) if success else None + ) + + return confirmation, messages + + +def shipment_cancel_request(payload: models.ShipmentCancelRequest, _) -> lib.Serializable: + return lib.Serializable(payload.shipment_identifier) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/shipment/create.py b/modules/connectors/freightcom/karrio/providers/freightcom/shipment/create.py new file mode 100644 index 0000000000..fac7b7932e --- /dev/null +++ b/modules/connectors/freightcom/karrio/providers/freightcom/shipment/create.py @@ -0,0 +1,297 @@ +import karrio.schemas.freightcom.shipping_request as freightcom +import karrio.schemas.freightcom.shipping_response as shipping +import typing +import datetime +import uuid +import karrio.lib as lib +import karrio.core.units as units +import karrio.core.models as models +import karrio.providers.freightcom.error as error +import karrio.providers.freightcom.utils as provider_utils +import karrio.providers.freightcom.units as provider_units + + +def parse_shipment_response( + _response: lib.Deserializable[dict], + settings: provider_utils.Settings, +) -> typing.Tuple[models.ShipmentDetails, typing.List[models.Message]]: + """Parse Freightcom shipping response into Karrio format""" + response = _response.deserialize() + messages = error.parse_error_response(response, settings) + + shipment = _extract_details(response.get("shipment", {}), settings, ctx=_response.ctx) if "shipment" in response else None + return shipment, messages + + +def _extract_details( + data: dict, + settings: provider_utils.Settings, + ctx: dict, +) -> models.ShipmentDetails: + shipment = lib.to_object(shipping.ShipmentType, data) + label_type = "ZPL" if ctx.get("label_type") == "ZPL" else "PDF" + label_url = [_.url for _ in shipment.labels if _.format == label_type.lower() and _.size == "a6" and not _.padded] + label = provider_utils.download_label(label_url[0]) if label_url else None + tracking_numbers = ( + [ + shipment.primary_tracking_number + ] + + [ + tn for tn in shipment.tracking_numbers + if tn != shipment.primary_tracking_number + ] + ) + + rate = shipment.rate + service = provider_units.ShippingService.map( + rate.service_id, + ) + + courier = provider_units.ShippingCourier.find(rate.service_id) + return models.ShipmentDetails( + carrier_id=settings.carrier_id, + carrier_name=settings.carrier_name, + tracking_number=shipment.primary_tracking_number, + shipment_identifier=shipment.id, + label_type=label_type, + docs=models.Documents(label=label), + meta=dict( + + carrier_tracking_link=shipment.tracking_url, + tracking_numbers=tracking_numbers, + rate_provider=courier.name_or_key, + service_name=service.name_or_key, + freightcom_service_id=rate.service_id, + freightcom_unique_id=shipment.unique_id, + ) + ) + + +def shipment_request( + payload: models.ShipmentRequest, + settings: provider_utils.Settings, +) -> lib.Serializable: + shipper = lib.to_address(payload.shipper) + recipient = lib.to_address(payload.recipient) + packages = lib.to_packages(payload.parcels) + options = lib.to_shipping_options( + payload.options, + package_options=packages.options, + initializer=provider_units.shipping_options_initializer, + ) + + packaging_type = provider_units.PackagingType.map( + packages.package_type or "small_box" + ).value + + ship_datetime = lib.to_next_business_datetime( + options.shipping_date.state or datetime.datetime.now(), + current_format="%Y-%m-%dT%H:%M", + ) + + is_intl = shipper.country_code != recipient.country_code + customs = lib.to_customs_info( + payload.customs, + shipper=payload.shipper, + recipient=payload.recipient, + weight_unit=packages.weight_unit, + default_to=( + models.Customs( + commodities=( + packages.items + if any(packages.items) + else [ + models.Commodity( + quantity=1, + sku=f"000{index}", + weight=pkg.weight.value, + weight_unit=pkg.weight_unit.value, + description=pkg.parcel.content, + ) + for index, pkg in enumerate(packages, start=1) + ] + ) + ) + if is_intl + else None + ), + ) + + payment_method_id = settings.payment_method + + if not payment_method_id: + raise Exception("No payment method found need to be set in config") + + request = freightcom.ShippingRequestType( + unique_id=str(uuid.uuid4()), + payment_method_id=payment_method_id, + service_id=provider_units.ShippingService.map(payload.service).value_or_key, + details=freightcom.ShippingRequestDetailsType( + origin=freightcom.DestinationType( + name=shipper.company_name or shipper.person_name, + address=freightcom.AddressType( + address_line_1=shipper.address_line1, + address_line_2=shipper.address_line2, + city=shipper.city, + region=shipper.state_code, + country=shipper.country_code, + postal_code=shipper.postal_code, + ), + residential=shipper.residential is True, + contact_name=shipper.person_name if shipper.company_name else "", + phone_number=freightcom.NumberType( + number=shipper.phone_number + ) if shipper.phone_number else None, + email_addresses=[shipper.email] if shipper.email else [], + ), + destination=freightcom.DestinationType( + name=recipient.company_name or recipient.person_name, + address=freightcom.AddressType( + address_line_1=recipient.address_line1, + address_line_2=recipient.address_line2, + city=recipient.city, + region=recipient.state_code, + country=recipient.country_code, + postal_code=recipient.postal_code, + ), + residential=recipient.residential is True, + contact_name=recipient.person_name, + phone_number=freightcom.NumberType( + number=recipient.phone_number + ) if recipient.phone_number else None, + email_addresses=[recipient.email] if recipient.email else [], + ready_at=freightcom.ReadyType( + hour=ship_datetime.hour, + minute=0 + ), + ready_until=freightcom.ReadyType( + hour=17, + minute=0 + ), + receives_email_updates=options.email_notification.state, + signature_requirement="required" if options.signature_confirmation.state else "not-required" + ), + expected_ship_date=freightcom.DateType( + year=ship_datetime.year, + month=ship_datetime.month, + day=ship_datetime.day, + ), + packaging_type=packaging_type, + packaging_properties=freightcom.PackagingPropertiesType( + pallet_type="ltl" if packaging_type == "pallet" else None, + has_stackable_pallets=options.stackable.state if packaging_type == "pallet" else None, + dangerous_goods=options.dangerous_goods.state, + dangerous_goods_details=freightcom.DangerousGoodsDetailsType( + packaging_group=options.dangerous_goods_group.state, + goods_class=options.dangerous_goods_class.state, + ) if options.dangerous_goods.state else None, + pallets=[ + freightcom.PalletType( + measurements=freightcom.PackageMeasurementsType( + weight=freightcom.WeightType( + unit="kg", + value=parcel.weight.KG + ), + cuboid=freightcom.CuboidType( + unit="cm", + l=parcel.length.CM, + w=parcel.width.CM, + h=parcel.height.CM + ) + ), + description=parcel.description or "N/A", + freight_class=options.freight_class.state, + ) for parcel in packages + ] if packaging_type == "pallet" else [], + packages=[ + freightcom.PackageType( + measurements=freightcom.PackageMeasurementsType( + weight=freightcom.WeightType( + unit="kg", + value=parcel.weight.KG + ), + cuboid=freightcom.CuboidType( + unit="cm", + l=parcel.length.CM, + w=parcel.width.CM, + h=parcel.height.CM + ) + ), + description=parcel.description or "N/A", + ) for parcel in packages + ] if packaging_type == "package" else [], + courierpaks=[ + freightcom.CourierpakType( + measurements=freightcom.CourierpakMeasurementsType( + weight=freightcom.WeightType( + unit="kg", + value=parcel.weight.KG + ), + ), + description=parcel.description or "N/A", + ) for parcel in packages + ] if packaging_type == "courier-pak" else [], + ), + reference_codes=[payload.reference] if payload.reference else [] + ), + customs_invoice=( + freightcom.CustomsInvoiceType( + source="details", + broker=freightcom.BrokerType( + use_carrier=True, + ), + details=freightcom.CustomsInvoiceDetailsType( + products=[ + freightcom.ProductType( + product_name=item.description, + weight=freightcom.WeightType( + unit="kg" if item.weight_unit.upper() == "KG" else "lb", + value=lib.to_decimal(item.weight) + ), + hs_code=item.hs_code, + country_of_origin=item.origin_country, + num_units=item.quantity, + unit_price=freightcom.TotalCostType( + currency=item.value_currency, + value=str(item.value_amount) + ), + description=item.description + ) for item in customs.commodities + ], + tax_recipient=freightcom.TaxRecipientType( + type=provider_units.PaymentType.map( + customs.duty.paid_by + ).value + or "shipper", + name=customs.duty_billing_address.company_name or customs.duty.person_name, + address=freightcom.AddressType( + address_line_1=customs.duty_billing_address.address_line1, + address_line_2=customs.duty_billing_address.address_line2, + city=customs.duty_billing_address.city, + region=customs.duty_billing_address.state_code, + country=customs.duty_billing_address.country_code, + postal_code=customs.duty_billing_address.postal_code, + ), + phone_number=freightcom.NumberType( + number=customs.duty_billing_address.phone_number + ), + reason_for_export=provider_units.CustomsContentType.map( + customs.content_type + ).value, + ) + ) + ) + if customs and customs.commodities + else None + ), + #TODO: validate if we need to do pickup in the ship request + # pickup_details=freightcom.PickupDetailsType( + # + # ) + ) + + return lib.Serializable( + request, + lib.to_dict, + dict(label_type=payload.label_type or "PDF") + ) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/shipping.py b/modules/connectors/freightcom/karrio/providers/freightcom/shipping.py deleted file mode 100644 index d34c0c9408..0000000000 --- a/modules/connectors/freightcom/karrio/providers/freightcom/shipping.py +++ /dev/null @@ -1,294 +0,0 @@ -from karrio.schemas.freightcom.shipping_request import ( - Freightcom, - ShippingRequestType, - FromType, - ToType, - PackagesType, - PackageType, - PaymentType as RequestPaymentType, - CODType, - CODReturnAddressType, - ContactType, - ReferenceType, - CustomsInvoiceType, - ItemType, - BillToType, -) -from karrio.schemas.freightcom.shipping_reply import ( - ShippingReplyType, - QuoteType, -) - -import typing -import karrio.lib as lib -import karrio.core.models as models -import karrio.providers.freightcom.error as provider_error -import karrio.providers.freightcom.units as provider_units -import karrio.providers.freightcom.utils as provider_utils - - -def parse_shipping_reply( - _response: lib.Deserializable[lib.Element], - settings: provider_utils.Settings, -) -> typing.Tuple[models.ShipmentDetails, typing.List[models.Message]]: - response = _response.deserialize() - shipping_node = lib.find_element("ShippingReply", response, first=True) - shipment = ( - _extract_shipment(shipping_node, settings) - if shipping_node is not None - else None - ) - - return shipment, provider_error.parse_error_response(response, settings) - - -def _extract_shipment( - node: lib.Element, - settings: provider_utils.Settings, -) -> models.ShipmentDetails: - shipping = lib.to_object(ShippingReplyType, node) - quote: QuoteType = shipping.Quote or QuoteType() - - tracking_number = getattr( - next(iter(shipping.Package), None), "trackingNumber", None - ) - rate_provider, service, service_name = provider_units.ShippingService.info( - quote.serviceId, quote.carrierId, quote.serviceName, quote.carrierName - ) - invoice = dict(invoice=shipping.CustomsInvoice) if shipping.CustomsInvoice else {} - charges = [ - ("Base charge", quote.baseCharge), - ("Fuel surcharge", quote.fuelSurcharge), - *((surcharge.name, surcharge.amount) for surcharge in quote.Surcharge), - ] - - return models.ShipmentDetails( - carrier_name=settings.carrier_name, - carrier_id=settings.carrier_id, - tracking_number=tracking_number, - shipment_identifier=shipping.Order.id, - selected_rate=( - models.RateDetails( - carrier_name=settings.carrier_name, - carrier_id=settings.carrier_id, - service=service, - currency=quote.currency, - total_charge=lib.to_decimal(quote.totalCharge), - transit_days=quote.transitDays, - extra_charges=[ - models.ChargeDetails( - name=name, - currency="CAD", - amount=lib.to_decimal(amount), - ) - for name, amount in charges - if amount - ], - meta=dict(rate_provider=rate_provider, service_name=service_name), - ) - if shipping.Quote is not None - else None - ), - docs=models.Documents(label=shipping.Labels, **invoice), - meta=dict( - rate_provider=rate_provider, - service_name=service_name, - tracking_url=shipping.TrackingURL, - ), - ) - - -def shipping_request( - payload: models.ShipmentRequest, - settings: provider_utils.Settings, -) -> lib.Serializable: - shipper = lib.to_address(payload.shipper) - recipient = lib.to_address(payload.recipient) - service = provider_units.ShippingService.map(payload.service).value_or_key - packages = lib.to_packages( - payload.parcels, - package_option_type=provider_units.ShippingOption, - required=["weight", "height", "width", "length"], - ) - options = lib.to_shipping_options( - payload.options, - package_options=packages.options, - initializer=provider_units.shipping_options_initializer, - ) - - is_intl = shipper.country_code != recipient.country_code - customs = lib.to_customs_info( - payload.customs, - shipper=payload.shipper, - recipient=payload.recipient, - weight_unit=packages.weight_unit, - default_to=( - models.Customs( - commodities=( - packages.items - if any(packages.items) - else [ - models.Commodity( - quantity=1, - sku=f"000{index}", - weight=pkg.weight.value, - weight_unit=pkg.weight_unit.value, - description=pkg.parcel.content, - ) - for index, pkg in enumerate(packages, start=1) - ] - ) - ) - if is_intl - else None - ), - ) - - packaging_type = provider_units.FreightPackagingType.map( - packages.package_type or "small_box" - ).value - packaging = ( - "Pallet" - if packaging_type in [provider_units.FreightPackagingType.pallet.value] - else "Package" - ) - payment = payload.payment or models.Payment() - payment_type = ( - provider_units.PaymentType[payment.paid_by] if payload.payment else None - ) - - request = Freightcom( - version="3.1.0", - username=settings.username, - password=settings.password, - ShippingRequest=ShippingRequestType( - saturdayPickupRequired=options.freightcom_saturday_pickup_required.state, - homelandSecurity=options.freightcom_homeland_security.state, - pierCharge=None, - exhibitionConventionSite=options.freightcom_exhibition_convention_site.state, - militaryBaseDelivery=options.freightcom_military_base_delivery.state, - customsIn_bondFreight=options.freightcom_customs_in_bond_freight.state, - limitedAccess=options.freightcom_limited_access.state, - excessLength=options.freightcom_excess_length.state, - tailgatePickup=options.freightcom_tailgate_pickup.state, - residentialPickup=options.freightcom_residential_pickup.state, - crossBorderFee=None, - notifyRecipient=options.freightcom_notify_recipient.state, - singleShipment=options.freightcom_single_shipment.state, - tailgateDelivery=options.freightcom_tailgate_delivery.state, - residentialDelivery=options.freightcom_residential_delivery.state, - insuranceType=(options.insurance.state is not None), - scheduledShipDate=None, - insideDelivery=options.freightcom_inside_delivery.state, - isSaturdayService=options.freightcom_is_saturday_service.state, - dangerousGoodsType=options.freightcom_dangerous_goods_type.state, - serviceId=service, - stackable=options.freightcom_stackable.state, - From=FromType( - id=None, - company=shipper.company_name, - instructions=None, - email=shipper.email, - attention=shipper.person_name, - phone=shipper.phone_number, - tailgateRequired=None, - residential=shipper.residential, - address1=shipper.street, - address2=lib.text(shipper.address_line2), - city=shipper.city, - state=shipper.state_code, - zip=shipper.postal_code, - country=shipper.country_code, - ), - To=ToType( - id=None, - company=recipient.company_name, - notifyRecipient=None, - instructions=None, - email=recipient.email, - attention=recipient.person_name, - phone=recipient.phone_number, - tailgateRequired=None, - residential=recipient.residential, - address1=recipient.street, - address2=lib.text(recipient.address_line2), - city=recipient.city, - state=recipient.state_code, - zip=recipient.postal_code, - country=recipient.country_code, - ), - COD=( - CODType( - paymentType=provider_units.PaymentType.recipient.value, - CODReturnAddress=CODReturnAddressType( - codCompany=recipient.company_name, - codName=recipient.person_name, - codAddress1=lib.text(recipient.address_line1), - codCity=recipient.city, - codStateCode=recipient.state_code, - codZip=recipient.postal_code, - codCountry=recipient.country_code, - ), - ) - if options.cash_on_delivery.state is not None - else None - ), - Packages=PackagesType( - Package=[ - PackageType( - length=provider_utils.ceil(package.length.IN), - width=provider_utils.ceil(package.width.IN), - height=provider_utils.ceil(package.height.IN), - weight=provider_utils.ceil(package.weight.LB), - type_=packaging_type, - freightClass=package.parcel.freight_class, - nmfcCode=None, - insuranceAmount=package.options.insurance.state, - codAmount=package.options.cash_on_delivery.state, - description=package.parcel.description, - ) - for package in packages - ], - type_=packaging, - ), - Payment=(RequestPaymentType(type_=payment_type) if payment_type else None), - Reference=( - [ReferenceType(name="REF", code=payload.reference)] - if payload.reference != "" - else None - ), - CustomsInvoice=( - CustomsInvoiceType( - BillTo=BillToType( - company=customs.duty_billing_address.company_name, - name=customs.duty_billing_address.person_name, - address1=customs.duty_billing_address.address_line, - city=customs.duty_billing_address.city, - state=customs.duty_billing_address.state_code, - zip=customs.duty_billing_address.postal_code, - country=customs.duty_billing_address.country_code, - ), - Contact=ContactType( - name=customs.duty_billing_address.person_name, - phone=customs.duty_billing_address.phone_number, - ), - Item=[ - ItemType( - code=(item.hs_code or item.sku or "0000"), - description=lib.text( - item.description or item.title or "item" - ), - originCountry=(item.origin_country or shipper.country_code), - unitPrice=item.value_amount, - quantity=(item.quantity or 1), - ) - for item in customs.commodities - ], - ) - if payload.customs - else None - ), - ), - ) - - return lib.Serializable(request, provider_utils.standard_request_serializer) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/units.py b/modules/connectors/freightcom/karrio/providers/freightcom/units.py index 5b13a7a110..f8892ac073 100644 --- a/modules/connectors/freightcom/karrio/providers/freightcom/units.py +++ b/modules/connectors/freightcom/karrio/providers/freightcom/units.py @@ -1,10 +1,39 @@ -import re +import typing +import pathlib import karrio.lib as lib import karrio.core.units as units +METADATA_JSON = lib.load_json(pathlib.Path(__file__).resolve().parent / "metadata.json") -class FreightPackagingType(lib.StrEnum): - freightcom_pallet = "Pallet" +FREIGHTCOM_CARRIER_METADATA = [_ for _ in METADATA_JSON["PROD_SERVICES"] + METADATA_JSON["DEV_SERVICES"]] + + + +KARRIO_CARRIER_MAPPING = { + "Freightcom": "freightcom", + "ups_courier": "ups", + "canada_post": "canadapost", + 'fed_ex_courier': "fedex", + 'fed_ex_express': "fedex", + 'fed_ex_freight': "fedex", + 'fed_ex_ground': "fedex", + "dhl_canada": "dhl_express", + "dhl_e_commerce": "dhl_express", +} + +class PaymentMethodType(lib.StrEnum): + net_terms = "net-terms" + credit_card = "credit-card" + +class ConnectionConfig(lib.Enum): + """Carrier specific connection configs""" + payment_method_type = lib.OptionEnum("payment_method_type", PaymentMethodType) + shipping_options = lib.OptionEnum("shipping_options", list) + shipping_services = lib.OptionEnum("shipping_services", list) + +class PackagingType(lib.StrEnum): + # TODO: review types + freightcom_pallet = "pallet" freightcom_drum = "Drum" freightcom_boxes = "Boxes" freightcom_rolls = "Rolls" @@ -15,103 +44,44 @@ class FreightPackagingType(lib.StrEnum): freightcom_pails = "Pails" freightcom_reels = "Reels" - freightcom_envelope = "Envelope" - freightcom_courier = "Courier" - freightcom_pak = "Pak" - freightcom_package = "Package" + freightcom_envelope = "envelope" + freightcom_courier = "courier-pak" + freightcom_pak = "courier-pak" + freightcom_package = "package" """ Unified Packaging type mapping """ envelope = freightcom_envelope pak = freightcom_pak tube = freightcom_pipes_tubes pallet = freightcom_pallet - small_box = freightcom_boxes - medium_box = freightcom_boxes - large_box = freightcom_boxes + small_box = freightcom_package + medium_box = freightcom_package your_packaging = freightcom_package + class PaymentType(lib.StrEnum): # TODO:: retrieve the complete list of payment types - check = "Check" - - sender = "Sender" - recipient = "Recipient" - third_party = "Third Party" - credit_card = "Card" - - -class ShippingService(lib.StrEnum): - freightcom_all = "0" - freightcom_usf_holland = "1911" - freightcom_central_transport = "2029" - freightcom_estes = "2107" - freightcom_canpar_ground = "3400" - freightcom_canpar_select = "3404" - freightcom_canpar_overnight = "3407" - freightcom_dicom_ground = "3700" - freightcom_purolator_ground = "4000" - freightcom_purolator_express = "4003" - freightcom_purolator_express_9_am = "4004" - freightcom_purolator_express_10_30_am = "4005" - freightcom_purolator_ground_us = "4016" - freightcom_purolator_express_us = "4015" - freightcom_purolator_express_us_9_am = "4013" - freightcom_purolator_express_us_10_30_am = "4014" - freightcom_fedex_express_saver = "4100" - freightcom_fedex_ground = "4101" - freightcom_fedex_2day = "4102" - freightcom_fedex_priority_overnight = "4104" - freightcom_fedex_standard_overnight = "4105" - freightcom_fedex_first_overnight = "4106" - freightcom_fedex_international_priority = "4108" - freightcom_fedex_international_economy = "4109" - freightcom_ups_standard = "4600" - freightcom_ups_expedited = "4601" - freightcom_ups_express_saver = "4602" - freightcom_ups_express = "4603" - freightcom_ups_express_early = "4604" - freightcom_ups_3day_select = "4605" - freightcom_ups_worldwide_expedited = "4606" - freightcom_ups_worldwide_express = "4607" - freightcom_ups_worldwide_express_plus = "4608" - freightcom_ups_worldwide_express_saver = "4609" - freightcom_dhl_express_easy = "5202" - freightcom_dhl_express_10_30 = "5208" - freightcom_dhl_express_worldwide = "5211" - freightcom_dhl_express_12_00 = "5215" - freightcom_dhl_economy_select = "5216" - freightcom_dhl_ecommerce_am_service = "5706" - freightcom_dhl_ecommerce_ground_service = "5707" - freightcom_canadapost_regular_parcel = "6301" - freightcom_canadapost_expedited_parcel = "6300" - freightcom_canadapost_xpresspost = "6303" - freightcom_canadapost_priority = "6302" - - @classmethod - def info(cls, serviceId, carrierId, serviceName, carrierName): - carrier_name = CARRIER_IDS.get(str(carrierId)) or carrierName - service = cls.map(str(serviceId)) - formatted_name = re.sub( - r"((?<=[a-z])[A-Z]|(? units.Options: + package_options: units.ShippingOptions = None, +) -> units.ShippingOptions: """ Apply default values to the given options. """ - _options = options.copy() if package_options is not None: - _options.update(package_options.content) + options.update(package_options.content) + + def items_filter(key: str) -> bool: + return key in ShippingOption # type: ignore + + return units.ShippingOptions(options, ShippingOption, items_filter=items_filter) + + +def to_carrier_code(service: str) -> str: + _code = lib.to_snake_case(service['carrier_name']) + return KARRIO_CARRIER_MAPPING.get(_code, _code) + +def to_service_code(service: typing.Dict[str, str]) -> str: + return f"freightcom_{to_carrier_code(service)}_{lib.to_slug(service['service_name'])}" + +def find_courier(search: str): + courier: dict = next( + ( + item + for item in FREIGHTCOM_CARRIER_METADATA + if to_carrier_code(item) == search + or item['carrier_name'] == search + or item['id'] == search + ), + {}, + ) + + if courier: + return ShippingCourier.map(to_carrier_code(courier)) + + return ShippingCourier.map(search) + +def get_carrier_name(carrier_id: str) -> str: + return next( + ( + service['carrier_name'] + for service in METADATA_JSON["PROD_SERVICES"] + if service['id'].split('.')[0] == carrier_id + ), + None + ) + +# FREIGHTCOM_SERVICE_METADATA = { +# lib.to_snake_case(service['service_name']): { +# **service, +# 'carrier': service['id'].split('.')[0].split('-')[0], +# 'carrier_name': service['carrier_name'] +# } +# for service in METADATA_JSON["PROD_SERVICES"] + METADATA_JSON["DEV_SERVICES"] +# } + + +ShippingService = lib.StrEnum( + "ShippingService", + { + to_service_code(service): service['id'] + for service in FREIGHTCOM_CARRIER_METADATA + }, +) +ShippingCourier = lib.StrEnum( + "ShippingCourier", + { + to_carrier_code(service): service['carrier_name'] + for service in FREIGHTCOM_CARRIER_METADATA + }, +) +# RateProvider = lib.StrEnum( +# "RateProvider", +# { +# carrier_id: carrier['name'] +# for carrier_id, carrier in FREIGHTCOM_CARRIER_METADATA.items() +# }, +# ) + + +setattr(ShippingCourier, "find", find_courier) - return units.ShippingOptions(_options, ShippingOption) diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/utils.py b/modules/connectors/freightcom/karrio/providers/freightcom/utils.py index 9bd6d449b8..faa8610ec8 100644 --- a/modules/connectors/freightcom/karrio/providers/freightcom/utils.py +++ b/modules/connectors/freightcom/karrio/providers/freightcom/utils.py @@ -1,14 +1,17 @@ -import math +import base64 from typing import Optional +import math + +from karrio.lib import request +from karrio import lib from karrio.core import Settings as BaseSettings -from karrio.core.utils import XP class Settings(BaseSettings): """Freightcom connection settings.""" - username: str - password: str + api_key: str + account_country_code: str = None metadata: dict = {} @@ -17,19 +20,48 @@ class Settings(BaseSettings): @property def server_url(self): return ( - "https://test.freightcom.com/rpc2" + "https://customer-external-api.ssd-test.freightcom.com" if self.test_mode - else "https://app.freightcom.com/rpc2" + else "https://external-api.freightcom.com" ) @property def carrier_name(self): return "freightcom" + @property + def connection_config(self) -> lib.units.Options: + from karrio.providers.freightcom.units import ConnectionConfig + + return lib.to_connection_config( + self.config or {}, + option_type=ConnectionConfig, + ) + + @property + def payment_method(self): + + if not self.connection_config.payment_method_type.state: + raise Exception(f"Payment method type not set") + + cache_key = f"payment|{self.carrier_name}|{self.connection_config.payment_method_type.state}|{self.api_key}" + + payment = self.connection_cache.get(cache_key) or {} + payment_id = payment.get("id") -def standard_request_serializer(element) -> str: - return XP.export( - element, namespacedef_='xmlns="http://www.freightcom.net/XMLSchema"' + if payment_id: + return payment_id + + self.connection_cache.set(cache_key, lambda: get_payment_id(self)) + new_auth = self.connection_cache.get(cache_key) + + return new_auth.get("id") + + +def download_label(file_url: str) -> str: + return request( + decoder=lambda b: base64.encodebytes(b).decode("utf-8"), + url=file_url, ) @@ -37,3 +69,27 @@ def ceil(value: Optional[float]) -> Optional[int]: if value is None: return None return math.ceil(value) + +def get_payment_id(settings: Settings) -> dict: + + try: + from karrio.mappers.freightcom.proxy import Proxy + + proxy = Proxy(settings) + response = proxy._get_payments_methods() + methods = response.deserialize() + + selected_method = next(( + method for method in methods + if settings.connection_config.payment_method_type.type.map( + method.get('type')).name == settings.connection_config.payment_method_type.state + ), None) + + + if not selected_method: + raise Exception(f"Payment method {settings.connection_config.payment_method_type.stat} not found in API") + + return selected_method + + except Exception as e: + raise diff --git a/modules/connectors/freightcom/karrio/providers/freightcom/void_shipment.py b/modules/connectors/freightcom/karrio/providers/freightcom/void_shipment.py deleted file mode 100644 index 1200d25fdc..0000000000 --- a/modules/connectors/freightcom/karrio/providers/freightcom/void_shipment.py +++ /dev/null @@ -1,50 +0,0 @@ -from typing import List, Tuple -from karrio.schemas.freightcom.shipment_cancel_request import ( - ShipmentCancelRequestType, - Freightcom, - OrderType, -) -from karrio.core.models import ShipmentCancelRequest, ConfirmationDetails, Message -from karrio.core.utils import ( - Element, - Serializable, -) -from karrio.providers.freightcom.error import parse_error_response -from karrio.providers.freightcom.utils import Settings, standard_request_serializer -import karrio.lib as lib - - -def parse_shipment_cancel_reply( - _response: lib.Deserializable[Element], - settings: Settings, -) -> Tuple[ConfirmationDetails, List[Message]]: - response = _response.deserialize() - errors = parse_error_response(response, settings) - success = len(errors) == 0 - confirmation: ConfirmationDetails = ( - ConfirmationDetails( - carrier_id=settings.carrier_id, - carrier_name=settings.carrier_name, - success=success, - operation="Cancel Shipment", - ) - if success - else None - ) - - return confirmation, errors - - -def shipment_cancel_request( - payload: ShipmentCancelRequest, settings: Settings -) -> Serializable: - request = Freightcom( - username=settings.username, - password=settings.password, - version="3.1.0", - ShipmentCancelRequest=ShipmentCancelRequestType( - Order=OrderType(orderId=payload.shipment_identifier) - ), - ) - - return Serializable(request, standard_request_serializer) diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/error.py b/modules/connectors/freightcom/karrio/schemas/freightcom/error.py deleted file mode 100644 index 91dd55dbe7..0000000000 --- a/modules/connectors/freightcom/karrio/schemas/freightcom/error.py +++ /dev/null @@ -1,1859 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# -# Generated Fri Oct 21 12:33:21 2022 by generateDS.py version 2.41.1. -# Python 3.10.8 (v3.10.8:aaaf517424, Oct 11 2022, 10:14:40) [Clang 13.0.0 (clang-1300.0.29.30)] -# -# Command line options: -# ('--no-namespace-defs', '') -# ('-o', './karrio.schemas.freightcom/error.py') -# -# Command line arguments: -# ./vendor/schemas/error.xsd -# -# Command line: -# /Users/danielk/Documents/karrio/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio.schemas.freightcom/error.py" ./vendor/schemas/error.xsd -# -# Current working directory (os.getcwd()): -# freightcom -# - -import sys - -try: - ModulenotfoundExp_ = ModuleNotFoundError -except NameError: - ModulenotfoundExp_ = ImportError -from six.moves import zip_longest -import os -import re as re_ -import base64 -import datetime as datetime_ -import decimal as decimal_ -from lxml import etree as etree_ - - -Validate_simpletypes_ = True -SaveElementTreeNode = True -TagNamePrefix = "" -if sys.version_info.major == 2: - BaseStrType_ = basestring -else: - BaseStrType_ = str - - -def parsexml_(infile, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - try: - if isinstance(infile, os.PathLike): - infile = os.path.join(infile) - except AttributeError: - pass - doc = etree_.parse(infile, parser=parser, **kwargs) - return doc - - -def parsexmlstring_(instring, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - element = etree_.fromstring(instring, parser=parser, **kwargs) - return element - - -# -# Namespace prefix definition table (and other attributes, too) -# -# The module generatedsnamespaces, if it is importable, must contain -# a dictionary named GeneratedsNamespaceDefs. This Python dictionary -# should map element type names (strings) to XML schema namespace prefix -# definitions. The export method for any class for which there is -# a namespace prefix definition, will export that definition in the -# XML representation of that element. See the export method of -# any generated element type class for an example of the use of this -# table. -# A sample table is: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceDefs = { -# "ElementtypeA": "http://www.xxx.com/namespaceA", -# "ElementtypeB": "http://www.xxx.com/namespaceB", -# } -# -# Additionally, the generatedsnamespaces module can contain a python -# dictionary named GenerateDSNamespaceTypePrefixes that associates element -# types with the namespace prefixes that are to be added to the -# "xsi:type" attribute value. See the _exportAttributes method of -# any generated element type and the generation of "xsi:type" for an -# example of the use of this table. -# An example table: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceTypePrefixes = { -# "ElementtypeC": "aaa:", -# "ElementtypeD": "bbb:", -# } -# - -try: - from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_ -except ModulenotfoundExp_: - GenerateDSNamespaceDefs_ = {} -try: - from generatedsnamespaces import ( - GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_, - ) -except ModulenotfoundExp_: - GenerateDSNamespaceTypePrefixes_ = {} - -# -# You can replace the following class definition by defining an -# importable module named "generatedscollector" containing a class -# named "GdsCollector". See the default class definition below for -# clues about the possible content of that class. -# -try: - from generatedscollector import GdsCollector as GdsCollector_ -except ModulenotfoundExp_: - - class GdsCollector_(object): - def __init__(self, messages=None): - if messages is None: - self.messages = [] - else: - self.messages = messages - - def add_message(self, msg): - self.messages.append(msg) - - def get_messages(self): - return self.messages - - def clear_messages(self): - self.messages = [] - - def print_messages(self): - for msg in self.messages: - print("Warning: {}".format(msg)) - - def write_messages(self, outstream): - for msg in self.messages: - outstream.write("Warning: {}\n".format(msg)) - - -# -# The super-class for enum types -# - -try: - from enum import Enum -except ModulenotfoundExp_: - Enum = object - -# -# The root super-class for element type classes -# -# Calls to the methods in these classes are generated by generateDS.py. -# You can replace these methods by re-implementing the following class -# in a module named generatedssuper.py. - -try: - from generatedssuper import GeneratedsSuper -except ModulenotfoundExp_ as exp: - try: - from generatedssupersuper import GeneratedsSuperSuper - except ModulenotfoundExp_ as exp: - - class GeneratedsSuperSuper(object): - pass - - class GeneratedsSuper(GeneratedsSuperSuper): - __hash__ = object.__hash__ - tzoff_pattern = re_.compile(r"(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$") - - class _FixedOffsetTZ(datetime_.tzinfo): - def __init__(self, offset, name): - self.__offset = datetime_.timedelta(minutes=offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return None - - def __str__(self): - settings = { - "str_pretty_print": True, - "str_indent_level": 0, - "str_namespaceprefix": "", - "str_name": self.__class__.__name__, - "str_namespacedefs": "", - } - for n in settings: - if hasattr(self, n): - settings[n] = getattr(self, n) - if sys.version_info.major == 2: - from StringIO import StringIO - else: - from io import StringIO - output = StringIO() - self.export( - output, - settings["str_indent_level"], - pretty_print=settings["str_pretty_print"], - namespaceprefix_=settings["str_namespaceprefix"], - name_=settings["str_name"], - namespacedef_=settings["str_namespacedefs"], - ) - strval = output.getvalue() - output.close() - return strval - - def gds_format_string(self, input_data, input_name=""): - return input_data - - def gds_parse_string(self, input_data, node=None, input_name=""): - return input_data - - def gds_validate_string(self, input_data, node=None, input_name=""): - if not input_data: - return "" - else: - return input_data - - def gds_format_base64(self, input_data, input_name=""): - return base64.b64encode(input_data).decode("ascii") - - def gds_validate_base64(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_integer(self, input_data, input_name=""): - return "%d" % int(input_data) - - def gds_parse_integer(self, input_data, node=None, input_name=""): - try: - ival = int(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires integer value: %s" % exp) - return ival - - def gds_validate_integer(self, input_data, node=None, input_name=""): - try: - value = int(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires integer value") - return value - - def gds_format_integer_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_integer_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - int(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of integer values") - return values - - def gds_format_float(self, input_data, input_name=""): - return ("%.15f" % float(input_data)).rstrip("0") - - def gds_parse_float(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires float or double value: %s" % exp) - return fval_ - - def gds_validate_float(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires float value") - return value - - def gds_format_float_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_float_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of float values") - return values - - def gds_format_decimal(self, input_data, input_name=""): - return_value = "%s" % input_data - if "." in return_value: - return_value = return_value.rstrip("0") - if return_value.endswith("."): - return_value = return_value.rstrip(".") - return return_value - - def gds_parse_decimal(self, input_data, node=None, input_name=""): - try: - decimal_value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return decimal_value - - def gds_validate_decimal(self, input_data, node=None, input_name=""): - try: - value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return value - - def gds_format_decimal_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return " ".join([self.gds_format_decimal(item) for item in input_data]) - - def gds_validate_decimal_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - decimal_.Decimal(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of decimal values") - return values - - def gds_format_double(self, input_data, input_name=""): - return "%s" % input_data - - def gds_parse_double(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires double or float value: %s" % exp) - return fval_ - - def gds_validate_double(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires double or float value") - return value - - def gds_format_double_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_double_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error( - node, "Requires sequence of double or float values" - ) - return values - - def gds_format_boolean(self, input_data, input_name=""): - return ("%s" % input_data).lower() - - def gds_parse_boolean(self, input_data, node=None, input_name=""): - input_data = input_data.strip() - if input_data in ("true", "1"): - bval = True - elif input_data in ("false", "0"): - bval = False - else: - raise_parse_error(node, "Requires boolean value") - return bval - - def gds_validate_boolean(self, input_data, node=None, input_name=""): - if input_data not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, "Requires boolean value " "(one of True, 1, False, 0)" - ) - return input_data - - def gds_format_boolean_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_boolean_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - value = self.gds_parse_boolean(value, node, input_name) - if value not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, - "Requires sequence of boolean values " - "(one of True, 1, False, 0)", - ) - return values - - def gds_validate_datetime(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_datetime(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d.%s" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - @classmethod - def gds_parse_datetime(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - time_parts = input_data.split(".") - if len(time_parts) > 1: - micro_seconds = int(float("0." + time_parts[1]) * 1000000) - input_data = "%s.%s" % ( - time_parts[0], - "{}".format(micro_seconds).rjust(6, "0"), - ) - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt - - def gds_validate_date(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_date(self, input_data, input_name=""): - _svalue = "%04d-%02d-%02d" % ( - input_data.year, - input_data.month, - input_data.day, - ) - try: - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - except AttributeError: - pass - return _svalue - - @classmethod - def gds_parse_date(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%d") - dt = dt.replace(tzinfo=tz) - return dt.date() - - def gds_validate_time(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_time(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%02d:%02d:%02d" % ( - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%02d:%02d:%02d.%s" % ( - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - def gds_validate_simple_patterns(self, patterns, target): - # pat is a list of lists of strings/patterns. - # The target value must match at least one of the patterns - # in order for the test to succeed. - found1 = True - target = str(target) - for patterns1 in patterns: - found2 = False - for patterns2 in patterns1: - mo = re_.search(patterns2, target) - if mo is not None and len(mo.group(0)) == len(target): - found2 = True - break - if not found2: - found1 = False - break - return found1 - - @classmethod - def gds_parse_time(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - if len(input_data.split(".")) > 1: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt.time() - - def gds_check_cardinality_( - self, value, input_name, min_occurs=0, max_occurs=1, required=None - ): - if value is None: - length = 0 - elif isinstance(value, list): - length = len(value) - else: - length = 1 - if required is not None: - if required and length < 1: - self.gds_collector_.add_message( - "Required value {}{} is missing".format( - input_name, self.gds_get_node_lineno_() - ) - ) - if length < min_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is below " - "the minimum allowed, " - "expected at least {}, found {}".format( - input_name, self.gds_get_node_lineno_(), min_occurs, length - ) - ) - elif length > max_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is above " - "the maximum allowed, " - "expected at most {}, found {}".format( - input_name, self.gds_get_node_lineno_(), max_occurs, length - ) - ) - - def gds_validate_builtin_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value, input_name=input_name) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_validate_defined_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_str_lower(self, instring): - return instring.lower() - - def get_path_(self, node): - path_list = [] - self.get_path_list_(node, path_list) - path_list.reverse() - path = "/".join(path_list) - return path - - Tag_strip_pattern_ = re_.compile(r"\{.*\}") - - def get_path_list_(self, node, path_list): - if node is None: - return - tag = GeneratedsSuper.Tag_strip_pattern_.sub("", node.tag) - if tag: - path_list.append(tag) - self.get_path_list_(node.getparent(), path_list) - - def get_class_obj_(self, node, default_class=None): - class_obj1 = default_class - if "xsi" in node.nsmap: - classname = node.get("{%s}type" % node.nsmap["xsi"]) - if classname is not None: - names = classname.split(":") - if len(names) == 2: - classname = names[1] - class_obj2 = globals().get(classname) - if class_obj2 is not None: - class_obj1 = class_obj2 - return class_obj1 - - def gds_build_any(self, node, type_name=None): - # provide default value in case option --disable-xml is used. - content = "" - content = etree_.tostring(node, encoding="unicode") - return content - - @classmethod - def gds_reverse_node_mapping(cls, mapping): - return dict(((v, k) for k, v in mapping.items())) - - @staticmethod - def gds_encode(instring): - if sys.version_info.major == 2: - if ExternalEncoding: - encoding = ExternalEncoding - else: - encoding = "utf-8" - return instring.encode(encoding) - else: - return instring - - @staticmethod - def convert_unicode(instring): - if isinstance(instring, str): - result = quote_xml(instring) - elif sys.version_info.major == 2 and isinstance(instring, unicode): - result = quote_xml(instring).encode("utf8") - else: - result = GeneratedsSuper.gds_encode(str(instring)) - return result - - def __eq__(self, other): - def excl_select_objs_(obj): - return obj[0] != "parent_object_" and obj[0] != "gds_collector_" - - if type(self) != type(other): - return False - return all( - x == y - for x, y in zip_longest( - filter(excl_select_objs_, self.__dict__.items()), - filter(excl_select_objs_, other.__dict__.items()), - ) - ) - - def __ne__(self, other): - return not self.__eq__(other) - - # Django ETL transform hooks. - def gds_djo_etl_transform(self): - pass - - def gds_djo_etl_transform_db_obj(self, dbobj): - pass - - # SQLAlchemy ETL transform hooks. - def gds_sqa_etl_transform(self): - return 0, None - - def gds_sqa_etl_transform_db_obj(self, dbobj): - pass - - def gds_get_node_lineno_(self): - if ( - hasattr(self, "gds_elementtree_node_") - and self.gds_elementtree_node_ is not None - ): - return " near line {}".format(self.gds_elementtree_node_.sourceline) - else: - return "" - - def getSubclassFromModule_(module, class_): - """Get the subclass of a class from a specific module.""" - name = class_.__name__ + "Sub" - if hasattr(module, name): - return getattr(module, name) - else: - return None - - -# -# If you have installed IPython you can uncomment and use the following. -# IPython is available from http://ipython.scipy.org/. -# - -## from IPython.Shell import IPShellEmbed -## args = '' -## ipshell = IPShellEmbed(args, -## banner = 'Dropping into IPython', -## exit_msg = 'Leaving Interpreter, back to program.') - -# Then use the following line where and when you want to drop into the -# IPython shell: -# ipshell(' -- Entering ipshell.\nHit Ctrl-D to exit') - -# -# Globals -# - -ExternalEncoding = "" -# Set this to false in order to deactivate during export, the use of -# name space prefixes captured from the input document. -UseCapturedNS_ = True -CapturedNsmap_ = {} -Tag_pattern_ = re_.compile(r"({.*})?(.*)") -String_cleanup_pat_ = re_.compile(r"[\n\r\s]+") -Namespace_extract_pat_ = re_.compile(r"{(.*)}(.*)") -CDATA_pattern_ = re_.compile(r"", re_.DOTALL) - -# Change this to redirect the generated superclass module to use a -# specific subclass module. -CurrentSubclassModule_ = None - -# -# Support/utility functions. -# - - -def showIndent(outfile, level, pretty_print=True): - if pretty_print: - for idx in range(level): - outfile.write(" ") - - -def quote_xml(inStr): - "Escape markup chars, but do not modify CDATA sections." - if not inStr: - return "" - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s2 = "" - pos = 0 - matchobjects = CDATA_pattern_.finditer(s1) - for mo in matchobjects: - s3 = s1[pos : mo.start()] - s2 += quote_xml_aux(s3) - s2 += s1[mo.start() : mo.end()] - pos = mo.end() - s3 = s1[pos:] - s2 += quote_xml_aux(s3) - return s2 - - -def quote_xml_aux(inStr): - s1 = inStr.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - return s1 - - -def quote_attrib(inStr): - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s1 = s1.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - s1 = s1.replace("\n", " ") - if '"' in s1: - if "'" in s1: - s1 = '"%s"' % s1.replace('"', """) - else: - s1 = "'%s'" % s1 - else: - s1 = '"%s"' % s1 - return s1 - - -def quote_python(inStr): - s1 = inStr - if s1.find("'") == -1: - if s1.find("\n") == -1: - return "'%s'" % s1 - else: - return "'''%s'''" % s1 - else: - if s1.find('"') != -1: - s1 = s1.replace('"', '\\"') - if s1.find("\n") == -1: - return '"%s"' % s1 - else: - return '"""%s"""' % s1 - - -def get_all_text_(node): - if node.text is not None: - text = node.text - else: - text = "" - for child in node: - if child.tail is not None: - text += child.tail - return text - - -def find_attr_value_(attr_name, node): - attrs = node.attrib - attr_parts = attr_name.split(":") - value = None - if len(attr_parts) == 1: - value = attrs.get(attr_name) - elif len(attr_parts) == 2: - prefix, name = attr_parts - if prefix == "xml": - namespace = "http://www.w3.org/XML/1998/namespace" - else: - namespace = node.nsmap.get(prefix) - if namespace is not None: - value = attrs.get( - "{%s}%s" - % ( - namespace, - name, - ) - ) - return value - - -def encode_str_2_3(instr): - return instr - - -class GDSParseError(Exception): - pass - - -def raise_parse_error(node, msg): - if node is not None: - msg = "%s (element %s/line %d)" % ( - msg, - node.tag, - node.sourceline, - ) - raise GDSParseError(msg) - - -class MixedContainer: - # Constants for category: - CategoryNone = 0 - CategoryText = 1 - CategorySimple = 2 - CategoryComplex = 3 - # Constants for content_type: - TypeNone = 0 - TypeText = 1 - TypeString = 2 - TypeInteger = 3 - TypeFloat = 4 - TypeDecimal = 5 - TypeDouble = 6 - TypeBoolean = 7 - TypeBase64 = 8 - - def __init__(self, category, content_type, name, value): - self.category = category - self.content_type = content_type - self.name = name - self.value = value - - def getCategory(self): - return self.category - - def getContenttype(self, content_type): - return self.content_type - - def getValue(self): - return self.value - - def getName(self): - return self.name - - def export(self, outfile, level, name, namespace, pretty_print=True): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - outfile.write(self.value) - elif self.category == MixedContainer.CategorySimple: - self.exportSimple(outfile, level, name) - else: # category == MixedContainer.CategoryComplex - self.value.export( - outfile, level, namespace, name_=name, pretty_print=pretty_print - ) - - def exportSimple(self, outfile, level, name): - if self.content_type == MixedContainer.TypeString: - outfile.write("<%s>%s" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - outfile.write("<%s>%d" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - outfile.write("<%s>%f" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeDouble: - outfile.write("<%s>%g" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeBase64: - outfile.write( - "<%s>%s" % (self.name, base64.b64encode(self.value), self.name) - ) - - def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - if len(element) > 0: - if element[-1].tail is None: - element[-1].tail = self.value - else: - element[-1].tail += self.value - else: - if element.text is None: - element.text = self.value - else: - element.text += self.value - elif self.category == MixedContainer.CategorySimple: - subelement = etree_.SubElement(element, "%s" % self.name) - subelement.text = self.to_etree_simple() - else: # category == MixedContainer.CategoryComplex - self.value.to_etree(element) - - def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.content_type == MixedContainer.TypeString: - text = self.value - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - text = "%d" % self.value - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - text = "%f" % self.value - elif self.content_type == MixedContainer.TypeDouble: - text = "%g" % self.value - elif self.content_type == MixedContainer.TypeBase64: - text = "%s" % base64.b64encode(self.value) - return text - - def exportLiteral(self, outfile, level, name): - if self.category == MixedContainer.CategoryText: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - elif self.category == MixedContainer.CategorySimple: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - else: # category == MixedContainer.CategoryComplex - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s",\n' - % ( - self.category, - self.content_type, - self.name, - ) - ) - self.value.exportLiteral(outfile, level + 1) - showIndent(outfile, level) - outfile.write(")\n") - - -class MemberSpec_(object): - def __init__( - self, - name="", - data_type="", - container=0, - optional=0, - child_attrs=None, - choice=None, - ): - self.name = name - self.data_type = data_type - self.container = container - self.child_attrs = child_attrs - self.choice = choice - self.optional = optional - - def set_name(self, name): - self.name = name - - def get_name(self): - return self.name - - def set_data_type(self, data_type): - self.data_type = data_type - - def get_data_type_chain(self): - return self.data_type - - def get_data_type(self): - if isinstance(self.data_type, list): - if len(self.data_type) > 0: - return self.data_type[-1] - else: - return "xs:string" - else: - return self.data_type - - def set_container(self, container): - self.container = container - - def get_container(self): - return self.container - - def set_child_attrs(self, child_attrs): - self.child_attrs = child_attrs - - def get_child_attrs(self): - return self.child_attrs - - def set_choice(self, choice): - self.choice = choice - - def get_choice(self): - return self.choice - - def set_optional(self, optional): - self.optional = optional - - def get_optional(self): - return self.optional - - -def _cast(typ, value): - if typ is None or value is None: - return value - return typ(value) - - -# -# Data representation classes. -# - - -class Freightcom(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, version=None, ErrorReply=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.version = _cast(None, version) - self.version_nsprefix_ = None - self.ErrorReply = ErrorReply - self.ErrorReply_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, Freightcom) - if subclass is not None: - return subclass(*args_, **kwargs_) - if Freightcom.subclass: - return Freightcom.subclass(*args_, **kwargs_) - else: - return Freightcom(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_ErrorReply(self): - return self.ErrorReply - - def set_ErrorReply(self, ErrorReply): - self.ErrorReply = ErrorReply - - def get_version(self): - return self.version - - def set_version(self, version): - self.version = version - - def _hasContent(self): - if self.ErrorReply is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("Freightcom") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "Freightcom": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="Freightcom" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="Freightcom", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="Freightcom" - ): - if self.version is not None and "version" not in already_processed: - already_processed.add("version") - outfile.write( - " version=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.version), input_name="version" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.ErrorReply is not None: - namespaceprefix_ = ( - self.ErrorReply_nsprefix_ + ":" - if (UseCapturedNS_ and self.ErrorReply_nsprefix_) - else "" - ) - self.ErrorReply.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="ErrorReply", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("version", node) - if value is not None and "version" not in already_processed: - already_processed.add("version") - self.version = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "ErrorReply": - obj_ = ErrorReplyType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.ErrorReply = obj_ - obj_.original_tagname_ = "ErrorReply" - - -# end class Freightcom - - -class ErrorReplyType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, Error=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.Error = Error - self.Error_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ErrorReplyType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ErrorReplyType.subclass: - return ErrorReplyType.subclass(*args_, **kwargs_) - else: - return ErrorReplyType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Error(self): - return self.Error - - def set_Error(self, Error): - self.Error = Error - - def _hasContent(self): - if self.Error is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ErrorReplyType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ErrorReplyType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ErrorReplyType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="ErrorReplyType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ErrorReplyType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="ErrorReplyType", - ): - pass - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ErrorReplyType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.Error is not None: - namespaceprefix_ = ( - self.Error_nsprefix_ + ":" - if (UseCapturedNS_ and self.Error_nsprefix_) - else "" - ) - self.Error.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Error", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - pass - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Error": - obj_ = ErrorType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Error = obj_ - obj_.original_tagname_ = "Error" - - -# end class ErrorReplyType - - -class ErrorType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, Message=None, valueOf_=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.Message = _cast(None, Message) - self.Message_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ErrorType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ErrorType.subclass: - return ErrorType.subclass(*args_, **kwargs_) - else: - return ErrorType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Message(self): - return self.Message - - def set_Message(self, Message): - self.Message = Message - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ErrorType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ErrorType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ErrorType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="ErrorType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ErrorType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="ErrorType" - ): - if self.Message is not None and "Message" not in already_processed: - already_processed.add("Message") - outfile.write( - " Message=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.Message), input_name="Message" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ErrorType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("Message", node) - if value is not None and "Message" not in already_processed: - already_processed.add("Message") - self.Message = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class ErrorType - - -GDSClassesMapping = {} - - -USAGE_TEXT = """ -Usage: python .py [ -s ] -""" - - -def usage(): - print(USAGE_TEXT) - sys.exit(1) - - -def get_root_tag(node): - tag = Tag_pattern_.match(node.tag).groups()[-1] - prefix_tag = TagNamePrefix + tag - rootClass = GDSClassesMapping.get(prefix_tag) - if rootClass is None: - rootClass = globals().get(prefix_tag) - return tag, rootClass - - -def get_required_ns_prefix_defs(rootNode): - """Get all name space prefix definitions required in this XML doc. - Return a dictionary of definitions and a char string of definitions. - """ - nsmap = { - prefix: uri - for node in rootNode.iter() - for (prefix, uri) in node.nsmap.items() - if prefix is not None - } - namespacedefs = " ".join( - ['xmlns:{}="{}"'.format(prefix, uri) for prefix, uri in nsmap.items()] - ) - return nsmap, namespacedefs - - -def parse(inFileName, silence=False, print_warnings=True): - global CapturedNsmap_ - gds_collector = GdsCollector_() - parser = None - doc = parsexml_(inFileName, parser) - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode) - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export( - sys.stdout, 0, name_=rootTag, namespacedef_=namespacedefs, pretty_print=True - ) - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseEtree( - inFileName, - silence=False, - print_warnings=True, - mapping=None, - reverse_mapping=None, - nsmap=None, -): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if mapping is None: - mapping = {} - if reverse_mapping is None: - reverse_mapping = {} - rootElement = rootObj.to_etree( - None, - name_=rootTag, - mapping_=mapping, - reverse_mapping_=reverse_mapping, - nsmap_=nsmap, - ) - reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - content = etree_.tostring( - rootElement, pretty_print=True, xml_declaration=True, encoding="utf-8" - ) - sys.stdout.write(str(content)) - sys.stdout.write("\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj, rootElement, mapping, reverse_node_mapping - - -def parseString(inString, silence=False, print_warnings=True): - """Parse a string, create the object tree, and export it. - - Arguments: - - inString -- A string. This XML fragment should not start - with an XML declaration containing an encoding. - - silence -- A boolean. If False, export the object. - Returns -- The root object in the tree. - """ - parser = None - rootNode = parsexmlstring_(inString, parser) - gds_collector = GdsCollector_() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if not SaveElementTreeNode: - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export(sys.stdout, 0, name_=rootTag, namespacedef_="") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseLiteral(inFileName, silence=False, print_warnings=True): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write("#from error import *\n\n") - sys.stdout.write("import error as model_\n\n") - sys.stdout.write("rootObj = model_.rootClass(\n") - rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) - sys.stdout.write(")\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def main(): - args = sys.argv[1:] - if len(args) == 1: - parse(args[0]) - else: - usage() - - -if __name__ == "__main__": - # import pdb; pdb.set_trace() - main() - -RenameMappings_ = {} - -# -# Mapping of namespaces to types defined in them -# and the file in which each is defined. -# simpleTypes are marked "ST" and complexTypes "CT". -NamespaceToDefMappings_ = {"http://www.freightcom.net/xml/XMLSchema": []} - -__all__ = ["ErrorReplyType", "ErrorType", "Freightcom"] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/error_response.py b/modules/connectors/freightcom/karrio/schemas/freightcom/error_response.py new file mode 100644 index 0000000000..bdfac46fff --- /dev/null +++ b/modules/connectors/freightcom/karrio/schemas/freightcom/error_response.py @@ -0,0 +1,14 @@ +from attr import s +from typing import Optional +from jstruct import JStruct + + +@s(auto_attribs=True) +class DataType: + services: Optional[str] = None + + +@s(auto_attribs=True) +class ErrorResponseType: + message: Optional[str] = None + data: Optional[DataType] = JStruct[DataType] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/pickup_request.py b/modules/connectors/freightcom/karrio/schemas/freightcom/pickup_request.py new file mode 100644 index 0000000000..8b059a5901 --- /dev/null +++ b/modules/connectors/freightcom/karrio/schemas/freightcom/pickup_request.py @@ -0,0 +1,46 @@ +from attr import s +from typing import Optional +from jstruct import JStruct + + +@s(auto_attribs=True) +class DateType: + year: Optional[int] = None + month: Optional[int] = None + day: Optional[int] = None + + +@s(auto_attribs=True) +class ReadyType: + hour: Optional[int] = None + minute: Optional[int] = None + + +@s(auto_attribs=True) +class DispatchDetailsType: + date: Optional[DateType] = JStruct[DateType] + ready_at: Optional[ReadyType] = JStruct[ReadyType] + ready_until: Optional[ReadyType] = JStruct[ReadyType] + + +@s(auto_attribs=True) +class ContactPhoneNumberType: + number: Optional[str] = None + extension: Optional[int] = None + + +@s(auto_attribs=True) +class PickupDetailsType: + pre_scheduled_pickup: Optional[bool] = None + date: Optional[DateType] = JStruct[DateType] + ready_at: Optional[ReadyType] = JStruct[ReadyType] + ready_until: Optional[ReadyType] = JStruct[ReadyType] + pickup_location: Optional[str] = None + contact_name: Optional[str] = None + contact_phone_number: Optional[ContactPhoneNumberType] = JStruct[ContactPhoneNumberType] + + +@s(auto_attribs=True) +class PickupRequestType: + pickup_details: Optional[PickupDetailsType] = JStruct[PickupDetailsType] + dispatch_details: Optional[DispatchDetailsType] = JStruct[DispatchDetailsType] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/quote_reply.py b/modules/connectors/freightcom/karrio/schemas/freightcom/quote_reply.py deleted file mode 100644 index d7448ed712..0000000000 --- a/modules/connectors/freightcom/karrio/schemas/freightcom/quote_reply.py +++ /dev/null @@ -1,2555 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# -# Generated Fri Oct 21 12:33:20 2022 by generateDS.py version 2.41.1. -# Python 3.10.8 (v3.10.8:aaaf517424, Oct 11 2022, 10:14:40) [Clang 13.0.0 (clang-1300.0.29.30)] -# -# Command line options: -# ('--no-namespace-defs', '') -# ('-o', './karrio.schemas.freightcom/quote_reply.py') -# -# Command line arguments: -# ./vendor/schemas/quote_reply.xsd -# -# Command line: -# /Users/danielk/Documents/karrio/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio.schemas.freightcom/quote_reply.py" ./vendor/schemas/quote_reply.xsd -# -# Current working directory (os.getcwd()): -# freightcom -# - -import sys - -try: - ModulenotfoundExp_ = ModuleNotFoundError -except NameError: - ModulenotfoundExp_ = ImportError -from six.moves import zip_longest -import os -import re as re_ -import base64 -import datetime as datetime_ -import decimal as decimal_ -from lxml import etree as etree_ - - -Validate_simpletypes_ = True -SaveElementTreeNode = True -TagNamePrefix = "" -if sys.version_info.major == 2: - BaseStrType_ = basestring -else: - BaseStrType_ = str - - -def parsexml_(infile, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - try: - if isinstance(infile, os.PathLike): - infile = os.path.join(infile) - except AttributeError: - pass - doc = etree_.parse(infile, parser=parser, **kwargs) - return doc - - -def parsexmlstring_(instring, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - element = etree_.fromstring(instring, parser=parser, **kwargs) - return element - - -# -# Namespace prefix definition table (and other attributes, too) -# -# The module generatedsnamespaces, if it is importable, must contain -# a dictionary named GeneratedsNamespaceDefs. This Python dictionary -# should map element type names (strings) to XML schema namespace prefix -# definitions. The export method for any class for which there is -# a namespace prefix definition, will export that definition in the -# XML representation of that element. See the export method of -# any generated element type class for an example of the use of this -# table. -# A sample table is: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceDefs = { -# "ElementtypeA": "http://www.xxx.com/namespaceA", -# "ElementtypeB": "http://www.xxx.com/namespaceB", -# } -# -# Additionally, the generatedsnamespaces module can contain a python -# dictionary named GenerateDSNamespaceTypePrefixes that associates element -# types with the namespace prefixes that are to be added to the -# "xsi:type" attribute value. See the _exportAttributes method of -# any generated element type and the generation of "xsi:type" for an -# example of the use of this table. -# An example table: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceTypePrefixes = { -# "ElementtypeC": "aaa:", -# "ElementtypeD": "bbb:", -# } -# - -try: - from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_ -except ModulenotfoundExp_: - GenerateDSNamespaceDefs_ = {} -try: - from generatedsnamespaces import ( - GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_, - ) -except ModulenotfoundExp_: - GenerateDSNamespaceTypePrefixes_ = {} - -# -# You can replace the following class definition by defining an -# importable module named "generatedscollector" containing a class -# named "GdsCollector". See the default class definition below for -# clues about the possible content of that class. -# -try: - from generatedscollector import GdsCollector as GdsCollector_ -except ModulenotfoundExp_: - - class GdsCollector_(object): - def __init__(self, messages=None): - if messages is None: - self.messages = [] - else: - self.messages = messages - - def add_message(self, msg): - self.messages.append(msg) - - def get_messages(self): - return self.messages - - def clear_messages(self): - self.messages = [] - - def print_messages(self): - for msg in self.messages: - print("Warning: {}".format(msg)) - - def write_messages(self, outstream): - for msg in self.messages: - outstream.write("Warning: {}\n".format(msg)) - - -# -# The super-class for enum types -# - -try: - from enum import Enum -except ModulenotfoundExp_: - Enum = object - -# -# The root super-class for element type classes -# -# Calls to the methods in these classes are generated by generateDS.py. -# You can replace these methods by re-implementing the following class -# in a module named generatedssuper.py. - -try: - from generatedssuper import GeneratedsSuper -except ModulenotfoundExp_ as exp: - try: - from generatedssupersuper import GeneratedsSuperSuper - except ModulenotfoundExp_ as exp: - - class GeneratedsSuperSuper(object): - pass - - class GeneratedsSuper(GeneratedsSuperSuper): - __hash__ = object.__hash__ - tzoff_pattern = re_.compile(r"(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$") - - class _FixedOffsetTZ(datetime_.tzinfo): - def __init__(self, offset, name): - self.__offset = datetime_.timedelta(minutes=offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return None - - def __str__(self): - settings = { - "str_pretty_print": True, - "str_indent_level": 0, - "str_namespaceprefix": "", - "str_name": self.__class__.__name__, - "str_namespacedefs": "", - } - for n in settings: - if hasattr(self, n): - settings[n] = getattr(self, n) - if sys.version_info.major == 2: - from StringIO import StringIO - else: - from io import StringIO - output = StringIO() - self.export( - output, - settings["str_indent_level"], - pretty_print=settings["str_pretty_print"], - namespaceprefix_=settings["str_namespaceprefix"], - name_=settings["str_name"], - namespacedef_=settings["str_namespacedefs"], - ) - strval = output.getvalue() - output.close() - return strval - - def gds_format_string(self, input_data, input_name=""): - return input_data - - def gds_parse_string(self, input_data, node=None, input_name=""): - return input_data - - def gds_validate_string(self, input_data, node=None, input_name=""): - if not input_data: - return "" - else: - return input_data - - def gds_format_base64(self, input_data, input_name=""): - return base64.b64encode(input_data).decode("ascii") - - def gds_validate_base64(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_integer(self, input_data, input_name=""): - return "%d" % int(input_data) - - def gds_parse_integer(self, input_data, node=None, input_name=""): - try: - ival = int(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires integer value: %s" % exp) - return ival - - def gds_validate_integer(self, input_data, node=None, input_name=""): - try: - value = int(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires integer value") - return value - - def gds_format_integer_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_integer_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - int(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of integer values") - return values - - def gds_format_float(self, input_data, input_name=""): - return ("%.15f" % float(input_data)).rstrip("0") - - def gds_parse_float(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires float or double value: %s" % exp) - return fval_ - - def gds_validate_float(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires float value") - return value - - def gds_format_float_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_float_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of float values") - return values - - def gds_format_decimal(self, input_data, input_name=""): - return_value = "%s" % input_data - if "." in return_value: - return_value = return_value.rstrip("0") - if return_value.endswith("."): - return_value = return_value.rstrip(".") - return return_value - - def gds_parse_decimal(self, input_data, node=None, input_name=""): - try: - decimal_value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return decimal_value - - def gds_validate_decimal(self, input_data, node=None, input_name=""): - try: - value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return value - - def gds_format_decimal_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return " ".join([self.gds_format_decimal(item) for item in input_data]) - - def gds_validate_decimal_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - decimal_.Decimal(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of decimal values") - return values - - def gds_format_double(self, input_data, input_name=""): - return "%s" % input_data - - def gds_parse_double(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires double or float value: %s" % exp) - return fval_ - - def gds_validate_double(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires double or float value") - return value - - def gds_format_double_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_double_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error( - node, "Requires sequence of double or float values" - ) - return values - - def gds_format_boolean(self, input_data, input_name=""): - return ("%s" % input_data).lower() - - def gds_parse_boolean(self, input_data, node=None, input_name=""): - input_data = input_data.strip() - if input_data in ("true", "1"): - bval = True - elif input_data in ("false", "0"): - bval = False - else: - raise_parse_error(node, "Requires boolean value") - return bval - - def gds_validate_boolean(self, input_data, node=None, input_name=""): - if input_data not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, "Requires boolean value " "(one of True, 1, False, 0)" - ) - return input_data - - def gds_format_boolean_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_boolean_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - value = self.gds_parse_boolean(value, node, input_name) - if value not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, - "Requires sequence of boolean values " - "(one of True, 1, False, 0)", - ) - return values - - def gds_validate_datetime(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_datetime(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d.%s" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - @classmethod - def gds_parse_datetime(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - time_parts = input_data.split(".") - if len(time_parts) > 1: - micro_seconds = int(float("0." + time_parts[1]) * 1000000) - input_data = "%s.%s" % ( - time_parts[0], - "{}".format(micro_seconds).rjust(6, "0"), - ) - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt - - def gds_validate_date(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_date(self, input_data, input_name=""): - _svalue = "%04d-%02d-%02d" % ( - input_data.year, - input_data.month, - input_data.day, - ) - try: - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - except AttributeError: - pass - return _svalue - - @classmethod - def gds_parse_date(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%d") - dt = dt.replace(tzinfo=tz) - return dt.date() - - def gds_validate_time(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_time(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%02d:%02d:%02d" % ( - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%02d:%02d:%02d.%s" % ( - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - def gds_validate_simple_patterns(self, patterns, target): - # pat is a list of lists of strings/patterns. - # The target value must match at least one of the patterns - # in order for the test to succeed. - found1 = True - target = str(target) - for patterns1 in patterns: - found2 = False - for patterns2 in patterns1: - mo = re_.search(patterns2, target) - if mo is not None and len(mo.group(0)) == len(target): - found2 = True - break - if not found2: - found1 = False - break - return found1 - - @classmethod - def gds_parse_time(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - if len(input_data.split(".")) > 1: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt.time() - - def gds_check_cardinality_( - self, value, input_name, min_occurs=0, max_occurs=1, required=None - ): - if value is None: - length = 0 - elif isinstance(value, list): - length = len(value) - else: - length = 1 - if required is not None: - if required and length < 1: - self.gds_collector_.add_message( - "Required value {}{} is missing".format( - input_name, self.gds_get_node_lineno_() - ) - ) - if length < min_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is below " - "the minimum allowed, " - "expected at least {}, found {}".format( - input_name, self.gds_get_node_lineno_(), min_occurs, length - ) - ) - elif length > max_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is above " - "the maximum allowed, " - "expected at most {}, found {}".format( - input_name, self.gds_get_node_lineno_(), max_occurs, length - ) - ) - - def gds_validate_builtin_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value, input_name=input_name) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_validate_defined_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_str_lower(self, instring): - return instring.lower() - - def get_path_(self, node): - path_list = [] - self.get_path_list_(node, path_list) - path_list.reverse() - path = "/".join(path_list) - return path - - Tag_strip_pattern_ = re_.compile(r"\{.*\}") - - def get_path_list_(self, node, path_list): - if node is None: - return - tag = GeneratedsSuper.Tag_strip_pattern_.sub("", node.tag) - if tag: - path_list.append(tag) - self.get_path_list_(node.getparent(), path_list) - - def get_class_obj_(self, node, default_class=None): - class_obj1 = default_class - if "xsi" in node.nsmap: - classname = node.get("{%s}type" % node.nsmap["xsi"]) - if classname is not None: - names = classname.split(":") - if len(names) == 2: - classname = names[1] - class_obj2 = globals().get(classname) - if class_obj2 is not None: - class_obj1 = class_obj2 - return class_obj1 - - def gds_build_any(self, node, type_name=None): - # provide default value in case option --disable-xml is used. - content = "" - content = etree_.tostring(node, encoding="unicode") - return content - - @classmethod - def gds_reverse_node_mapping(cls, mapping): - return dict(((v, k) for k, v in mapping.items())) - - @staticmethod - def gds_encode(instring): - if sys.version_info.major == 2: - if ExternalEncoding: - encoding = ExternalEncoding - else: - encoding = "utf-8" - return instring.encode(encoding) - else: - return instring - - @staticmethod - def convert_unicode(instring): - if isinstance(instring, str): - result = quote_xml(instring) - elif sys.version_info.major == 2 and isinstance(instring, unicode): - result = quote_xml(instring).encode("utf8") - else: - result = GeneratedsSuper.gds_encode(str(instring)) - return result - - def __eq__(self, other): - def excl_select_objs_(obj): - return obj[0] != "parent_object_" and obj[0] != "gds_collector_" - - if type(self) != type(other): - return False - return all( - x == y - for x, y in zip_longest( - filter(excl_select_objs_, self.__dict__.items()), - filter(excl_select_objs_, other.__dict__.items()), - ) - ) - - def __ne__(self, other): - return not self.__eq__(other) - - # Django ETL transform hooks. - def gds_djo_etl_transform(self): - pass - - def gds_djo_etl_transform_db_obj(self, dbobj): - pass - - # SQLAlchemy ETL transform hooks. - def gds_sqa_etl_transform(self): - return 0, None - - def gds_sqa_etl_transform_db_obj(self, dbobj): - pass - - def gds_get_node_lineno_(self): - if ( - hasattr(self, "gds_elementtree_node_") - and self.gds_elementtree_node_ is not None - ): - return " near line {}".format(self.gds_elementtree_node_.sourceline) - else: - return "" - - def getSubclassFromModule_(module, class_): - """Get the subclass of a class from a specific module.""" - name = class_.__name__ + "Sub" - if hasattr(module, name): - return getattr(module, name) - else: - return None - - -# -# If you have installed IPython you can uncomment and use the following. -# IPython is available from http://ipython.scipy.org/. -# - -## from IPython.Shell import IPShellEmbed -## args = '' -## ipshell = IPShellEmbed(args, -## banner = 'Dropping into IPython', -## exit_msg = 'Leaving Interpreter, back to program.') - -# Then use the following line where and when you want to drop into the -# IPython shell: -# ipshell(' -- Entering ipshell.\nHit Ctrl-D to exit') - -# -# Globals -# - -ExternalEncoding = "" -# Set this to false in order to deactivate during export, the use of -# name space prefixes captured from the input document. -UseCapturedNS_ = True -CapturedNsmap_ = {} -Tag_pattern_ = re_.compile(r"({.*})?(.*)") -String_cleanup_pat_ = re_.compile(r"[\n\r\s]+") -Namespace_extract_pat_ = re_.compile(r"{(.*)}(.*)") -CDATA_pattern_ = re_.compile(r"", re_.DOTALL) - -# Change this to redirect the generated superclass module to use a -# specific subclass module. -CurrentSubclassModule_ = None - -# -# Support/utility functions. -# - - -def showIndent(outfile, level, pretty_print=True): - if pretty_print: - for idx in range(level): - outfile.write(" ") - - -def quote_xml(inStr): - "Escape markup chars, but do not modify CDATA sections." - if not inStr: - return "" - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s2 = "" - pos = 0 - matchobjects = CDATA_pattern_.finditer(s1) - for mo in matchobjects: - s3 = s1[pos : mo.start()] - s2 += quote_xml_aux(s3) - s2 += s1[mo.start() : mo.end()] - pos = mo.end() - s3 = s1[pos:] - s2 += quote_xml_aux(s3) - return s2 - - -def quote_xml_aux(inStr): - s1 = inStr.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - return s1 - - -def quote_attrib(inStr): - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s1 = s1.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - s1 = s1.replace("\n", " ") - if '"' in s1: - if "'" in s1: - s1 = '"%s"' % s1.replace('"', """) - else: - s1 = "'%s'" % s1 - else: - s1 = '"%s"' % s1 - return s1 - - -def quote_python(inStr): - s1 = inStr - if s1.find("'") == -1: - if s1.find("\n") == -1: - return "'%s'" % s1 - else: - return "'''%s'''" % s1 - else: - if s1.find('"') != -1: - s1 = s1.replace('"', '\\"') - if s1.find("\n") == -1: - return '"%s"' % s1 - else: - return '"""%s"""' % s1 - - -def get_all_text_(node): - if node.text is not None: - text = node.text - else: - text = "" - for child in node: - if child.tail is not None: - text += child.tail - return text - - -def find_attr_value_(attr_name, node): - attrs = node.attrib - attr_parts = attr_name.split(":") - value = None - if len(attr_parts) == 1: - value = attrs.get(attr_name) - elif len(attr_parts) == 2: - prefix, name = attr_parts - if prefix == "xml": - namespace = "http://www.w3.org/XML/1998/namespace" - else: - namespace = node.nsmap.get(prefix) - if namespace is not None: - value = attrs.get( - "{%s}%s" - % ( - namespace, - name, - ) - ) - return value - - -def encode_str_2_3(instr): - return instr - - -class GDSParseError(Exception): - pass - - -def raise_parse_error(node, msg): - if node is not None: - msg = "%s (element %s/line %d)" % ( - msg, - node.tag, - node.sourceline, - ) - raise GDSParseError(msg) - - -class MixedContainer: - # Constants for category: - CategoryNone = 0 - CategoryText = 1 - CategorySimple = 2 - CategoryComplex = 3 - # Constants for content_type: - TypeNone = 0 - TypeText = 1 - TypeString = 2 - TypeInteger = 3 - TypeFloat = 4 - TypeDecimal = 5 - TypeDouble = 6 - TypeBoolean = 7 - TypeBase64 = 8 - - def __init__(self, category, content_type, name, value): - self.category = category - self.content_type = content_type - self.name = name - self.value = value - - def getCategory(self): - return self.category - - def getContenttype(self, content_type): - return self.content_type - - def getValue(self): - return self.value - - def getName(self): - return self.name - - def export(self, outfile, level, name, namespace, pretty_print=True): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - outfile.write(self.value) - elif self.category == MixedContainer.CategorySimple: - self.exportSimple(outfile, level, name) - else: # category == MixedContainer.CategoryComplex - self.value.export( - outfile, level, namespace, name_=name, pretty_print=pretty_print - ) - - def exportSimple(self, outfile, level, name): - if self.content_type == MixedContainer.TypeString: - outfile.write("<%s>%s" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - outfile.write("<%s>%d" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - outfile.write("<%s>%f" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeDouble: - outfile.write("<%s>%g" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeBase64: - outfile.write( - "<%s>%s" % (self.name, base64.b64encode(self.value), self.name) - ) - - def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - if len(element) > 0: - if element[-1].tail is None: - element[-1].tail = self.value - else: - element[-1].tail += self.value - else: - if element.text is None: - element.text = self.value - else: - element.text += self.value - elif self.category == MixedContainer.CategorySimple: - subelement = etree_.SubElement(element, "%s" % self.name) - subelement.text = self.to_etree_simple() - else: # category == MixedContainer.CategoryComplex - self.value.to_etree(element) - - def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.content_type == MixedContainer.TypeString: - text = self.value - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - text = "%d" % self.value - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - text = "%f" % self.value - elif self.content_type == MixedContainer.TypeDouble: - text = "%g" % self.value - elif self.content_type == MixedContainer.TypeBase64: - text = "%s" % base64.b64encode(self.value) - return text - - def exportLiteral(self, outfile, level, name): - if self.category == MixedContainer.CategoryText: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - elif self.category == MixedContainer.CategorySimple: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - else: # category == MixedContainer.CategoryComplex - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s",\n' - % ( - self.category, - self.content_type, - self.name, - ) - ) - self.value.exportLiteral(outfile, level + 1) - showIndent(outfile, level) - outfile.write(")\n") - - -class MemberSpec_(object): - def __init__( - self, - name="", - data_type="", - container=0, - optional=0, - child_attrs=None, - choice=None, - ): - self.name = name - self.data_type = data_type - self.container = container - self.child_attrs = child_attrs - self.choice = choice - self.optional = optional - - def set_name(self, name): - self.name = name - - def get_name(self): - return self.name - - def set_data_type(self, data_type): - self.data_type = data_type - - def get_data_type_chain(self): - return self.data_type - - def get_data_type(self): - if isinstance(self.data_type, list): - if len(self.data_type) > 0: - return self.data_type[-1] - else: - return "xs:string" - else: - return self.data_type - - def set_container(self, container): - self.container = container - - def get_container(self): - return self.container - - def set_child_attrs(self, child_attrs): - self.child_attrs = child_attrs - - def get_child_attrs(self): - return self.child_attrs - - def set_choice(self, choice): - self.choice = choice - - def get_choice(self): - return self.choice - - def set_optional(self, optional): - self.optional = optional - - def get_optional(self): - return self.optional - - -def _cast(typ, value): - if typ is None or value is None: - return value - return typ(value) - - -# -# Data representation classes. -# - - -class Freightcom(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, version=None, QuoteReply=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.version = _cast(None, version) - self.version_nsprefix_ = None - self.QuoteReply = QuoteReply - self.QuoteReply_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, Freightcom) - if subclass is not None: - return subclass(*args_, **kwargs_) - if Freightcom.subclass: - return Freightcom.subclass(*args_, **kwargs_) - else: - return Freightcom(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_QuoteReply(self): - return self.QuoteReply - - def set_QuoteReply(self, QuoteReply): - self.QuoteReply = QuoteReply - - def get_version(self): - return self.version - - def set_version(self, version): - self.version = version - - def _hasContent(self): - if self.QuoteReply is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("Freightcom") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "Freightcom": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="Freightcom" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="Freightcom", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="Freightcom" - ): - if self.version is not None and "version" not in already_processed: - already_processed.add("version") - outfile.write( - " version=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.version), input_name="version" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.QuoteReply is not None: - namespaceprefix_ = ( - self.QuoteReply_nsprefix_ + ":" - if (UseCapturedNS_ and self.QuoteReply_nsprefix_) - else "" - ) - self.QuoteReply.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="QuoteReply", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("version", node) - if value is not None and "version" not in already_processed: - already_processed.add("version") - self.version = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "QuoteReply": - obj_ = QuoteReplyType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.QuoteReply = obj_ - obj_.original_tagname_ = "QuoteReply" - - -# end class Freightcom - - -class QuoteReplyType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, Quote=None, CarrierErrorMessage=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - if Quote is None: - self.Quote = [] - else: - self.Quote = Quote - self.Quote_nsprefix_ = None - self.CarrierErrorMessage = CarrierErrorMessage - self.CarrierErrorMessage_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, QuoteReplyType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if QuoteReplyType.subclass: - return QuoteReplyType.subclass(*args_, **kwargs_) - else: - return QuoteReplyType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Quote(self): - return self.Quote - - def set_Quote(self, Quote): - self.Quote = Quote - - def add_Quote(self, value): - self.Quote.append(value) - - def insert_Quote_at(self, index, value): - self.Quote.insert(index, value) - - def replace_Quote_at(self, index, value): - self.Quote[index] = value - - def get_CarrierErrorMessage(self): - return self.CarrierErrorMessage - - def set_CarrierErrorMessage(self, CarrierErrorMessage): - self.CarrierErrorMessage = CarrierErrorMessage - - def _hasContent(self): - if self.Quote or self.CarrierErrorMessage is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="QuoteReplyType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("QuoteReplyType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "QuoteReplyType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="QuoteReplyType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="QuoteReplyType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="QuoteReplyType", - ): - pass - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="QuoteReplyType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - for Quote_ in self.Quote: - namespaceprefix_ = ( - self.Quote_nsprefix_ + ":" - if (UseCapturedNS_ and self.Quote_nsprefix_) - else "" - ) - Quote_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Quote", - pretty_print=pretty_print, - ) - if self.CarrierErrorMessage is not None: - namespaceprefix_ = ( - self.CarrierErrorMessage_nsprefix_ + ":" - if (UseCapturedNS_ and self.CarrierErrorMessage_nsprefix_) - else "" - ) - self.CarrierErrorMessage.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="CarrierErrorMessage", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - pass - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Quote": - obj_ = QuoteType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Quote.append(obj_) - obj_.original_tagname_ = "Quote" - elif nodeName_ == "CarrierErrorMessage": - obj_ = CarrierErrorMessageType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.CarrierErrorMessage = obj_ - obj_.original_tagname_ = "CarrierErrorMessage" - - -# end class QuoteReplyType - - -class QuoteType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - carrierId=None, - carrierName=None, - serviceId=None, - serviceName=None, - modeTransport=None, - transitDays=None, - currency=None, - baseCharge=None, - fuelSurcharge=None, - totalCharge=None, - cubedWeight=None, - Surcharge=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.carrierId = _cast(int, carrierId) - self.carrierId_nsprefix_ = None - self.carrierName = _cast(None, carrierName) - self.carrierName_nsprefix_ = None - self.serviceId = _cast(int, serviceId) - self.serviceId_nsprefix_ = None - self.serviceName = _cast(None, serviceName) - self.serviceName_nsprefix_ = None - self.modeTransport = _cast(None, modeTransport) - self.modeTransport_nsprefix_ = None - self.transitDays = _cast(int, transitDays) - self.transitDays_nsprefix_ = None - self.currency = _cast(None, currency) - self.currency_nsprefix_ = None - self.baseCharge = _cast(float, baseCharge) - self.baseCharge_nsprefix_ = None - self.fuelSurcharge = _cast(float, fuelSurcharge) - self.fuelSurcharge_nsprefix_ = None - self.totalCharge = _cast(float, totalCharge) - self.totalCharge_nsprefix_ = None - self.cubedWeight = _cast(float, cubedWeight) - self.cubedWeight_nsprefix_ = None - if Surcharge is None: - self.Surcharge = [] - else: - self.Surcharge = Surcharge - self.Surcharge_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, QuoteType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if QuoteType.subclass: - return QuoteType.subclass(*args_, **kwargs_) - else: - return QuoteType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Surcharge(self): - return self.Surcharge - - def set_Surcharge(self, Surcharge): - self.Surcharge = Surcharge - - def add_Surcharge(self, value): - self.Surcharge.append(value) - - def insert_Surcharge_at(self, index, value): - self.Surcharge.insert(index, value) - - def replace_Surcharge_at(self, index, value): - self.Surcharge[index] = value - - def get_carrierId(self): - return self.carrierId - - def set_carrierId(self, carrierId): - self.carrierId = carrierId - - def get_carrierName(self): - return self.carrierName - - def set_carrierName(self, carrierName): - self.carrierName = carrierName - - def get_serviceId(self): - return self.serviceId - - def set_serviceId(self, serviceId): - self.serviceId = serviceId - - def get_serviceName(self): - return self.serviceName - - def set_serviceName(self, serviceName): - self.serviceName = serviceName - - def get_modeTransport(self): - return self.modeTransport - - def set_modeTransport(self, modeTransport): - self.modeTransport = modeTransport - - def get_transitDays(self): - return self.transitDays - - def set_transitDays(self, transitDays): - self.transitDays = transitDays - - def get_currency(self): - return self.currency - - def set_currency(self, currency): - self.currency = currency - - def get_baseCharge(self): - return self.baseCharge - - def set_baseCharge(self, baseCharge): - self.baseCharge = baseCharge - - def get_fuelSurcharge(self): - return self.fuelSurcharge - - def set_fuelSurcharge(self, fuelSurcharge): - self.fuelSurcharge = fuelSurcharge - - def get_totalCharge(self): - return self.totalCharge - - def set_totalCharge(self, totalCharge): - self.totalCharge = totalCharge - - def get_cubedWeight(self): - return self.cubedWeight - - def set_cubedWeight(self, cubedWeight): - self.cubedWeight = cubedWeight - - def _hasContent(self): - if self.Surcharge: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="QuoteType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("QuoteType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "QuoteType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="QuoteType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="QuoteType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="QuoteType" - ): - if self.carrierId is not None and "carrierId" not in already_processed: - already_processed.add("carrierId") - outfile.write( - ' carrierId="%s"' - % self.gds_format_integer(self.carrierId, input_name="carrierId") - ) - if self.carrierName is not None and "carrierName" not in already_processed: - already_processed.add("carrierName") - outfile.write( - " carrierName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.carrierName), input_name="carrierName" - ) - ), - ) - ) - if self.serviceId is not None and "serviceId" not in already_processed: - already_processed.add("serviceId") - outfile.write( - ' serviceId="%s"' - % self.gds_format_integer(self.serviceId, input_name="serviceId") - ) - if self.serviceName is not None and "serviceName" not in already_processed: - already_processed.add("serviceName") - outfile.write( - " serviceName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.serviceName), input_name="serviceName" - ) - ), - ) - ) - if self.modeTransport is not None and "modeTransport" not in already_processed: - already_processed.add("modeTransport") - outfile.write( - " modeTransport=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.modeTransport), input_name="modeTransport" - ) - ), - ) - ) - if self.transitDays is not None and "transitDays" not in already_processed: - already_processed.add("transitDays") - outfile.write( - ' transitDays="%s"' - % self.gds_format_integer(self.transitDays, input_name="transitDays") - ) - if self.currency is not None and "currency" not in already_processed: - already_processed.add("currency") - outfile.write( - " currency=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.currency), input_name="currency" - ) - ), - ) - ) - if self.baseCharge is not None and "baseCharge" not in already_processed: - already_processed.add("baseCharge") - outfile.write( - ' baseCharge="%s"' - % self.gds_format_float(self.baseCharge, input_name="baseCharge") - ) - if self.fuelSurcharge is not None and "fuelSurcharge" not in already_processed: - already_processed.add("fuelSurcharge") - outfile.write( - ' fuelSurcharge="%s"' - % self.gds_format_float(self.fuelSurcharge, input_name="fuelSurcharge") - ) - if self.totalCharge is not None and "totalCharge" not in already_processed: - already_processed.add("totalCharge") - outfile.write( - ' totalCharge="%s"' - % self.gds_format_float(self.totalCharge, input_name="totalCharge") - ) - if self.cubedWeight is not None and "cubedWeight" not in already_processed: - already_processed.add("cubedWeight") - outfile.write( - ' cubedWeight="%s"' - % self.gds_format_float(self.cubedWeight, input_name="cubedWeight") - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="QuoteType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - for Surcharge_ in self.Surcharge: - namespaceprefix_ = ( - self.Surcharge_nsprefix_ + ":" - if (UseCapturedNS_ and self.Surcharge_nsprefix_) - else "" - ) - Surcharge_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Surcharge", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("carrierId", node) - if value is not None and "carrierId" not in already_processed: - already_processed.add("carrierId") - self.carrierId = self.gds_parse_integer(value, node, "carrierId") - value = find_attr_value_("carrierName", node) - if value is not None and "carrierName" not in already_processed: - already_processed.add("carrierName") - self.carrierName = value - value = find_attr_value_("serviceId", node) - if value is not None and "serviceId" not in already_processed: - already_processed.add("serviceId") - self.serviceId = self.gds_parse_integer(value, node, "serviceId") - value = find_attr_value_("serviceName", node) - if value is not None and "serviceName" not in already_processed: - already_processed.add("serviceName") - self.serviceName = value - value = find_attr_value_("modeTransport", node) - if value is not None and "modeTransport" not in already_processed: - already_processed.add("modeTransport") - self.modeTransport = value - value = find_attr_value_("transitDays", node) - if value is not None and "transitDays" not in already_processed: - already_processed.add("transitDays") - self.transitDays = self.gds_parse_integer(value, node, "transitDays") - value = find_attr_value_("currency", node) - if value is not None and "currency" not in already_processed: - already_processed.add("currency") - self.currency = value - value = find_attr_value_("baseCharge", node) - if value is not None and "baseCharge" not in already_processed: - already_processed.add("baseCharge") - value = self.gds_parse_float(value, node, "baseCharge") - self.baseCharge = value - value = find_attr_value_("fuelSurcharge", node) - if value is not None and "fuelSurcharge" not in already_processed: - already_processed.add("fuelSurcharge") - value = self.gds_parse_float(value, node, "fuelSurcharge") - self.fuelSurcharge = value - value = find_attr_value_("totalCharge", node) - if value is not None and "totalCharge" not in already_processed: - already_processed.add("totalCharge") - value = self.gds_parse_float(value, node, "totalCharge") - self.totalCharge = value - value = find_attr_value_("cubedWeight", node) - if value is not None and "cubedWeight" not in already_processed: - already_processed.add("cubedWeight") - value = self.gds_parse_float(value, node, "cubedWeight") - self.cubedWeight = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Surcharge": - obj_ = SurchargeType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Surcharge.append(obj_) - obj_.original_tagname_ = "Surcharge" - - -# end class QuoteType - - -class SurchargeType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - id=None, - name=None, - amount=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.id = _cast(None, id) - self.id_nsprefix_ = None - self.name = _cast(None, name) - self.name_nsprefix_ = None - self.amount = _cast(float, amount) - self.amount_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, SurchargeType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if SurchargeType.subclass: - return SurchargeType.subclass(*args_, **kwargs_) - else: - return SurchargeType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_id(self): - return self.id - - def set_id(self, id): - self.id = id - - def get_name(self): - return self.name - - def set_name(self, name): - self.name = name - - def get_amount(self): - return self.amount - - def set_amount(self, amount): - self.amount = amount - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="SurchargeType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("SurchargeType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "SurchargeType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="SurchargeType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="SurchargeType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="SurchargeType", - ): - if self.id is not None and "id" not in already_processed: - already_processed.add("id") - outfile.write( - " id=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.id), input_name="id") - ), - ) - ) - if self.name is not None and "name" not in already_processed: - already_processed.add("name") - outfile.write( - " name=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.name), input_name="name" - ) - ), - ) - ) - if self.amount is not None and "amount" not in already_processed: - already_processed.add("amount") - outfile.write( - ' amount="%s"' % self.gds_format_float(self.amount, input_name="amount") - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="SurchargeType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("id", node) - if value is not None and "id" not in already_processed: - already_processed.add("id") - self.id = value - value = find_attr_value_("name", node) - if value is not None and "name" not in already_processed: - already_processed.add("name") - self.name = value - value = find_attr_value_("amount", node) - if value is not None and "amount" not in already_processed: - already_processed.add("amount") - value = self.gds_parse_float(value, node, "amount") - self.amount = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class SurchargeType - - -class CarrierErrorMessageType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - size=None, - errorMessage0=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.size = _cast(int, size) - self.size_nsprefix_ = None - self.errorMessage0 = _cast(None, errorMessage0) - self.errorMessage0_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, CarrierErrorMessageType - ) - if subclass is not None: - return subclass(*args_, **kwargs_) - if CarrierErrorMessageType.subclass: - return CarrierErrorMessageType.subclass(*args_, **kwargs_) - else: - return CarrierErrorMessageType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_size(self): - return self.size - - def set_size(self, size): - self.size = size - - def get_errorMessage0(self): - return self.errorMessage0 - - def set_errorMessage0(self, errorMessage0): - self.errorMessage0 = errorMessage0 - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CarrierErrorMessageType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("CarrierErrorMessageType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "CarrierErrorMessageType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="CarrierErrorMessageType", - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="CarrierErrorMessageType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="CarrierErrorMessageType", - ): - if self.size is not None and "size" not in already_processed: - already_processed.add("size") - outfile.write( - ' size="%s"' % self.gds_format_integer(self.size, input_name="size") - ) - if self.errorMessage0 is not None and "errorMessage0" not in already_processed: - already_processed.add("errorMessage0") - outfile.write( - " errorMessage0=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.errorMessage0), input_name="errorMessage0" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CarrierErrorMessageType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("size", node) - if value is not None and "size" not in already_processed: - already_processed.add("size") - self.size = self.gds_parse_integer(value, node, "size") - value = find_attr_value_("errorMessage0", node) - if value is not None and "errorMessage0" not in already_processed: - already_processed.add("errorMessage0") - self.errorMessage0 = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class CarrierErrorMessageType - - -GDSClassesMapping = {} - - -USAGE_TEXT = """ -Usage: python .py [ -s ] -""" - - -def usage(): - print(USAGE_TEXT) - sys.exit(1) - - -def get_root_tag(node): - tag = Tag_pattern_.match(node.tag).groups()[-1] - prefix_tag = TagNamePrefix + tag - rootClass = GDSClassesMapping.get(prefix_tag) - if rootClass is None: - rootClass = globals().get(prefix_tag) - return tag, rootClass - - -def get_required_ns_prefix_defs(rootNode): - """Get all name space prefix definitions required in this XML doc. - Return a dictionary of definitions and a char string of definitions. - """ - nsmap = { - prefix: uri - for node in rootNode.iter() - for (prefix, uri) in node.nsmap.items() - if prefix is not None - } - namespacedefs = " ".join( - ['xmlns:{}="{}"'.format(prefix, uri) for prefix, uri in nsmap.items()] - ) - return nsmap, namespacedefs - - -def parse(inFileName, silence=False, print_warnings=True): - global CapturedNsmap_ - gds_collector = GdsCollector_() - parser = None - doc = parsexml_(inFileName, parser) - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode) - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export( - sys.stdout, 0, name_=rootTag, namespacedef_=namespacedefs, pretty_print=True - ) - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseEtree( - inFileName, - silence=False, - print_warnings=True, - mapping=None, - reverse_mapping=None, - nsmap=None, -): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if mapping is None: - mapping = {} - if reverse_mapping is None: - reverse_mapping = {} - rootElement = rootObj.to_etree( - None, - name_=rootTag, - mapping_=mapping, - reverse_mapping_=reverse_mapping, - nsmap_=nsmap, - ) - reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - content = etree_.tostring( - rootElement, pretty_print=True, xml_declaration=True, encoding="utf-8" - ) - sys.stdout.write(str(content)) - sys.stdout.write("\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj, rootElement, mapping, reverse_node_mapping - - -def parseString(inString, silence=False, print_warnings=True): - """Parse a string, create the object tree, and export it. - - Arguments: - - inString -- A string. This XML fragment should not start - with an XML declaration containing an encoding. - - silence -- A boolean. If False, export the object. - Returns -- The root object in the tree. - """ - parser = None - rootNode = parsexmlstring_(inString, parser) - gds_collector = GdsCollector_() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if not SaveElementTreeNode: - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export(sys.stdout, 0, name_=rootTag, namespacedef_="") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseLiteral(inFileName, silence=False, print_warnings=True): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write("#from quote_reply import *\n\n") - sys.stdout.write("import quote_reply as model_\n\n") - sys.stdout.write("rootObj = model_.rootClass(\n") - rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) - sys.stdout.write(")\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def main(): - args = sys.argv[1:] - if len(args) == 1: - parse(args[0]) - else: - usage() - - -if __name__ == "__main__": - # import pdb; pdb.set_trace() - main() - -RenameMappings_ = {} - -# -# Mapping of namespaces to types defined in them -# and the file in which each is defined. -# simpleTypes are marked "ST" and complexTypes "CT". -NamespaceToDefMappings_ = {"http://www.freightcom.net/xml/XMLSchema": []} - -__all__ = [ - "CarrierErrorMessageType", - "Freightcom", - "QuoteReplyType", - "QuoteType", - "SurchargeType", -] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/quote_request.py b/modules/connectors/freightcom/karrio/schemas/freightcom/quote_request.py deleted file mode 100644 index 1d0ee26009..0000000000 --- a/modules/connectors/freightcom/karrio/schemas/freightcom/quote_request.py +++ /dev/null @@ -1,4522 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# -# Generated Fri Oct 21 12:33:20 2022 by generateDS.py version 2.41.1. -# Python 3.10.8 (v3.10.8:aaaf517424, Oct 11 2022, 10:14:40) [Clang 13.0.0 (clang-1300.0.29.30)] -# -# Command line options: -# ('--no-namespace-defs', '') -# ('-o', './karrio.schemas.freightcom/quote_request.py') -# -# Command line arguments: -# ./vendor/schemas/quote_request.xsd -# -# Command line: -# /Users/danielk/Documents/karrio/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio.schemas.freightcom/quote_request.py" ./vendor/schemas/quote_request.xsd -# -# Current working directory (os.getcwd()): -# freightcom -# - -import sys - -try: - ModulenotfoundExp_ = ModuleNotFoundError -except NameError: - ModulenotfoundExp_ = ImportError -from six.moves import zip_longest -import os -import re as re_ -import base64 -import datetime as datetime_ -import decimal as decimal_ -from lxml import etree as etree_ - - -Validate_simpletypes_ = True -SaveElementTreeNode = True -TagNamePrefix = "" -if sys.version_info.major == 2: - BaseStrType_ = basestring -else: - BaseStrType_ = str - - -def parsexml_(infile, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - try: - if isinstance(infile, os.PathLike): - infile = os.path.join(infile) - except AttributeError: - pass - doc = etree_.parse(infile, parser=parser, **kwargs) - return doc - - -def parsexmlstring_(instring, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - element = etree_.fromstring(instring, parser=parser, **kwargs) - return element - - -# -# Namespace prefix definition table (and other attributes, too) -# -# The module generatedsnamespaces, if it is importable, must contain -# a dictionary named GeneratedsNamespaceDefs. This Python dictionary -# should map element type names (strings) to XML schema namespace prefix -# definitions. The export method for any class for which there is -# a namespace prefix definition, will export that definition in the -# XML representation of that element. See the export method of -# any generated element type class for an example of the use of this -# table. -# A sample table is: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceDefs = { -# "ElementtypeA": "http://www.xxx.com/namespaceA", -# "ElementtypeB": "http://www.xxx.com/namespaceB", -# } -# -# Additionally, the generatedsnamespaces module can contain a python -# dictionary named GenerateDSNamespaceTypePrefixes that associates element -# types with the namespace prefixes that are to be added to the -# "xsi:type" attribute value. See the _exportAttributes method of -# any generated element type and the generation of "xsi:type" for an -# example of the use of this table. -# An example table: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceTypePrefixes = { -# "ElementtypeC": "aaa:", -# "ElementtypeD": "bbb:", -# } -# - -try: - from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_ -except ModulenotfoundExp_: - GenerateDSNamespaceDefs_ = {} -try: - from generatedsnamespaces import ( - GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_, - ) -except ModulenotfoundExp_: - GenerateDSNamespaceTypePrefixes_ = {} - -# -# You can replace the following class definition by defining an -# importable module named "generatedscollector" containing a class -# named "GdsCollector". See the default class definition below for -# clues about the possible content of that class. -# -try: - from generatedscollector import GdsCollector as GdsCollector_ -except ModulenotfoundExp_: - - class GdsCollector_(object): - def __init__(self, messages=None): - if messages is None: - self.messages = [] - else: - self.messages = messages - - def add_message(self, msg): - self.messages.append(msg) - - def get_messages(self): - return self.messages - - def clear_messages(self): - self.messages = [] - - def print_messages(self): - for msg in self.messages: - print("Warning: {}".format(msg)) - - def write_messages(self, outstream): - for msg in self.messages: - outstream.write("Warning: {}\n".format(msg)) - - -# -# The super-class for enum types -# - -try: - from enum import Enum -except ModulenotfoundExp_: - Enum = object - -# -# The root super-class for element type classes -# -# Calls to the methods in these classes are generated by generateDS.py. -# You can replace these methods by re-implementing the following class -# in a module named generatedssuper.py. - -try: - from generatedssuper import GeneratedsSuper -except ModulenotfoundExp_ as exp: - try: - from generatedssupersuper import GeneratedsSuperSuper - except ModulenotfoundExp_ as exp: - - class GeneratedsSuperSuper(object): - pass - - class GeneratedsSuper(GeneratedsSuperSuper): - __hash__ = object.__hash__ - tzoff_pattern = re_.compile(r"(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$") - - class _FixedOffsetTZ(datetime_.tzinfo): - def __init__(self, offset, name): - self.__offset = datetime_.timedelta(minutes=offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return None - - def __str__(self): - settings = { - "str_pretty_print": True, - "str_indent_level": 0, - "str_namespaceprefix": "", - "str_name": self.__class__.__name__, - "str_namespacedefs": "", - } - for n in settings: - if hasattr(self, n): - settings[n] = getattr(self, n) - if sys.version_info.major == 2: - from StringIO import StringIO - else: - from io import StringIO - output = StringIO() - self.export( - output, - settings["str_indent_level"], - pretty_print=settings["str_pretty_print"], - namespaceprefix_=settings["str_namespaceprefix"], - name_=settings["str_name"], - namespacedef_=settings["str_namespacedefs"], - ) - strval = output.getvalue() - output.close() - return strval - - def gds_format_string(self, input_data, input_name=""): - return input_data - - def gds_parse_string(self, input_data, node=None, input_name=""): - return input_data - - def gds_validate_string(self, input_data, node=None, input_name=""): - if not input_data: - return "" - else: - return input_data - - def gds_format_base64(self, input_data, input_name=""): - return base64.b64encode(input_data).decode("ascii") - - def gds_validate_base64(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_integer(self, input_data, input_name=""): - return "%d" % int(input_data) - - def gds_parse_integer(self, input_data, node=None, input_name=""): - try: - ival = int(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires integer value: %s" % exp) - return ival - - def gds_validate_integer(self, input_data, node=None, input_name=""): - try: - value = int(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires integer value") - return value - - def gds_format_integer_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_integer_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - int(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of integer values") - return values - - def gds_format_float(self, input_data, input_name=""): - return ("%.15f" % float(input_data)).rstrip("0") - - def gds_parse_float(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires float or double value: %s" % exp) - return fval_ - - def gds_validate_float(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires float value") - return value - - def gds_format_float_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_float_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of float values") - return values - - def gds_format_decimal(self, input_data, input_name=""): - return_value = "%s" % input_data - if "." in return_value: - return_value = return_value.rstrip("0") - if return_value.endswith("."): - return_value = return_value.rstrip(".") - return return_value - - def gds_parse_decimal(self, input_data, node=None, input_name=""): - try: - decimal_value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return decimal_value - - def gds_validate_decimal(self, input_data, node=None, input_name=""): - try: - value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return value - - def gds_format_decimal_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return " ".join([self.gds_format_decimal(item) for item in input_data]) - - def gds_validate_decimal_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - decimal_.Decimal(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of decimal values") - return values - - def gds_format_double(self, input_data, input_name=""): - return "%s" % input_data - - def gds_parse_double(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires double or float value: %s" % exp) - return fval_ - - def gds_validate_double(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires double or float value") - return value - - def gds_format_double_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_double_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error( - node, "Requires sequence of double or float values" - ) - return values - - def gds_format_boolean(self, input_data, input_name=""): - return ("%s" % input_data).lower() - - def gds_parse_boolean(self, input_data, node=None, input_name=""): - input_data = input_data.strip() - if input_data in ("true", "1"): - bval = True - elif input_data in ("false", "0"): - bval = False - else: - raise_parse_error(node, "Requires boolean value") - return bval - - def gds_validate_boolean(self, input_data, node=None, input_name=""): - if input_data not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, "Requires boolean value " "(one of True, 1, False, 0)" - ) - return input_data - - def gds_format_boolean_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_boolean_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - value = self.gds_parse_boolean(value, node, input_name) - if value not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, - "Requires sequence of boolean values " - "(one of True, 1, False, 0)", - ) - return values - - def gds_validate_datetime(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_datetime(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d.%s" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - @classmethod - def gds_parse_datetime(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - time_parts = input_data.split(".") - if len(time_parts) > 1: - micro_seconds = int(float("0." + time_parts[1]) * 1000000) - input_data = "%s.%s" % ( - time_parts[0], - "{}".format(micro_seconds).rjust(6, "0"), - ) - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt - - def gds_validate_date(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_date(self, input_data, input_name=""): - _svalue = "%04d-%02d-%02d" % ( - input_data.year, - input_data.month, - input_data.day, - ) - try: - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - except AttributeError: - pass - return _svalue - - @classmethod - def gds_parse_date(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%d") - dt = dt.replace(tzinfo=tz) - return dt.date() - - def gds_validate_time(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_time(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%02d:%02d:%02d" % ( - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%02d:%02d:%02d.%s" % ( - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - def gds_validate_simple_patterns(self, patterns, target): - # pat is a list of lists of strings/patterns. - # The target value must match at least one of the patterns - # in order for the test to succeed. - found1 = True - target = str(target) - for patterns1 in patterns: - found2 = False - for patterns2 in patterns1: - mo = re_.search(patterns2, target) - if mo is not None and len(mo.group(0)) == len(target): - found2 = True - break - if not found2: - found1 = False - break - return found1 - - @classmethod - def gds_parse_time(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - if len(input_data.split(".")) > 1: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt.time() - - def gds_check_cardinality_( - self, value, input_name, min_occurs=0, max_occurs=1, required=None - ): - if value is None: - length = 0 - elif isinstance(value, list): - length = len(value) - else: - length = 1 - if required is not None: - if required and length < 1: - self.gds_collector_.add_message( - "Required value {}{} is missing".format( - input_name, self.gds_get_node_lineno_() - ) - ) - if length < min_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is below " - "the minimum allowed, " - "expected at least {}, found {}".format( - input_name, self.gds_get_node_lineno_(), min_occurs, length - ) - ) - elif length > max_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is above " - "the maximum allowed, " - "expected at most {}, found {}".format( - input_name, self.gds_get_node_lineno_(), max_occurs, length - ) - ) - - def gds_validate_builtin_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value, input_name=input_name) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_validate_defined_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_str_lower(self, instring): - return instring.lower() - - def get_path_(self, node): - path_list = [] - self.get_path_list_(node, path_list) - path_list.reverse() - path = "/".join(path_list) - return path - - Tag_strip_pattern_ = re_.compile(r"\{.*\}") - - def get_path_list_(self, node, path_list): - if node is None: - return - tag = GeneratedsSuper.Tag_strip_pattern_.sub("", node.tag) - if tag: - path_list.append(tag) - self.get_path_list_(node.getparent(), path_list) - - def get_class_obj_(self, node, default_class=None): - class_obj1 = default_class - if "xsi" in node.nsmap: - classname = node.get("{%s}type" % node.nsmap["xsi"]) - if classname is not None: - names = classname.split(":") - if len(names) == 2: - classname = names[1] - class_obj2 = globals().get(classname) - if class_obj2 is not None: - class_obj1 = class_obj2 - return class_obj1 - - def gds_build_any(self, node, type_name=None): - # provide default value in case option --disable-xml is used. - content = "" - content = etree_.tostring(node, encoding="unicode") - return content - - @classmethod - def gds_reverse_node_mapping(cls, mapping): - return dict(((v, k) for k, v in mapping.items())) - - @staticmethod - def gds_encode(instring): - if sys.version_info.major == 2: - if ExternalEncoding: - encoding = ExternalEncoding - else: - encoding = "utf-8" - return instring.encode(encoding) - else: - return instring - - @staticmethod - def convert_unicode(instring): - if isinstance(instring, str): - result = quote_xml(instring) - elif sys.version_info.major == 2 and isinstance(instring, unicode): - result = quote_xml(instring).encode("utf8") - else: - result = GeneratedsSuper.gds_encode(str(instring)) - return result - - def __eq__(self, other): - def excl_select_objs_(obj): - return obj[0] != "parent_object_" and obj[0] != "gds_collector_" - - if type(self) != type(other): - return False - return all( - x == y - for x, y in zip_longest( - filter(excl_select_objs_, self.__dict__.items()), - filter(excl_select_objs_, other.__dict__.items()), - ) - ) - - def __ne__(self, other): - return not self.__eq__(other) - - # Django ETL transform hooks. - def gds_djo_etl_transform(self): - pass - - def gds_djo_etl_transform_db_obj(self, dbobj): - pass - - # SQLAlchemy ETL transform hooks. - def gds_sqa_etl_transform(self): - return 0, None - - def gds_sqa_etl_transform_db_obj(self, dbobj): - pass - - def gds_get_node_lineno_(self): - if ( - hasattr(self, "gds_elementtree_node_") - and self.gds_elementtree_node_ is not None - ): - return " near line {}".format(self.gds_elementtree_node_.sourceline) - else: - return "" - - def getSubclassFromModule_(module, class_): - """Get the subclass of a class from a specific module.""" - name = class_.__name__ + "Sub" - if hasattr(module, name): - return getattr(module, name) - else: - return None - - -# -# If you have installed IPython you can uncomment and use the following. -# IPython is available from http://ipython.scipy.org/. -# - -## from IPython.Shell import IPShellEmbed -## args = '' -## ipshell = IPShellEmbed(args, -## banner = 'Dropping into IPython', -## exit_msg = 'Leaving Interpreter, back to program.') - -# Then use the following line where and when you want to drop into the -# IPython shell: -# ipshell(' -- Entering ipshell.\nHit Ctrl-D to exit') - -# -# Globals -# - -ExternalEncoding = "" -# Set this to false in order to deactivate during export, the use of -# name space prefixes captured from the input document. -UseCapturedNS_ = True -CapturedNsmap_ = {} -Tag_pattern_ = re_.compile(r"({.*})?(.*)") -String_cleanup_pat_ = re_.compile(r"[\n\r\s]+") -Namespace_extract_pat_ = re_.compile(r"{(.*)}(.*)") -CDATA_pattern_ = re_.compile(r"", re_.DOTALL) - -# Change this to redirect the generated superclass module to use a -# specific subclass module. -CurrentSubclassModule_ = None - -# -# Support/utility functions. -# - - -def showIndent(outfile, level, pretty_print=True): - if pretty_print: - for idx in range(level): - outfile.write(" ") - - -def quote_xml(inStr): - "Escape markup chars, but do not modify CDATA sections." - if not inStr: - return "" - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s2 = "" - pos = 0 - matchobjects = CDATA_pattern_.finditer(s1) - for mo in matchobjects: - s3 = s1[pos : mo.start()] - s2 += quote_xml_aux(s3) - s2 += s1[mo.start() : mo.end()] - pos = mo.end() - s3 = s1[pos:] - s2 += quote_xml_aux(s3) - return s2 - - -def quote_xml_aux(inStr): - s1 = inStr.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - return s1 - - -def quote_attrib(inStr): - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s1 = s1.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - s1 = s1.replace("\n", " ") - if '"' in s1: - if "'" in s1: - s1 = '"%s"' % s1.replace('"', """) - else: - s1 = "'%s'" % s1 - else: - s1 = '"%s"' % s1 - return s1 - - -def quote_python(inStr): - s1 = inStr - if s1.find("'") == -1: - if s1.find("\n") == -1: - return "'%s'" % s1 - else: - return "'''%s'''" % s1 - else: - if s1.find('"') != -1: - s1 = s1.replace('"', '\\"') - if s1.find("\n") == -1: - return '"%s"' % s1 - else: - return '"""%s"""' % s1 - - -def get_all_text_(node): - if node.text is not None: - text = node.text - else: - text = "" - for child in node: - if child.tail is not None: - text += child.tail - return text - - -def find_attr_value_(attr_name, node): - attrs = node.attrib - attr_parts = attr_name.split(":") - value = None - if len(attr_parts) == 1: - value = attrs.get(attr_name) - elif len(attr_parts) == 2: - prefix, name = attr_parts - if prefix == "xml": - namespace = "http://www.w3.org/XML/1998/namespace" - else: - namespace = node.nsmap.get(prefix) - if namespace is not None: - value = attrs.get( - "{%s}%s" - % ( - namespace, - name, - ) - ) - return value - - -def encode_str_2_3(instr): - return instr - - -class GDSParseError(Exception): - pass - - -def raise_parse_error(node, msg): - if node is not None: - msg = "%s (element %s/line %d)" % ( - msg, - node.tag, - node.sourceline, - ) - raise GDSParseError(msg) - - -class MixedContainer: - # Constants for category: - CategoryNone = 0 - CategoryText = 1 - CategorySimple = 2 - CategoryComplex = 3 - # Constants for content_type: - TypeNone = 0 - TypeText = 1 - TypeString = 2 - TypeInteger = 3 - TypeFloat = 4 - TypeDecimal = 5 - TypeDouble = 6 - TypeBoolean = 7 - TypeBase64 = 8 - - def __init__(self, category, content_type, name, value): - self.category = category - self.content_type = content_type - self.name = name - self.value = value - - def getCategory(self): - return self.category - - def getContenttype(self, content_type): - return self.content_type - - def getValue(self): - return self.value - - def getName(self): - return self.name - - def export(self, outfile, level, name, namespace, pretty_print=True): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - outfile.write(self.value) - elif self.category == MixedContainer.CategorySimple: - self.exportSimple(outfile, level, name) - else: # category == MixedContainer.CategoryComplex - self.value.export( - outfile, level, namespace, name_=name, pretty_print=pretty_print - ) - - def exportSimple(self, outfile, level, name): - if self.content_type == MixedContainer.TypeString: - outfile.write("<%s>%s" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - outfile.write("<%s>%d" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - outfile.write("<%s>%f" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeDouble: - outfile.write("<%s>%g" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeBase64: - outfile.write( - "<%s>%s" % (self.name, base64.b64encode(self.value), self.name) - ) - - def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - if len(element) > 0: - if element[-1].tail is None: - element[-1].tail = self.value - else: - element[-1].tail += self.value - else: - if element.text is None: - element.text = self.value - else: - element.text += self.value - elif self.category == MixedContainer.CategorySimple: - subelement = etree_.SubElement(element, "%s" % self.name) - subelement.text = self.to_etree_simple() - else: # category == MixedContainer.CategoryComplex - self.value.to_etree(element) - - def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.content_type == MixedContainer.TypeString: - text = self.value - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - text = "%d" % self.value - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - text = "%f" % self.value - elif self.content_type == MixedContainer.TypeDouble: - text = "%g" % self.value - elif self.content_type == MixedContainer.TypeBase64: - text = "%s" % base64.b64encode(self.value) - return text - - def exportLiteral(self, outfile, level, name): - if self.category == MixedContainer.CategoryText: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - elif self.category == MixedContainer.CategorySimple: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - else: # category == MixedContainer.CategoryComplex - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s",\n' - % ( - self.category, - self.content_type, - self.name, - ) - ) - self.value.exportLiteral(outfile, level + 1) - showIndent(outfile, level) - outfile.write(")\n") - - -class MemberSpec_(object): - def __init__( - self, - name="", - data_type="", - container=0, - optional=0, - child_attrs=None, - choice=None, - ): - self.name = name - self.data_type = data_type - self.container = container - self.child_attrs = child_attrs - self.choice = choice - self.optional = optional - - def set_name(self, name): - self.name = name - - def get_name(self): - return self.name - - def set_data_type(self, data_type): - self.data_type = data_type - - def get_data_type_chain(self): - return self.data_type - - def get_data_type(self): - if isinstance(self.data_type, list): - if len(self.data_type) > 0: - return self.data_type[-1] - else: - return "xs:string" - else: - return self.data_type - - def set_container(self, container): - self.container = container - - def get_container(self): - return self.container - - def set_child_attrs(self, child_attrs): - self.child_attrs = child_attrs - - def get_child_attrs(self): - return self.child_attrs - - def set_choice(self, choice): - self.choice = choice - - def get_choice(self): - return self.choice - - def set_optional(self, optional): - self.optional = optional - - def get_optional(self): - return self.optional - - -def _cast(typ, value): - if typ is None or value is None: - return value - return typ(value) - - -# -# Data representation classes. -# - - -class Freightcom(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - username=None, - password=None, - version=None, - QuoteRequest=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.username = _cast(None, username) - self.username_nsprefix_ = None - self.password = _cast(None, password) - self.password_nsprefix_ = None - self.version = _cast(None, version) - self.version_nsprefix_ = None - self.QuoteRequest = QuoteRequest - self.QuoteRequest_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, Freightcom) - if subclass is not None: - return subclass(*args_, **kwargs_) - if Freightcom.subclass: - return Freightcom.subclass(*args_, **kwargs_) - else: - return Freightcom(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_QuoteRequest(self): - return self.QuoteRequest - - def set_QuoteRequest(self, QuoteRequest): - self.QuoteRequest = QuoteRequest - - def get_username(self): - return self.username - - def set_username(self, username): - self.username = username - - def get_password(self): - return self.password - - def set_password(self, password): - self.password = password - - def get_version(self): - return self.version - - def set_version(self, version): - self.version = version - - def _hasContent(self): - if self.QuoteRequest is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("Freightcom") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "Freightcom": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="Freightcom" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="Freightcom", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="Freightcom" - ): - if self.username is not None and "username" not in already_processed: - already_processed.add("username") - outfile.write( - " username=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.username), input_name="username" - ) - ), - ) - ) - if self.password is not None and "password" not in already_processed: - already_processed.add("password") - outfile.write( - " password=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.password), input_name="password" - ) - ), - ) - ) - if self.version is not None and "version" not in already_processed: - already_processed.add("version") - outfile.write( - " version=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.version), input_name="version" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.QuoteRequest is not None: - namespaceprefix_ = ( - self.QuoteRequest_nsprefix_ + ":" - if (UseCapturedNS_ and self.QuoteRequest_nsprefix_) - else "" - ) - self.QuoteRequest.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="QuoteRequest", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("username", node) - if value is not None and "username" not in already_processed: - already_processed.add("username") - self.username = value - value = find_attr_value_("password", node) - if value is not None and "password" not in already_processed: - already_processed.add("password") - self.password = value - value = find_attr_value_("version", node) - if value is not None and "version" not in already_processed: - already_processed.add("version") - self.version = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "QuoteRequest": - obj_ = QuoteRequestType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.QuoteRequest = obj_ - obj_.original_tagname_ = "QuoteRequest" - - -# end class Freightcom - - -class QuoteRequestType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - saturdayPickupRequired=None, - homelandSecurity=None, - pierCharge=None, - exhibitionConventionSite=None, - militaryBaseDelivery=None, - customsIn_bondFreight=None, - limitedAccess=None, - excessLength=None, - tailgatePickup=None, - residentialPickup=None, - crossBorderFee=None, - notifyRecipient=None, - singleShipment=None, - tailgateDelivery=None, - residentialDelivery=None, - insuranceType=None, - scheduledShipDate=None, - insideDelivery=None, - isSaturdayService=None, - dangerousGoodsType=None, - serviceId=None, - stackable=None, - From=None, - To=None, - COD=None, - Packages=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.saturdayPickupRequired = _cast(None, saturdayPickupRequired) - self.saturdayPickupRequired_nsprefix_ = None - self.homelandSecurity = _cast(None, homelandSecurity) - self.homelandSecurity_nsprefix_ = None - self.pierCharge = _cast(None, pierCharge) - self.pierCharge_nsprefix_ = None - self.exhibitionConventionSite = _cast(None, exhibitionConventionSite) - self.exhibitionConventionSite_nsprefix_ = None - self.militaryBaseDelivery = _cast(None, militaryBaseDelivery) - self.militaryBaseDelivery_nsprefix_ = None - self.customsIn_bondFreight = _cast(None, customsIn_bondFreight) - self.customsIn_bondFreight_nsprefix_ = None - self.limitedAccess = _cast(None, limitedAccess) - self.limitedAccess_nsprefix_ = None - self.excessLength = _cast(None, excessLength) - self.excessLength_nsprefix_ = None - self.tailgatePickup = _cast(None, tailgatePickup) - self.tailgatePickup_nsprefix_ = None - self.residentialPickup = _cast(None, residentialPickup) - self.residentialPickup_nsprefix_ = None - self.crossBorderFee = _cast(None, crossBorderFee) - self.crossBorderFee_nsprefix_ = None - self.notifyRecipient = _cast(None, notifyRecipient) - self.notifyRecipient_nsprefix_ = None - self.singleShipment = _cast(None, singleShipment) - self.singleShipment_nsprefix_ = None - self.tailgateDelivery = _cast(None, tailgateDelivery) - self.tailgateDelivery_nsprefix_ = None - self.residentialDelivery = _cast(None, residentialDelivery) - self.residentialDelivery_nsprefix_ = None - self.insuranceType = _cast(None, insuranceType) - self.insuranceType_nsprefix_ = None - self.scheduledShipDate = _cast(None, scheduledShipDate) - self.scheduledShipDate_nsprefix_ = None - self.insideDelivery = _cast(None, insideDelivery) - self.insideDelivery_nsprefix_ = None - self.isSaturdayService = _cast(None, isSaturdayService) - self.isSaturdayService_nsprefix_ = None - self.dangerousGoodsType = _cast(None, dangerousGoodsType) - self.dangerousGoodsType_nsprefix_ = None - self.serviceId = _cast(int, serviceId) - self.serviceId_nsprefix_ = None - self.stackable = _cast(None, stackable) - self.stackable_nsprefix_ = None - self.From = From - self.From_nsprefix_ = None - self.To = To - self.To_nsprefix_ = None - self.COD = COD - self.COD_nsprefix_ = None - self.Packages = Packages - self.Packages_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, QuoteRequestType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if QuoteRequestType.subclass: - return QuoteRequestType.subclass(*args_, **kwargs_) - else: - return QuoteRequestType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_From(self): - return self.From - - def set_From(self, From): - self.From = From - - def get_To(self): - return self.To - - def set_To(self, To): - self.To = To - - def get_COD(self): - return self.COD - - def set_COD(self, COD): - self.COD = COD - - def get_Packages(self): - return self.Packages - - def set_Packages(self, Packages): - self.Packages = Packages - - def get_saturdayPickupRequired(self): - return self.saturdayPickupRequired - - def set_saturdayPickupRequired(self, saturdayPickupRequired): - self.saturdayPickupRequired = saturdayPickupRequired - - def get_homelandSecurity(self): - return self.homelandSecurity - - def set_homelandSecurity(self, homelandSecurity): - self.homelandSecurity = homelandSecurity - - def get_pierCharge(self): - return self.pierCharge - - def set_pierCharge(self, pierCharge): - self.pierCharge = pierCharge - - def get_exhibitionConventionSite(self): - return self.exhibitionConventionSite - - def set_exhibitionConventionSite(self, exhibitionConventionSite): - self.exhibitionConventionSite = exhibitionConventionSite - - def get_militaryBaseDelivery(self): - return self.militaryBaseDelivery - - def set_militaryBaseDelivery(self, militaryBaseDelivery): - self.militaryBaseDelivery = militaryBaseDelivery - - def get_customsIn_bondFreight(self): - return self.customsIn_bondFreight - - def set_customsIn_bondFreight(self, customsIn_bondFreight): - self.customsIn_bondFreight = customsIn_bondFreight - - def get_limitedAccess(self): - return self.limitedAccess - - def set_limitedAccess(self, limitedAccess): - self.limitedAccess = limitedAccess - - def get_excessLength(self): - return self.excessLength - - def set_excessLength(self, excessLength): - self.excessLength = excessLength - - def get_tailgatePickup(self): - return self.tailgatePickup - - def set_tailgatePickup(self, tailgatePickup): - self.tailgatePickup = tailgatePickup - - def get_residentialPickup(self): - return self.residentialPickup - - def set_residentialPickup(self, residentialPickup): - self.residentialPickup = residentialPickup - - def get_crossBorderFee(self): - return self.crossBorderFee - - def set_crossBorderFee(self, crossBorderFee): - self.crossBorderFee = crossBorderFee - - def get_notifyRecipient(self): - return self.notifyRecipient - - def set_notifyRecipient(self, notifyRecipient): - self.notifyRecipient = notifyRecipient - - def get_singleShipment(self): - return self.singleShipment - - def set_singleShipment(self, singleShipment): - self.singleShipment = singleShipment - - def get_tailgateDelivery(self): - return self.tailgateDelivery - - def set_tailgateDelivery(self, tailgateDelivery): - self.tailgateDelivery = tailgateDelivery - - def get_residentialDelivery(self): - return self.residentialDelivery - - def set_residentialDelivery(self, residentialDelivery): - self.residentialDelivery = residentialDelivery - - def get_insuranceType(self): - return self.insuranceType - - def set_insuranceType(self, insuranceType): - self.insuranceType = insuranceType - - def get_scheduledShipDate(self): - return self.scheduledShipDate - - def set_scheduledShipDate(self, scheduledShipDate): - self.scheduledShipDate = scheduledShipDate - - def get_insideDelivery(self): - return self.insideDelivery - - def set_insideDelivery(self, insideDelivery): - self.insideDelivery = insideDelivery - - def get_isSaturdayService(self): - return self.isSaturdayService - - def set_isSaturdayService(self, isSaturdayService): - self.isSaturdayService = isSaturdayService - - def get_dangerousGoodsType(self): - return self.dangerousGoodsType - - def set_dangerousGoodsType(self, dangerousGoodsType): - self.dangerousGoodsType = dangerousGoodsType - - def get_serviceId(self): - return self.serviceId - - def set_serviceId(self, serviceId): - self.serviceId = serviceId - - def get_stackable(self): - return self.stackable - - def set_stackable(self, stackable): - self.stackable = stackable - - def _hasContent(self): - if ( - self.From is not None - or self.To is not None - or self.COD is not None - or self.Packages is not None - ): - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="QuoteRequestType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("QuoteRequestType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "QuoteRequestType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="QuoteRequestType", - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="QuoteRequestType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="QuoteRequestType", - ): - if ( - self.saturdayPickupRequired is not None - and "saturdayPickupRequired" not in already_processed - ): - already_processed.add("saturdayPickupRequired") - outfile.write( - " saturdayPickupRequired=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.saturdayPickupRequired), - input_name="saturdayPickupRequired", - ) - ), - ) - ) - if ( - self.homelandSecurity is not None - and "homelandSecurity" not in already_processed - ): - already_processed.add("homelandSecurity") - outfile.write( - " homelandSecurity=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.homelandSecurity), - input_name="homelandSecurity", - ) - ), - ) - ) - if self.pierCharge is not None and "pierCharge" not in already_processed: - already_processed.add("pierCharge") - outfile.write( - " pierCharge=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.pierCharge), input_name="pierCharge" - ) - ), - ) - ) - if ( - self.exhibitionConventionSite is not None - and "exhibitionConventionSite" not in already_processed - ): - already_processed.add("exhibitionConventionSite") - outfile.write( - " exhibitionConventionSite=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.exhibitionConventionSite), - input_name="exhibitionConventionSite", - ) - ), - ) - ) - if ( - self.militaryBaseDelivery is not None - and "militaryBaseDelivery" not in already_processed - ): - already_processed.add("militaryBaseDelivery") - outfile.write( - " militaryBaseDelivery=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.militaryBaseDelivery), - input_name="militaryBaseDelivery", - ) - ), - ) - ) - if ( - self.customsIn_bondFreight is not None - and "customsIn_bondFreight" not in already_processed - ): - already_processed.add("customsIn_bondFreight") - outfile.write( - " customsIn-bondFreight=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.customsIn_bondFreight), - input_name="customsIn-bondFreight", - ) - ), - ) - ) - if self.limitedAccess is not None and "limitedAccess" not in already_processed: - already_processed.add("limitedAccess") - outfile.write( - " limitedAccess=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.limitedAccess), input_name="limitedAccess" - ) - ), - ) - ) - if self.excessLength is not None and "excessLength" not in already_processed: - already_processed.add("excessLength") - outfile.write( - " excessLength=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.excessLength), input_name="excessLength" - ) - ), - ) - ) - if ( - self.tailgatePickup is not None - and "tailgatePickup" not in already_processed - ): - already_processed.add("tailgatePickup") - outfile.write( - " tailgatePickup=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.tailgatePickup), - input_name="tailgatePickup", - ) - ), - ) - ) - if ( - self.residentialPickup is not None - and "residentialPickup" not in already_processed - ): - already_processed.add("residentialPickup") - outfile.write( - " residentialPickup=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.residentialPickup), - input_name="residentialPickup", - ) - ), - ) - ) - if ( - self.crossBorderFee is not None - and "crossBorderFee" not in already_processed - ): - already_processed.add("crossBorderFee") - outfile.write( - " crossBorderFee=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.crossBorderFee), - input_name="crossBorderFee", - ) - ), - ) - ) - if ( - self.notifyRecipient is not None - and "notifyRecipient" not in already_processed - ): - already_processed.add("notifyRecipient") - outfile.write( - " notifyRecipient=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.notifyRecipient), - input_name="notifyRecipient", - ) - ), - ) - ) - if ( - self.singleShipment is not None - and "singleShipment" not in already_processed - ): - already_processed.add("singleShipment") - outfile.write( - " singleShipment=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.singleShipment), - input_name="singleShipment", - ) - ), - ) - ) - if ( - self.tailgateDelivery is not None - and "tailgateDelivery" not in already_processed - ): - already_processed.add("tailgateDelivery") - outfile.write( - " tailgateDelivery=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.tailgateDelivery), - input_name="tailgateDelivery", - ) - ), - ) - ) - if ( - self.residentialDelivery is not None - and "residentialDelivery" not in already_processed - ): - already_processed.add("residentialDelivery") - outfile.write( - " residentialDelivery=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.residentialDelivery), - input_name="residentialDelivery", - ) - ), - ) - ) - if self.insuranceType is not None and "insuranceType" not in already_processed: - already_processed.add("insuranceType") - outfile.write( - " insuranceType=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.insuranceType), input_name="insuranceType" - ) - ), - ) - ) - if ( - self.scheduledShipDate is not None - and "scheduledShipDate" not in already_processed - ): - already_processed.add("scheduledShipDate") - outfile.write( - " scheduledShipDate=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.scheduledShipDate), - input_name="scheduledShipDate", - ) - ), - ) - ) - if ( - self.insideDelivery is not None - and "insideDelivery" not in already_processed - ): - already_processed.add("insideDelivery") - outfile.write( - " insideDelivery=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.insideDelivery), - input_name="insideDelivery", - ) - ), - ) - ) - if ( - self.isSaturdayService is not None - and "isSaturdayService" not in already_processed - ): - already_processed.add("isSaturdayService") - outfile.write( - " isSaturdayService=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.isSaturdayService), - input_name="isSaturdayService", - ) - ), - ) - ) - if ( - self.dangerousGoodsType is not None - and "dangerousGoodsType" not in already_processed - ): - already_processed.add("dangerousGoodsType") - outfile.write( - " dangerousGoodsType=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.dangerousGoodsType), - input_name="dangerousGoodsType", - ) - ), - ) - ) - if self.serviceId is not None and "serviceId" not in already_processed: - already_processed.add("serviceId") - outfile.write( - ' serviceId="%s"' - % self.gds_format_integer(self.serviceId, input_name="serviceId") - ) - if self.stackable is not None and "stackable" not in already_processed: - already_processed.add("stackable") - outfile.write( - " stackable=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.stackable), input_name="stackable" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="QuoteRequestType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.From is not None: - namespaceprefix_ = ( - self.From_nsprefix_ + ":" - if (UseCapturedNS_ and self.From_nsprefix_) - else "" - ) - self.From.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="From", - pretty_print=pretty_print, - ) - if self.To is not None: - namespaceprefix_ = ( - self.To_nsprefix_ + ":" - if (UseCapturedNS_ and self.To_nsprefix_) - else "" - ) - self.To.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="To", - pretty_print=pretty_print, - ) - if self.COD is not None: - namespaceprefix_ = ( - self.COD_nsprefix_ + ":" - if (UseCapturedNS_ and self.COD_nsprefix_) - else "" - ) - self.COD.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="COD", - pretty_print=pretty_print, - ) - if self.Packages is not None: - namespaceprefix_ = ( - self.Packages_nsprefix_ + ":" - if (UseCapturedNS_ and self.Packages_nsprefix_) - else "" - ) - self.Packages.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Packages", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("saturdayPickupRequired", node) - if value is not None and "saturdayPickupRequired" not in already_processed: - already_processed.add("saturdayPickupRequired") - self.saturdayPickupRequired = value - value = find_attr_value_("homelandSecurity", node) - if value is not None and "homelandSecurity" not in already_processed: - already_processed.add("homelandSecurity") - self.homelandSecurity = value - value = find_attr_value_("pierCharge", node) - if value is not None and "pierCharge" not in already_processed: - already_processed.add("pierCharge") - self.pierCharge = value - value = find_attr_value_("exhibitionConventionSite", node) - if value is not None and "exhibitionConventionSite" not in already_processed: - already_processed.add("exhibitionConventionSite") - self.exhibitionConventionSite = value - value = find_attr_value_("militaryBaseDelivery", node) - if value is not None and "militaryBaseDelivery" not in already_processed: - already_processed.add("militaryBaseDelivery") - self.militaryBaseDelivery = value - value = find_attr_value_("customsIn-bondFreight", node) - if value is not None and "customsIn-bondFreight" not in already_processed: - already_processed.add("customsIn-bondFreight") - self.customsIn_bondFreight = value - value = find_attr_value_("limitedAccess", node) - if value is not None and "limitedAccess" not in already_processed: - already_processed.add("limitedAccess") - self.limitedAccess = value - value = find_attr_value_("excessLength", node) - if value is not None and "excessLength" not in already_processed: - already_processed.add("excessLength") - self.excessLength = value - value = find_attr_value_("tailgatePickup", node) - if value is not None and "tailgatePickup" not in already_processed: - already_processed.add("tailgatePickup") - self.tailgatePickup = value - value = find_attr_value_("residentialPickup", node) - if value is not None and "residentialPickup" not in already_processed: - already_processed.add("residentialPickup") - self.residentialPickup = value - value = find_attr_value_("crossBorderFee", node) - if value is not None and "crossBorderFee" not in already_processed: - already_processed.add("crossBorderFee") - self.crossBorderFee = value - value = find_attr_value_("notifyRecipient", node) - if value is not None and "notifyRecipient" not in already_processed: - already_processed.add("notifyRecipient") - self.notifyRecipient = value - value = find_attr_value_("singleShipment", node) - if value is not None and "singleShipment" not in already_processed: - already_processed.add("singleShipment") - self.singleShipment = value - value = find_attr_value_("tailgateDelivery", node) - if value is not None and "tailgateDelivery" not in already_processed: - already_processed.add("tailgateDelivery") - self.tailgateDelivery = value - value = find_attr_value_("residentialDelivery", node) - if value is not None and "residentialDelivery" not in already_processed: - already_processed.add("residentialDelivery") - self.residentialDelivery = value - value = find_attr_value_("insuranceType", node) - if value is not None and "insuranceType" not in already_processed: - already_processed.add("insuranceType") - self.insuranceType = value - value = find_attr_value_("scheduledShipDate", node) - if value is not None and "scheduledShipDate" not in already_processed: - already_processed.add("scheduledShipDate") - self.scheduledShipDate = value - value = find_attr_value_("insideDelivery", node) - if value is not None and "insideDelivery" not in already_processed: - already_processed.add("insideDelivery") - self.insideDelivery = value - value = find_attr_value_("isSaturdayService", node) - if value is not None and "isSaturdayService" not in already_processed: - already_processed.add("isSaturdayService") - self.isSaturdayService = value - value = find_attr_value_("dangerousGoodsType", node) - if value is not None and "dangerousGoodsType" not in already_processed: - already_processed.add("dangerousGoodsType") - self.dangerousGoodsType = value - value = find_attr_value_("serviceId", node) - if value is not None and "serviceId" not in already_processed: - already_processed.add("serviceId") - self.serviceId = self.gds_parse_integer(value, node, "serviceId") - value = find_attr_value_("stackable", node) - if value is not None and "stackable" not in already_processed: - already_processed.add("stackable") - self.stackable = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "From": - obj_ = FromType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.From = obj_ - obj_.original_tagname_ = "From" - elif nodeName_ == "To": - obj_ = ToType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.To = obj_ - obj_.original_tagname_ = "To" - elif nodeName_ == "COD": - obj_ = CODType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.COD = obj_ - obj_.original_tagname_ = "COD" - elif nodeName_ == "Packages": - obj_ = PackagesType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Packages = obj_ - obj_.original_tagname_ = "Packages" - - -# end class QuoteRequestType - - -class FromType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - id=None, - company=None, - instructions=None, - email=None, - attention=None, - phone=None, - tailgateRequired=None, - residential=None, - address1=None, - address2=None, - city=None, - state=None, - country=None, - zip=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.id = _cast(None, id) - self.id_nsprefix_ = None - self.company = _cast(None, company) - self.company_nsprefix_ = None - self.instructions = _cast(None, instructions) - self.instructions_nsprefix_ = None - self.email = _cast(None, email) - self.email_nsprefix_ = None - self.attention = _cast(None, attention) - self.attention_nsprefix_ = None - self.phone = _cast(None, phone) - self.phone_nsprefix_ = None - self.tailgateRequired = _cast(None, tailgateRequired) - self.tailgateRequired_nsprefix_ = None - self.residential = _cast(None, residential) - self.residential_nsprefix_ = None - self.address1 = _cast(None, address1) - self.address1_nsprefix_ = None - self.address2 = _cast(None, address2) - self.address2_nsprefix_ = None - self.city = _cast(None, city) - self.city_nsprefix_ = None - self.state = _cast(None, state) - self.state_nsprefix_ = None - self.country = _cast(None, country) - self.country_nsprefix_ = None - self.zip = _cast(None, zip) - self.zip_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, FromType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if FromType.subclass: - return FromType.subclass(*args_, **kwargs_) - else: - return FromType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_id(self): - return self.id - - def set_id(self, id): - self.id = id - - def get_company(self): - return self.company - - def set_company(self, company): - self.company = company - - def get_instructions(self): - return self.instructions - - def set_instructions(self, instructions): - self.instructions = instructions - - def get_email(self): - return self.email - - def set_email(self, email): - self.email = email - - def get_attention(self): - return self.attention - - def set_attention(self, attention): - self.attention = attention - - def get_phone(self): - return self.phone - - def set_phone(self, phone): - self.phone = phone - - def get_tailgateRequired(self): - return self.tailgateRequired - - def set_tailgateRequired(self, tailgateRequired): - self.tailgateRequired = tailgateRequired - - def get_residential(self): - return self.residential - - def set_residential(self, residential): - self.residential = residential - - def get_address1(self): - return self.address1 - - def set_address1(self, address1): - self.address1 = address1 - - def get_address2(self): - return self.address2 - - def set_address2(self, address2): - self.address2 = address2 - - def get_city(self): - return self.city - - def set_city(self, city): - self.city = city - - def get_state(self): - return self.state - - def set_state(self, state): - self.state = state - - def get_country(self): - return self.country - - def set_country(self, country): - self.country = country - - def get_zip(self): - return self.zip - - def set_zip(self, zip): - self.zip = zip - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="FromType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("FromType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "FromType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="FromType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="FromType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="FromType" - ): - if self.id is not None and "id" not in already_processed: - already_processed.add("id") - outfile.write( - " id=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.id), input_name="id") - ), - ) - ) - if self.company is not None and "company" not in already_processed: - already_processed.add("company") - outfile.write( - " company=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.company), input_name="company" - ) - ), - ) - ) - if self.instructions is not None and "instructions" not in already_processed: - already_processed.add("instructions") - outfile.write( - " instructions=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.instructions), input_name="instructions" - ) - ), - ) - ) - if self.email is not None and "email" not in already_processed: - already_processed.add("email") - outfile.write( - " email=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.email), input_name="email" - ) - ), - ) - ) - if self.attention is not None and "attention" not in already_processed: - already_processed.add("attention") - outfile.write( - " attention=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.attention), input_name="attention" - ) - ), - ) - ) - if self.phone is not None and "phone" not in already_processed: - already_processed.add("phone") - outfile.write( - " phone=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.phone), input_name="phone" - ) - ), - ) - ) - if ( - self.tailgateRequired is not None - and "tailgateRequired" not in already_processed - ): - already_processed.add("tailgateRequired") - outfile.write( - " tailgateRequired=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.tailgateRequired), - input_name="tailgateRequired", - ) - ), - ) - ) - if self.residential is not None and "residential" not in already_processed: - already_processed.add("residential") - outfile.write( - " residential=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.residential), input_name="residential" - ) - ), - ) - ) - if self.address1 is not None and "address1" not in already_processed: - already_processed.add("address1") - outfile.write( - " address1=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address1), input_name="address1" - ) - ), - ) - ) - if self.address2 is not None and "address2" not in already_processed: - already_processed.add("address2") - outfile.write( - " address2=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address2), input_name="address2" - ) - ), - ) - ) - if self.city is not None and "city" not in already_processed: - already_processed.add("city") - outfile.write( - " city=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.city), input_name="city" - ) - ), - ) - ) - if self.state is not None and "state" not in already_processed: - already_processed.add("state") - outfile.write( - " state=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.state), input_name="state" - ) - ), - ) - ) - if self.country is not None and "country" not in already_processed: - already_processed.add("country") - outfile.write( - " country=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.country), input_name="country" - ) - ), - ) - ) - if self.zip is not None and "zip" not in already_processed: - already_processed.add("zip") - outfile.write( - " zip=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.zip), input_name="zip") - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="FromType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("id", node) - if value is not None and "id" not in already_processed: - already_processed.add("id") - self.id = value - value = find_attr_value_("company", node) - if value is not None and "company" not in already_processed: - already_processed.add("company") - self.company = value - value = find_attr_value_("instructions", node) - if value is not None and "instructions" not in already_processed: - already_processed.add("instructions") - self.instructions = value - value = find_attr_value_("email", node) - if value is not None and "email" not in already_processed: - already_processed.add("email") - self.email = value - value = find_attr_value_("attention", node) - if value is not None and "attention" not in already_processed: - already_processed.add("attention") - self.attention = value - value = find_attr_value_("phone", node) - if value is not None and "phone" not in already_processed: - already_processed.add("phone") - self.phone = value - value = find_attr_value_("tailgateRequired", node) - if value is not None and "tailgateRequired" not in already_processed: - already_processed.add("tailgateRequired") - self.tailgateRequired = value - value = find_attr_value_("residential", node) - if value is not None and "residential" not in already_processed: - already_processed.add("residential") - self.residential = value - value = find_attr_value_("address1", node) - if value is not None and "address1" not in already_processed: - already_processed.add("address1") - self.address1 = value - value = find_attr_value_("address2", node) - if value is not None and "address2" not in already_processed: - already_processed.add("address2") - self.address2 = value - value = find_attr_value_("city", node) - if value is not None and "city" not in already_processed: - already_processed.add("city") - self.city = value - value = find_attr_value_("state", node) - if value is not None and "state" not in already_processed: - already_processed.add("state") - self.state = value - value = find_attr_value_("country", node) - if value is not None and "country" not in already_processed: - already_processed.add("country") - self.country = value - value = find_attr_value_("zip", node) - if value is not None and "zip" not in already_processed: - already_processed.add("zip") - self.zip = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class FromType - - -class ToType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - id=None, - company=None, - notifyRecipient=None, - instructions=None, - email=None, - attention=None, - phone=None, - tailgateRequired=None, - residential=None, - address1=None, - address2=None, - city=None, - state=None, - zip=None, - country=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.id = _cast(None, id) - self.id_nsprefix_ = None - self.company = _cast(None, company) - self.company_nsprefix_ = None - self.notifyRecipient = _cast(None, notifyRecipient) - self.notifyRecipient_nsprefix_ = None - self.instructions = _cast(None, instructions) - self.instructions_nsprefix_ = None - self.email = _cast(None, email) - self.email_nsprefix_ = None - self.attention = _cast(None, attention) - self.attention_nsprefix_ = None - self.phone = _cast(None, phone) - self.phone_nsprefix_ = None - self.tailgateRequired = _cast(None, tailgateRequired) - self.tailgateRequired_nsprefix_ = None - self.residential = _cast(None, residential) - self.residential_nsprefix_ = None - self.address1 = _cast(None, address1) - self.address1_nsprefix_ = None - self.address2 = _cast(None, address2) - self.address2_nsprefix_ = None - self.city = _cast(None, city) - self.city_nsprefix_ = None - self.state = _cast(None, state) - self.state_nsprefix_ = None - self.zip = _cast(None, zip) - self.zip_nsprefix_ = None - self.country = _cast(None, country) - self.country_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ToType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ToType.subclass: - return ToType.subclass(*args_, **kwargs_) - else: - return ToType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_id(self): - return self.id - - def set_id(self, id): - self.id = id - - def get_company(self): - return self.company - - def set_company(self, company): - self.company = company - - def get_notifyRecipient(self): - return self.notifyRecipient - - def set_notifyRecipient(self, notifyRecipient): - self.notifyRecipient = notifyRecipient - - def get_instructions(self): - return self.instructions - - def set_instructions(self, instructions): - self.instructions = instructions - - def get_email(self): - return self.email - - def set_email(self, email): - self.email = email - - def get_attention(self): - return self.attention - - def set_attention(self, attention): - self.attention = attention - - def get_phone(self): - return self.phone - - def set_phone(self, phone): - self.phone = phone - - def get_tailgateRequired(self): - return self.tailgateRequired - - def set_tailgateRequired(self, tailgateRequired): - self.tailgateRequired = tailgateRequired - - def get_residential(self): - return self.residential - - def set_residential(self, residential): - self.residential = residential - - def get_address1(self): - return self.address1 - - def set_address1(self, address1): - self.address1 = address1 - - def get_address2(self): - return self.address2 - - def set_address2(self, address2): - self.address2 = address2 - - def get_city(self): - return self.city - - def set_city(self, city): - self.city = city - - def get_state(self): - return self.state - - def set_state(self, state): - self.state = state - - def get_zip(self): - return self.zip - - def set_zip(self, zip): - self.zip = zip - - def get_country(self): - return self.country - - def set_country(self, country): - self.country = country - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ToType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ToType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ToType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="ToType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ToType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="ToType" - ): - if self.id is not None and "id" not in already_processed: - already_processed.add("id") - outfile.write( - " id=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.id), input_name="id") - ), - ) - ) - if self.company is not None and "company" not in already_processed: - already_processed.add("company") - outfile.write( - " company=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.company), input_name="company" - ) - ), - ) - ) - if ( - self.notifyRecipient is not None - and "notifyRecipient" not in already_processed - ): - already_processed.add("notifyRecipient") - outfile.write( - " notifyRecipient=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.notifyRecipient), - input_name="notifyRecipient", - ) - ), - ) - ) - if self.instructions is not None and "instructions" not in already_processed: - already_processed.add("instructions") - outfile.write( - " instructions=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.instructions), input_name="instructions" - ) - ), - ) - ) - if self.email is not None and "email" not in already_processed: - already_processed.add("email") - outfile.write( - " email=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.email), input_name="email" - ) - ), - ) - ) - if self.attention is not None and "attention" not in already_processed: - already_processed.add("attention") - outfile.write( - " attention=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.attention), input_name="attention" - ) - ), - ) - ) - if self.phone is not None and "phone" not in already_processed: - already_processed.add("phone") - outfile.write( - " phone=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.phone), input_name="phone" - ) - ), - ) - ) - if ( - self.tailgateRequired is not None - and "tailgateRequired" not in already_processed - ): - already_processed.add("tailgateRequired") - outfile.write( - " tailgateRequired=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.tailgateRequired), - input_name="tailgateRequired", - ) - ), - ) - ) - if self.residential is not None and "residential" not in already_processed: - already_processed.add("residential") - outfile.write( - " residential=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.residential), input_name="residential" - ) - ), - ) - ) - if self.address1 is not None and "address1" not in already_processed: - already_processed.add("address1") - outfile.write( - " address1=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address1), input_name="address1" - ) - ), - ) - ) - if self.address2 is not None and "address2" not in already_processed: - already_processed.add("address2") - outfile.write( - " address2=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address2), input_name="address2" - ) - ), - ) - ) - if self.city is not None and "city" not in already_processed: - already_processed.add("city") - outfile.write( - " city=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.city), input_name="city" - ) - ), - ) - ) - if self.state is not None and "state" not in already_processed: - already_processed.add("state") - outfile.write( - " state=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.state), input_name="state" - ) - ), - ) - ) - if self.zip is not None and "zip" not in already_processed: - already_processed.add("zip") - outfile.write( - " zip=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.zip), input_name="zip") - ), - ) - ) - if self.country is not None and "country" not in already_processed: - already_processed.add("country") - outfile.write( - " country=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.country), input_name="country" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ToType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("id", node) - if value is not None and "id" not in already_processed: - already_processed.add("id") - self.id = value - value = find_attr_value_("company", node) - if value is not None and "company" not in already_processed: - already_processed.add("company") - self.company = value - value = find_attr_value_("notifyRecipient", node) - if value is not None and "notifyRecipient" not in already_processed: - already_processed.add("notifyRecipient") - self.notifyRecipient = value - value = find_attr_value_("instructions", node) - if value is not None and "instructions" not in already_processed: - already_processed.add("instructions") - self.instructions = value - value = find_attr_value_("email", node) - if value is not None and "email" not in already_processed: - already_processed.add("email") - self.email = value - value = find_attr_value_("attention", node) - if value is not None and "attention" not in already_processed: - already_processed.add("attention") - self.attention = value - value = find_attr_value_("phone", node) - if value is not None and "phone" not in already_processed: - already_processed.add("phone") - self.phone = value - value = find_attr_value_("tailgateRequired", node) - if value is not None and "tailgateRequired" not in already_processed: - already_processed.add("tailgateRequired") - self.tailgateRequired = value - value = find_attr_value_("residential", node) - if value is not None and "residential" not in already_processed: - already_processed.add("residential") - self.residential = value - value = find_attr_value_("address1", node) - if value is not None and "address1" not in already_processed: - already_processed.add("address1") - self.address1 = value - value = find_attr_value_("address2", node) - if value is not None and "address2" not in already_processed: - already_processed.add("address2") - self.address2 = value - value = find_attr_value_("city", node) - if value is not None and "city" not in already_processed: - already_processed.add("city") - self.city = value - value = find_attr_value_("state", node) - if value is not None and "state" not in already_processed: - already_processed.add("state") - self.state = value - value = find_attr_value_("zip", node) - if value is not None and "zip" not in already_processed: - already_processed.add("zip") - self.zip = value - value = find_attr_value_("country", node) - if value is not None and "country" not in already_processed: - already_processed.add("country") - self.country = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class ToType - - -class CODType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, paymentType=None, CODReturnAddress=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.paymentType = _cast(None, paymentType) - self.paymentType_nsprefix_ = None - self.CODReturnAddress = CODReturnAddress - self.CODReturnAddress_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, CODType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if CODType.subclass: - return CODType.subclass(*args_, **kwargs_) - else: - return CODType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_CODReturnAddress(self): - return self.CODReturnAddress - - def set_CODReturnAddress(self, CODReturnAddress): - self.CODReturnAddress = CODReturnAddress - - def get_paymentType(self): - return self.paymentType - - def set_paymentType(self, paymentType): - self.paymentType = paymentType - - def _hasContent(self): - if self.CODReturnAddress is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CODType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("CODType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "CODType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="CODType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="CODType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="CODType" - ): - if self.paymentType is not None and "paymentType" not in already_processed: - already_processed.add("paymentType") - outfile.write( - " paymentType=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.paymentType), input_name="paymentType" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CODType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.CODReturnAddress is not None: - namespaceprefix_ = ( - self.CODReturnAddress_nsprefix_ + ":" - if (UseCapturedNS_ and self.CODReturnAddress_nsprefix_) - else "" - ) - self.CODReturnAddress.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="CODReturnAddress", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("paymentType", node) - if value is not None and "paymentType" not in already_processed: - already_processed.add("paymentType") - self.paymentType = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "CODReturnAddress": - obj_ = CODReturnAddressType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.CODReturnAddress = obj_ - obj_.original_tagname_ = "CODReturnAddress" - - -# end class CODType - - -class CODReturnAddressType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - codCompany=None, - codName=None, - codAddress1=None, - codCity=None, - codStateCode=None, - codZip=None, - codCountry=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.codCompany = _cast(None, codCompany) - self.codCompany_nsprefix_ = None - self.codName = _cast(None, codName) - self.codName_nsprefix_ = None - self.codAddress1 = _cast(None, codAddress1) - self.codAddress1_nsprefix_ = None - self.codCity = _cast(None, codCity) - self.codCity_nsprefix_ = None - self.codStateCode = _cast(None, codStateCode) - self.codStateCode_nsprefix_ = None - self.codZip = _cast(None, codZip) - self.codZip_nsprefix_ = None - self.codCountry = _cast(None, codCountry) - self.codCountry_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, CODReturnAddressType - ) - if subclass is not None: - return subclass(*args_, **kwargs_) - if CODReturnAddressType.subclass: - return CODReturnAddressType.subclass(*args_, **kwargs_) - else: - return CODReturnAddressType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_codCompany(self): - return self.codCompany - - def set_codCompany(self, codCompany): - self.codCompany = codCompany - - def get_codName(self): - return self.codName - - def set_codName(self, codName): - self.codName = codName - - def get_codAddress1(self): - return self.codAddress1 - - def set_codAddress1(self, codAddress1): - self.codAddress1 = codAddress1 - - def get_codCity(self): - return self.codCity - - def set_codCity(self, codCity): - self.codCity = codCity - - def get_codStateCode(self): - return self.codStateCode - - def set_codStateCode(self, codStateCode): - self.codStateCode = codStateCode - - def get_codZip(self): - return self.codZip - - def set_codZip(self, codZip): - self.codZip = codZip - - def get_codCountry(self): - return self.codCountry - - def set_codCountry(self, codCountry): - self.codCountry = codCountry - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CODReturnAddressType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("CODReturnAddressType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "CODReturnAddressType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="CODReturnAddressType", - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="CODReturnAddressType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="CODReturnAddressType", - ): - if self.codCompany is not None and "codCompany" not in already_processed: - already_processed.add("codCompany") - outfile.write( - " codCompany=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codCompany), input_name="codCompany" - ) - ), - ) - ) - if self.codName is not None and "codName" not in already_processed: - already_processed.add("codName") - outfile.write( - " codName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codName), input_name="codName" - ) - ), - ) - ) - if self.codAddress1 is not None and "codAddress1" not in already_processed: - already_processed.add("codAddress1") - outfile.write( - " codAddress1=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codAddress1), input_name="codAddress1" - ) - ), - ) - ) - if self.codCity is not None and "codCity" not in already_processed: - already_processed.add("codCity") - outfile.write( - " codCity=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codCity), input_name="codCity" - ) - ), - ) - ) - if self.codStateCode is not None and "codStateCode" not in already_processed: - already_processed.add("codStateCode") - outfile.write( - " codStateCode=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codStateCode), input_name="codStateCode" - ) - ), - ) - ) - if self.codZip is not None and "codZip" not in already_processed: - already_processed.add("codZip") - outfile.write( - " codZip=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codZip), input_name="codZip" - ) - ), - ) - ) - if self.codCountry is not None and "codCountry" not in already_processed: - already_processed.add("codCountry") - outfile.write( - " codCountry=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codCountry), input_name="codCountry" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CODReturnAddressType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("codCompany", node) - if value is not None and "codCompany" not in already_processed: - already_processed.add("codCompany") - self.codCompany = value - value = find_attr_value_("codName", node) - if value is not None and "codName" not in already_processed: - already_processed.add("codName") - self.codName = value - value = find_attr_value_("codAddress1", node) - if value is not None and "codAddress1" not in already_processed: - already_processed.add("codAddress1") - self.codAddress1 = value - value = find_attr_value_("codCity", node) - if value is not None and "codCity" not in already_processed: - already_processed.add("codCity") - self.codCity = value - value = find_attr_value_("codStateCode", node) - if value is not None and "codStateCode" not in already_processed: - already_processed.add("codStateCode") - self.codStateCode = value - value = find_attr_value_("codZip", node) - if value is not None and "codZip" not in already_processed: - already_processed.add("codZip") - self.codZip = value - value = find_attr_value_("codCountry", node) - if value is not None and "codCountry" not in already_processed: - already_processed.add("codCountry") - self.codCountry = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class CODReturnAddressType - - -class PackagesType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, type_=None, Package=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.type_ = _cast(None, type_) - self.type__nsprefix_ = None - if Package is None: - self.Package = [] - else: - self.Package = Package - self.Package_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, PackagesType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if PackagesType.subclass: - return PackagesType.subclass(*args_, **kwargs_) - else: - return PackagesType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Package(self): - return self.Package - - def set_Package(self, Package): - self.Package = Package - - def add_Package(self, value): - self.Package.append(value) - - def insert_Package_at(self, index, value): - self.Package.insert(index, value) - - def replace_Package_at(self, index, value): - self.Package[index] = value - - def get_type(self): - return self.type_ - - def set_type(self, type_): - self.type_ = type_ - - def _hasContent(self): - if self.Package: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackagesType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("PackagesType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "PackagesType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="PackagesType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="PackagesType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="PackagesType", - ): - if self.type_ is not None and "type_" not in already_processed: - already_processed.add("type_") - outfile.write( - " type=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.type_), input_name="type" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackagesType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - for Package_ in self.Package: - namespaceprefix_ = ( - self.Package_nsprefix_ + ":" - if (UseCapturedNS_ and self.Package_nsprefix_) - else "" - ) - Package_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Package", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("type", node) - if value is not None and "type" not in already_processed: - already_processed.add("type") - self.type_ = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Package": - obj_ = PackageType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Package.append(obj_) - obj_.original_tagname_ = "Package" - - -# end class PackagesType - - -class PackageType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - length=None, - width=None, - height=None, - weight=None, - type_=None, - freightClass=None, - nmfcCode=None, - insuranceAmount=None, - codAmount=None, - description=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.length = _cast(int, length) - self.length_nsprefix_ = None - self.width = _cast(int, width) - self.width_nsprefix_ = None - self.height = _cast(int, height) - self.height_nsprefix_ = None - self.weight = _cast(int, weight) - self.weight_nsprefix_ = None - self.type_ = _cast(None, type_) - self.type__nsprefix_ = None - self.freightClass = _cast(int, freightClass) - self.freightClass_nsprefix_ = None - self.nmfcCode = _cast(None, nmfcCode) - self.nmfcCode_nsprefix_ = None - self.insuranceAmount = _cast(float, insuranceAmount) - self.insuranceAmount_nsprefix_ = None - self.codAmount = _cast(float, codAmount) - self.codAmount_nsprefix_ = None - self.description = _cast(None, description) - self.description_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, PackageType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if PackageType.subclass: - return PackageType.subclass(*args_, **kwargs_) - else: - return PackageType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_length(self): - return self.length - - def set_length(self, length): - self.length = length - - def get_width(self): - return self.width - - def set_width(self, width): - self.width = width - - def get_height(self): - return self.height - - def set_height(self, height): - self.height = height - - def get_weight(self): - return self.weight - - def set_weight(self, weight): - self.weight = weight - - def get_type(self): - return self.type_ - - def set_type(self, type_): - self.type_ = type_ - - def get_freightClass(self): - return self.freightClass - - def set_freightClass(self, freightClass): - self.freightClass = freightClass - - def get_nmfcCode(self): - return self.nmfcCode - - def set_nmfcCode(self, nmfcCode): - self.nmfcCode = nmfcCode - - def get_insuranceAmount(self): - return self.insuranceAmount - - def set_insuranceAmount(self, insuranceAmount): - self.insuranceAmount = insuranceAmount - - def get_codAmount(self): - return self.codAmount - - def set_codAmount(self, codAmount): - self.codAmount = codAmount - - def get_description(self): - return self.description - - def set_description(self, description): - self.description = description - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackageType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("PackageType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "PackageType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="PackageType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="PackageType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="PackageType", - ): - if self.length is not None and "length" not in already_processed: - already_processed.add("length") - outfile.write( - ' length="%s"' - % self.gds_format_integer(self.length, input_name="length") - ) - if self.width is not None and "width" not in already_processed: - already_processed.add("width") - outfile.write( - ' width="%s"' % self.gds_format_integer(self.width, input_name="width") - ) - if self.height is not None and "height" not in already_processed: - already_processed.add("height") - outfile.write( - ' height="%s"' - % self.gds_format_integer(self.height, input_name="height") - ) - if self.weight is not None and "weight" not in already_processed: - already_processed.add("weight") - outfile.write( - ' weight="%s"' - % self.gds_format_integer(self.weight, input_name="weight") - ) - if self.type_ is not None and "type_" not in already_processed: - already_processed.add("type_") - outfile.write( - " type=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.type_), input_name="type" - ) - ), - ) - ) - if self.freightClass is not None and "freightClass" not in already_processed: - already_processed.add("freightClass") - outfile.write( - ' freightClass="%s"' - % self.gds_format_integer(self.freightClass, input_name="freightClass") - ) - if self.nmfcCode is not None and "nmfcCode" not in already_processed: - already_processed.add("nmfcCode") - outfile.write( - " nmfcCode=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.nmfcCode), input_name="nmfcCode" - ) - ), - ) - ) - if ( - self.insuranceAmount is not None - and "insuranceAmount" not in already_processed - ): - already_processed.add("insuranceAmount") - outfile.write( - ' insuranceAmount="%s"' - % self.gds_format_float( - self.insuranceAmount, input_name="insuranceAmount" - ) - ) - if self.codAmount is not None and "codAmount" not in already_processed: - already_processed.add("codAmount") - outfile.write( - ' codAmount="%s"' - % self.gds_format_float(self.codAmount, input_name="codAmount") - ) - if self.description is not None and "description" not in already_processed: - already_processed.add("description") - outfile.write( - " description=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.description), input_name="description" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackageType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("length", node) - if value is not None and "length" not in already_processed: - already_processed.add("length") - self.length = self.gds_parse_integer(value, node, "length") - value = find_attr_value_("width", node) - if value is not None and "width" not in already_processed: - already_processed.add("width") - self.width = self.gds_parse_integer(value, node, "width") - value = find_attr_value_("height", node) - if value is not None and "height" not in already_processed: - already_processed.add("height") - self.height = self.gds_parse_integer(value, node, "height") - value = find_attr_value_("weight", node) - if value is not None and "weight" not in already_processed: - already_processed.add("weight") - self.weight = self.gds_parse_integer(value, node, "weight") - value = find_attr_value_("type", node) - if value is not None and "type" not in already_processed: - already_processed.add("type") - self.type_ = value - value = find_attr_value_("freightClass", node) - if value is not None and "freightClass" not in already_processed: - already_processed.add("freightClass") - self.freightClass = self.gds_parse_integer(value, node, "freightClass") - value = find_attr_value_("nmfcCode", node) - if value is not None and "nmfcCode" not in already_processed: - already_processed.add("nmfcCode") - self.nmfcCode = value - value = find_attr_value_("insuranceAmount", node) - if value is not None and "insuranceAmount" not in already_processed: - already_processed.add("insuranceAmount") - value = self.gds_parse_float(value, node, "insuranceAmount") - self.insuranceAmount = value - value = find_attr_value_("codAmount", node) - if value is not None and "codAmount" not in already_processed: - already_processed.add("codAmount") - value = self.gds_parse_float(value, node, "codAmount") - self.codAmount = value - value = find_attr_value_("description", node) - if value is not None and "description" not in already_processed: - already_processed.add("description") - self.description = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class PackageType - - -GDSClassesMapping = {} - - -USAGE_TEXT = """ -Usage: python .py [ -s ] -""" - - -def usage(): - print(USAGE_TEXT) - sys.exit(1) - - -def get_root_tag(node): - tag = Tag_pattern_.match(node.tag).groups()[-1] - prefix_tag = TagNamePrefix + tag - rootClass = GDSClassesMapping.get(prefix_tag) - if rootClass is None: - rootClass = globals().get(prefix_tag) - return tag, rootClass - - -def get_required_ns_prefix_defs(rootNode): - """Get all name space prefix definitions required in this XML doc. - Return a dictionary of definitions and a char string of definitions. - """ - nsmap = { - prefix: uri - for node in rootNode.iter() - for (prefix, uri) in node.nsmap.items() - if prefix is not None - } - namespacedefs = " ".join( - ['xmlns:{}="{}"'.format(prefix, uri) for prefix, uri in nsmap.items()] - ) - return nsmap, namespacedefs - - -def parse(inFileName, silence=False, print_warnings=True): - global CapturedNsmap_ - gds_collector = GdsCollector_() - parser = None - doc = parsexml_(inFileName, parser) - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode) - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export( - sys.stdout, 0, name_=rootTag, namespacedef_=namespacedefs, pretty_print=True - ) - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseEtree( - inFileName, - silence=False, - print_warnings=True, - mapping=None, - reverse_mapping=None, - nsmap=None, -): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if mapping is None: - mapping = {} - if reverse_mapping is None: - reverse_mapping = {} - rootElement = rootObj.to_etree( - None, - name_=rootTag, - mapping_=mapping, - reverse_mapping_=reverse_mapping, - nsmap_=nsmap, - ) - reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - content = etree_.tostring( - rootElement, pretty_print=True, xml_declaration=True, encoding="utf-8" - ) - sys.stdout.write(str(content)) - sys.stdout.write("\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj, rootElement, mapping, reverse_node_mapping - - -def parseString(inString, silence=False, print_warnings=True): - """Parse a string, create the object tree, and export it. - - Arguments: - - inString -- A string. This XML fragment should not start - with an XML declaration containing an encoding. - - silence -- A boolean. If False, export the object. - Returns -- The root object in the tree. - """ - parser = None - rootNode = parsexmlstring_(inString, parser) - gds_collector = GdsCollector_() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if not SaveElementTreeNode: - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export(sys.stdout, 0, name_=rootTag, namespacedef_="") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseLiteral(inFileName, silence=False, print_warnings=True): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write("#from quote_request import *\n\n") - sys.stdout.write("import quote_request as model_\n\n") - sys.stdout.write("rootObj = model_.rootClass(\n") - rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) - sys.stdout.write(")\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def main(): - args = sys.argv[1:] - if len(args) == 1: - parse(args[0]) - else: - usage() - - -if __name__ == "__main__": - # import pdb; pdb.set_trace() - main() - -RenameMappings_ = {} - -# -# Mapping of namespaces to types defined in them -# and the file in which each is defined. -# simpleTypes are marked "ST" and complexTypes "CT". -NamespaceToDefMappings_ = {"http://www.freightcom.net/XMLSchema": []} - -__all__ = [ - "CODReturnAddressType", - "CODType", - "Freightcom", - "FromType", - "PackageType", - "PackagesType", - "QuoteRequestType", - "ToType", -] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/rate_request.py b/modules/connectors/freightcom/karrio/schemas/freightcom/rate_request.py new file mode 100644 index 0000000000..5ee52b6086 --- /dev/null +++ b/modules/connectors/freightcom/karrio/schemas/freightcom/rate_request.py @@ -0,0 +1,173 @@ +from attr import s +from typing import Optional, List +from jstruct import JStruct, JList + + +@s(auto_attribs=True) +class AddressType: + address_line_1: Optional[str] = None + address_line_2: Optional[str] = None + unit_number: Optional[str] = None + city: Optional[str] = None + region: Optional[str] = None + country: Optional[str] = None + postal_code: Optional[str] = None + + +@s(auto_attribs=True) +class PhoneNumberType: + number: Optional[str] = None + extension: Optional[int] = None + + +@s(auto_attribs=True) +class ReadyType: + hour: Optional[int] = None + minute: Optional[int] = None + + +@s(auto_attribs=True) +class DestinationType: + name: Optional[str] = None + address: Optional[AddressType] = JStruct[AddressType] + residential: Optional[bool] = None + tailgate_required: Optional[bool] = None + instructions: Optional[str] = None + contact_name: Optional[str] = None + phone_number: Optional[PhoneNumberType] = JStruct[PhoneNumberType] + email_addresses: List[str] = [] + receives_email_updates: Optional[bool] = None + ready_at: Optional[ReadyType] = JStruct[ReadyType] + ready_until: Optional[ReadyType] = JStruct[ReadyType] + signature_requirement: Optional[str] = None + + +@s(auto_attribs=True) +class ExpectedShipDateType: + year: Optional[int] = None + month: Optional[int] = None + day: Optional[int] = None + + +@s(auto_attribs=True) +class WeightType: + unit: Optional[str] = None + value: Optional[float] = None + + +@s(auto_attribs=True) +class CourierpakMeasurementsType: + weight: Optional[WeightType] = JStruct[WeightType] + + +@s(auto_attribs=True) +class CourierpakType: + measurements: Optional[CourierpakMeasurementsType] = JStruct[CourierpakMeasurementsType] + description: Optional[str] = None + + +@s(auto_attribs=True) +class DangerousGoodsDetailsType: + packaging_group: Optional[str] = None + goods_class: Optional[str] = None + description: Optional[str] = None + united_nations_number: Optional[str] = None + emergency_contact_name: Optional[str] = None + emergency_contact_phone_number: Optional[PhoneNumberType] = JStruct[PhoneNumberType] + + +@s(auto_attribs=True) +class TotalCostType: + currency: Optional[str] = None + value: Optional[int] = None + + +@s(auto_attribs=True) +class InsuranceType: + type: Optional[str] = None + total_cost: Optional[TotalCostType] = JStruct[TotalCostType] + + +@s(auto_attribs=True) +class CuboidType: + unit: Optional[str] = None + l: Optional[int] = None + w: Optional[int] = None + h: Optional[int] = None + + +@s(auto_attribs=True) +class PackageMeasurementsType: + weight: Optional[WeightType] = JStruct[WeightType] + cuboid: Optional[CuboidType] = JStruct[CuboidType] + + +@s(auto_attribs=True) +class PackageType: + measurements: Optional[PackageMeasurementsType] = JStruct[PackageMeasurementsType] + description: Optional[str] = None + + +@s(auto_attribs=True) +class InBondDetailsType: + type: Optional[str] = None + name: Optional[str] = None + address: Optional[str] = None + contact_method: Optional[str] = None + contact_email_address: Optional[str] = None + contact_phone_number: Optional[PhoneNumberType] = JStruct[PhoneNumberType] + + +@s(auto_attribs=True) +class PalletServiceDetailsType: + limited_access_delivery_type: Optional[str] = None + limited_access_delivery_other_name: Optional[str] = None + in_bond: Optional[bool] = None + in_bond_details: Optional[InBondDetailsType] = JStruct[InBondDetailsType] + appointment_delivery: Optional[bool] = None + protect_from_freeze: Optional[bool] = None + threshold_pickup: Optional[bool] = None + threshold_delivery: Optional[bool] = None + + +@s(auto_attribs=True) +class PalletType: + measurements: Optional[PackageMeasurementsType] = JStruct[PackageMeasurementsType] + description: Optional[str] = None + freight_class: Optional[str] = None + nmfc: Optional[str] = None + contents_type: Optional[str] = None + num_pieces: Optional[int] = None + + +@s(auto_attribs=True) +class PackagingPropertiesType: + pallet_type: Optional[str] = None + has_stackable_pallets: Optional[bool] = None + dangerous_goods: Optional[str] = None + dangerous_goods_details: Optional[DangerousGoodsDetailsType] = JStruct[DangerousGoodsDetailsType] + pallets: List[PalletType] = JList[PalletType] + packages: List[PackageType] = JList[PackageType] + courierpaks: List[CourierpakType] = JList[CourierpakType] + includes_return_label: Optional[bool] = None + special_handling_required: Optional[bool] = None + has_dangerous_goods: Optional[bool] = None + pallet_service_details: Optional[PalletServiceDetailsType] = JStruct[PalletServiceDetailsType] + insurance: Optional[InsuranceType] = JStruct[InsuranceType] + + +@s(auto_attribs=True) +class DetailsType: + origin: Optional[DestinationType] = JStruct[DestinationType] + destination: Optional[DestinationType] = JStruct[DestinationType] + expected_ship_date: Optional[ExpectedShipDateType] = JStruct[ExpectedShipDateType] + packaging_type: Optional[str] = None + packaging_properties: Optional[PackagingPropertiesType] = JStruct[PackagingPropertiesType] + reference_codes: List[str] = [] + + +@s(auto_attribs=True) +class RateRequestType: + services: List[str] = [] + excluded_services: List[str] = [] + details: Optional[DetailsType] = JStruct[DetailsType] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/rate_response.py b/modules/connectors/freightcom/karrio/schemas/freightcom/rate_response.py new file mode 100644 index 0000000000..95a8c5f0b1 --- /dev/null +++ b/modules/connectors/freightcom/karrio/schemas/freightcom/rate_response.py @@ -0,0 +1,49 @@ +from attr import s +from typing import Optional, List +from jstruct import JStruct, JList + + +@s(auto_attribs=True) +class BaseType: + currency: Optional[str] = None + value: Optional[int] = None + + +@s(auto_attribs=True) +class SurchargeType: + type: Optional[str] = None + amount: Optional[BaseType] = JStruct[BaseType] + + +@s(auto_attribs=True) +class ValidUntilType: + year: Optional[int] = None + month: Optional[int] = None + day: Optional[int] = None + + +@s(auto_attribs=True) +class RateType: + carrier_name: Optional[str] = None + service_name: Optional[str] = None + service_id: Optional[str] = None + valid_until: Optional[ValidUntilType] = JStruct[ValidUntilType] + total: Optional[BaseType] = JStruct[BaseType] + base: Optional[BaseType] = JStruct[BaseType] + surcharges: List[SurchargeType] = JList[SurchargeType] + taxes: List[SurchargeType] = JList[SurchargeType] + transit_time_days: Optional[int] = None + transit_time_not_available: Optional[bool] = None + + +@s(auto_attribs=True) +class StatusType: + done: Optional[bool] = None + total: Optional[int] = None + complete: Optional[int] = None + + +@s(auto_attribs=True) +class RateResponseType: + status: Optional[StatusType] = JStruct[StatusType] + rates: List[RateType] = JList[RateType] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/shipment_cancel_reply.py b/modules/connectors/freightcom/karrio/schemas/freightcom/shipment_cancel_reply.py deleted file mode 100644 index c1c5aff29a..0000000000 --- a/modules/connectors/freightcom/karrio/schemas/freightcom/shipment_cancel_reply.py +++ /dev/null @@ -1,2063 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# -# Generated Fri Oct 21 12:33:21 2022 by generateDS.py version 2.41.1. -# Python 3.10.8 (v3.10.8:aaaf517424, Oct 11 2022, 10:14:40) [Clang 13.0.0 (clang-1300.0.29.30)] -# -# Command line options: -# ('--no-namespace-defs', '') -# ('-o', './karrio.schemas.freightcom/shipment_cancel_reply.py') -# -# Command line arguments: -# ./vendor/schemas/shipment_cancel_reply.xsd -# -# Command line: -# /Users/danielk/Documents/karrio/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio.schemas.freightcom/shipment_cancel_reply.py" ./vendor/schemas/shipment_cancel_reply.xsd -# -# Current working directory (os.getcwd()): -# freightcom -# - -import sys - -try: - ModulenotfoundExp_ = ModuleNotFoundError -except NameError: - ModulenotfoundExp_ = ImportError -from six.moves import zip_longest -import os -import re as re_ -import base64 -import datetime as datetime_ -import decimal as decimal_ -from lxml import etree as etree_ - - -Validate_simpletypes_ = True -SaveElementTreeNode = True -TagNamePrefix = "" -if sys.version_info.major == 2: - BaseStrType_ = basestring -else: - BaseStrType_ = str - - -def parsexml_(infile, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - try: - if isinstance(infile, os.PathLike): - infile = os.path.join(infile) - except AttributeError: - pass - doc = etree_.parse(infile, parser=parser, **kwargs) - return doc - - -def parsexmlstring_(instring, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - element = etree_.fromstring(instring, parser=parser, **kwargs) - return element - - -# -# Namespace prefix definition table (and other attributes, too) -# -# The module generatedsnamespaces, if it is importable, must contain -# a dictionary named GeneratedsNamespaceDefs. This Python dictionary -# should map element type names (strings) to XML schema namespace prefix -# definitions. The export method for any class for which there is -# a namespace prefix definition, will export that definition in the -# XML representation of that element. See the export method of -# any generated element type class for an example of the use of this -# table. -# A sample table is: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceDefs = { -# "ElementtypeA": "http://www.xxx.com/namespaceA", -# "ElementtypeB": "http://www.xxx.com/namespaceB", -# } -# -# Additionally, the generatedsnamespaces module can contain a python -# dictionary named GenerateDSNamespaceTypePrefixes that associates element -# types with the namespace prefixes that are to be added to the -# "xsi:type" attribute value. See the _exportAttributes method of -# any generated element type and the generation of "xsi:type" for an -# example of the use of this table. -# An example table: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceTypePrefixes = { -# "ElementtypeC": "aaa:", -# "ElementtypeD": "bbb:", -# } -# - -try: - from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_ -except ModulenotfoundExp_: - GenerateDSNamespaceDefs_ = {} -try: - from generatedsnamespaces import ( - GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_, - ) -except ModulenotfoundExp_: - GenerateDSNamespaceTypePrefixes_ = {} - -# -# You can replace the following class definition by defining an -# importable module named "generatedscollector" containing a class -# named "GdsCollector". See the default class definition below for -# clues about the possible content of that class. -# -try: - from generatedscollector import GdsCollector as GdsCollector_ -except ModulenotfoundExp_: - - class GdsCollector_(object): - def __init__(self, messages=None): - if messages is None: - self.messages = [] - else: - self.messages = messages - - def add_message(self, msg): - self.messages.append(msg) - - def get_messages(self): - return self.messages - - def clear_messages(self): - self.messages = [] - - def print_messages(self): - for msg in self.messages: - print("Warning: {}".format(msg)) - - def write_messages(self, outstream): - for msg in self.messages: - outstream.write("Warning: {}\n".format(msg)) - - -# -# The super-class for enum types -# - -try: - from enum import Enum -except ModulenotfoundExp_: - Enum = object - -# -# The root super-class for element type classes -# -# Calls to the methods in these classes are generated by generateDS.py. -# You can replace these methods by re-implementing the following class -# in a module named generatedssuper.py. - -try: - from generatedssuper import GeneratedsSuper -except ModulenotfoundExp_ as exp: - try: - from generatedssupersuper import GeneratedsSuperSuper - except ModulenotfoundExp_ as exp: - - class GeneratedsSuperSuper(object): - pass - - class GeneratedsSuper(GeneratedsSuperSuper): - __hash__ = object.__hash__ - tzoff_pattern = re_.compile(r"(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$") - - class _FixedOffsetTZ(datetime_.tzinfo): - def __init__(self, offset, name): - self.__offset = datetime_.timedelta(minutes=offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return None - - def __str__(self): - settings = { - "str_pretty_print": True, - "str_indent_level": 0, - "str_namespaceprefix": "", - "str_name": self.__class__.__name__, - "str_namespacedefs": "", - } - for n in settings: - if hasattr(self, n): - settings[n] = getattr(self, n) - if sys.version_info.major == 2: - from StringIO import StringIO - else: - from io import StringIO - output = StringIO() - self.export( - output, - settings["str_indent_level"], - pretty_print=settings["str_pretty_print"], - namespaceprefix_=settings["str_namespaceprefix"], - name_=settings["str_name"], - namespacedef_=settings["str_namespacedefs"], - ) - strval = output.getvalue() - output.close() - return strval - - def gds_format_string(self, input_data, input_name=""): - return input_data - - def gds_parse_string(self, input_data, node=None, input_name=""): - return input_data - - def gds_validate_string(self, input_data, node=None, input_name=""): - if not input_data: - return "" - else: - return input_data - - def gds_format_base64(self, input_data, input_name=""): - return base64.b64encode(input_data).decode("ascii") - - def gds_validate_base64(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_integer(self, input_data, input_name=""): - return "%d" % int(input_data) - - def gds_parse_integer(self, input_data, node=None, input_name=""): - try: - ival = int(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires integer value: %s" % exp) - return ival - - def gds_validate_integer(self, input_data, node=None, input_name=""): - try: - value = int(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires integer value") - return value - - def gds_format_integer_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_integer_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - int(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of integer values") - return values - - def gds_format_float(self, input_data, input_name=""): - return ("%.15f" % float(input_data)).rstrip("0") - - def gds_parse_float(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires float or double value: %s" % exp) - return fval_ - - def gds_validate_float(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires float value") - return value - - def gds_format_float_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_float_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of float values") - return values - - def gds_format_decimal(self, input_data, input_name=""): - return_value = "%s" % input_data - if "." in return_value: - return_value = return_value.rstrip("0") - if return_value.endswith("."): - return_value = return_value.rstrip(".") - return return_value - - def gds_parse_decimal(self, input_data, node=None, input_name=""): - try: - decimal_value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return decimal_value - - def gds_validate_decimal(self, input_data, node=None, input_name=""): - try: - value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return value - - def gds_format_decimal_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return " ".join([self.gds_format_decimal(item) for item in input_data]) - - def gds_validate_decimal_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - decimal_.Decimal(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of decimal values") - return values - - def gds_format_double(self, input_data, input_name=""): - return "%s" % input_data - - def gds_parse_double(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires double or float value: %s" % exp) - return fval_ - - def gds_validate_double(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires double or float value") - return value - - def gds_format_double_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_double_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error( - node, "Requires sequence of double or float values" - ) - return values - - def gds_format_boolean(self, input_data, input_name=""): - return ("%s" % input_data).lower() - - def gds_parse_boolean(self, input_data, node=None, input_name=""): - input_data = input_data.strip() - if input_data in ("true", "1"): - bval = True - elif input_data in ("false", "0"): - bval = False - else: - raise_parse_error(node, "Requires boolean value") - return bval - - def gds_validate_boolean(self, input_data, node=None, input_name=""): - if input_data not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, "Requires boolean value " "(one of True, 1, False, 0)" - ) - return input_data - - def gds_format_boolean_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_boolean_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - value = self.gds_parse_boolean(value, node, input_name) - if value not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, - "Requires sequence of boolean values " - "(one of True, 1, False, 0)", - ) - return values - - def gds_validate_datetime(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_datetime(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d.%s" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - @classmethod - def gds_parse_datetime(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - time_parts = input_data.split(".") - if len(time_parts) > 1: - micro_seconds = int(float("0." + time_parts[1]) * 1000000) - input_data = "%s.%s" % ( - time_parts[0], - "{}".format(micro_seconds).rjust(6, "0"), - ) - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt - - def gds_validate_date(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_date(self, input_data, input_name=""): - _svalue = "%04d-%02d-%02d" % ( - input_data.year, - input_data.month, - input_data.day, - ) - try: - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - except AttributeError: - pass - return _svalue - - @classmethod - def gds_parse_date(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%d") - dt = dt.replace(tzinfo=tz) - return dt.date() - - def gds_validate_time(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_time(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%02d:%02d:%02d" % ( - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%02d:%02d:%02d.%s" % ( - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - def gds_validate_simple_patterns(self, patterns, target): - # pat is a list of lists of strings/patterns. - # The target value must match at least one of the patterns - # in order for the test to succeed. - found1 = True - target = str(target) - for patterns1 in patterns: - found2 = False - for patterns2 in patterns1: - mo = re_.search(patterns2, target) - if mo is not None and len(mo.group(0)) == len(target): - found2 = True - break - if not found2: - found1 = False - break - return found1 - - @classmethod - def gds_parse_time(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - if len(input_data.split(".")) > 1: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt.time() - - def gds_check_cardinality_( - self, value, input_name, min_occurs=0, max_occurs=1, required=None - ): - if value is None: - length = 0 - elif isinstance(value, list): - length = len(value) - else: - length = 1 - if required is not None: - if required and length < 1: - self.gds_collector_.add_message( - "Required value {}{} is missing".format( - input_name, self.gds_get_node_lineno_() - ) - ) - if length < min_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is below " - "the minimum allowed, " - "expected at least {}, found {}".format( - input_name, self.gds_get_node_lineno_(), min_occurs, length - ) - ) - elif length > max_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is above " - "the maximum allowed, " - "expected at most {}, found {}".format( - input_name, self.gds_get_node_lineno_(), max_occurs, length - ) - ) - - def gds_validate_builtin_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value, input_name=input_name) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_validate_defined_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_str_lower(self, instring): - return instring.lower() - - def get_path_(self, node): - path_list = [] - self.get_path_list_(node, path_list) - path_list.reverse() - path = "/".join(path_list) - return path - - Tag_strip_pattern_ = re_.compile(r"\{.*\}") - - def get_path_list_(self, node, path_list): - if node is None: - return - tag = GeneratedsSuper.Tag_strip_pattern_.sub("", node.tag) - if tag: - path_list.append(tag) - self.get_path_list_(node.getparent(), path_list) - - def get_class_obj_(self, node, default_class=None): - class_obj1 = default_class - if "xsi" in node.nsmap: - classname = node.get("{%s}type" % node.nsmap["xsi"]) - if classname is not None: - names = classname.split(":") - if len(names) == 2: - classname = names[1] - class_obj2 = globals().get(classname) - if class_obj2 is not None: - class_obj1 = class_obj2 - return class_obj1 - - def gds_build_any(self, node, type_name=None): - # provide default value in case option --disable-xml is used. - content = "" - content = etree_.tostring(node, encoding="unicode") - return content - - @classmethod - def gds_reverse_node_mapping(cls, mapping): - return dict(((v, k) for k, v in mapping.items())) - - @staticmethod - def gds_encode(instring): - if sys.version_info.major == 2: - if ExternalEncoding: - encoding = ExternalEncoding - else: - encoding = "utf-8" - return instring.encode(encoding) - else: - return instring - - @staticmethod - def convert_unicode(instring): - if isinstance(instring, str): - result = quote_xml(instring) - elif sys.version_info.major == 2 and isinstance(instring, unicode): - result = quote_xml(instring).encode("utf8") - else: - result = GeneratedsSuper.gds_encode(str(instring)) - return result - - def __eq__(self, other): - def excl_select_objs_(obj): - return obj[0] != "parent_object_" and obj[0] != "gds_collector_" - - if type(self) != type(other): - return False - return all( - x == y - for x, y in zip_longest( - filter(excl_select_objs_, self.__dict__.items()), - filter(excl_select_objs_, other.__dict__.items()), - ) - ) - - def __ne__(self, other): - return not self.__eq__(other) - - # Django ETL transform hooks. - def gds_djo_etl_transform(self): - pass - - def gds_djo_etl_transform_db_obj(self, dbobj): - pass - - # SQLAlchemy ETL transform hooks. - def gds_sqa_etl_transform(self): - return 0, None - - def gds_sqa_etl_transform_db_obj(self, dbobj): - pass - - def gds_get_node_lineno_(self): - if ( - hasattr(self, "gds_elementtree_node_") - and self.gds_elementtree_node_ is not None - ): - return " near line {}".format(self.gds_elementtree_node_.sourceline) - else: - return "" - - def getSubclassFromModule_(module, class_): - """Get the subclass of a class from a specific module.""" - name = class_.__name__ + "Sub" - if hasattr(module, name): - return getattr(module, name) - else: - return None - - -# -# If you have installed IPython you can uncomment and use the following. -# IPython is available from http://ipython.scipy.org/. -# - -## from IPython.Shell import IPShellEmbed -## args = '' -## ipshell = IPShellEmbed(args, -## banner = 'Dropping into IPython', -## exit_msg = 'Leaving Interpreter, back to program.') - -# Then use the following line where and when you want to drop into the -# IPython shell: -# ipshell(' -- Entering ipshell.\nHit Ctrl-D to exit') - -# -# Globals -# - -ExternalEncoding = "" -# Set this to false in order to deactivate during export, the use of -# name space prefixes captured from the input document. -UseCapturedNS_ = True -CapturedNsmap_ = {} -Tag_pattern_ = re_.compile(r"({.*})?(.*)") -String_cleanup_pat_ = re_.compile(r"[\n\r\s]+") -Namespace_extract_pat_ = re_.compile(r"{(.*)}(.*)") -CDATA_pattern_ = re_.compile(r"", re_.DOTALL) - -# Change this to redirect the generated superclass module to use a -# specific subclass module. -CurrentSubclassModule_ = None - -# -# Support/utility functions. -# - - -def showIndent(outfile, level, pretty_print=True): - if pretty_print: - for idx in range(level): - outfile.write(" ") - - -def quote_xml(inStr): - "Escape markup chars, but do not modify CDATA sections." - if not inStr: - return "" - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s2 = "" - pos = 0 - matchobjects = CDATA_pattern_.finditer(s1) - for mo in matchobjects: - s3 = s1[pos : mo.start()] - s2 += quote_xml_aux(s3) - s2 += s1[mo.start() : mo.end()] - pos = mo.end() - s3 = s1[pos:] - s2 += quote_xml_aux(s3) - return s2 - - -def quote_xml_aux(inStr): - s1 = inStr.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - return s1 - - -def quote_attrib(inStr): - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s1 = s1.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - s1 = s1.replace("\n", " ") - if '"' in s1: - if "'" in s1: - s1 = '"%s"' % s1.replace('"', """) - else: - s1 = "'%s'" % s1 - else: - s1 = '"%s"' % s1 - return s1 - - -def quote_python(inStr): - s1 = inStr - if s1.find("'") == -1: - if s1.find("\n") == -1: - return "'%s'" % s1 - else: - return "'''%s'''" % s1 - else: - if s1.find('"') != -1: - s1 = s1.replace('"', '\\"') - if s1.find("\n") == -1: - return '"%s"' % s1 - else: - return '"""%s"""' % s1 - - -def get_all_text_(node): - if node.text is not None: - text = node.text - else: - text = "" - for child in node: - if child.tail is not None: - text += child.tail - return text - - -def find_attr_value_(attr_name, node): - attrs = node.attrib - attr_parts = attr_name.split(":") - value = None - if len(attr_parts) == 1: - value = attrs.get(attr_name) - elif len(attr_parts) == 2: - prefix, name = attr_parts - if prefix == "xml": - namespace = "http://www.w3.org/XML/1998/namespace" - else: - namespace = node.nsmap.get(prefix) - if namespace is not None: - value = attrs.get( - "{%s}%s" - % ( - namespace, - name, - ) - ) - return value - - -def encode_str_2_3(instr): - return instr - - -class GDSParseError(Exception): - pass - - -def raise_parse_error(node, msg): - if node is not None: - msg = "%s (element %s/line %d)" % ( - msg, - node.tag, - node.sourceline, - ) - raise GDSParseError(msg) - - -class MixedContainer: - # Constants for category: - CategoryNone = 0 - CategoryText = 1 - CategorySimple = 2 - CategoryComplex = 3 - # Constants for content_type: - TypeNone = 0 - TypeText = 1 - TypeString = 2 - TypeInteger = 3 - TypeFloat = 4 - TypeDecimal = 5 - TypeDouble = 6 - TypeBoolean = 7 - TypeBase64 = 8 - - def __init__(self, category, content_type, name, value): - self.category = category - self.content_type = content_type - self.name = name - self.value = value - - def getCategory(self): - return self.category - - def getContenttype(self, content_type): - return self.content_type - - def getValue(self): - return self.value - - def getName(self): - return self.name - - def export(self, outfile, level, name, namespace, pretty_print=True): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - outfile.write(self.value) - elif self.category == MixedContainer.CategorySimple: - self.exportSimple(outfile, level, name) - else: # category == MixedContainer.CategoryComplex - self.value.export( - outfile, level, namespace, name_=name, pretty_print=pretty_print - ) - - def exportSimple(self, outfile, level, name): - if self.content_type == MixedContainer.TypeString: - outfile.write("<%s>%s" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - outfile.write("<%s>%d" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - outfile.write("<%s>%f" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeDouble: - outfile.write("<%s>%g" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeBase64: - outfile.write( - "<%s>%s" % (self.name, base64.b64encode(self.value), self.name) - ) - - def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - if len(element) > 0: - if element[-1].tail is None: - element[-1].tail = self.value - else: - element[-1].tail += self.value - else: - if element.text is None: - element.text = self.value - else: - element.text += self.value - elif self.category == MixedContainer.CategorySimple: - subelement = etree_.SubElement(element, "%s" % self.name) - subelement.text = self.to_etree_simple() - else: # category == MixedContainer.CategoryComplex - self.value.to_etree(element) - - def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.content_type == MixedContainer.TypeString: - text = self.value - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - text = "%d" % self.value - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - text = "%f" % self.value - elif self.content_type == MixedContainer.TypeDouble: - text = "%g" % self.value - elif self.content_type == MixedContainer.TypeBase64: - text = "%s" % base64.b64encode(self.value) - return text - - def exportLiteral(self, outfile, level, name): - if self.category == MixedContainer.CategoryText: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - elif self.category == MixedContainer.CategorySimple: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - else: # category == MixedContainer.CategoryComplex - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s",\n' - % ( - self.category, - self.content_type, - self.name, - ) - ) - self.value.exportLiteral(outfile, level + 1) - showIndent(outfile, level) - outfile.write(")\n") - - -class MemberSpec_(object): - def __init__( - self, - name="", - data_type="", - container=0, - optional=0, - child_attrs=None, - choice=None, - ): - self.name = name - self.data_type = data_type - self.container = container - self.child_attrs = child_attrs - self.choice = choice - self.optional = optional - - def set_name(self, name): - self.name = name - - def get_name(self): - return self.name - - def set_data_type(self, data_type): - self.data_type = data_type - - def get_data_type_chain(self): - return self.data_type - - def get_data_type(self): - if isinstance(self.data_type, list): - if len(self.data_type) > 0: - return self.data_type[-1] - else: - return "xs:string" - else: - return self.data_type - - def set_container(self, container): - self.container = container - - def get_container(self): - return self.container - - def set_child_attrs(self, child_attrs): - self.child_attrs = child_attrs - - def get_child_attrs(self): - return self.child_attrs - - def set_choice(self, choice): - self.choice = choice - - def get_choice(self): - return self.choice - - def set_optional(self, optional): - self.optional = optional - - def get_optional(self): - return self.optional - - -def _cast(typ, value): - if typ is None or value is None: - return value - return typ(value) - - -# -# Data representation classes. -# - - -class Freightcom(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, version=None, ShipmentCancelReply=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.version = _cast(None, version) - self.version_nsprefix_ = None - self.ShipmentCancelReply = ShipmentCancelReply - self.ShipmentCancelReply_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, Freightcom) - if subclass is not None: - return subclass(*args_, **kwargs_) - if Freightcom.subclass: - return Freightcom.subclass(*args_, **kwargs_) - else: - return Freightcom(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_ShipmentCancelReply(self): - return self.ShipmentCancelReply - - def set_ShipmentCancelReply(self, ShipmentCancelReply): - self.ShipmentCancelReply = ShipmentCancelReply - - def get_version(self): - return self.version - - def set_version(self, version): - self.version = version - - def _hasContent(self): - if self.ShipmentCancelReply is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("Freightcom") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "Freightcom": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="Freightcom" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="Freightcom", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="Freightcom" - ): - if self.version is not None and "version" not in already_processed: - already_processed.add("version") - outfile.write( - " version=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.version), input_name="version" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.ShipmentCancelReply is not None: - namespaceprefix_ = ( - self.ShipmentCancelReply_nsprefix_ + ":" - if (UseCapturedNS_ and self.ShipmentCancelReply_nsprefix_) - else "" - ) - self.ShipmentCancelReply.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="ShipmentCancelReply", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("version", node) - if value is not None and "version" not in already_processed: - already_processed.add("version") - self.version = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "ShipmentCancelReply": - obj_ = ShipmentCancelReplyType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.ShipmentCancelReply = obj_ - obj_.original_tagname_ = "ShipmentCancelReply" - - -# end class Freightcom - - -class ShipmentCancelReplyType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, Order=None, Status=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.Order = Order - self.Order_nsprefix_ = None - self.Status = Status - self.Status_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, ShipmentCancelReplyType - ) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ShipmentCancelReplyType.subclass: - return ShipmentCancelReplyType.subclass(*args_, **kwargs_) - else: - return ShipmentCancelReplyType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Order(self): - return self.Order - - def set_Order(self, Order): - self.Order = Order - - def get_Status(self): - return self.Status - - def set_Status(self, Status): - self.Status = Status - - def _hasContent(self): - if self.Order is not None or self.Status is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ShipmentCancelReplyType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ShipmentCancelReplyType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ShipmentCancelReplyType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="ShipmentCancelReplyType", - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ShipmentCancelReplyType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="ShipmentCancelReplyType", - ): - pass - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ShipmentCancelReplyType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.Order is not None: - namespaceprefix_ = ( - self.Order_nsprefix_ + ":" - if (UseCapturedNS_ and self.Order_nsprefix_) - else "" - ) - self.Order.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Order", - pretty_print=pretty_print, - ) - if self.Status is not None: - namespaceprefix_ = ( - self.Status_nsprefix_ + ":" - if (UseCapturedNS_ and self.Status_nsprefix_) - else "" - ) - self.Status.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Status", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - pass - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Order": - obj_ = OrderType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Order = obj_ - obj_.original_tagname_ = "Order" - elif nodeName_ == "Status": - obj_ = StatusType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Status = obj_ - obj_.original_tagname_ = "Status" - - -# end class ShipmentCancelReplyType - - -class OrderType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, orderId=None, message=None, valueOf_=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.orderId = _cast(int, orderId) - self.orderId_nsprefix_ = None - self.message = _cast(None, message) - self.message_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, OrderType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if OrderType.subclass: - return OrderType.subclass(*args_, **kwargs_) - else: - return OrderType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_orderId(self): - return self.orderId - - def set_orderId(self, orderId): - self.orderId = orderId - - def get_message(self): - return self.message - - def set_message(self, message): - self.message = message - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="OrderType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("OrderType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "OrderType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="OrderType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="OrderType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="OrderType" - ): - if self.orderId is not None and "orderId" not in already_processed: - already_processed.add("orderId") - outfile.write( - ' orderId="%s"' - % self.gds_format_integer(self.orderId, input_name="orderId") - ) - if self.message is not None and "message" not in already_processed: - already_processed.add("message") - outfile.write( - " message=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.message), input_name="message" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="OrderType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("orderId", node) - if value is not None and "orderId" not in already_processed: - already_processed.add("orderId") - self.orderId = self.gds_parse_integer(value, node, "orderId") - value = find_attr_value_("message", node) - if value is not None and "message" not in already_processed: - already_processed.add("message") - self.message = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class OrderType - - -class StatusType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, statusId=None, valueOf_=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.statusId = _cast(int, statusId) - self.statusId_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, StatusType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if StatusType.subclass: - return StatusType.subclass(*args_, **kwargs_) - else: - return StatusType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_statusId(self): - return self.statusId - - def set_statusId(self, statusId): - self.statusId = statusId - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="StatusType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("StatusType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "StatusType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="StatusType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="StatusType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="StatusType" - ): - if self.statusId is not None and "statusId" not in already_processed: - already_processed.add("statusId") - outfile.write( - ' statusId="%s"' - % self.gds_format_integer(self.statusId, input_name="statusId") - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="StatusType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("statusId", node) - if value is not None and "statusId" not in already_processed: - already_processed.add("statusId") - self.statusId = self.gds_parse_integer(value, node, "statusId") - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class StatusType - - -GDSClassesMapping = {} - - -USAGE_TEXT = """ -Usage: python .py [ -s ] -""" - - -def usage(): - print(USAGE_TEXT) - sys.exit(1) - - -def get_root_tag(node): - tag = Tag_pattern_.match(node.tag).groups()[-1] - prefix_tag = TagNamePrefix + tag - rootClass = GDSClassesMapping.get(prefix_tag) - if rootClass is None: - rootClass = globals().get(prefix_tag) - return tag, rootClass - - -def get_required_ns_prefix_defs(rootNode): - """Get all name space prefix definitions required in this XML doc. - Return a dictionary of definitions and a char string of definitions. - """ - nsmap = { - prefix: uri - for node in rootNode.iter() - for (prefix, uri) in node.nsmap.items() - if prefix is not None - } - namespacedefs = " ".join( - ['xmlns:{}="{}"'.format(prefix, uri) for prefix, uri in nsmap.items()] - ) - return nsmap, namespacedefs - - -def parse(inFileName, silence=False, print_warnings=True): - global CapturedNsmap_ - gds_collector = GdsCollector_() - parser = None - doc = parsexml_(inFileName, parser) - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode) - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export( - sys.stdout, 0, name_=rootTag, namespacedef_=namespacedefs, pretty_print=True - ) - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseEtree( - inFileName, - silence=False, - print_warnings=True, - mapping=None, - reverse_mapping=None, - nsmap=None, -): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if mapping is None: - mapping = {} - if reverse_mapping is None: - reverse_mapping = {} - rootElement = rootObj.to_etree( - None, - name_=rootTag, - mapping_=mapping, - reverse_mapping_=reverse_mapping, - nsmap_=nsmap, - ) - reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - content = etree_.tostring( - rootElement, pretty_print=True, xml_declaration=True, encoding="utf-8" - ) - sys.stdout.write(str(content)) - sys.stdout.write("\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj, rootElement, mapping, reverse_node_mapping - - -def parseString(inString, silence=False, print_warnings=True): - """Parse a string, create the object tree, and export it. - - Arguments: - - inString -- A string. This XML fragment should not start - with an XML declaration containing an encoding. - - silence -- A boolean. If False, export the object. - Returns -- The root object in the tree. - """ - parser = None - rootNode = parsexmlstring_(inString, parser) - gds_collector = GdsCollector_() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if not SaveElementTreeNode: - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export(sys.stdout, 0, name_=rootTag, namespacedef_="") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseLiteral(inFileName, silence=False, print_warnings=True): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write("#from shipment_cancel_reply import *\n\n") - sys.stdout.write("import shipment_cancel_reply as model_\n\n") - sys.stdout.write("rootObj = model_.rootClass(\n") - rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) - sys.stdout.write(")\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def main(): - args = sys.argv[1:] - if len(args) == 1: - parse(args[0]) - else: - usage() - - -if __name__ == "__main__": - # import pdb; pdb.set_trace() - main() - -RenameMappings_ = {} - -# -# Mapping of namespaces to types defined in them -# and the file in which each is defined. -# simpleTypes are marked "ST" and complexTypes "CT". -NamespaceToDefMappings_ = {"http://www.freightcom.net/XMLSchema": []} - -__all__ = ["Freightcom", "OrderType", "ShipmentCancelReplyType", "StatusType"] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/shipment_cancel_request.py b/modules/connectors/freightcom/karrio/schemas/freightcom/shipment_cancel_request.py deleted file mode 100644 index f3a61689b1..0000000000 --- a/modules/connectors/freightcom/karrio/schemas/freightcom/shipment_cancel_request.py +++ /dev/null @@ -1,1915 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# -# Generated Fri Oct 21 12:33:21 2022 by generateDS.py version 2.41.1. -# Python 3.10.8 (v3.10.8:aaaf517424, Oct 11 2022, 10:14:40) [Clang 13.0.0 (clang-1300.0.29.30)] -# -# Command line options: -# ('--no-namespace-defs', '') -# ('-o', './karrio.schemas.freightcom/shipment_cancel_request.py') -# -# Command line arguments: -# ./vendor/schemas/shipment_cancel_request.xsd -# -# Command line: -# /Users/danielk/Documents/karrio/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio.schemas.freightcom/shipment_cancel_request.py" ./vendor/schemas/shipment_cancel_request.xsd -# -# Current working directory (os.getcwd()): -# freightcom -# - -import sys - -try: - ModulenotfoundExp_ = ModuleNotFoundError -except NameError: - ModulenotfoundExp_ = ImportError -from six.moves import zip_longest -import os -import re as re_ -import base64 -import datetime as datetime_ -import decimal as decimal_ -from lxml import etree as etree_ - - -Validate_simpletypes_ = True -SaveElementTreeNode = True -TagNamePrefix = "" -if sys.version_info.major == 2: - BaseStrType_ = basestring -else: - BaseStrType_ = str - - -def parsexml_(infile, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - try: - if isinstance(infile, os.PathLike): - infile = os.path.join(infile) - except AttributeError: - pass - doc = etree_.parse(infile, parser=parser, **kwargs) - return doc - - -def parsexmlstring_(instring, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - element = etree_.fromstring(instring, parser=parser, **kwargs) - return element - - -# -# Namespace prefix definition table (and other attributes, too) -# -# The module generatedsnamespaces, if it is importable, must contain -# a dictionary named GeneratedsNamespaceDefs. This Python dictionary -# should map element type names (strings) to XML schema namespace prefix -# definitions. The export method for any class for which there is -# a namespace prefix definition, will export that definition in the -# XML representation of that element. See the export method of -# any generated element type class for an example of the use of this -# table. -# A sample table is: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceDefs = { -# "ElementtypeA": "http://www.xxx.com/namespaceA", -# "ElementtypeB": "http://www.xxx.com/namespaceB", -# } -# -# Additionally, the generatedsnamespaces module can contain a python -# dictionary named GenerateDSNamespaceTypePrefixes that associates element -# types with the namespace prefixes that are to be added to the -# "xsi:type" attribute value. See the _exportAttributes method of -# any generated element type and the generation of "xsi:type" for an -# example of the use of this table. -# An example table: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceTypePrefixes = { -# "ElementtypeC": "aaa:", -# "ElementtypeD": "bbb:", -# } -# - -try: - from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_ -except ModulenotfoundExp_: - GenerateDSNamespaceDefs_ = {} -try: - from generatedsnamespaces import ( - GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_, - ) -except ModulenotfoundExp_: - GenerateDSNamespaceTypePrefixes_ = {} - -# -# You can replace the following class definition by defining an -# importable module named "generatedscollector" containing a class -# named "GdsCollector". See the default class definition below for -# clues about the possible content of that class. -# -try: - from generatedscollector import GdsCollector as GdsCollector_ -except ModulenotfoundExp_: - - class GdsCollector_(object): - def __init__(self, messages=None): - if messages is None: - self.messages = [] - else: - self.messages = messages - - def add_message(self, msg): - self.messages.append(msg) - - def get_messages(self): - return self.messages - - def clear_messages(self): - self.messages = [] - - def print_messages(self): - for msg in self.messages: - print("Warning: {}".format(msg)) - - def write_messages(self, outstream): - for msg in self.messages: - outstream.write("Warning: {}\n".format(msg)) - - -# -# The super-class for enum types -# - -try: - from enum import Enum -except ModulenotfoundExp_: - Enum = object - -# -# The root super-class for element type classes -# -# Calls to the methods in these classes are generated by generateDS.py. -# You can replace these methods by re-implementing the following class -# in a module named generatedssuper.py. - -try: - from generatedssuper import GeneratedsSuper -except ModulenotfoundExp_ as exp: - try: - from generatedssupersuper import GeneratedsSuperSuper - except ModulenotfoundExp_ as exp: - - class GeneratedsSuperSuper(object): - pass - - class GeneratedsSuper(GeneratedsSuperSuper): - __hash__ = object.__hash__ - tzoff_pattern = re_.compile(r"(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$") - - class _FixedOffsetTZ(datetime_.tzinfo): - def __init__(self, offset, name): - self.__offset = datetime_.timedelta(minutes=offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return None - - def __str__(self): - settings = { - "str_pretty_print": True, - "str_indent_level": 0, - "str_namespaceprefix": "", - "str_name": self.__class__.__name__, - "str_namespacedefs": "", - } - for n in settings: - if hasattr(self, n): - settings[n] = getattr(self, n) - if sys.version_info.major == 2: - from StringIO import StringIO - else: - from io import StringIO - output = StringIO() - self.export( - output, - settings["str_indent_level"], - pretty_print=settings["str_pretty_print"], - namespaceprefix_=settings["str_namespaceprefix"], - name_=settings["str_name"], - namespacedef_=settings["str_namespacedefs"], - ) - strval = output.getvalue() - output.close() - return strval - - def gds_format_string(self, input_data, input_name=""): - return input_data - - def gds_parse_string(self, input_data, node=None, input_name=""): - return input_data - - def gds_validate_string(self, input_data, node=None, input_name=""): - if not input_data: - return "" - else: - return input_data - - def gds_format_base64(self, input_data, input_name=""): - return base64.b64encode(input_data).decode("ascii") - - def gds_validate_base64(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_integer(self, input_data, input_name=""): - return "%d" % int(input_data) - - def gds_parse_integer(self, input_data, node=None, input_name=""): - try: - ival = int(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires integer value: %s" % exp) - return ival - - def gds_validate_integer(self, input_data, node=None, input_name=""): - try: - value = int(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires integer value") - return value - - def gds_format_integer_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_integer_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - int(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of integer values") - return values - - def gds_format_float(self, input_data, input_name=""): - return ("%.15f" % float(input_data)).rstrip("0") - - def gds_parse_float(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires float or double value: %s" % exp) - return fval_ - - def gds_validate_float(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires float value") - return value - - def gds_format_float_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_float_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of float values") - return values - - def gds_format_decimal(self, input_data, input_name=""): - return_value = "%s" % input_data - if "." in return_value: - return_value = return_value.rstrip("0") - if return_value.endswith("."): - return_value = return_value.rstrip(".") - return return_value - - def gds_parse_decimal(self, input_data, node=None, input_name=""): - try: - decimal_value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return decimal_value - - def gds_validate_decimal(self, input_data, node=None, input_name=""): - try: - value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return value - - def gds_format_decimal_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return " ".join([self.gds_format_decimal(item) for item in input_data]) - - def gds_validate_decimal_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - decimal_.Decimal(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of decimal values") - return values - - def gds_format_double(self, input_data, input_name=""): - return "%s" % input_data - - def gds_parse_double(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires double or float value: %s" % exp) - return fval_ - - def gds_validate_double(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires double or float value") - return value - - def gds_format_double_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_double_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error( - node, "Requires sequence of double or float values" - ) - return values - - def gds_format_boolean(self, input_data, input_name=""): - return ("%s" % input_data).lower() - - def gds_parse_boolean(self, input_data, node=None, input_name=""): - input_data = input_data.strip() - if input_data in ("true", "1"): - bval = True - elif input_data in ("false", "0"): - bval = False - else: - raise_parse_error(node, "Requires boolean value") - return bval - - def gds_validate_boolean(self, input_data, node=None, input_name=""): - if input_data not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, "Requires boolean value " "(one of True, 1, False, 0)" - ) - return input_data - - def gds_format_boolean_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_boolean_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - value = self.gds_parse_boolean(value, node, input_name) - if value not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, - "Requires sequence of boolean values " - "(one of True, 1, False, 0)", - ) - return values - - def gds_validate_datetime(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_datetime(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d.%s" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - @classmethod - def gds_parse_datetime(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - time_parts = input_data.split(".") - if len(time_parts) > 1: - micro_seconds = int(float("0." + time_parts[1]) * 1000000) - input_data = "%s.%s" % ( - time_parts[0], - "{}".format(micro_seconds).rjust(6, "0"), - ) - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt - - def gds_validate_date(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_date(self, input_data, input_name=""): - _svalue = "%04d-%02d-%02d" % ( - input_data.year, - input_data.month, - input_data.day, - ) - try: - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - except AttributeError: - pass - return _svalue - - @classmethod - def gds_parse_date(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%d") - dt = dt.replace(tzinfo=tz) - return dt.date() - - def gds_validate_time(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_time(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%02d:%02d:%02d" % ( - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%02d:%02d:%02d.%s" % ( - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - def gds_validate_simple_patterns(self, patterns, target): - # pat is a list of lists of strings/patterns. - # The target value must match at least one of the patterns - # in order for the test to succeed. - found1 = True - target = str(target) - for patterns1 in patterns: - found2 = False - for patterns2 in patterns1: - mo = re_.search(patterns2, target) - if mo is not None and len(mo.group(0)) == len(target): - found2 = True - break - if not found2: - found1 = False - break - return found1 - - @classmethod - def gds_parse_time(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - if len(input_data.split(".")) > 1: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt.time() - - def gds_check_cardinality_( - self, value, input_name, min_occurs=0, max_occurs=1, required=None - ): - if value is None: - length = 0 - elif isinstance(value, list): - length = len(value) - else: - length = 1 - if required is not None: - if required and length < 1: - self.gds_collector_.add_message( - "Required value {}{} is missing".format( - input_name, self.gds_get_node_lineno_() - ) - ) - if length < min_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is below " - "the minimum allowed, " - "expected at least {}, found {}".format( - input_name, self.gds_get_node_lineno_(), min_occurs, length - ) - ) - elif length > max_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is above " - "the maximum allowed, " - "expected at most {}, found {}".format( - input_name, self.gds_get_node_lineno_(), max_occurs, length - ) - ) - - def gds_validate_builtin_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value, input_name=input_name) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_validate_defined_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_str_lower(self, instring): - return instring.lower() - - def get_path_(self, node): - path_list = [] - self.get_path_list_(node, path_list) - path_list.reverse() - path = "/".join(path_list) - return path - - Tag_strip_pattern_ = re_.compile(r"\{.*\}") - - def get_path_list_(self, node, path_list): - if node is None: - return - tag = GeneratedsSuper.Tag_strip_pattern_.sub("", node.tag) - if tag: - path_list.append(tag) - self.get_path_list_(node.getparent(), path_list) - - def get_class_obj_(self, node, default_class=None): - class_obj1 = default_class - if "xsi" in node.nsmap: - classname = node.get("{%s}type" % node.nsmap["xsi"]) - if classname is not None: - names = classname.split(":") - if len(names) == 2: - classname = names[1] - class_obj2 = globals().get(classname) - if class_obj2 is not None: - class_obj1 = class_obj2 - return class_obj1 - - def gds_build_any(self, node, type_name=None): - # provide default value in case option --disable-xml is used. - content = "" - content = etree_.tostring(node, encoding="unicode") - return content - - @classmethod - def gds_reverse_node_mapping(cls, mapping): - return dict(((v, k) for k, v in mapping.items())) - - @staticmethod - def gds_encode(instring): - if sys.version_info.major == 2: - if ExternalEncoding: - encoding = ExternalEncoding - else: - encoding = "utf-8" - return instring.encode(encoding) - else: - return instring - - @staticmethod - def convert_unicode(instring): - if isinstance(instring, str): - result = quote_xml(instring) - elif sys.version_info.major == 2 and isinstance(instring, unicode): - result = quote_xml(instring).encode("utf8") - else: - result = GeneratedsSuper.gds_encode(str(instring)) - return result - - def __eq__(self, other): - def excl_select_objs_(obj): - return obj[0] != "parent_object_" and obj[0] != "gds_collector_" - - if type(self) != type(other): - return False - return all( - x == y - for x, y in zip_longest( - filter(excl_select_objs_, self.__dict__.items()), - filter(excl_select_objs_, other.__dict__.items()), - ) - ) - - def __ne__(self, other): - return not self.__eq__(other) - - # Django ETL transform hooks. - def gds_djo_etl_transform(self): - pass - - def gds_djo_etl_transform_db_obj(self, dbobj): - pass - - # SQLAlchemy ETL transform hooks. - def gds_sqa_etl_transform(self): - return 0, None - - def gds_sqa_etl_transform_db_obj(self, dbobj): - pass - - def gds_get_node_lineno_(self): - if ( - hasattr(self, "gds_elementtree_node_") - and self.gds_elementtree_node_ is not None - ): - return " near line {}".format(self.gds_elementtree_node_.sourceline) - else: - return "" - - def getSubclassFromModule_(module, class_): - """Get the subclass of a class from a specific module.""" - name = class_.__name__ + "Sub" - if hasattr(module, name): - return getattr(module, name) - else: - return None - - -# -# If you have installed IPython you can uncomment and use the following. -# IPython is available from http://ipython.scipy.org/. -# - -## from IPython.Shell import IPShellEmbed -## args = '' -## ipshell = IPShellEmbed(args, -## banner = 'Dropping into IPython', -## exit_msg = 'Leaving Interpreter, back to program.') - -# Then use the following line where and when you want to drop into the -# IPython shell: -# ipshell(' -- Entering ipshell.\nHit Ctrl-D to exit') - -# -# Globals -# - -ExternalEncoding = "" -# Set this to false in order to deactivate during export, the use of -# name space prefixes captured from the input document. -UseCapturedNS_ = True -CapturedNsmap_ = {} -Tag_pattern_ = re_.compile(r"({.*})?(.*)") -String_cleanup_pat_ = re_.compile(r"[\n\r\s]+") -Namespace_extract_pat_ = re_.compile(r"{(.*)}(.*)") -CDATA_pattern_ = re_.compile(r"", re_.DOTALL) - -# Change this to redirect the generated superclass module to use a -# specific subclass module. -CurrentSubclassModule_ = None - -# -# Support/utility functions. -# - - -def showIndent(outfile, level, pretty_print=True): - if pretty_print: - for idx in range(level): - outfile.write(" ") - - -def quote_xml(inStr): - "Escape markup chars, but do not modify CDATA sections." - if not inStr: - return "" - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s2 = "" - pos = 0 - matchobjects = CDATA_pattern_.finditer(s1) - for mo in matchobjects: - s3 = s1[pos : mo.start()] - s2 += quote_xml_aux(s3) - s2 += s1[mo.start() : mo.end()] - pos = mo.end() - s3 = s1[pos:] - s2 += quote_xml_aux(s3) - return s2 - - -def quote_xml_aux(inStr): - s1 = inStr.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - return s1 - - -def quote_attrib(inStr): - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s1 = s1.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - s1 = s1.replace("\n", " ") - if '"' in s1: - if "'" in s1: - s1 = '"%s"' % s1.replace('"', """) - else: - s1 = "'%s'" % s1 - else: - s1 = '"%s"' % s1 - return s1 - - -def quote_python(inStr): - s1 = inStr - if s1.find("'") == -1: - if s1.find("\n") == -1: - return "'%s'" % s1 - else: - return "'''%s'''" % s1 - else: - if s1.find('"') != -1: - s1 = s1.replace('"', '\\"') - if s1.find("\n") == -1: - return '"%s"' % s1 - else: - return '"""%s"""' % s1 - - -def get_all_text_(node): - if node.text is not None: - text = node.text - else: - text = "" - for child in node: - if child.tail is not None: - text += child.tail - return text - - -def find_attr_value_(attr_name, node): - attrs = node.attrib - attr_parts = attr_name.split(":") - value = None - if len(attr_parts) == 1: - value = attrs.get(attr_name) - elif len(attr_parts) == 2: - prefix, name = attr_parts - if prefix == "xml": - namespace = "http://www.w3.org/XML/1998/namespace" - else: - namespace = node.nsmap.get(prefix) - if namespace is not None: - value = attrs.get( - "{%s}%s" - % ( - namespace, - name, - ) - ) - return value - - -def encode_str_2_3(instr): - return instr - - -class GDSParseError(Exception): - pass - - -def raise_parse_error(node, msg): - if node is not None: - msg = "%s (element %s/line %d)" % ( - msg, - node.tag, - node.sourceline, - ) - raise GDSParseError(msg) - - -class MixedContainer: - # Constants for category: - CategoryNone = 0 - CategoryText = 1 - CategorySimple = 2 - CategoryComplex = 3 - # Constants for content_type: - TypeNone = 0 - TypeText = 1 - TypeString = 2 - TypeInteger = 3 - TypeFloat = 4 - TypeDecimal = 5 - TypeDouble = 6 - TypeBoolean = 7 - TypeBase64 = 8 - - def __init__(self, category, content_type, name, value): - self.category = category - self.content_type = content_type - self.name = name - self.value = value - - def getCategory(self): - return self.category - - def getContenttype(self, content_type): - return self.content_type - - def getValue(self): - return self.value - - def getName(self): - return self.name - - def export(self, outfile, level, name, namespace, pretty_print=True): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - outfile.write(self.value) - elif self.category == MixedContainer.CategorySimple: - self.exportSimple(outfile, level, name) - else: # category == MixedContainer.CategoryComplex - self.value.export( - outfile, level, namespace, name_=name, pretty_print=pretty_print - ) - - def exportSimple(self, outfile, level, name): - if self.content_type == MixedContainer.TypeString: - outfile.write("<%s>%s" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - outfile.write("<%s>%d" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - outfile.write("<%s>%f" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeDouble: - outfile.write("<%s>%g" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeBase64: - outfile.write( - "<%s>%s" % (self.name, base64.b64encode(self.value), self.name) - ) - - def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - if len(element) > 0: - if element[-1].tail is None: - element[-1].tail = self.value - else: - element[-1].tail += self.value - else: - if element.text is None: - element.text = self.value - else: - element.text += self.value - elif self.category == MixedContainer.CategorySimple: - subelement = etree_.SubElement(element, "%s" % self.name) - subelement.text = self.to_etree_simple() - else: # category == MixedContainer.CategoryComplex - self.value.to_etree(element) - - def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.content_type == MixedContainer.TypeString: - text = self.value - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - text = "%d" % self.value - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - text = "%f" % self.value - elif self.content_type == MixedContainer.TypeDouble: - text = "%g" % self.value - elif self.content_type == MixedContainer.TypeBase64: - text = "%s" % base64.b64encode(self.value) - return text - - def exportLiteral(self, outfile, level, name): - if self.category == MixedContainer.CategoryText: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - elif self.category == MixedContainer.CategorySimple: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - else: # category == MixedContainer.CategoryComplex - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s",\n' - % ( - self.category, - self.content_type, - self.name, - ) - ) - self.value.exportLiteral(outfile, level + 1) - showIndent(outfile, level) - outfile.write(")\n") - - -class MemberSpec_(object): - def __init__( - self, - name="", - data_type="", - container=0, - optional=0, - child_attrs=None, - choice=None, - ): - self.name = name - self.data_type = data_type - self.container = container - self.child_attrs = child_attrs - self.choice = choice - self.optional = optional - - def set_name(self, name): - self.name = name - - def get_name(self): - return self.name - - def set_data_type(self, data_type): - self.data_type = data_type - - def get_data_type_chain(self): - return self.data_type - - def get_data_type(self): - if isinstance(self.data_type, list): - if len(self.data_type) > 0: - return self.data_type[-1] - else: - return "xs:string" - else: - return self.data_type - - def set_container(self, container): - self.container = container - - def get_container(self): - return self.container - - def set_child_attrs(self, child_attrs): - self.child_attrs = child_attrs - - def get_child_attrs(self): - return self.child_attrs - - def set_choice(self, choice): - self.choice = choice - - def get_choice(self): - return self.choice - - def set_optional(self, optional): - self.optional = optional - - def get_optional(self): - return self.optional - - -def _cast(typ, value): - if typ is None or value is None: - return value - return typ(value) - - -# -# Data representation classes. -# - - -class Freightcom(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - username=None, - password=None, - version=None, - ShipmentCancelRequest=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.username = _cast(None, username) - self.username_nsprefix_ = None - self.password = _cast(None, password) - self.password_nsprefix_ = None - self.version = _cast(None, version) - self.version_nsprefix_ = None - self.ShipmentCancelRequest = ShipmentCancelRequest - self.ShipmentCancelRequest_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, Freightcom) - if subclass is not None: - return subclass(*args_, **kwargs_) - if Freightcom.subclass: - return Freightcom.subclass(*args_, **kwargs_) - else: - return Freightcom(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_ShipmentCancelRequest(self): - return self.ShipmentCancelRequest - - def set_ShipmentCancelRequest(self, ShipmentCancelRequest): - self.ShipmentCancelRequest = ShipmentCancelRequest - - def get_username(self): - return self.username - - def set_username(self, username): - self.username = username - - def get_password(self): - return self.password - - def set_password(self, password): - self.password = password - - def get_version(self): - return self.version - - def set_version(self, version): - self.version = version - - def _hasContent(self): - if self.ShipmentCancelRequest is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("Freightcom") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "Freightcom": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="Freightcom" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="Freightcom", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="Freightcom" - ): - if self.username is not None and "username" not in already_processed: - already_processed.add("username") - outfile.write( - " username=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.username), input_name="username" - ) - ), - ) - ) - if self.password is not None and "password" not in already_processed: - already_processed.add("password") - outfile.write( - " password=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.password), input_name="password" - ) - ), - ) - ) - if self.version is not None and "version" not in already_processed: - already_processed.add("version") - outfile.write( - " version=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.version), input_name="version" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.ShipmentCancelRequest is not None: - namespaceprefix_ = ( - self.ShipmentCancelRequest_nsprefix_ + ":" - if (UseCapturedNS_ and self.ShipmentCancelRequest_nsprefix_) - else "" - ) - self.ShipmentCancelRequest.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="ShipmentCancelRequest", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("username", node) - if value is not None and "username" not in already_processed: - already_processed.add("username") - self.username = value - value = find_attr_value_("password", node) - if value is not None and "password" not in already_processed: - already_processed.add("password") - self.password = value - value = find_attr_value_("version", node) - if value is not None and "version" not in already_processed: - already_processed.add("version") - self.version = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "ShipmentCancelRequest": - obj_ = ShipmentCancelRequestType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.ShipmentCancelRequest = obj_ - obj_.original_tagname_ = "ShipmentCancelRequest" - - -# end class Freightcom - - -class ShipmentCancelRequestType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, Order=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.Order = Order - self.Order_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, ShipmentCancelRequestType - ) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ShipmentCancelRequestType.subclass: - return ShipmentCancelRequestType.subclass(*args_, **kwargs_) - else: - return ShipmentCancelRequestType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Order(self): - return self.Order - - def set_Order(self, Order): - self.Order = Order - - def _hasContent(self): - if self.Order is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ShipmentCancelRequestType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ShipmentCancelRequestType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ShipmentCancelRequestType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="ShipmentCancelRequestType", - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ShipmentCancelRequestType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="ShipmentCancelRequestType", - ): - pass - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ShipmentCancelRequestType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.Order is not None: - namespaceprefix_ = ( - self.Order_nsprefix_ + ":" - if (UseCapturedNS_ and self.Order_nsprefix_) - else "" - ) - self.Order.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Order", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - pass - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Order": - obj_ = OrderType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Order = obj_ - obj_.original_tagname_ = "Order" - - -# end class ShipmentCancelRequestType - - -class OrderType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, orderId=None, valueOf_=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.orderId = _cast(int, orderId) - self.orderId_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, OrderType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if OrderType.subclass: - return OrderType.subclass(*args_, **kwargs_) - else: - return OrderType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_orderId(self): - return self.orderId - - def set_orderId(self, orderId): - self.orderId = orderId - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="OrderType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("OrderType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "OrderType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="OrderType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="OrderType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="OrderType" - ): - if self.orderId is not None and "orderId" not in already_processed: - already_processed.add("orderId") - outfile.write( - ' orderId="%s"' - % self.gds_format_integer(self.orderId, input_name="orderId") - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="OrderType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("orderId", node) - if value is not None and "orderId" not in already_processed: - already_processed.add("orderId") - self.orderId = self.gds_parse_integer(value, node, "orderId") - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class OrderType - - -GDSClassesMapping = {} - - -USAGE_TEXT = """ -Usage: python .py [ -s ] -""" - - -def usage(): - print(USAGE_TEXT) - sys.exit(1) - - -def get_root_tag(node): - tag = Tag_pattern_.match(node.tag).groups()[-1] - prefix_tag = TagNamePrefix + tag - rootClass = GDSClassesMapping.get(prefix_tag) - if rootClass is None: - rootClass = globals().get(prefix_tag) - return tag, rootClass - - -def get_required_ns_prefix_defs(rootNode): - """Get all name space prefix definitions required in this XML doc. - Return a dictionary of definitions and a char string of definitions. - """ - nsmap = { - prefix: uri - for node in rootNode.iter() - for (prefix, uri) in node.nsmap.items() - if prefix is not None - } - namespacedefs = " ".join( - ['xmlns:{}="{}"'.format(prefix, uri) for prefix, uri in nsmap.items()] - ) - return nsmap, namespacedefs - - -def parse(inFileName, silence=False, print_warnings=True): - global CapturedNsmap_ - gds_collector = GdsCollector_() - parser = None - doc = parsexml_(inFileName, parser) - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode) - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export( - sys.stdout, 0, name_=rootTag, namespacedef_=namespacedefs, pretty_print=True - ) - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseEtree( - inFileName, - silence=False, - print_warnings=True, - mapping=None, - reverse_mapping=None, - nsmap=None, -): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if mapping is None: - mapping = {} - if reverse_mapping is None: - reverse_mapping = {} - rootElement = rootObj.to_etree( - None, - name_=rootTag, - mapping_=mapping, - reverse_mapping_=reverse_mapping, - nsmap_=nsmap, - ) - reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - content = etree_.tostring( - rootElement, pretty_print=True, xml_declaration=True, encoding="utf-8" - ) - sys.stdout.write(str(content)) - sys.stdout.write("\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj, rootElement, mapping, reverse_node_mapping - - -def parseString(inString, silence=False, print_warnings=True): - """Parse a string, create the object tree, and export it. - - Arguments: - - inString -- A string. This XML fragment should not start - with an XML declaration containing an encoding. - - silence -- A boolean. If False, export the object. - Returns -- The root object in the tree. - """ - parser = None - rootNode = parsexmlstring_(inString, parser) - gds_collector = GdsCollector_() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if not SaveElementTreeNode: - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export(sys.stdout, 0, name_=rootTag, namespacedef_="") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseLiteral(inFileName, silence=False, print_warnings=True): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write("#from shipment_cancel_request import *\n\n") - sys.stdout.write("import shipment_cancel_request as model_\n\n") - sys.stdout.write("rootObj = model_.rootClass(\n") - rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) - sys.stdout.write(")\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def main(): - args = sys.argv[1:] - if len(args) == 1: - parse(args[0]) - else: - usage() - - -if __name__ == "__main__": - # import pdb; pdb.set_trace() - main() - -RenameMappings_ = {} - -# -# Mapping of namespaces to types defined in them -# and the file in which each is defined. -# simpleTypes are marked "ST" and complexTypes "CT". -NamespaceToDefMappings_ = {"http://www.freightcom.net/XMLSchema": []} - -__all__ = ["Freightcom", "OrderType", "ShipmentCancelRequestType"] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_reply.py b/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_reply.py deleted file mode 100644 index 5e22828b58..0000000000 --- a/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_reply.py +++ /dev/null @@ -1,4236 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# -# Generated Fri Oct 21 12:33:20 2022 by generateDS.py version 2.41.1. -# Python 3.10.8 (v3.10.8:aaaf517424, Oct 11 2022, 10:14:40) [Clang 13.0.0 (clang-1300.0.29.30)] -# -# Command line options: -# ('--no-namespace-defs', '') -# ('-o', './karrio.schemas.freightcom/shipping_reply.py') -# -# Command line arguments: -# ./vendor/schemas/shipping_reply.xsd -# -# Command line: -# /Users/danielk/Documents/karrio/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio.schemas.freightcom/shipping_reply.py" ./vendor/schemas/shipping_reply.xsd -# -# Current working directory (os.getcwd()): -# freightcom -# - -import sys - -try: - ModulenotfoundExp_ = ModuleNotFoundError -except NameError: - ModulenotfoundExp_ = ImportError -from six.moves import zip_longest -import os -import re as re_ -import base64 -import datetime as datetime_ -import decimal as decimal_ -from lxml import etree as etree_ - - -Validate_simpletypes_ = True -SaveElementTreeNode = True -TagNamePrefix = "" -if sys.version_info.major == 2: - BaseStrType_ = basestring -else: - BaseStrType_ = str - - -def parsexml_(infile, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - try: - if isinstance(infile, os.PathLike): - infile = os.path.join(infile) - except AttributeError: - pass - doc = etree_.parse(infile, parser=parser, **kwargs) - return doc - - -def parsexmlstring_(instring, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - element = etree_.fromstring(instring, parser=parser, **kwargs) - return element - - -# -# Namespace prefix definition table (and other attributes, too) -# -# The module generatedsnamespaces, if it is importable, must contain -# a dictionary named GeneratedsNamespaceDefs. This Python dictionary -# should map element type names (strings) to XML schema namespace prefix -# definitions. The export method for any class for which there is -# a namespace prefix definition, will export that definition in the -# XML representation of that element. See the export method of -# any generated element type class for an example of the use of this -# table. -# A sample table is: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceDefs = { -# "ElementtypeA": "http://www.xxx.com/namespaceA", -# "ElementtypeB": "http://www.xxx.com/namespaceB", -# } -# -# Additionally, the generatedsnamespaces module can contain a python -# dictionary named GenerateDSNamespaceTypePrefixes that associates element -# types with the namespace prefixes that are to be added to the -# "xsi:type" attribute value. See the _exportAttributes method of -# any generated element type and the generation of "xsi:type" for an -# example of the use of this table. -# An example table: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceTypePrefixes = { -# "ElementtypeC": "aaa:", -# "ElementtypeD": "bbb:", -# } -# - -try: - from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_ -except ModulenotfoundExp_: - GenerateDSNamespaceDefs_ = {} -try: - from generatedsnamespaces import ( - GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_, - ) -except ModulenotfoundExp_: - GenerateDSNamespaceTypePrefixes_ = {} - -# -# You can replace the following class definition by defining an -# importable module named "generatedscollector" containing a class -# named "GdsCollector". See the default class definition below for -# clues about the possible content of that class. -# -try: - from generatedscollector import GdsCollector as GdsCollector_ -except ModulenotfoundExp_: - - class GdsCollector_(object): - def __init__(self, messages=None): - if messages is None: - self.messages = [] - else: - self.messages = messages - - def add_message(self, msg): - self.messages.append(msg) - - def get_messages(self): - return self.messages - - def clear_messages(self): - self.messages = [] - - def print_messages(self): - for msg in self.messages: - print("Warning: {}".format(msg)) - - def write_messages(self, outstream): - for msg in self.messages: - outstream.write("Warning: {}\n".format(msg)) - - -# -# The super-class for enum types -# - -try: - from enum import Enum -except ModulenotfoundExp_: - Enum = object - -# -# The root super-class for element type classes -# -# Calls to the methods in these classes are generated by generateDS.py. -# You can replace these methods by re-implementing the following class -# in a module named generatedssuper.py. - -try: - from generatedssuper import GeneratedsSuper -except ModulenotfoundExp_ as exp: - try: - from generatedssupersuper import GeneratedsSuperSuper - except ModulenotfoundExp_ as exp: - - class GeneratedsSuperSuper(object): - pass - - class GeneratedsSuper(GeneratedsSuperSuper): - __hash__ = object.__hash__ - tzoff_pattern = re_.compile(r"(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$") - - class _FixedOffsetTZ(datetime_.tzinfo): - def __init__(self, offset, name): - self.__offset = datetime_.timedelta(minutes=offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return None - - def __str__(self): - settings = { - "str_pretty_print": True, - "str_indent_level": 0, - "str_namespaceprefix": "", - "str_name": self.__class__.__name__, - "str_namespacedefs": "", - } - for n in settings: - if hasattr(self, n): - settings[n] = getattr(self, n) - if sys.version_info.major == 2: - from StringIO import StringIO - else: - from io import StringIO - output = StringIO() - self.export( - output, - settings["str_indent_level"], - pretty_print=settings["str_pretty_print"], - namespaceprefix_=settings["str_namespaceprefix"], - name_=settings["str_name"], - namespacedef_=settings["str_namespacedefs"], - ) - strval = output.getvalue() - output.close() - return strval - - def gds_format_string(self, input_data, input_name=""): - return input_data - - def gds_parse_string(self, input_data, node=None, input_name=""): - return input_data - - def gds_validate_string(self, input_data, node=None, input_name=""): - if not input_data: - return "" - else: - return input_data - - def gds_format_base64(self, input_data, input_name=""): - return base64.b64encode(input_data).decode("ascii") - - def gds_validate_base64(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_integer(self, input_data, input_name=""): - return "%d" % int(input_data) - - def gds_parse_integer(self, input_data, node=None, input_name=""): - try: - ival = int(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires integer value: %s" % exp) - return ival - - def gds_validate_integer(self, input_data, node=None, input_name=""): - try: - value = int(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires integer value") - return value - - def gds_format_integer_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_integer_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - int(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of integer values") - return values - - def gds_format_float(self, input_data, input_name=""): - return ("%.15f" % float(input_data)).rstrip("0") - - def gds_parse_float(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires float or double value: %s" % exp) - return fval_ - - def gds_validate_float(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires float value") - return value - - def gds_format_float_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_float_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of float values") - return values - - def gds_format_decimal(self, input_data, input_name=""): - return_value = "%s" % input_data - if "." in return_value: - return_value = return_value.rstrip("0") - if return_value.endswith("."): - return_value = return_value.rstrip(".") - return return_value - - def gds_parse_decimal(self, input_data, node=None, input_name=""): - try: - decimal_value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return decimal_value - - def gds_validate_decimal(self, input_data, node=None, input_name=""): - try: - value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return value - - def gds_format_decimal_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return " ".join([self.gds_format_decimal(item) for item in input_data]) - - def gds_validate_decimal_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - decimal_.Decimal(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of decimal values") - return values - - def gds_format_double(self, input_data, input_name=""): - return "%s" % input_data - - def gds_parse_double(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires double or float value: %s" % exp) - return fval_ - - def gds_validate_double(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires double or float value") - return value - - def gds_format_double_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_double_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error( - node, "Requires sequence of double or float values" - ) - return values - - def gds_format_boolean(self, input_data, input_name=""): - return ("%s" % input_data).lower() - - def gds_parse_boolean(self, input_data, node=None, input_name=""): - input_data = input_data.strip() - if input_data in ("true", "1"): - bval = True - elif input_data in ("false", "0"): - bval = False - else: - raise_parse_error(node, "Requires boolean value") - return bval - - def gds_validate_boolean(self, input_data, node=None, input_name=""): - if input_data not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, "Requires boolean value " "(one of True, 1, False, 0)" - ) - return input_data - - def gds_format_boolean_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_boolean_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - value = self.gds_parse_boolean(value, node, input_name) - if value not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, - "Requires sequence of boolean values " - "(one of True, 1, False, 0)", - ) - return values - - def gds_validate_datetime(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_datetime(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d.%s" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - @classmethod - def gds_parse_datetime(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - time_parts = input_data.split(".") - if len(time_parts) > 1: - micro_seconds = int(float("0." + time_parts[1]) * 1000000) - input_data = "%s.%s" % ( - time_parts[0], - "{}".format(micro_seconds).rjust(6, "0"), - ) - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt - - def gds_validate_date(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_date(self, input_data, input_name=""): - _svalue = "%04d-%02d-%02d" % ( - input_data.year, - input_data.month, - input_data.day, - ) - try: - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - except AttributeError: - pass - return _svalue - - @classmethod - def gds_parse_date(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%d") - dt = dt.replace(tzinfo=tz) - return dt.date() - - def gds_validate_time(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_time(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%02d:%02d:%02d" % ( - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%02d:%02d:%02d.%s" % ( - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - def gds_validate_simple_patterns(self, patterns, target): - # pat is a list of lists of strings/patterns. - # The target value must match at least one of the patterns - # in order for the test to succeed. - found1 = True - target = str(target) - for patterns1 in patterns: - found2 = False - for patterns2 in patterns1: - mo = re_.search(patterns2, target) - if mo is not None and len(mo.group(0)) == len(target): - found2 = True - break - if not found2: - found1 = False - break - return found1 - - @classmethod - def gds_parse_time(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - if len(input_data.split(".")) > 1: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt.time() - - def gds_check_cardinality_( - self, value, input_name, min_occurs=0, max_occurs=1, required=None - ): - if value is None: - length = 0 - elif isinstance(value, list): - length = len(value) - else: - length = 1 - if required is not None: - if required and length < 1: - self.gds_collector_.add_message( - "Required value {}{} is missing".format( - input_name, self.gds_get_node_lineno_() - ) - ) - if length < min_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is below " - "the minimum allowed, " - "expected at least {}, found {}".format( - input_name, self.gds_get_node_lineno_(), min_occurs, length - ) - ) - elif length > max_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is above " - "the maximum allowed, " - "expected at most {}, found {}".format( - input_name, self.gds_get_node_lineno_(), max_occurs, length - ) - ) - - def gds_validate_builtin_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value, input_name=input_name) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_validate_defined_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_str_lower(self, instring): - return instring.lower() - - def get_path_(self, node): - path_list = [] - self.get_path_list_(node, path_list) - path_list.reverse() - path = "/".join(path_list) - return path - - Tag_strip_pattern_ = re_.compile(r"\{.*\}") - - def get_path_list_(self, node, path_list): - if node is None: - return - tag = GeneratedsSuper.Tag_strip_pattern_.sub("", node.tag) - if tag: - path_list.append(tag) - self.get_path_list_(node.getparent(), path_list) - - def get_class_obj_(self, node, default_class=None): - class_obj1 = default_class - if "xsi" in node.nsmap: - classname = node.get("{%s}type" % node.nsmap["xsi"]) - if classname is not None: - names = classname.split(":") - if len(names) == 2: - classname = names[1] - class_obj2 = globals().get(classname) - if class_obj2 is not None: - class_obj1 = class_obj2 - return class_obj1 - - def gds_build_any(self, node, type_name=None): - # provide default value in case option --disable-xml is used. - content = "" - content = etree_.tostring(node, encoding="unicode") - return content - - @classmethod - def gds_reverse_node_mapping(cls, mapping): - return dict(((v, k) for k, v in mapping.items())) - - @staticmethod - def gds_encode(instring): - if sys.version_info.major == 2: - if ExternalEncoding: - encoding = ExternalEncoding - else: - encoding = "utf-8" - return instring.encode(encoding) - else: - return instring - - @staticmethod - def convert_unicode(instring): - if isinstance(instring, str): - result = quote_xml(instring) - elif sys.version_info.major == 2 and isinstance(instring, unicode): - result = quote_xml(instring).encode("utf8") - else: - result = GeneratedsSuper.gds_encode(str(instring)) - return result - - def __eq__(self, other): - def excl_select_objs_(obj): - return obj[0] != "parent_object_" and obj[0] != "gds_collector_" - - if type(self) != type(other): - return False - return all( - x == y - for x, y in zip_longest( - filter(excl_select_objs_, self.__dict__.items()), - filter(excl_select_objs_, other.__dict__.items()), - ) - ) - - def __ne__(self, other): - return not self.__eq__(other) - - # Django ETL transform hooks. - def gds_djo_etl_transform(self): - pass - - def gds_djo_etl_transform_db_obj(self, dbobj): - pass - - # SQLAlchemy ETL transform hooks. - def gds_sqa_etl_transform(self): - return 0, None - - def gds_sqa_etl_transform_db_obj(self, dbobj): - pass - - def gds_get_node_lineno_(self): - if ( - hasattr(self, "gds_elementtree_node_") - and self.gds_elementtree_node_ is not None - ): - return " near line {}".format(self.gds_elementtree_node_.sourceline) - else: - return "" - - def getSubclassFromModule_(module, class_): - """Get the subclass of a class from a specific module.""" - name = class_.__name__ + "Sub" - if hasattr(module, name): - return getattr(module, name) - else: - return None - - -# -# If you have installed IPython you can uncomment and use the following. -# IPython is available from http://ipython.scipy.org/. -# - -## from IPython.Shell import IPShellEmbed -## args = '' -## ipshell = IPShellEmbed(args, -## banner = 'Dropping into IPython', -## exit_msg = 'Leaving Interpreter, back to program.') - -# Then use the following line where and when you want to drop into the -# IPython shell: -# ipshell(' -- Entering ipshell.\nHit Ctrl-D to exit') - -# -# Globals -# - -ExternalEncoding = "" -# Set this to false in order to deactivate during export, the use of -# name space prefixes captured from the input document. -UseCapturedNS_ = True -CapturedNsmap_ = {} -Tag_pattern_ = re_.compile(r"({.*})?(.*)") -String_cleanup_pat_ = re_.compile(r"[\n\r\s]+") -Namespace_extract_pat_ = re_.compile(r"{(.*)}(.*)") -CDATA_pattern_ = re_.compile(r"", re_.DOTALL) - -# Change this to redirect the generated superclass module to use a -# specific subclass module. -CurrentSubclassModule_ = None - -# -# Support/utility functions. -# - - -def showIndent(outfile, level, pretty_print=True): - if pretty_print: - for idx in range(level): - outfile.write(" ") - - -def quote_xml(inStr): - "Escape markup chars, but do not modify CDATA sections." - if not inStr: - return "" - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s2 = "" - pos = 0 - matchobjects = CDATA_pattern_.finditer(s1) - for mo in matchobjects: - s3 = s1[pos : mo.start()] - s2 += quote_xml_aux(s3) - s2 += s1[mo.start() : mo.end()] - pos = mo.end() - s3 = s1[pos:] - s2 += quote_xml_aux(s3) - return s2 - - -def quote_xml_aux(inStr): - s1 = inStr.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - return s1 - - -def quote_attrib(inStr): - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s1 = s1.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - s1 = s1.replace("\n", " ") - if '"' in s1: - if "'" in s1: - s1 = '"%s"' % s1.replace('"', """) - else: - s1 = "'%s'" % s1 - else: - s1 = '"%s"' % s1 - return s1 - - -def quote_python(inStr): - s1 = inStr - if s1.find("'") == -1: - if s1.find("\n") == -1: - return "'%s'" % s1 - else: - return "'''%s'''" % s1 - else: - if s1.find('"') != -1: - s1 = s1.replace('"', '\\"') - if s1.find("\n") == -1: - return '"%s"' % s1 - else: - return '"""%s"""' % s1 - - -def get_all_text_(node): - if node.text is not None: - text = node.text - else: - text = "" - for child in node: - if child.tail is not None: - text += child.tail - return text - - -def find_attr_value_(attr_name, node): - attrs = node.attrib - attr_parts = attr_name.split(":") - value = None - if len(attr_parts) == 1: - value = attrs.get(attr_name) - elif len(attr_parts) == 2: - prefix, name = attr_parts - if prefix == "xml": - namespace = "http://www.w3.org/XML/1998/namespace" - else: - namespace = node.nsmap.get(prefix) - if namespace is not None: - value = attrs.get( - "{%s}%s" - % ( - namespace, - name, - ) - ) - return value - - -def encode_str_2_3(instr): - return instr - - -class GDSParseError(Exception): - pass - - -def raise_parse_error(node, msg): - if node is not None: - msg = "%s (element %s/line %d)" % ( - msg, - node.tag, - node.sourceline, - ) - raise GDSParseError(msg) - - -class MixedContainer: - # Constants for category: - CategoryNone = 0 - CategoryText = 1 - CategorySimple = 2 - CategoryComplex = 3 - # Constants for content_type: - TypeNone = 0 - TypeText = 1 - TypeString = 2 - TypeInteger = 3 - TypeFloat = 4 - TypeDecimal = 5 - TypeDouble = 6 - TypeBoolean = 7 - TypeBase64 = 8 - - def __init__(self, category, content_type, name, value): - self.category = category - self.content_type = content_type - self.name = name - self.value = value - - def getCategory(self): - return self.category - - def getContenttype(self, content_type): - return self.content_type - - def getValue(self): - return self.value - - def getName(self): - return self.name - - def export(self, outfile, level, name, namespace, pretty_print=True): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - outfile.write(self.value) - elif self.category == MixedContainer.CategorySimple: - self.exportSimple(outfile, level, name) - else: # category == MixedContainer.CategoryComplex - self.value.export( - outfile, level, namespace, name_=name, pretty_print=pretty_print - ) - - def exportSimple(self, outfile, level, name): - if self.content_type == MixedContainer.TypeString: - outfile.write("<%s>%s" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - outfile.write("<%s>%d" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - outfile.write("<%s>%f" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeDouble: - outfile.write("<%s>%g" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeBase64: - outfile.write( - "<%s>%s" % (self.name, base64.b64encode(self.value), self.name) - ) - - def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - if len(element) > 0: - if element[-1].tail is None: - element[-1].tail = self.value - else: - element[-1].tail += self.value - else: - if element.text is None: - element.text = self.value - else: - element.text += self.value - elif self.category == MixedContainer.CategorySimple: - subelement = etree_.SubElement(element, "%s" % self.name) - subelement.text = self.to_etree_simple() - else: # category == MixedContainer.CategoryComplex - self.value.to_etree(element) - - def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.content_type == MixedContainer.TypeString: - text = self.value - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - text = "%d" % self.value - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - text = "%f" % self.value - elif self.content_type == MixedContainer.TypeDouble: - text = "%g" % self.value - elif self.content_type == MixedContainer.TypeBase64: - text = "%s" % base64.b64encode(self.value) - return text - - def exportLiteral(self, outfile, level, name): - if self.category == MixedContainer.CategoryText: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - elif self.category == MixedContainer.CategorySimple: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - else: # category == MixedContainer.CategoryComplex - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s",\n' - % ( - self.category, - self.content_type, - self.name, - ) - ) - self.value.exportLiteral(outfile, level + 1) - showIndent(outfile, level) - outfile.write(")\n") - - -class MemberSpec_(object): - def __init__( - self, - name="", - data_type="", - container=0, - optional=0, - child_attrs=None, - choice=None, - ): - self.name = name - self.data_type = data_type - self.container = container - self.child_attrs = child_attrs - self.choice = choice - self.optional = optional - - def set_name(self, name): - self.name = name - - def get_name(self): - return self.name - - def set_data_type(self, data_type): - self.data_type = data_type - - def get_data_type_chain(self): - return self.data_type - - def get_data_type(self): - if isinstance(self.data_type, list): - if len(self.data_type) > 0: - return self.data_type[-1] - else: - return "xs:string" - else: - return self.data_type - - def set_container(self, container): - self.container = container - - def get_container(self): - return self.container - - def set_child_attrs(self, child_attrs): - self.child_attrs = child_attrs - - def get_child_attrs(self): - return self.child_attrs - - def set_choice(self, choice): - self.choice = choice - - def get_choice(self): - return self.choice - - def set_optional(self, optional): - self.optional = optional - - def get_optional(self): - return self.optional - - -def _cast(typ, value): - if typ is None or value is None: - return value - return typ(value) - - -# -# Data representation classes. -# - - -class Freightcom(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, version=None, ShippingReply=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.version = _cast(None, version) - self.version_nsprefix_ = None - self.ShippingReply = ShippingReply - self.ShippingReply_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, Freightcom) - if subclass is not None: - return subclass(*args_, **kwargs_) - if Freightcom.subclass: - return Freightcom.subclass(*args_, **kwargs_) - else: - return Freightcom(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_ShippingReply(self): - return self.ShippingReply - - def set_ShippingReply(self, ShippingReply): - self.ShippingReply = ShippingReply - - def get_version(self): - return self.version - - def set_version(self, version): - self.version = version - - def _hasContent(self): - if self.ShippingReply is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("Freightcom") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "Freightcom": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="Freightcom" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="Freightcom", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="Freightcom" - ): - if self.version is not None and "version" not in already_processed: - already_processed.add("version") - outfile.write( - " version=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.version), input_name="version" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.ShippingReply is not None: - namespaceprefix_ = ( - self.ShippingReply_nsprefix_ + ":" - if (UseCapturedNS_ and self.ShippingReply_nsprefix_) - else "" - ) - self.ShippingReply.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="ShippingReply", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("version", node) - if value is not None and "version" not in already_processed: - already_processed.add("version") - self.version = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "ShippingReply": - obj_ = ShippingReplyType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.ShippingReply = obj_ - obj_.original_tagname_ = "ShippingReply" - - -# end class Freightcom - - -class ShippingReplyType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - Order=None, - Carrier=None, - Reference=None, - Package=None, - Pickup=None, - TrackingURL=None, - Labels=None, - CustomsInvoice=None, - LabelData=None, - Quote=None, - BillingAddress=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.Order = Order - self.Order_nsprefix_ = None - self.Carrier = Carrier - self.Carrier_nsprefix_ = None - self.Reference = Reference - self.Reference_nsprefix_ = None - if Package is None: - self.Package = [] - else: - self.Package = Package - self.Package_nsprefix_ = None - self.Pickup = Pickup - self.Pickup_nsprefix_ = None - self.TrackingURL = TrackingURL - self.TrackingURL_nsprefix_ = None - self.Labels = Labels - self.Labels_nsprefix_ = None - self.CustomsInvoice = CustomsInvoice - self.CustomsInvoice_nsprefix_ = None - self.LabelData = LabelData - self.LabelData_nsprefix_ = None - self.Quote = Quote - self.Quote_nsprefix_ = None - self.BillingAddress = BillingAddress - self.BillingAddress_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ShippingReplyType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ShippingReplyType.subclass: - return ShippingReplyType.subclass(*args_, **kwargs_) - else: - return ShippingReplyType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Order(self): - return self.Order - - def set_Order(self, Order): - self.Order = Order - - def get_Carrier(self): - return self.Carrier - - def set_Carrier(self, Carrier): - self.Carrier = Carrier - - def get_Reference(self): - return self.Reference - - def set_Reference(self, Reference): - self.Reference = Reference - - def get_Package(self): - return self.Package - - def set_Package(self, Package): - self.Package = Package - - def add_Package(self, value): - self.Package.append(value) - - def insert_Package_at(self, index, value): - self.Package.insert(index, value) - - def replace_Package_at(self, index, value): - self.Package[index] = value - - def get_Pickup(self): - return self.Pickup - - def set_Pickup(self, Pickup): - self.Pickup = Pickup - - def get_TrackingURL(self): - return self.TrackingURL - - def set_TrackingURL(self, TrackingURL): - self.TrackingURL = TrackingURL - - def get_Labels(self): - return self.Labels - - def set_Labels(self, Labels): - self.Labels = Labels - - def get_CustomsInvoice(self): - return self.CustomsInvoice - - def set_CustomsInvoice(self, CustomsInvoice): - self.CustomsInvoice = CustomsInvoice - - def get_LabelData(self): - return self.LabelData - - def set_LabelData(self, LabelData): - self.LabelData = LabelData - - def get_Quote(self): - return self.Quote - - def set_Quote(self, Quote): - self.Quote = Quote - - def get_BillingAddress(self): - return self.BillingAddress - - def set_BillingAddress(self, BillingAddress): - self.BillingAddress = BillingAddress - - def _hasContent(self): - if ( - self.Order is not None - or self.Carrier is not None - or self.Reference is not None - or self.Package - or self.Pickup is not None - or self.TrackingURL is not None - or self.Labels is not None - or self.CustomsInvoice is not None - or self.LabelData is not None - or self.Quote is not None - or self.BillingAddress is not None - ): - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ShippingReplyType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ShippingReplyType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ShippingReplyType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="ShippingReplyType", - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ShippingReplyType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="ShippingReplyType", - ): - pass - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ShippingReplyType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.Order is not None: - namespaceprefix_ = ( - self.Order_nsprefix_ + ":" - if (UseCapturedNS_ and self.Order_nsprefix_) - else "" - ) - self.Order.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Order", - pretty_print=pretty_print, - ) - if self.Carrier is not None: - namespaceprefix_ = ( - self.Carrier_nsprefix_ + ":" - if (UseCapturedNS_ and self.Carrier_nsprefix_) - else "" - ) - self.Carrier.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Carrier", - pretty_print=pretty_print, - ) - if self.Reference is not None: - namespaceprefix_ = ( - self.Reference_nsprefix_ + ":" - if (UseCapturedNS_ and self.Reference_nsprefix_) - else "" - ) - self.Reference.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Reference", - pretty_print=pretty_print, - ) - for Package_ in self.Package: - namespaceprefix_ = ( - self.Package_nsprefix_ + ":" - if (UseCapturedNS_ and self.Package_nsprefix_) - else "" - ) - Package_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Package", - pretty_print=pretty_print, - ) - if self.Pickup is not None: - namespaceprefix_ = ( - self.Pickup_nsprefix_ + ":" - if (UseCapturedNS_ and self.Pickup_nsprefix_) - else "" - ) - self.Pickup.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Pickup", - pretty_print=pretty_print, - ) - if self.TrackingURL is not None: - namespaceprefix_ = ( - self.TrackingURL_nsprefix_ + ":" - if (UseCapturedNS_ and self.TrackingURL_nsprefix_) - else "" - ) - showIndent(outfile, level, pretty_print) - outfile.write( - "<%sTrackingURL>%s%s" - % ( - namespaceprefix_, - self.gds_encode( - self.gds_format_string( - quote_xml(self.TrackingURL), input_name="TrackingURL" - ) - ), - namespaceprefix_, - eol_, - ) - ) - if self.Labels is not None: - namespaceprefix_ = ( - self.Labels_nsprefix_ + ":" - if (UseCapturedNS_ and self.Labels_nsprefix_) - else "" - ) - showIndent(outfile, level, pretty_print) - outfile.write( - "<%sLabels>%s%s" - % ( - namespaceprefix_, - self.gds_encode( - self.gds_format_string( - quote_xml(self.Labels), input_name="Labels" - ) - ), - namespaceprefix_, - eol_, - ) - ) - if self.CustomsInvoice is not None: - namespaceprefix_ = ( - self.CustomsInvoice_nsprefix_ + ":" - if (UseCapturedNS_ and self.CustomsInvoice_nsprefix_) - else "" - ) - showIndent(outfile, level, pretty_print) - outfile.write( - "<%sCustomsInvoice>%s%s" - % ( - namespaceprefix_, - self.gds_encode( - self.gds_format_string( - quote_xml(self.CustomsInvoice), input_name="CustomsInvoice" - ) - ), - namespaceprefix_, - eol_, - ) - ) - if self.LabelData is not None: - namespaceprefix_ = ( - self.LabelData_nsprefix_ + ":" - if (UseCapturedNS_ and self.LabelData_nsprefix_) - else "" - ) - self.LabelData.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="LabelData", - pretty_print=pretty_print, - ) - if self.Quote is not None: - namespaceprefix_ = ( - self.Quote_nsprefix_ + ":" - if (UseCapturedNS_ and self.Quote_nsprefix_) - else "" - ) - self.Quote.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Quote", - pretty_print=pretty_print, - ) - if self.BillingAddress is not None: - namespaceprefix_ = ( - self.BillingAddress_nsprefix_ + ":" - if (UseCapturedNS_ and self.BillingAddress_nsprefix_) - else "" - ) - self.BillingAddress.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="BillingAddress", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - pass - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Order": - obj_ = OrderType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Order = obj_ - obj_.original_tagname_ = "Order" - elif nodeName_ == "Carrier": - obj_ = CarrierType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Carrier = obj_ - obj_.original_tagname_ = "Carrier" - elif nodeName_ == "Reference": - obj_ = ReferenceType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Reference = obj_ - obj_.original_tagname_ = "Reference" - elif nodeName_ == "Package": - obj_ = PackageType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Package.append(obj_) - obj_.original_tagname_ = "Package" - elif nodeName_ == "Pickup": - obj_ = PickupType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Pickup = obj_ - obj_.original_tagname_ = "Pickup" - elif nodeName_ == "TrackingURL": - value_ = child_.text - value_ = self.gds_parse_string(value_, node, "TrackingURL") - value_ = self.gds_validate_string(value_, node, "TrackingURL") - self.TrackingURL = value_ - self.TrackingURL_nsprefix_ = child_.prefix - elif nodeName_ == "Labels": - value_ = child_.text - value_ = self.gds_parse_string(value_, node, "Labels") - value_ = self.gds_validate_string(value_, node, "Labels") - self.Labels = value_ - self.Labels_nsprefix_ = child_.prefix - elif nodeName_ == "CustomsInvoice": - value_ = child_.text - value_ = self.gds_parse_string(value_, node, "CustomsInvoice") - value_ = self.gds_validate_string(value_, node, "CustomsInvoice") - self.CustomsInvoice = value_ - self.CustomsInvoice_nsprefix_ = child_.prefix - elif nodeName_ == "LabelData": - obj_ = LabelDataType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.LabelData = obj_ - obj_.original_tagname_ = "LabelData" - elif nodeName_ == "Quote": - obj_ = QuoteType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Quote = obj_ - obj_.original_tagname_ = "Quote" - elif nodeName_ == "BillingAddress": - obj_ = BillingAddressType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.BillingAddress = obj_ - obj_.original_tagname_ = "BillingAddress" - - -# end class ShippingReplyType - - -class OrderType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, id=None, valueOf_=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.id = _cast(None, id) - self.id_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, OrderType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if OrderType.subclass: - return OrderType.subclass(*args_, **kwargs_) - else: - return OrderType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_id(self): - return self.id - - def set_id(self, id): - self.id = id - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="OrderType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("OrderType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "OrderType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="OrderType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="OrderType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="OrderType" - ): - if self.id is not None and "id" not in already_processed: - already_processed.add("id") - outfile.write( - " id=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.id), input_name="id") - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="OrderType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("id", node) - if value is not None and "id" not in already_processed: - already_processed.add("id") - self.id = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class OrderType - - -class CarrierType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - carrierName=None, - serviceName=None, - SCAC=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.carrierName = _cast(None, carrierName) - self.carrierName_nsprefix_ = None - self.serviceName = _cast(None, serviceName) - self.serviceName_nsprefix_ = None - self.SCAC = _cast(None, SCAC) - self.SCAC_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, CarrierType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if CarrierType.subclass: - return CarrierType.subclass(*args_, **kwargs_) - else: - return CarrierType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_carrierName(self): - return self.carrierName - - def set_carrierName(self, carrierName): - self.carrierName = carrierName - - def get_serviceName(self): - return self.serviceName - - def set_serviceName(self, serviceName): - self.serviceName = serviceName - - def get_SCAC(self): - return self.SCAC - - def set_SCAC(self, SCAC): - self.SCAC = SCAC - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CarrierType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("CarrierType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "CarrierType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="CarrierType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="CarrierType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="CarrierType", - ): - if self.carrierName is not None and "carrierName" not in already_processed: - already_processed.add("carrierName") - outfile.write( - " carrierName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.carrierName), input_name="carrierName" - ) - ), - ) - ) - if self.serviceName is not None and "serviceName" not in already_processed: - already_processed.add("serviceName") - outfile.write( - " serviceName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.serviceName), input_name="serviceName" - ) - ), - ) - ) - if self.SCAC is not None and "SCAC" not in already_processed: - already_processed.add("SCAC") - outfile.write( - " SCAC=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.SCAC), input_name="SCAC" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CarrierType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("carrierName", node) - if value is not None and "carrierName" not in already_processed: - already_processed.add("carrierName") - self.carrierName = value - value = find_attr_value_("serviceName", node) - if value is not None and "serviceName" not in already_processed: - already_processed.add("serviceName") - self.serviceName = value - value = find_attr_value_("SCAC", node) - if value is not None and "SCAC" not in already_processed: - already_processed.add("SCAC") - self.SCAC = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class CarrierType - - -class ReferenceType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, code=None, name=None, valueOf_=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.code = _cast(None, code) - self.code_nsprefix_ = None - self.name = _cast(None, name) - self.name_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ReferenceType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ReferenceType.subclass: - return ReferenceType.subclass(*args_, **kwargs_) - else: - return ReferenceType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_code(self): - return self.code - - def set_code(self, code): - self.code = code - - def get_name(self): - return self.name - - def set_name(self, name): - self.name = name - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ReferenceType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ReferenceType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ReferenceType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="ReferenceType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ReferenceType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="ReferenceType", - ): - if self.code is not None and "code" not in already_processed: - already_processed.add("code") - outfile.write( - " code=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.code), input_name="code" - ) - ), - ) - ) - if self.name is not None and "name" not in already_processed: - already_processed.add("name") - outfile.write( - " name=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.name), input_name="name" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ReferenceType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("code", node) - if value is not None and "code" not in already_processed: - already_processed.add("code") - self.code = value - value = find_attr_value_("name", node) - if value is not None and "name" not in already_processed: - already_processed.add("name") - self.name = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class ReferenceType - - -class PackageType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, trackingNumber=None, valueOf_=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.trackingNumber = _cast(None, trackingNumber) - self.trackingNumber_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, PackageType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if PackageType.subclass: - return PackageType.subclass(*args_, **kwargs_) - else: - return PackageType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_trackingNumber(self): - return self.trackingNumber - - def set_trackingNumber(self, trackingNumber): - self.trackingNumber = trackingNumber - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackageType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("PackageType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "PackageType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="PackageType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="PackageType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="PackageType", - ): - if ( - self.trackingNumber is not None - and "trackingNumber" not in already_processed - ): - already_processed.add("trackingNumber") - outfile.write( - " trackingNumber=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.trackingNumber), - input_name="trackingNumber", - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackageType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("trackingNumber", node) - if value is not None and "trackingNumber" not in already_processed: - already_processed.add("trackingNumber") - self.trackingNumber = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class PackageType - - -class PickupType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, confirmationNumber=None, valueOf_=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.confirmationNumber = _cast(None, confirmationNumber) - self.confirmationNumber_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, PickupType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if PickupType.subclass: - return PickupType.subclass(*args_, **kwargs_) - else: - return PickupType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_confirmationNumber(self): - return self.confirmationNumber - - def set_confirmationNumber(self, confirmationNumber): - self.confirmationNumber = confirmationNumber - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PickupType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("PickupType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "PickupType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="PickupType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="PickupType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="PickupType" - ): - if ( - self.confirmationNumber is not None - and "confirmationNumber" not in already_processed - ): - already_processed.add("confirmationNumber") - outfile.write( - " confirmationNumber=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.confirmationNumber), - input_name="confirmationNumber", - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PickupType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("confirmationNumber", node) - if value is not None and "confirmationNumber" not in already_processed: - already_processed.add("confirmationNumber") - self.confirmationNumber = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class PickupType - - -class LabelDataType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, Label=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - if Label is None: - self.Label = [] - else: - self.Label = Label - self.Label_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, LabelDataType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if LabelDataType.subclass: - return LabelDataType.subclass(*args_, **kwargs_) - else: - return LabelDataType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Label(self): - return self.Label - - def set_Label(self, Label): - self.Label = Label - - def add_Label(self, value): - self.Label.append(value) - - def insert_Label_at(self, index, value): - self.Label.insert(index, value) - - def replace_Label_at(self, index, value): - self.Label[index] = value - - def _hasContent(self): - if self.Label: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="LabelDataType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("LabelDataType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "LabelDataType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="LabelDataType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="LabelDataType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="LabelDataType", - ): - pass - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="LabelDataType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - for Label_ in self.Label: - namespaceprefix_ = ( - self.Label_nsprefix_ + ":" - if (UseCapturedNS_ and self.Label_nsprefix_) - else "" - ) - Label_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Label", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - pass - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Label": - obj_ = LabelType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Label.append(obj_) - obj_.original_tagname_ = "Label" - - -# end class LabelDataType - - -class LabelType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, Type=None, Data=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.Type = Type - self.Type_nsprefix_ = None - self.Data = Data - self.Data_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, LabelType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if LabelType.subclass: - return LabelType.subclass(*args_, **kwargs_) - else: - return LabelType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Type(self): - return self.Type - - def set_Type(self, Type): - self.Type = Type - - def get_Data(self): - return self.Data - - def set_Data(self, Data): - self.Data = Data - - def _hasContent(self): - if self.Type is not None or self.Data is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="LabelType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("LabelType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "LabelType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="LabelType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="LabelType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="LabelType" - ): - pass - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="LabelType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.Type is not None: - namespaceprefix_ = ( - self.Type_nsprefix_ + ":" - if (UseCapturedNS_ and self.Type_nsprefix_) - else "" - ) - showIndent(outfile, level, pretty_print) - outfile.write( - "<%sType>%s%s" - % ( - namespaceprefix_, - self.gds_encode( - self.gds_format_string(quote_xml(self.Type), input_name="Type") - ), - namespaceprefix_, - eol_, - ) - ) - if self.Data is not None: - namespaceprefix_ = ( - self.Data_nsprefix_ + ":" - if (UseCapturedNS_ and self.Data_nsprefix_) - else "" - ) - showIndent(outfile, level, pretty_print) - outfile.write( - "<%sData>%s%s" - % ( - namespaceprefix_, - self.gds_encode( - self.gds_format_string(quote_xml(self.Data), input_name="Data") - ), - namespaceprefix_, - eol_, - ) - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - pass - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Type": - value_ = child_.text - value_ = self.gds_parse_string(value_, node, "Type") - value_ = self.gds_validate_string(value_, node, "Type") - self.Type = value_ - self.Type_nsprefix_ = child_.prefix - elif nodeName_ == "Data": - value_ = child_.text - value_ = self.gds_parse_string(value_, node, "Data") - value_ = self.gds_validate_string(value_, node, "Data") - self.Data = value_ - self.Data_nsprefix_ = child_.prefix - - -# end class LabelType - - -class QuoteType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - carrierId=None, - carrierName=None, - serviceId=None, - serviceName=None, - modeTransport=None, - transitDays=None, - baseCharge=None, - fuelSurcharge=None, - totalCharge=None, - currency=None, - Surcharge=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.carrierId = _cast(int, carrierId) - self.carrierId_nsprefix_ = None - self.carrierName = _cast(None, carrierName) - self.carrierName_nsprefix_ = None - self.serviceId = _cast(int, serviceId) - self.serviceId_nsprefix_ = None - self.serviceName = _cast(None, serviceName) - self.serviceName_nsprefix_ = None - self.modeTransport = _cast(None, modeTransport) - self.modeTransport_nsprefix_ = None - self.transitDays = _cast(int, transitDays) - self.transitDays_nsprefix_ = None - self.baseCharge = _cast(float, baseCharge) - self.baseCharge_nsprefix_ = None - self.fuelSurcharge = _cast(float, fuelSurcharge) - self.fuelSurcharge_nsprefix_ = None - self.totalCharge = _cast(float, totalCharge) - self.totalCharge_nsprefix_ = None - self.currency = _cast(None, currency) - self.currency_nsprefix_ = None - if Surcharge is None: - self.Surcharge = [] - else: - self.Surcharge = Surcharge - self.Surcharge_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, QuoteType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if QuoteType.subclass: - return QuoteType.subclass(*args_, **kwargs_) - else: - return QuoteType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Surcharge(self): - return self.Surcharge - - def set_Surcharge(self, Surcharge): - self.Surcharge = Surcharge - - def add_Surcharge(self, value): - self.Surcharge.append(value) - - def insert_Surcharge_at(self, index, value): - self.Surcharge.insert(index, value) - - def replace_Surcharge_at(self, index, value): - self.Surcharge[index] = value - - def get_carrierId(self): - return self.carrierId - - def set_carrierId(self, carrierId): - self.carrierId = carrierId - - def get_carrierName(self): - return self.carrierName - - def set_carrierName(self, carrierName): - self.carrierName = carrierName - - def get_serviceId(self): - return self.serviceId - - def set_serviceId(self, serviceId): - self.serviceId = serviceId - - def get_serviceName(self): - return self.serviceName - - def set_serviceName(self, serviceName): - self.serviceName = serviceName - - def get_modeTransport(self): - return self.modeTransport - - def set_modeTransport(self, modeTransport): - self.modeTransport = modeTransport - - def get_transitDays(self): - return self.transitDays - - def set_transitDays(self, transitDays): - self.transitDays = transitDays - - def get_baseCharge(self): - return self.baseCharge - - def set_baseCharge(self, baseCharge): - self.baseCharge = baseCharge - - def get_fuelSurcharge(self): - return self.fuelSurcharge - - def set_fuelSurcharge(self, fuelSurcharge): - self.fuelSurcharge = fuelSurcharge - - def get_totalCharge(self): - return self.totalCharge - - def set_totalCharge(self, totalCharge): - self.totalCharge = totalCharge - - def get_currency(self): - return self.currency - - def set_currency(self, currency): - self.currency = currency - - def _hasContent(self): - if self.Surcharge: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="QuoteType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("QuoteType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "QuoteType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="QuoteType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="QuoteType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="QuoteType" - ): - if self.carrierId is not None and "carrierId" not in already_processed: - already_processed.add("carrierId") - outfile.write( - ' carrierId="%s"' - % self.gds_format_integer(self.carrierId, input_name="carrierId") - ) - if self.carrierName is not None and "carrierName" not in already_processed: - already_processed.add("carrierName") - outfile.write( - " carrierName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.carrierName), input_name="carrierName" - ) - ), - ) - ) - if self.serviceId is not None and "serviceId" not in already_processed: - already_processed.add("serviceId") - outfile.write( - ' serviceId="%s"' - % self.gds_format_integer(self.serviceId, input_name="serviceId") - ) - if self.serviceName is not None and "serviceName" not in already_processed: - already_processed.add("serviceName") - outfile.write( - " serviceName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.serviceName), input_name="serviceName" - ) - ), - ) - ) - if self.modeTransport is not None and "modeTransport" not in already_processed: - already_processed.add("modeTransport") - outfile.write( - " modeTransport=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.modeTransport), input_name="modeTransport" - ) - ), - ) - ) - if self.transitDays is not None and "transitDays" not in already_processed: - already_processed.add("transitDays") - outfile.write( - ' transitDays="%s"' - % self.gds_format_integer(self.transitDays, input_name="transitDays") - ) - if self.baseCharge is not None and "baseCharge" not in already_processed: - already_processed.add("baseCharge") - outfile.write( - ' baseCharge="%s"' - % self.gds_format_float(self.baseCharge, input_name="baseCharge") - ) - if self.fuelSurcharge is not None and "fuelSurcharge" not in already_processed: - already_processed.add("fuelSurcharge") - outfile.write( - ' fuelSurcharge="%s"' - % self.gds_format_float(self.fuelSurcharge, input_name="fuelSurcharge") - ) - if self.totalCharge is not None and "totalCharge" not in already_processed: - already_processed.add("totalCharge") - outfile.write( - ' totalCharge="%s"' - % self.gds_format_float(self.totalCharge, input_name="totalCharge") - ) - if self.currency is not None and "currency" not in already_processed: - already_processed.add("currency") - outfile.write( - " currency=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.currency), input_name="currency" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="QuoteType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - for Surcharge_ in self.Surcharge: - namespaceprefix_ = ( - self.Surcharge_nsprefix_ + ":" - if (UseCapturedNS_ and self.Surcharge_nsprefix_) - else "" - ) - Surcharge_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Surcharge", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("carrierId", node) - if value is not None and "carrierId" not in already_processed: - already_processed.add("carrierId") - self.carrierId = self.gds_parse_integer(value, node, "carrierId") - value = find_attr_value_("carrierName", node) - if value is not None and "carrierName" not in already_processed: - already_processed.add("carrierName") - self.carrierName = value - value = find_attr_value_("serviceId", node) - if value is not None and "serviceId" not in already_processed: - already_processed.add("serviceId") - self.serviceId = self.gds_parse_integer(value, node, "serviceId") - value = find_attr_value_("serviceName", node) - if value is not None and "serviceName" not in already_processed: - already_processed.add("serviceName") - self.serviceName = value - value = find_attr_value_("modeTransport", node) - if value is not None and "modeTransport" not in already_processed: - already_processed.add("modeTransport") - self.modeTransport = value - value = find_attr_value_("transitDays", node) - if value is not None and "transitDays" not in already_processed: - already_processed.add("transitDays") - self.transitDays = self.gds_parse_integer(value, node, "transitDays") - value = find_attr_value_("baseCharge", node) - if value is not None and "baseCharge" not in already_processed: - already_processed.add("baseCharge") - value = self.gds_parse_float(value, node, "baseCharge") - self.baseCharge = value - value = find_attr_value_("fuelSurcharge", node) - if value is not None and "fuelSurcharge" not in already_processed: - already_processed.add("fuelSurcharge") - value = self.gds_parse_float(value, node, "fuelSurcharge") - self.fuelSurcharge = value - value = find_attr_value_("totalCharge", node) - if value is not None and "totalCharge" not in already_processed: - already_processed.add("totalCharge") - value = self.gds_parse_float(value, node, "totalCharge") - self.totalCharge = value - value = find_attr_value_("currency", node) - if value is not None and "currency" not in already_processed: - already_processed.add("currency") - self.currency = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Surcharge": - obj_ = SurchargeType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Surcharge.append(obj_) - obj_.original_tagname_ = "Surcharge" - - -# end class QuoteType - - -class SurchargeType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - id=None, - name=None, - amount=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.id = _cast(None, id) - self.id_nsprefix_ = None - self.name = _cast(None, name) - self.name_nsprefix_ = None - self.amount = _cast(float, amount) - self.amount_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, SurchargeType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if SurchargeType.subclass: - return SurchargeType.subclass(*args_, **kwargs_) - else: - return SurchargeType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_id(self): - return self.id - - def set_id(self, id): - self.id = id - - def get_name(self): - return self.name - - def set_name(self, name): - self.name = name - - def get_amount(self): - return self.amount - - def set_amount(self, amount): - self.amount = amount - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="SurchargeType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("SurchargeType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "SurchargeType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="SurchargeType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="SurchargeType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="SurchargeType", - ): - if self.id is not None and "id" not in already_processed: - already_processed.add("id") - outfile.write( - " id=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.id), input_name="id") - ), - ) - ) - if self.name is not None and "name" not in already_processed: - already_processed.add("name") - outfile.write( - " name=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.name), input_name="name" - ) - ), - ) - ) - if self.amount is not None and "amount" not in already_processed: - already_processed.add("amount") - outfile.write( - ' amount="%s"' % self.gds_format_float(self.amount, input_name="amount") - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="SurchargeType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("id", node) - if value is not None and "id" not in already_processed: - already_processed.add("id") - self.id = value - value = find_attr_value_("name", node) - if value is not None and "name" not in already_processed: - already_processed.add("name") - self.name = value - value = find_attr_value_("amount", node) - if value is not None and "amount" not in already_processed: - already_processed.add("amount") - value = self.gds_parse_float(value, node, "amount") - self.amount = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class SurchargeType - - -class BillingAddressType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - CompanyName=None, - Address1=None, - Address2=None, - City=None, - ProvinceCode=None, - CountryCode=None, - zip=None, - PhoneNo=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.CompanyName = _cast(None, CompanyName) - self.CompanyName_nsprefix_ = None - self.Address1 = _cast(None, Address1) - self.Address1_nsprefix_ = None - self.Address2 = _cast(None, Address2) - self.Address2_nsprefix_ = None - self.City = _cast(None, City) - self.City_nsprefix_ = None - self.ProvinceCode = _cast(None, ProvinceCode) - self.ProvinceCode_nsprefix_ = None - self.CountryCode = _cast(None, CountryCode) - self.CountryCode_nsprefix_ = None - self.zip = _cast(None, zip) - self.zip_nsprefix_ = None - self.PhoneNo = _cast(None, PhoneNo) - self.PhoneNo_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, BillingAddressType - ) - if subclass is not None: - return subclass(*args_, **kwargs_) - if BillingAddressType.subclass: - return BillingAddressType.subclass(*args_, **kwargs_) - else: - return BillingAddressType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_CompanyName(self): - return self.CompanyName - - def set_CompanyName(self, CompanyName): - self.CompanyName = CompanyName - - def get_Address1(self): - return self.Address1 - - def set_Address1(self, Address1): - self.Address1 = Address1 - - def get_Address2(self): - return self.Address2 - - def set_Address2(self, Address2): - self.Address2 = Address2 - - def get_City(self): - return self.City - - def set_City(self, City): - self.City = City - - def get_ProvinceCode(self): - return self.ProvinceCode - - def set_ProvinceCode(self, ProvinceCode): - self.ProvinceCode = ProvinceCode - - def get_CountryCode(self): - return self.CountryCode - - def set_CountryCode(self, CountryCode): - self.CountryCode = CountryCode - - def get_zip(self): - return self.zip - - def set_zip(self, zip): - self.zip = zip - - def get_PhoneNo(self): - return self.PhoneNo - - def set_PhoneNo(self, PhoneNo): - self.PhoneNo = PhoneNo - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="BillingAddressType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("BillingAddressType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "BillingAddressType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="BillingAddressType", - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="BillingAddressType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="BillingAddressType", - ): - if self.CompanyName is not None and "CompanyName" not in already_processed: - already_processed.add("CompanyName") - outfile.write( - " CompanyName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.CompanyName), input_name="CompanyName" - ) - ), - ) - ) - if self.Address1 is not None and "Address1" not in already_processed: - already_processed.add("Address1") - outfile.write( - " Address1=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.Address1), input_name="Address1" - ) - ), - ) - ) - if self.Address2 is not None and "Address2" not in already_processed: - already_processed.add("Address2") - outfile.write( - " Address2=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.Address2), input_name="Address2" - ) - ), - ) - ) - if self.City is not None and "City" not in already_processed: - already_processed.add("City") - outfile.write( - " City=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.City), input_name="City" - ) - ), - ) - ) - if self.ProvinceCode is not None and "ProvinceCode" not in already_processed: - already_processed.add("ProvinceCode") - outfile.write( - " ProvinceCode=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.ProvinceCode), input_name="ProvinceCode" - ) - ), - ) - ) - if self.CountryCode is not None and "CountryCode" not in already_processed: - already_processed.add("CountryCode") - outfile.write( - " CountryCode=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.CountryCode), input_name="CountryCode" - ) - ), - ) - ) - if self.zip is not None and "zip" not in already_processed: - already_processed.add("zip") - outfile.write( - " zip=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.zip), input_name="zip") - ), - ) - ) - if self.PhoneNo is not None and "PhoneNo" not in already_processed: - already_processed.add("PhoneNo") - outfile.write( - " PhoneNo=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.PhoneNo), input_name="PhoneNo" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="BillingAddressType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("CompanyName", node) - if value is not None and "CompanyName" not in already_processed: - already_processed.add("CompanyName") - self.CompanyName = value - value = find_attr_value_("Address1", node) - if value is not None and "Address1" not in already_processed: - already_processed.add("Address1") - self.Address1 = value - value = find_attr_value_("Address2", node) - if value is not None and "Address2" not in already_processed: - already_processed.add("Address2") - self.Address2 = value - value = find_attr_value_("City", node) - if value is not None and "City" not in already_processed: - already_processed.add("City") - self.City = value - value = find_attr_value_("ProvinceCode", node) - if value is not None and "ProvinceCode" not in already_processed: - already_processed.add("ProvinceCode") - self.ProvinceCode = value - value = find_attr_value_("CountryCode", node) - if value is not None and "CountryCode" not in already_processed: - already_processed.add("CountryCode") - self.CountryCode = value - value = find_attr_value_("zip", node) - if value is not None and "zip" not in already_processed: - already_processed.add("zip") - self.zip = value - value = find_attr_value_("PhoneNo", node) - if value is not None and "PhoneNo" not in already_processed: - already_processed.add("PhoneNo") - self.PhoneNo = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class BillingAddressType - - -GDSClassesMapping = {} - - -USAGE_TEXT = """ -Usage: python .py [ -s ] -""" - - -def usage(): - print(USAGE_TEXT) - sys.exit(1) - - -def get_root_tag(node): - tag = Tag_pattern_.match(node.tag).groups()[-1] - prefix_tag = TagNamePrefix + tag - rootClass = GDSClassesMapping.get(prefix_tag) - if rootClass is None: - rootClass = globals().get(prefix_tag) - return tag, rootClass - - -def get_required_ns_prefix_defs(rootNode): - """Get all name space prefix definitions required in this XML doc. - Return a dictionary of definitions and a char string of definitions. - """ - nsmap = { - prefix: uri - for node in rootNode.iter() - for (prefix, uri) in node.nsmap.items() - if prefix is not None - } - namespacedefs = " ".join( - ['xmlns:{}="{}"'.format(prefix, uri) for prefix, uri in nsmap.items()] - ) - return nsmap, namespacedefs - - -def parse(inFileName, silence=False, print_warnings=True): - global CapturedNsmap_ - gds_collector = GdsCollector_() - parser = None - doc = parsexml_(inFileName, parser) - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode) - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export( - sys.stdout, 0, name_=rootTag, namespacedef_=namespacedefs, pretty_print=True - ) - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseEtree( - inFileName, - silence=False, - print_warnings=True, - mapping=None, - reverse_mapping=None, - nsmap=None, -): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if mapping is None: - mapping = {} - if reverse_mapping is None: - reverse_mapping = {} - rootElement = rootObj.to_etree( - None, - name_=rootTag, - mapping_=mapping, - reverse_mapping_=reverse_mapping, - nsmap_=nsmap, - ) - reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - content = etree_.tostring( - rootElement, pretty_print=True, xml_declaration=True, encoding="utf-8" - ) - sys.stdout.write(str(content)) - sys.stdout.write("\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj, rootElement, mapping, reverse_node_mapping - - -def parseString(inString, silence=False, print_warnings=True): - """Parse a string, create the object tree, and export it. - - Arguments: - - inString -- A string. This XML fragment should not start - with an XML declaration containing an encoding. - - silence -- A boolean. If False, export the object. - Returns -- The root object in the tree. - """ - parser = None - rootNode = parsexmlstring_(inString, parser) - gds_collector = GdsCollector_() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if not SaveElementTreeNode: - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export(sys.stdout, 0, name_=rootTag, namespacedef_="") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseLiteral(inFileName, silence=False, print_warnings=True): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write("#from shipping_reply import *\n\n") - sys.stdout.write("import shipping_reply as model_\n\n") - sys.stdout.write("rootObj = model_.rootClass(\n") - rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) - sys.stdout.write(")\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def main(): - args = sys.argv[1:] - if len(args) == 1: - parse(args[0]) - else: - usage() - - -if __name__ == "__main__": - # import pdb; pdb.set_trace() - main() - -RenameMappings_ = {} - -# -# Mapping of namespaces to types defined in them -# and the file in which each is defined. -# simpleTypes are marked "ST" and complexTypes "CT". -NamespaceToDefMappings_ = {"http://www.freightcom.net/XMLSchema": []} - -__all__ = [ - "BillingAddressType", - "CarrierType", - "Freightcom", - "LabelDataType", - "LabelType", - "OrderType", - "PackageType", - "PickupType", - "QuoteType", - "ReferenceType", - "ShippingReplyType", - "SurchargeType", -] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_request.py b/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_request.py index 1993f125c1..bde1ebf630 100644 --- a/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_request.py +++ b/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_request.py @@ -1,5953 +1,246 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +from attr import s +from typing import Optional, List +from jstruct import JStruct, JList + + +@s(auto_attribs=True) +class NumberType: + number: Optional[str] = None + extension: Optional[int] = None + + +@s(auto_attribs=True) +class BrokerType: + use_carrier: Optional[bool] = None + name: Optional[str] = None + account_number: Optional[str] = None + phone_number: Optional[NumberType] = JStruct[NumberType] + fax_number: Optional[NumberType] = JStruct[NumberType] + email_address: Optional[str] = None + usmca_number: Optional[str] = None + fda_number: Optional[str] = None + + +@s(auto_attribs=True) +class TotalCostType: + currency: Optional[str] = None + value: Optional[int] = None + + +@s(auto_attribs=True) +class WeightType: + unit: Optional[str] = None + value: Optional[float] = None + + +@s(auto_attribs=True) +class ProductType: + product_name: Optional[str] = None + weight: Optional[WeightType] = JStruct[WeightType] + hs_code: Optional[str] = None + country_of_origin: Optional[str] = None + num_units: Optional[int] = None + unit_price: Optional[TotalCostType] = JStruct[TotalCostType] + description: Optional[str] = None + + +@s(auto_attribs=True) +class AddressType: + address_line_1: Optional[str] = None + address_line_2: Optional[str] = None + unit_number: Optional[str] = None + city: Optional[str] = None + region: Optional[str] = None + country: Optional[str] = None + postal_code: Optional[str] = None + + +@s(auto_attribs=True) +class TaxRecipientType: + type: Optional[str] = None + shipper_tax_identifier: Optional[str] = None + receiver_tax_identifier: Optional[str] = None + third_party_tax_identifier: Optional[str] = None + other_tax_identifier: Optional[str] = None + name: Optional[str] = None + address: Optional[AddressType] = JStruct[AddressType] + phone_number: Optional[NumberType] = JStruct[NumberType] + reason_for_export: Optional[str] = None + additional_remarks: Optional[str] = None + comments: Optional[str] = None -# -# Generated Fri Oct 21 12:33:20 2022 by generateDS.py version 2.41.1. -# Python 3.10.8 (v3.10.8:aaaf517424, Oct 11 2022, 10:14:40) [Clang 13.0.0 (clang-1300.0.29.30)] -# -# Command line options: -# ('--no-namespace-defs', '') -# ('-o', './karrio.schemas.freightcom/shipping_request.py') -# -# Command line arguments: -# ./vendor/schemas/shipping_request.xsd -# -# Command line: -# /Users/danielk/Documents/karrio/karrio/.venv/karrio/bin/generateDS --no-namespace-defs -o "./karrio.schemas.freightcom/shipping_request.py" ./vendor/schemas/shipping_request.xsd -# -# Current working directory (os.getcwd()): -# freightcom -# - -import sys - -try: - ModulenotfoundExp_ = ModuleNotFoundError -except NameError: - ModulenotfoundExp_ = ImportError -from six.moves import zip_longest -import os -import re as re_ -import base64 -import datetime as datetime_ -import decimal as decimal_ -from lxml import etree as etree_ - - -Validate_simpletypes_ = True -SaveElementTreeNode = True -TagNamePrefix = "" -if sys.version_info.major == 2: - BaseStrType_ = basestring -else: - BaseStrType_ = str - - -def parsexml_(infile, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - try: - if isinstance(infile, os.PathLike): - infile = os.path.join(infile) - except AttributeError: - pass - doc = etree_.parse(infile, parser=parser, **kwargs) - return doc - - -def parsexmlstring_(instring, parser=None, **kwargs): - if parser is None: - # Use the lxml ElementTree compatible parser so that, e.g., - # we ignore comments. - try: - parser = etree_.ETCompatXMLParser() - except AttributeError: - # fallback to xml.etree - parser = etree_.XMLParser() - element = etree_.fromstring(instring, parser=parser, **kwargs) - return element - - -# -# Namespace prefix definition table (and other attributes, too) -# -# The module generatedsnamespaces, if it is importable, must contain -# a dictionary named GeneratedsNamespaceDefs. This Python dictionary -# should map element type names (strings) to XML schema namespace prefix -# definitions. The export method for any class for which there is -# a namespace prefix definition, will export that definition in the -# XML representation of that element. See the export method of -# any generated element type class for an example of the use of this -# table. -# A sample table is: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceDefs = { -# "ElementtypeA": "http://www.xxx.com/namespaceA", -# "ElementtypeB": "http://www.xxx.com/namespaceB", -# } -# -# Additionally, the generatedsnamespaces module can contain a python -# dictionary named GenerateDSNamespaceTypePrefixes that associates element -# types with the namespace prefixes that are to be added to the -# "xsi:type" attribute value. See the _exportAttributes method of -# any generated element type and the generation of "xsi:type" for an -# example of the use of this table. -# An example table: -# -# # File: generatedsnamespaces.py -# -# GenerateDSNamespaceTypePrefixes = { -# "ElementtypeC": "aaa:", -# "ElementtypeD": "bbb:", -# } -# - -try: - from generatedsnamespaces import GenerateDSNamespaceDefs as GenerateDSNamespaceDefs_ -except ModulenotfoundExp_: - GenerateDSNamespaceDefs_ = {} -try: - from generatedsnamespaces import ( - GenerateDSNamespaceTypePrefixes as GenerateDSNamespaceTypePrefixes_, - ) -except ModulenotfoundExp_: - GenerateDSNamespaceTypePrefixes_ = {} - -# -# You can replace the following class definition by defining an -# importable module named "generatedscollector" containing a class -# named "GdsCollector". See the default class definition below for -# clues about the possible content of that class. -# -try: - from generatedscollector import GdsCollector as GdsCollector_ -except ModulenotfoundExp_: - - class GdsCollector_(object): - def __init__(self, messages=None): - if messages is None: - self.messages = [] - else: - self.messages = messages - - def add_message(self, msg): - self.messages.append(msg) - - def get_messages(self): - return self.messages - - def clear_messages(self): - self.messages = [] - - def print_messages(self): - for msg in self.messages: - print("Warning: {}".format(msg)) - - def write_messages(self, outstream): - for msg in self.messages: - outstream.write("Warning: {}\n".format(msg)) - - -# -# The super-class for enum types -# - -try: - from enum import Enum -except ModulenotfoundExp_: - Enum = object - -# -# The root super-class for element type classes -# -# Calls to the methods in these classes are generated by generateDS.py. -# You can replace these methods by re-implementing the following class -# in a module named generatedssuper.py. - -try: - from generatedssuper import GeneratedsSuper -except ModulenotfoundExp_ as exp: - try: - from generatedssupersuper import GeneratedsSuperSuper - except ModulenotfoundExp_ as exp: - - class GeneratedsSuperSuper(object): - pass - - class GeneratedsSuper(GeneratedsSuperSuper): - __hash__ = object.__hash__ - tzoff_pattern = re_.compile(r"(\+|-)((0\d|1[0-3]):[0-5]\d|14:00)$") - - class _FixedOffsetTZ(datetime_.tzinfo): - def __init__(self, offset, name): - self.__offset = datetime_.timedelta(minutes=offset) - self.__name = name - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return self.__name - - def dst(self, dt): - return None - - def __str__(self): - settings = { - "str_pretty_print": True, - "str_indent_level": 0, - "str_namespaceprefix": "", - "str_name": self.__class__.__name__, - "str_namespacedefs": "", - } - for n in settings: - if hasattr(self, n): - settings[n] = getattr(self, n) - if sys.version_info.major == 2: - from StringIO import StringIO - else: - from io import StringIO - output = StringIO() - self.export( - output, - settings["str_indent_level"], - pretty_print=settings["str_pretty_print"], - namespaceprefix_=settings["str_namespaceprefix"], - name_=settings["str_name"], - namespacedef_=settings["str_namespacedefs"], - ) - strval = output.getvalue() - output.close() - return strval - - def gds_format_string(self, input_data, input_name=""): - return input_data - - def gds_parse_string(self, input_data, node=None, input_name=""): - return input_data - - def gds_validate_string(self, input_data, node=None, input_name=""): - if not input_data: - return "" - else: - return input_data - - def gds_format_base64(self, input_data, input_name=""): - return base64.b64encode(input_data).decode("ascii") - - def gds_validate_base64(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_integer(self, input_data, input_name=""): - return "%d" % int(input_data) - - def gds_parse_integer(self, input_data, node=None, input_name=""): - try: - ival = int(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires integer value: %s" % exp) - return ival - - def gds_validate_integer(self, input_data, node=None, input_name=""): - try: - value = int(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires integer value") - return value - - def gds_format_integer_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_integer_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - int(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of integer values") - return values - - def gds_format_float(self, input_data, input_name=""): - return ("%.15f" % float(input_data)).rstrip("0") - - def gds_parse_float(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires float or double value: %s" % exp) - return fval_ - - def gds_validate_float(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires float value") - return value - - def gds_format_float_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_float_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of float values") - return values - - def gds_format_decimal(self, input_data, input_name=""): - return_value = "%s" % input_data - if "." in return_value: - return_value = return_value.rstrip("0") - if return_value.endswith("."): - return_value = return_value.rstrip(".") - return return_value - - def gds_parse_decimal(self, input_data, node=None, input_name=""): - try: - decimal_value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return decimal_value - - def gds_validate_decimal(self, input_data, node=None, input_name=""): - try: - value = decimal_.Decimal(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires decimal value") - return value - - def gds_format_decimal_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return " ".join([self.gds_format_decimal(item) for item in input_data]) - - def gds_validate_decimal_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - decimal_.Decimal(value) - except (TypeError, ValueError): - raise_parse_error(node, "Requires sequence of decimal values") - return values - - def gds_format_double(self, input_data, input_name=""): - return "%s" % input_data - - def gds_parse_double(self, input_data, node=None, input_name=""): - try: - fval_ = float(input_data) - except (TypeError, ValueError) as exp: - raise_parse_error(node, "Requires double or float value: %s" % exp) - return fval_ - - def gds_validate_double(self, input_data, node=None, input_name=""): - try: - value = float(input_data) - except (TypeError, ValueError): - raise_parse_error(node, "Requires double or float value") - return value - - def gds_format_double_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_double_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - try: - float(value) - except (TypeError, ValueError): - raise_parse_error( - node, "Requires sequence of double or float values" - ) - return values - - def gds_format_boolean(self, input_data, input_name=""): - return ("%s" % input_data).lower() - - def gds_parse_boolean(self, input_data, node=None, input_name=""): - input_data = input_data.strip() - if input_data in ("true", "1"): - bval = True - elif input_data in ("false", "0"): - bval = False - else: - raise_parse_error(node, "Requires boolean value") - return bval - - def gds_validate_boolean(self, input_data, node=None, input_name=""): - if input_data not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, "Requires boolean value " "(one of True, 1, False, 0)" - ) - return input_data - - def gds_format_boolean_list(self, input_data, input_name=""): - if len(input_data) > 0 and not isinstance(input_data[0], BaseStrType_): - input_data = [str(s) for s in input_data] - return "%s" % " ".join(input_data) - - def gds_validate_boolean_list(self, input_data, node=None, input_name=""): - values = input_data.split() - for value in values: - value = self.gds_parse_boolean(value, node, input_name) - if value not in ( - True, - 1, - False, - 0, - ): - raise_parse_error( - node, - "Requires sequence of boolean values " - "(one of True, 1, False, 0)", - ) - return values - - def gds_validate_datetime(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_datetime(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%04d-%02d-%02dT%02d:%02d:%02d.%s" % ( - input_data.year, - input_data.month, - input_data.day, - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - @classmethod - def gds_parse_datetime(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - time_parts = input_data.split(".") - if len(time_parts) > 1: - micro_seconds = int(float("0." + time_parts[1]) * 1000000) - input_data = "%s.%s" % ( - time_parts[0], - "{}".format(micro_seconds).rjust(6, "0"), - ) - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%dT%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt - - def gds_validate_date(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_date(self, input_data, input_name=""): - _svalue = "%04d-%02d-%02d" % ( - input_data.year, - input_data.month, - input_data.day, - ) - try: - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - except AttributeError: - pass - return _svalue - - @classmethod - def gds_parse_date(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - dt = datetime_.datetime.strptime(input_data, "%Y-%m-%d") - dt = dt.replace(tzinfo=tz) - return dt.date() - - def gds_validate_time(self, input_data, node=None, input_name=""): - return input_data - - def gds_format_time(self, input_data, input_name=""): - if input_data.microsecond == 0: - _svalue = "%02d:%02d:%02d" % ( - input_data.hour, - input_data.minute, - input_data.second, - ) - else: - _svalue = "%02d:%02d:%02d.%s" % ( - input_data.hour, - input_data.minute, - input_data.second, - ("%f" % (float(input_data.microsecond) / 1000000))[2:], - ) - if input_data.tzinfo is not None: - tzoff = input_data.tzinfo.utcoffset(input_data) - if tzoff is not None: - total_seconds = tzoff.seconds + (86400 * tzoff.days) - if total_seconds == 0: - _svalue += "Z" - else: - if total_seconds < 0: - _svalue += "-" - total_seconds *= -1 - else: - _svalue += "+" - hours = total_seconds // 3600 - minutes = (total_seconds - (hours * 3600)) // 60 - _svalue += "{0:02d}:{1:02d}".format(hours, minutes) - return _svalue - - def gds_validate_simple_patterns(self, patterns, target): - # pat is a list of lists of strings/patterns. - # The target value must match at least one of the patterns - # in order for the test to succeed. - found1 = True - target = str(target) - for patterns1 in patterns: - found2 = False - for patterns2 in patterns1: - mo = re_.search(patterns2, target) - if mo is not None and len(mo.group(0)) == len(target): - found2 = True - break - if not found2: - found1 = False - break - return found1 - - @classmethod - def gds_parse_time(cls, input_data): - tz = None - if input_data[-1] == "Z": - tz = GeneratedsSuper._FixedOffsetTZ(0, "UTC") - input_data = input_data[:-1] - else: - results = GeneratedsSuper.tzoff_pattern.search(input_data) - if results is not None: - tzoff_parts = results.group(2).split(":") - tzoff = int(tzoff_parts[0]) * 60 + int(tzoff_parts[1]) - if results.group(1) == "-": - tzoff *= -1 - tz = GeneratedsSuper._FixedOffsetTZ(tzoff, results.group(0)) - input_data = input_data[:-6] - if len(input_data.split(".")) > 1: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S.%f") - else: - dt = datetime_.datetime.strptime(input_data, "%H:%M:%S") - dt = dt.replace(tzinfo=tz) - return dt.time() - - def gds_check_cardinality_( - self, value, input_name, min_occurs=0, max_occurs=1, required=None - ): - if value is None: - length = 0 - elif isinstance(value, list): - length = len(value) - else: - length = 1 - if required is not None: - if required and length < 1: - self.gds_collector_.add_message( - "Required value {}{} is missing".format( - input_name, self.gds_get_node_lineno_() - ) - ) - if length < min_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is below " - "the minimum allowed, " - "expected at least {}, found {}".format( - input_name, self.gds_get_node_lineno_(), min_occurs, length - ) - ) - elif length > max_occurs: - self.gds_collector_.add_message( - "Number of values for {}{} is above " - "the maximum allowed, " - "expected at most {}, found {}".format( - input_name, self.gds_get_node_lineno_(), max_occurs, length - ) - ) - - def gds_validate_builtin_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value, input_name=input_name) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_validate_defined_ST_( - self, - validator, - value, - input_name, - min_occurs=None, - max_occurs=None, - required=None, - ): - if value is not None: - try: - validator(value) - except GDSParseError as parse_error: - self.gds_collector_.add_message(str(parse_error)) - - def gds_str_lower(self, instring): - return instring.lower() - - def get_path_(self, node): - path_list = [] - self.get_path_list_(node, path_list) - path_list.reverse() - path = "/".join(path_list) - return path - - Tag_strip_pattern_ = re_.compile(r"\{.*\}") - - def get_path_list_(self, node, path_list): - if node is None: - return - tag = GeneratedsSuper.Tag_strip_pattern_.sub("", node.tag) - if tag: - path_list.append(tag) - self.get_path_list_(node.getparent(), path_list) - - def get_class_obj_(self, node, default_class=None): - class_obj1 = default_class - if "xsi" in node.nsmap: - classname = node.get("{%s}type" % node.nsmap["xsi"]) - if classname is not None: - names = classname.split(":") - if len(names) == 2: - classname = names[1] - class_obj2 = globals().get(classname) - if class_obj2 is not None: - class_obj1 = class_obj2 - return class_obj1 - - def gds_build_any(self, node, type_name=None): - # provide default value in case option --disable-xml is used. - content = "" - content = etree_.tostring(node, encoding="unicode") - return content - - @classmethod - def gds_reverse_node_mapping(cls, mapping): - return dict(((v, k) for k, v in mapping.items())) - - @staticmethod - def gds_encode(instring): - if sys.version_info.major == 2: - if ExternalEncoding: - encoding = ExternalEncoding - else: - encoding = "utf-8" - return instring.encode(encoding) - else: - return instring - - @staticmethod - def convert_unicode(instring): - if isinstance(instring, str): - result = quote_xml(instring) - elif sys.version_info.major == 2 and isinstance(instring, unicode): - result = quote_xml(instring).encode("utf8") - else: - result = GeneratedsSuper.gds_encode(str(instring)) - return result - - def __eq__(self, other): - def excl_select_objs_(obj): - return obj[0] != "parent_object_" and obj[0] != "gds_collector_" - - if type(self) != type(other): - return False - return all( - x == y - for x, y in zip_longest( - filter(excl_select_objs_, self.__dict__.items()), - filter(excl_select_objs_, other.__dict__.items()), - ) - ) - - def __ne__(self, other): - return not self.__eq__(other) - - # Django ETL transform hooks. - def gds_djo_etl_transform(self): - pass - - def gds_djo_etl_transform_db_obj(self, dbobj): - pass - - # SQLAlchemy ETL transform hooks. - def gds_sqa_etl_transform(self): - return 0, None - - def gds_sqa_etl_transform_db_obj(self, dbobj): - pass - - def gds_get_node_lineno_(self): - if ( - hasattr(self, "gds_elementtree_node_") - and self.gds_elementtree_node_ is not None - ): - return " near line {}".format(self.gds_elementtree_node_.sourceline) - else: - return "" - - def getSubclassFromModule_(module, class_): - """Get the subclass of a class from a specific module.""" - name = class_.__name__ + "Sub" - if hasattr(module, name): - return getattr(module, name) - else: - return None - - -# -# If you have installed IPython you can uncomment and use the following. -# IPython is available from http://ipython.scipy.org/. -# - -## from IPython.Shell import IPShellEmbed -## args = '' -## ipshell = IPShellEmbed(args, -## banner = 'Dropping into IPython', -## exit_msg = 'Leaving Interpreter, back to program.') - -# Then use the following line where and when you want to drop into the -# IPython shell: -# ipshell(' -- Entering ipshell.\nHit Ctrl-D to exit') - -# -# Globals -# - -ExternalEncoding = "" -# Set this to false in order to deactivate during export, the use of -# name space prefixes captured from the input document. -UseCapturedNS_ = True -CapturedNsmap_ = {} -Tag_pattern_ = re_.compile(r"({.*})?(.*)") -String_cleanup_pat_ = re_.compile(r"[\n\r\s]+") -Namespace_extract_pat_ = re_.compile(r"{(.*)}(.*)") -CDATA_pattern_ = re_.compile(r"", re_.DOTALL) - -# Change this to redirect the generated superclass module to use a -# specific subclass module. -CurrentSubclassModule_ = None - -# -# Support/utility functions. -# - - -def showIndent(outfile, level, pretty_print=True): - if pretty_print: - for idx in range(level): - outfile.write(" ") - - -def quote_xml(inStr): - "Escape markup chars, but do not modify CDATA sections." - if not inStr: - return "" - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s2 = "" - pos = 0 - matchobjects = CDATA_pattern_.finditer(s1) - for mo in matchobjects: - s3 = s1[pos : mo.start()] - s2 += quote_xml_aux(s3) - s2 += s1[mo.start() : mo.end()] - pos = mo.end() - s3 = s1[pos:] - s2 += quote_xml_aux(s3) - return s2 - - -def quote_xml_aux(inStr): - s1 = inStr.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - return s1 - - -def quote_attrib(inStr): - s1 = isinstance(inStr, BaseStrType_) and inStr or "%s" % inStr - s1 = s1.replace("&", "&") - s1 = s1.replace("<", "<") - s1 = s1.replace(">", ">") - s1 = s1.replace("\n", " ") - if '"' in s1: - if "'" in s1: - s1 = '"%s"' % s1.replace('"', """) - else: - s1 = "'%s'" % s1 - else: - s1 = '"%s"' % s1 - return s1 - - -def quote_python(inStr): - s1 = inStr - if s1.find("'") == -1: - if s1.find("\n") == -1: - return "'%s'" % s1 - else: - return "'''%s'''" % s1 - else: - if s1.find('"') != -1: - s1 = s1.replace('"', '\\"') - if s1.find("\n") == -1: - return '"%s"' % s1 - else: - return '"""%s"""' % s1 - - -def get_all_text_(node): - if node.text is not None: - text = node.text - else: - text = "" - for child in node: - if child.tail is not None: - text += child.tail - return text - - -def find_attr_value_(attr_name, node): - attrs = node.attrib - attr_parts = attr_name.split(":") - value = None - if len(attr_parts) == 1: - value = attrs.get(attr_name) - elif len(attr_parts) == 2: - prefix, name = attr_parts - if prefix == "xml": - namespace = "http://www.w3.org/XML/1998/namespace" - else: - namespace = node.nsmap.get(prefix) - if namespace is not None: - value = attrs.get( - "{%s}%s" - % ( - namespace, - name, - ) - ) - return value - - -def encode_str_2_3(instr): - return instr - - -class GDSParseError(Exception): - pass - - -def raise_parse_error(node, msg): - if node is not None: - msg = "%s (element %s/line %d)" % ( - msg, - node.tag, - node.sourceline, - ) - raise GDSParseError(msg) - - -class MixedContainer: - # Constants for category: - CategoryNone = 0 - CategoryText = 1 - CategorySimple = 2 - CategoryComplex = 3 - # Constants for content_type: - TypeNone = 0 - TypeText = 1 - TypeString = 2 - TypeInteger = 3 - TypeFloat = 4 - TypeDecimal = 5 - TypeDouble = 6 - TypeBoolean = 7 - TypeBase64 = 8 - - def __init__(self, category, content_type, name, value): - self.category = category - self.content_type = content_type - self.name = name - self.value = value - - def getCategory(self): - return self.category - - def getContenttype(self, content_type): - return self.content_type - - def getValue(self): - return self.value - - def getName(self): - return self.name - - def export(self, outfile, level, name, namespace, pretty_print=True): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - outfile.write(self.value) - elif self.category == MixedContainer.CategorySimple: - self.exportSimple(outfile, level, name) - else: # category == MixedContainer.CategoryComplex - self.value.export( - outfile, level, namespace, name_=name, pretty_print=pretty_print - ) - - def exportSimple(self, outfile, level, name): - if self.content_type == MixedContainer.TypeString: - outfile.write("<%s>%s" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - outfile.write("<%s>%d" % (self.name, self.value, self.name)) - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - outfile.write("<%s>%f" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeDouble: - outfile.write("<%s>%g" % (self.name, self.value, self.name)) - elif self.content_type == MixedContainer.TypeBase64: - outfile.write( - "<%s>%s" % (self.name, base64.b64encode(self.value), self.name) - ) - - def to_etree(self, element, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.category == MixedContainer.CategoryText: - # Prevent exporting empty content as empty lines. - if self.value.strip(): - if len(element) > 0: - if element[-1].tail is None: - element[-1].tail = self.value - else: - element[-1].tail += self.value - else: - if element.text is None: - element.text = self.value - else: - element.text += self.value - elif self.category == MixedContainer.CategorySimple: - subelement = etree_.SubElement(element, "%s" % self.name) - subelement.text = self.to_etree_simple() - else: # category == MixedContainer.CategoryComplex - self.value.to_etree(element) - - def to_etree_simple(self, mapping_=None, reverse_mapping_=None, nsmap_=None): - if self.content_type == MixedContainer.TypeString: - text = self.value - elif ( - self.content_type == MixedContainer.TypeInteger - or self.content_type == MixedContainer.TypeBoolean - ): - text = "%d" % self.value - elif ( - self.content_type == MixedContainer.TypeFloat - or self.content_type == MixedContainer.TypeDecimal - ): - text = "%f" % self.value - elif self.content_type == MixedContainer.TypeDouble: - text = "%g" % self.value - elif self.content_type == MixedContainer.TypeBase64: - text = "%s" % base64.b64encode(self.value) - return text - - def exportLiteral(self, outfile, level, name): - if self.category == MixedContainer.CategoryText: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - elif self.category == MixedContainer.CategorySimple: - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s", "%s"),\n' - % (self.category, self.content_type, self.name, self.value) - ) - else: # category == MixedContainer.CategoryComplex - showIndent(outfile, level) - outfile.write( - 'model_.MixedContainer(%d, %d, "%s",\n' - % ( - self.category, - self.content_type, - self.name, - ) - ) - self.value.exportLiteral(outfile, level + 1) - showIndent(outfile, level) - outfile.write(")\n") - - -class MemberSpec_(object): - def __init__( - self, - name="", - data_type="", - container=0, - optional=0, - child_attrs=None, - choice=None, - ): - self.name = name - self.data_type = data_type - self.container = container - self.child_attrs = child_attrs - self.choice = choice - self.optional = optional - - def set_name(self, name): - self.name = name - - def get_name(self): - return self.name - - def set_data_type(self, data_type): - self.data_type = data_type - - def get_data_type_chain(self): - return self.data_type - - def get_data_type(self): - if isinstance(self.data_type, list): - if len(self.data_type) > 0: - return self.data_type[-1] - else: - return "xs:string" - else: - return self.data_type - - def set_container(self, container): - self.container = container - - def get_container(self): - return self.container - - def set_child_attrs(self, child_attrs): - self.child_attrs = child_attrs - - def get_child_attrs(self): - return self.child_attrs - - def set_choice(self, choice): - self.choice = choice - - def get_choice(self): - return self.choice - - def set_optional(self, optional): - self.optional = optional - - def get_optional(self): - return self.optional - - -def _cast(typ, value): - if typ is None or value is None: - return value - return typ(value) - - -# -# Data representation classes. -# - - -class Freightcom(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - username=None, - password=None, - version=None, - ShippingRequest=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.username = _cast(None, username) - self.username_nsprefix_ = None - self.password = _cast(None, password) - self.password_nsprefix_ = None - self.version = _cast(None, version) - self.version_nsprefix_ = None - self.ShippingRequest = ShippingRequest - self.ShippingRequest_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, Freightcom) - if subclass is not None: - return subclass(*args_, **kwargs_) - if Freightcom.subclass: - return Freightcom.subclass(*args_, **kwargs_) - else: - return Freightcom(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_ShippingRequest(self): - return self.ShippingRequest - - def set_ShippingRequest(self, ShippingRequest): - self.ShippingRequest = ShippingRequest - - def get_username(self): - return self.username - - def set_username(self, username): - self.username = username - - def get_password(self): - return self.password - - def set_password(self, password): - self.password = password - - def get_version(self): - return self.version - - def set_version(self, version): - self.version = version - - def _hasContent(self): - if self.ShippingRequest is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("Freightcom") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "Freightcom": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="Freightcom" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="Freightcom", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="Freightcom" - ): - if self.username is not None and "username" not in already_processed: - already_processed.add("username") - outfile.write( - " username=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.username), input_name="username" - ) - ), - ) - ) - if self.password is not None and "password" not in already_processed: - already_processed.add("password") - outfile.write( - " password=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.password), input_name="password" - ) - ), - ) - ) - if self.version is not None and "version" not in already_processed: - already_processed.add("version") - outfile.write( - " version=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.version), input_name="version" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="Freightcom", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.ShippingRequest is not None: - namespaceprefix_ = ( - self.ShippingRequest_nsprefix_ + ":" - if (UseCapturedNS_ and self.ShippingRequest_nsprefix_) - else "" - ) - self.ShippingRequest.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="ShippingRequest", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("username", node) - if value is not None and "username" not in already_processed: - already_processed.add("username") - self.username = value - value = find_attr_value_("password", node) - if value is not None and "password" not in already_processed: - already_processed.add("password") - self.password = value - value = find_attr_value_("version", node) - if value is not None and "version" not in already_processed: - already_processed.add("version") - self.version = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "ShippingRequest": - obj_ = ShippingRequestType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.ShippingRequest = obj_ - obj_.original_tagname_ = "ShippingRequest" - - -# end class Freightcom - - -class ShippingRequestType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - saturdayPickupRequired=None, - homelandSecurity=None, - pierCharge=None, - exhibitionConventionSite=None, - militaryBaseDelivery=None, - customsIn_bondFreight=None, - limitedAccess=None, - excessLength=None, - tailgatePickup=None, - residentialPickup=None, - crossBorderFee=None, - notifyRecipient=None, - singleShipment=None, - tailgateDelivery=None, - residentialDelivery=None, - insuranceType=None, - scheduledShipDate=None, - insideDelivery=None, - isSaturdayService=None, - dangerousGoodsType=None, - serviceId=None, - stackable=None, - From=None, - To=None, - COD=None, - Packages=None, - Payment=None, - Reference=None, - CustomsInvoice=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.saturdayPickupRequired = _cast(None, saturdayPickupRequired) - self.saturdayPickupRequired_nsprefix_ = None - self.homelandSecurity = _cast(None, homelandSecurity) - self.homelandSecurity_nsprefix_ = None - self.pierCharge = _cast(None, pierCharge) - self.pierCharge_nsprefix_ = None - self.exhibitionConventionSite = _cast(None, exhibitionConventionSite) - self.exhibitionConventionSite_nsprefix_ = None - self.militaryBaseDelivery = _cast(None, militaryBaseDelivery) - self.militaryBaseDelivery_nsprefix_ = None - self.customsIn_bondFreight = _cast(None, customsIn_bondFreight) - self.customsIn_bondFreight_nsprefix_ = None - self.limitedAccess = _cast(None, limitedAccess) - self.limitedAccess_nsprefix_ = None - self.excessLength = _cast(None, excessLength) - self.excessLength_nsprefix_ = None - self.tailgatePickup = _cast(None, tailgatePickup) - self.tailgatePickup_nsprefix_ = None - self.residentialPickup = _cast(None, residentialPickup) - self.residentialPickup_nsprefix_ = None - self.crossBorderFee = _cast(None, crossBorderFee) - self.crossBorderFee_nsprefix_ = None - self.notifyRecipient = _cast(None, notifyRecipient) - self.notifyRecipient_nsprefix_ = None - self.singleShipment = _cast(None, singleShipment) - self.singleShipment_nsprefix_ = None - self.tailgateDelivery = _cast(None, tailgateDelivery) - self.tailgateDelivery_nsprefix_ = None - self.residentialDelivery = _cast(None, residentialDelivery) - self.residentialDelivery_nsprefix_ = None - self.insuranceType = _cast(None, insuranceType) - self.insuranceType_nsprefix_ = None - self.scheduledShipDate = _cast(None, scheduledShipDate) - self.scheduledShipDate_nsprefix_ = None - self.insideDelivery = _cast(None, insideDelivery) - self.insideDelivery_nsprefix_ = None - self.isSaturdayService = _cast(None, isSaturdayService) - self.isSaturdayService_nsprefix_ = None - self.dangerousGoodsType = _cast(None, dangerousGoodsType) - self.dangerousGoodsType_nsprefix_ = None - self.serviceId = _cast(int, serviceId) - self.serviceId_nsprefix_ = None - self.stackable = _cast(None, stackable) - self.stackable_nsprefix_ = None - self.From = From - self.From_nsprefix_ = None - self.To = To - self.To_nsprefix_ = None - self.COD = COD - self.COD_nsprefix_ = None - self.Packages = Packages - self.Packages_nsprefix_ = None - self.Payment = Payment - self.Payment_nsprefix_ = None - if Reference is None: - self.Reference = [] - else: - self.Reference = Reference - self.Reference_nsprefix_ = None - self.CustomsInvoice = CustomsInvoice - self.CustomsInvoice_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, ShippingRequestType - ) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ShippingRequestType.subclass: - return ShippingRequestType.subclass(*args_, **kwargs_) - else: - return ShippingRequestType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_From(self): - return self.From - - def set_From(self, From): - self.From = From - - def get_To(self): - return self.To - - def set_To(self, To): - self.To = To - - def get_COD(self): - return self.COD - - def set_COD(self, COD): - self.COD = COD - - def get_Packages(self): - return self.Packages - - def set_Packages(self, Packages): - self.Packages = Packages - - def get_Payment(self): - return self.Payment - - def set_Payment(self, Payment): - self.Payment = Payment - - def get_Reference(self): - return self.Reference - - def set_Reference(self, Reference): - self.Reference = Reference - - def add_Reference(self, value): - self.Reference.append(value) - - def insert_Reference_at(self, index, value): - self.Reference.insert(index, value) - - def replace_Reference_at(self, index, value): - self.Reference[index] = value - - def get_CustomsInvoice(self): - return self.CustomsInvoice - - def set_CustomsInvoice(self, CustomsInvoice): - self.CustomsInvoice = CustomsInvoice - - def get_saturdayPickupRequired(self): - return self.saturdayPickupRequired - - def set_saturdayPickupRequired(self, saturdayPickupRequired): - self.saturdayPickupRequired = saturdayPickupRequired - - def get_homelandSecurity(self): - return self.homelandSecurity - - def set_homelandSecurity(self, homelandSecurity): - self.homelandSecurity = homelandSecurity - - def get_pierCharge(self): - return self.pierCharge - - def set_pierCharge(self, pierCharge): - self.pierCharge = pierCharge - - def get_exhibitionConventionSite(self): - return self.exhibitionConventionSite - - def set_exhibitionConventionSite(self, exhibitionConventionSite): - self.exhibitionConventionSite = exhibitionConventionSite - - def get_militaryBaseDelivery(self): - return self.militaryBaseDelivery - - def set_militaryBaseDelivery(self, militaryBaseDelivery): - self.militaryBaseDelivery = militaryBaseDelivery - - def get_customsIn_bondFreight(self): - return self.customsIn_bondFreight - - def set_customsIn_bondFreight(self, customsIn_bondFreight): - self.customsIn_bondFreight = customsIn_bondFreight - - def get_limitedAccess(self): - return self.limitedAccess - - def set_limitedAccess(self, limitedAccess): - self.limitedAccess = limitedAccess - - def get_excessLength(self): - return self.excessLength - - def set_excessLength(self, excessLength): - self.excessLength = excessLength - - def get_tailgatePickup(self): - return self.tailgatePickup - - def set_tailgatePickup(self, tailgatePickup): - self.tailgatePickup = tailgatePickup - - def get_residentialPickup(self): - return self.residentialPickup - - def set_residentialPickup(self, residentialPickup): - self.residentialPickup = residentialPickup - - def get_crossBorderFee(self): - return self.crossBorderFee - - def set_crossBorderFee(self, crossBorderFee): - self.crossBorderFee = crossBorderFee - - def get_notifyRecipient(self): - return self.notifyRecipient - - def set_notifyRecipient(self, notifyRecipient): - self.notifyRecipient = notifyRecipient - - def get_singleShipment(self): - return self.singleShipment - - def set_singleShipment(self, singleShipment): - self.singleShipment = singleShipment - - def get_tailgateDelivery(self): - return self.tailgateDelivery - - def set_tailgateDelivery(self, tailgateDelivery): - self.tailgateDelivery = tailgateDelivery - - def get_residentialDelivery(self): - return self.residentialDelivery - - def set_residentialDelivery(self, residentialDelivery): - self.residentialDelivery = residentialDelivery - - def get_insuranceType(self): - return self.insuranceType - - def set_insuranceType(self, insuranceType): - self.insuranceType = insuranceType - - def get_scheduledShipDate(self): - return self.scheduledShipDate - - def set_scheduledShipDate(self, scheduledShipDate): - self.scheduledShipDate = scheduledShipDate - - def get_insideDelivery(self): - return self.insideDelivery - - def set_insideDelivery(self, insideDelivery): - self.insideDelivery = insideDelivery - - def get_isSaturdayService(self): - return self.isSaturdayService - - def set_isSaturdayService(self, isSaturdayService): - self.isSaturdayService = isSaturdayService - - def get_dangerousGoodsType(self): - return self.dangerousGoodsType - - def set_dangerousGoodsType(self, dangerousGoodsType): - self.dangerousGoodsType = dangerousGoodsType - - def get_serviceId(self): - return self.serviceId - - def set_serviceId(self, serviceId): - self.serviceId = serviceId - - def get_stackable(self): - return self.stackable - - def set_stackable(self, stackable): - self.stackable = stackable - - def _hasContent(self): - if ( - self.From is not None - or self.To is not None - or self.COD is not None - or self.Packages is not None - or self.Payment is not None - or self.Reference - or self.CustomsInvoice is not None - ): - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ShippingRequestType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ShippingRequestType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ShippingRequestType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="ShippingRequestType", - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ShippingRequestType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="ShippingRequestType", - ): - if ( - self.saturdayPickupRequired is not None - and "saturdayPickupRequired" not in already_processed - ): - already_processed.add("saturdayPickupRequired") - outfile.write( - " saturdayPickupRequired=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.saturdayPickupRequired), - input_name="saturdayPickupRequired", - ) - ), - ) - ) - if ( - self.homelandSecurity is not None - and "homelandSecurity" not in already_processed - ): - already_processed.add("homelandSecurity") - outfile.write( - " homelandSecurity=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.homelandSecurity), - input_name="homelandSecurity", - ) - ), - ) - ) - if self.pierCharge is not None and "pierCharge" not in already_processed: - already_processed.add("pierCharge") - outfile.write( - " pierCharge=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.pierCharge), input_name="pierCharge" - ) - ), - ) - ) - if ( - self.exhibitionConventionSite is not None - and "exhibitionConventionSite" not in already_processed - ): - already_processed.add("exhibitionConventionSite") - outfile.write( - " exhibitionConventionSite=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.exhibitionConventionSite), - input_name="exhibitionConventionSite", - ) - ), - ) - ) - if ( - self.militaryBaseDelivery is not None - and "militaryBaseDelivery" not in already_processed - ): - already_processed.add("militaryBaseDelivery") - outfile.write( - " militaryBaseDelivery=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.militaryBaseDelivery), - input_name="militaryBaseDelivery", - ) - ), - ) - ) - if ( - self.customsIn_bondFreight is not None - and "customsIn_bondFreight" not in already_processed - ): - already_processed.add("customsIn_bondFreight") - outfile.write( - " customsIn-bondFreight=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.customsIn_bondFreight), - input_name="customsIn-bondFreight", - ) - ), - ) - ) - if self.limitedAccess is not None and "limitedAccess" not in already_processed: - already_processed.add("limitedAccess") - outfile.write( - " limitedAccess=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.limitedAccess), input_name="limitedAccess" - ) - ), - ) - ) - if self.excessLength is not None and "excessLength" not in already_processed: - already_processed.add("excessLength") - outfile.write( - " excessLength=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.excessLength), input_name="excessLength" - ) - ), - ) - ) - if ( - self.tailgatePickup is not None - and "tailgatePickup" not in already_processed - ): - already_processed.add("tailgatePickup") - outfile.write( - " tailgatePickup=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.tailgatePickup), - input_name="tailgatePickup", - ) - ), - ) - ) - if ( - self.residentialPickup is not None - and "residentialPickup" not in already_processed - ): - already_processed.add("residentialPickup") - outfile.write( - " residentialPickup=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.residentialPickup), - input_name="residentialPickup", - ) - ), - ) - ) - if ( - self.crossBorderFee is not None - and "crossBorderFee" not in already_processed - ): - already_processed.add("crossBorderFee") - outfile.write( - " crossBorderFee=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.crossBorderFee), - input_name="crossBorderFee", - ) - ), - ) - ) - if ( - self.notifyRecipient is not None - and "notifyRecipient" not in already_processed - ): - already_processed.add("notifyRecipient") - outfile.write( - " notifyRecipient=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.notifyRecipient), - input_name="notifyRecipient", - ) - ), - ) - ) - if ( - self.singleShipment is not None - and "singleShipment" not in already_processed - ): - already_processed.add("singleShipment") - outfile.write( - " singleShipment=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.singleShipment), - input_name="singleShipment", - ) - ), - ) - ) - if ( - self.tailgateDelivery is not None - and "tailgateDelivery" not in already_processed - ): - already_processed.add("tailgateDelivery") - outfile.write( - " tailgateDelivery=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.tailgateDelivery), - input_name="tailgateDelivery", - ) - ), - ) - ) - if ( - self.residentialDelivery is not None - and "residentialDelivery" not in already_processed - ): - already_processed.add("residentialDelivery") - outfile.write( - " residentialDelivery=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.residentialDelivery), - input_name="residentialDelivery", - ) - ), - ) - ) - if self.insuranceType is not None and "insuranceType" not in already_processed: - already_processed.add("insuranceType") - outfile.write( - " insuranceType=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.insuranceType), input_name="insuranceType" - ) - ), - ) - ) - if ( - self.scheduledShipDate is not None - and "scheduledShipDate" not in already_processed - ): - already_processed.add("scheduledShipDate") - outfile.write( - " scheduledShipDate=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.scheduledShipDate), - input_name="scheduledShipDate", - ) - ), - ) - ) - if ( - self.insideDelivery is not None - and "insideDelivery" not in already_processed - ): - already_processed.add("insideDelivery") - outfile.write( - " insideDelivery=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.insideDelivery), - input_name="insideDelivery", - ) - ), - ) - ) - if ( - self.isSaturdayService is not None - and "isSaturdayService" not in already_processed - ): - already_processed.add("isSaturdayService") - outfile.write( - " isSaturdayService=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.isSaturdayService), - input_name="isSaturdayService", - ) - ), - ) - ) - if ( - self.dangerousGoodsType is not None - and "dangerousGoodsType" not in already_processed - ): - already_processed.add("dangerousGoodsType") - outfile.write( - " dangerousGoodsType=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.dangerousGoodsType), - input_name="dangerousGoodsType", - ) - ), - ) - ) - if self.serviceId is not None and "serviceId" not in already_processed: - already_processed.add("serviceId") - outfile.write( - ' serviceId="%s"' - % self.gds_format_integer(self.serviceId, input_name="serviceId") - ) - if self.stackable is not None and "stackable" not in already_processed: - already_processed.add("stackable") - outfile.write( - " stackable=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.stackable), input_name="stackable" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ShippingRequestType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.From is not None: - namespaceprefix_ = ( - self.From_nsprefix_ + ":" - if (UseCapturedNS_ and self.From_nsprefix_) - else "" - ) - self.From.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="From", - pretty_print=pretty_print, - ) - if self.To is not None: - namespaceprefix_ = ( - self.To_nsprefix_ + ":" - if (UseCapturedNS_ and self.To_nsprefix_) - else "" - ) - self.To.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="To", - pretty_print=pretty_print, - ) - if self.COD is not None: - namespaceprefix_ = ( - self.COD_nsprefix_ + ":" - if (UseCapturedNS_ and self.COD_nsprefix_) - else "" - ) - self.COD.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="COD", - pretty_print=pretty_print, - ) - if self.Packages is not None: - namespaceprefix_ = ( - self.Packages_nsprefix_ + ":" - if (UseCapturedNS_ and self.Packages_nsprefix_) - else "" - ) - self.Packages.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Packages", - pretty_print=pretty_print, - ) - if self.Payment is not None: - namespaceprefix_ = ( - self.Payment_nsprefix_ + ":" - if (UseCapturedNS_ and self.Payment_nsprefix_) - else "" - ) - self.Payment.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Payment", - pretty_print=pretty_print, - ) - for Reference_ in self.Reference: - namespaceprefix_ = ( - self.Reference_nsprefix_ + ":" - if (UseCapturedNS_ and self.Reference_nsprefix_) - else "" - ) - Reference_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Reference", - pretty_print=pretty_print, - ) - if self.CustomsInvoice is not None: - namespaceprefix_ = ( - self.CustomsInvoice_nsprefix_ + ":" - if (UseCapturedNS_ and self.CustomsInvoice_nsprefix_) - else "" - ) - self.CustomsInvoice.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="CustomsInvoice", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("saturdayPickupRequired", node) - if value is not None and "saturdayPickupRequired" not in already_processed: - already_processed.add("saturdayPickupRequired") - self.saturdayPickupRequired = value - value = find_attr_value_("homelandSecurity", node) - if value is not None and "homelandSecurity" not in already_processed: - already_processed.add("homelandSecurity") - self.homelandSecurity = value - value = find_attr_value_("pierCharge", node) - if value is not None and "pierCharge" not in already_processed: - already_processed.add("pierCharge") - self.pierCharge = value - value = find_attr_value_("exhibitionConventionSite", node) - if value is not None and "exhibitionConventionSite" not in already_processed: - already_processed.add("exhibitionConventionSite") - self.exhibitionConventionSite = value - value = find_attr_value_("militaryBaseDelivery", node) - if value is not None and "militaryBaseDelivery" not in already_processed: - already_processed.add("militaryBaseDelivery") - self.militaryBaseDelivery = value - value = find_attr_value_("customsIn-bondFreight", node) - if value is not None and "customsIn-bondFreight" not in already_processed: - already_processed.add("customsIn-bondFreight") - self.customsIn_bondFreight = value - value = find_attr_value_("limitedAccess", node) - if value is not None and "limitedAccess" not in already_processed: - already_processed.add("limitedAccess") - self.limitedAccess = value - value = find_attr_value_("excessLength", node) - if value is not None and "excessLength" not in already_processed: - already_processed.add("excessLength") - self.excessLength = value - value = find_attr_value_("tailgatePickup", node) - if value is not None and "tailgatePickup" not in already_processed: - already_processed.add("tailgatePickup") - self.tailgatePickup = value - value = find_attr_value_("residentialPickup", node) - if value is not None and "residentialPickup" not in already_processed: - already_processed.add("residentialPickup") - self.residentialPickup = value - value = find_attr_value_("crossBorderFee", node) - if value is not None and "crossBorderFee" not in already_processed: - already_processed.add("crossBorderFee") - self.crossBorderFee = value - value = find_attr_value_("notifyRecipient", node) - if value is not None and "notifyRecipient" not in already_processed: - already_processed.add("notifyRecipient") - self.notifyRecipient = value - value = find_attr_value_("singleShipment", node) - if value is not None and "singleShipment" not in already_processed: - already_processed.add("singleShipment") - self.singleShipment = value - value = find_attr_value_("tailgateDelivery", node) - if value is not None and "tailgateDelivery" not in already_processed: - already_processed.add("tailgateDelivery") - self.tailgateDelivery = value - value = find_attr_value_("residentialDelivery", node) - if value is not None and "residentialDelivery" not in already_processed: - already_processed.add("residentialDelivery") - self.residentialDelivery = value - value = find_attr_value_("insuranceType", node) - if value is not None and "insuranceType" not in already_processed: - already_processed.add("insuranceType") - self.insuranceType = value - value = find_attr_value_("scheduledShipDate", node) - if value is not None and "scheduledShipDate" not in already_processed: - already_processed.add("scheduledShipDate") - self.scheduledShipDate = value - value = find_attr_value_("insideDelivery", node) - if value is not None and "insideDelivery" not in already_processed: - already_processed.add("insideDelivery") - self.insideDelivery = value - value = find_attr_value_("isSaturdayService", node) - if value is not None and "isSaturdayService" not in already_processed: - already_processed.add("isSaturdayService") - self.isSaturdayService = value - value = find_attr_value_("dangerousGoodsType", node) - if value is not None and "dangerousGoodsType" not in already_processed: - already_processed.add("dangerousGoodsType") - self.dangerousGoodsType = value - value = find_attr_value_("serviceId", node) - if value is not None and "serviceId" not in already_processed: - already_processed.add("serviceId") - self.serviceId = self.gds_parse_integer(value, node, "serviceId") - value = find_attr_value_("stackable", node) - if value is not None and "stackable" not in already_processed: - already_processed.add("stackable") - self.stackable = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "From": - obj_ = FromType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.From = obj_ - obj_.original_tagname_ = "From" - elif nodeName_ == "To": - obj_ = ToType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.To = obj_ - obj_.original_tagname_ = "To" - elif nodeName_ == "COD": - obj_ = CODType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.COD = obj_ - obj_.original_tagname_ = "COD" - elif nodeName_ == "Packages": - obj_ = PackagesType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Packages = obj_ - obj_.original_tagname_ = "Packages" - elif nodeName_ == "Payment": - obj_ = PaymentType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Payment = obj_ - obj_.original_tagname_ = "Payment" - elif nodeName_ == "Reference": - obj_ = ReferenceType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Reference.append(obj_) - obj_.original_tagname_ = "Reference" - elif nodeName_ == "CustomsInvoice": - obj_ = CustomsInvoiceType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.CustomsInvoice = obj_ - obj_.original_tagname_ = "CustomsInvoice" - - -# end class ShippingRequestType - - -class FromType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - id=None, - company=None, - instructions=None, - email=None, - attention=None, - phone=None, - tailgateRequired=None, - residential=None, - address1=None, - address2=None, - city=None, - state=None, - country=None, - zip=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.id = _cast(None, id) - self.id_nsprefix_ = None - self.company = _cast(None, company) - self.company_nsprefix_ = None - self.instructions = _cast(None, instructions) - self.instructions_nsprefix_ = None - self.email = _cast(None, email) - self.email_nsprefix_ = None - self.attention = _cast(None, attention) - self.attention_nsprefix_ = None - self.phone = _cast(None, phone) - self.phone_nsprefix_ = None - self.tailgateRequired = _cast(None, tailgateRequired) - self.tailgateRequired_nsprefix_ = None - self.residential = _cast(None, residential) - self.residential_nsprefix_ = None - self.address1 = _cast(None, address1) - self.address1_nsprefix_ = None - self.address2 = _cast(None, address2) - self.address2_nsprefix_ = None - self.city = _cast(None, city) - self.city_nsprefix_ = None - self.state = _cast(None, state) - self.state_nsprefix_ = None - self.country = _cast(None, country) - self.country_nsprefix_ = None - self.zip = _cast(None, zip) - self.zip_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, FromType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if FromType.subclass: - return FromType.subclass(*args_, **kwargs_) - else: - return FromType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_id(self): - return self.id - - def set_id(self, id): - self.id = id - - def get_company(self): - return self.company - - def set_company(self, company): - self.company = company - - def get_instructions(self): - return self.instructions - - def set_instructions(self, instructions): - self.instructions = instructions - - def get_email(self): - return self.email - - def set_email(self, email): - self.email = email - - def get_attention(self): - return self.attention - - def set_attention(self, attention): - self.attention = attention - - def get_phone(self): - return self.phone - - def set_phone(self, phone): - self.phone = phone - - def get_tailgateRequired(self): - return self.tailgateRequired - - def set_tailgateRequired(self, tailgateRequired): - self.tailgateRequired = tailgateRequired - - def get_residential(self): - return self.residential - - def set_residential(self, residential): - self.residential = residential - - def get_address1(self): - return self.address1 - - def set_address1(self, address1): - self.address1 = address1 - - def get_address2(self): - return self.address2 - - def set_address2(self, address2): - self.address2 = address2 - - def get_city(self): - return self.city - - def set_city(self, city): - self.city = city - - def get_state(self): - return self.state - - def set_state(self, state): - self.state = state - - def get_country(self): - return self.country - - def set_country(self, country): - self.country = country - - def get_zip(self): - return self.zip - - def set_zip(self, zip): - self.zip = zip - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="FromType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("FromType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "FromType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="FromType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="FromType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="FromType" - ): - if self.id is not None and "id" not in already_processed: - already_processed.add("id") - outfile.write( - " id=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.id), input_name="id") - ), - ) - ) - if self.company is not None and "company" not in already_processed: - already_processed.add("company") - outfile.write( - " company=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.company), input_name="company" - ) - ), - ) - ) - if self.instructions is not None and "instructions" not in already_processed: - already_processed.add("instructions") - outfile.write( - " instructions=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.instructions), input_name="instructions" - ) - ), - ) - ) - if self.email is not None and "email" not in already_processed: - already_processed.add("email") - outfile.write( - " email=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.email), input_name="email" - ) - ), - ) - ) - if self.attention is not None and "attention" not in already_processed: - already_processed.add("attention") - outfile.write( - " attention=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.attention), input_name="attention" - ) - ), - ) - ) - if self.phone is not None and "phone" not in already_processed: - already_processed.add("phone") - outfile.write( - " phone=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.phone), input_name="phone" - ) - ), - ) - ) - if ( - self.tailgateRequired is not None - and "tailgateRequired" not in already_processed - ): - already_processed.add("tailgateRequired") - outfile.write( - " tailgateRequired=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.tailgateRequired), - input_name="tailgateRequired", - ) - ), - ) - ) - if self.residential is not None and "residential" not in already_processed: - already_processed.add("residential") - outfile.write( - " residential=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.residential), input_name="residential" - ) - ), - ) - ) - if self.address1 is not None and "address1" not in already_processed: - already_processed.add("address1") - outfile.write( - " address1=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address1), input_name="address1" - ) - ), - ) - ) - if self.address2 is not None and "address2" not in already_processed: - already_processed.add("address2") - outfile.write( - " address2=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address2), input_name="address2" - ) - ), - ) - ) - if self.city is not None and "city" not in already_processed: - already_processed.add("city") - outfile.write( - " city=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.city), input_name="city" - ) - ), - ) - ) - if self.state is not None and "state" not in already_processed: - already_processed.add("state") - outfile.write( - " state=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.state), input_name="state" - ) - ), - ) - ) - if self.country is not None and "country" not in already_processed: - already_processed.add("country") - outfile.write( - " country=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.country), input_name="country" - ) - ), - ) - ) - if self.zip is not None and "zip" not in already_processed: - already_processed.add("zip") - outfile.write( - " zip=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.zip), input_name="zip") - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="FromType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("id", node) - if value is not None and "id" not in already_processed: - already_processed.add("id") - self.id = value - value = find_attr_value_("company", node) - if value is not None and "company" not in already_processed: - already_processed.add("company") - self.company = value - value = find_attr_value_("instructions", node) - if value is not None and "instructions" not in already_processed: - already_processed.add("instructions") - self.instructions = value - value = find_attr_value_("email", node) - if value is not None and "email" not in already_processed: - already_processed.add("email") - self.email = value - value = find_attr_value_("attention", node) - if value is not None and "attention" not in already_processed: - already_processed.add("attention") - self.attention = value - value = find_attr_value_("phone", node) - if value is not None and "phone" not in already_processed: - already_processed.add("phone") - self.phone = value - value = find_attr_value_("tailgateRequired", node) - if value is not None and "tailgateRequired" not in already_processed: - already_processed.add("tailgateRequired") - self.tailgateRequired = value - value = find_attr_value_("residential", node) - if value is not None and "residential" not in already_processed: - already_processed.add("residential") - self.residential = value - value = find_attr_value_("address1", node) - if value is not None and "address1" not in already_processed: - already_processed.add("address1") - self.address1 = value - value = find_attr_value_("address2", node) - if value is not None and "address2" not in already_processed: - already_processed.add("address2") - self.address2 = value - value = find_attr_value_("city", node) - if value is not None and "city" not in already_processed: - already_processed.add("city") - self.city = value - value = find_attr_value_("state", node) - if value is not None and "state" not in already_processed: - already_processed.add("state") - self.state = value - value = find_attr_value_("country", node) - if value is not None and "country" not in already_processed: - already_processed.add("country") - self.country = value - value = find_attr_value_("zip", node) - if value is not None and "zip" not in already_processed: - already_processed.add("zip") - self.zip = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class FromType - - -class ToType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - id=None, - company=None, - notifyRecipient=None, - instructions=None, - email=None, - attention=None, - phone=None, - tailgateRequired=None, - residential=None, - address1=None, - address2=None, - city=None, - state=None, - zip=None, - country=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.id = _cast(None, id) - self.id_nsprefix_ = None - self.company = _cast(None, company) - self.company_nsprefix_ = None - self.notifyRecipient = _cast(None, notifyRecipient) - self.notifyRecipient_nsprefix_ = None - self.instructions = _cast(None, instructions) - self.instructions_nsprefix_ = None - self.email = _cast(None, email) - self.email_nsprefix_ = None - self.attention = _cast(None, attention) - self.attention_nsprefix_ = None - self.phone = _cast(None, phone) - self.phone_nsprefix_ = None - self.tailgateRequired = _cast(None, tailgateRequired) - self.tailgateRequired_nsprefix_ = None - self.residential = _cast(None, residential) - self.residential_nsprefix_ = None - self.address1 = _cast(None, address1) - self.address1_nsprefix_ = None - self.address2 = _cast(None, address2) - self.address2_nsprefix_ = None - self.city = _cast(None, city) - self.city_nsprefix_ = None - self.state = _cast(None, state) - self.state_nsprefix_ = None - self.zip = _cast(None, zip) - self.zip_nsprefix_ = None - self.country = _cast(None, country) - self.country_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ToType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ToType.subclass: - return ToType.subclass(*args_, **kwargs_) - else: - return ToType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_id(self): - return self.id - - def set_id(self, id): - self.id = id - - def get_company(self): - return self.company - - def set_company(self, company): - self.company = company - - def get_notifyRecipient(self): - return self.notifyRecipient - - def set_notifyRecipient(self, notifyRecipient): - self.notifyRecipient = notifyRecipient - - def get_instructions(self): - return self.instructions - - def set_instructions(self, instructions): - self.instructions = instructions - - def get_email(self): - return self.email - - def set_email(self, email): - self.email = email - - def get_attention(self): - return self.attention - - def set_attention(self, attention): - self.attention = attention - - def get_phone(self): - return self.phone - - def set_phone(self, phone): - self.phone = phone - - def get_tailgateRequired(self): - return self.tailgateRequired - - def set_tailgateRequired(self, tailgateRequired): - self.tailgateRequired = tailgateRequired - - def get_residential(self): - return self.residential - - def set_residential(self, residential): - self.residential = residential - - def get_address1(self): - return self.address1 - - def set_address1(self, address1): - self.address1 = address1 - - def get_address2(self): - return self.address2 - - def set_address2(self, address2): - self.address2 = address2 - - def get_city(self): - return self.city - - def set_city(self, city): - self.city = city - - def get_state(self): - return self.state - - def set_state(self, state): - self.state = state - - def get_zip(self): - return self.zip - - def set_zip(self, zip): - self.zip = zip - - def get_country(self): - return self.country - - def set_country(self, country): - self.country = country - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ToType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ToType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ToType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="ToType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ToType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="ToType" - ): - if self.id is not None and "id" not in already_processed: - already_processed.add("id") - outfile.write( - " id=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.id), input_name="id") - ), - ) - ) - if self.company is not None and "company" not in already_processed: - already_processed.add("company") - outfile.write( - " company=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.company), input_name="company" - ) - ), - ) - ) - if ( - self.notifyRecipient is not None - and "notifyRecipient" not in already_processed - ): - already_processed.add("notifyRecipient") - outfile.write( - " notifyRecipient=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.notifyRecipient), - input_name="notifyRecipient", - ) - ), - ) - ) - if self.instructions is not None and "instructions" not in already_processed: - already_processed.add("instructions") - outfile.write( - " instructions=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.instructions), input_name="instructions" - ) - ), - ) - ) - if self.email is not None and "email" not in already_processed: - already_processed.add("email") - outfile.write( - " email=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.email), input_name="email" - ) - ), - ) - ) - if self.attention is not None and "attention" not in already_processed: - already_processed.add("attention") - outfile.write( - " attention=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.attention), input_name="attention" - ) - ), - ) - ) - if self.phone is not None and "phone" not in already_processed: - already_processed.add("phone") - outfile.write( - " phone=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.phone), input_name="phone" - ) - ), - ) - ) - if ( - self.tailgateRequired is not None - and "tailgateRequired" not in already_processed - ): - already_processed.add("tailgateRequired") - outfile.write( - " tailgateRequired=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.tailgateRequired), - input_name="tailgateRequired", - ) - ), - ) - ) - if self.residential is not None and "residential" not in already_processed: - already_processed.add("residential") - outfile.write( - " residential=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.residential), input_name="residential" - ) - ), - ) - ) - if self.address1 is not None and "address1" not in already_processed: - already_processed.add("address1") - outfile.write( - " address1=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address1), input_name="address1" - ) - ), - ) - ) - if self.address2 is not None and "address2" not in already_processed: - already_processed.add("address2") - outfile.write( - " address2=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address2), input_name="address2" - ) - ), - ) - ) - if self.city is not None and "city" not in already_processed: - already_processed.add("city") - outfile.write( - " city=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.city), input_name="city" - ) - ), - ) - ) - if self.state is not None and "state" not in already_processed: - already_processed.add("state") - outfile.write( - " state=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.state), input_name="state" - ) - ), - ) - ) - if self.zip is not None and "zip" not in already_processed: - already_processed.add("zip") - outfile.write( - " zip=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.zip), input_name="zip") - ), - ) - ) - if self.country is not None and "country" not in already_processed: - already_processed.add("country") - outfile.write( - " country=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.country), input_name="country" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ToType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("id", node) - if value is not None and "id" not in already_processed: - already_processed.add("id") - self.id = value - value = find_attr_value_("company", node) - if value is not None and "company" not in already_processed: - already_processed.add("company") - self.company = value - value = find_attr_value_("notifyRecipient", node) - if value is not None and "notifyRecipient" not in already_processed: - already_processed.add("notifyRecipient") - self.notifyRecipient = value - value = find_attr_value_("instructions", node) - if value is not None and "instructions" not in already_processed: - already_processed.add("instructions") - self.instructions = value - value = find_attr_value_("email", node) - if value is not None and "email" not in already_processed: - already_processed.add("email") - self.email = value - value = find_attr_value_("attention", node) - if value is not None and "attention" not in already_processed: - already_processed.add("attention") - self.attention = value - value = find_attr_value_("phone", node) - if value is not None and "phone" not in already_processed: - already_processed.add("phone") - self.phone = value - value = find_attr_value_("tailgateRequired", node) - if value is not None and "tailgateRequired" not in already_processed: - already_processed.add("tailgateRequired") - self.tailgateRequired = value - value = find_attr_value_("residential", node) - if value is not None and "residential" not in already_processed: - already_processed.add("residential") - self.residential = value - value = find_attr_value_("address1", node) - if value is not None and "address1" not in already_processed: - already_processed.add("address1") - self.address1 = value - value = find_attr_value_("address2", node) - if value is not None and "address2" not in already_processed: - already_processed.add("address2") - self.address2 = value - value = find_attr_value_("city", node) - if value is not None and "city" not in already_processed: - already_processed.add("city") - self.city = value - value = find_attr_value_("state", node) - if value is not None and "state" not in already_processed: - already_processed.add("state") - self.state = value - value = find_attr_value_("zip", node) - if value is not None and "zip" not in already_processed: - already_processed.add("zip") - self.zip = value - value = find_attr_value_("country", node) - if value is not None and "country" not in already_processed: - already_processed.add("country") - self.country = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class ToType - - -class CODType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, paymentType=None, CODReturnAddress=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.paymentType = _cast(None, paymentType) - self.paymentType_nsprefix_ = None - self.CODReturnAddress = CODReturnAddress - self.CODReturnAddress_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, CODType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if CODType.subclass: - return CODType.subclass(*args_, **kwargs_) - else: - return CODType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_CODReturnAddress(self): - return self.CODReturnAddress - - def set_CODReturnAddress(self, CODReturnAddress): - self.CODReturnAddress = CODReturnAddress - - def get_paymentType(self): - return self.paymentType - - def set_paymentType(self, paymentType): - self.paymentType = paymentType - - def _hasContent(self): - if self.CODReturnAddress is not None: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CODType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("CODType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "CODType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="CODType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="CODType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="CODType" - ): - if self.paymentType is not None and "paymentType" not in already_processed: - already_processed.add("paymentType") - outfile.write( - " paymentType=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.paymentType), input_name="paymentType" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CODType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.CODReturnAddress is not None: - namespaceprefix_ = ( - self.CODReturnAddress_nsprefix_ + ":" - if (UseCapturedNS_ and self.CODReturnAddress_nsprefix_) - else "" - ) - self.CODReturnAddress.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="CODReturnAddress", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("paymentType", node) - if value is not None and "paymentType" not in already_processed: - already_processed.add("paymentType") - self.paymentType = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "CODReturnAddress": - obj_ = CODReturnAddressType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.CODReturnAddress = obj_ - obj_.original_tagname_ = "CODReturnAddress" - - -# end class CODType - - -class CODReturnAddressType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - codCompany=None, - codName=None, - codAddress1=None, - codCity=None, - codStateCode=None, - codZip=None, - codCountry=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.codCompany = _cast(None, codCompany) - self.codCompany_nsprefix_ = None - self.codName = _cast(None, codName) - self.codName_nsprefix_ = None - self.codAddress1 = _cast(None, codAddress1) - self.codAddress1_nsprefix_ = None - self.codCity = _cast(None, codCity) - self.codCity_nsprefix_ = None - self.codStateCode = _cast(None, codStateCode) - self.codStateCode_nsprefix_ = None - self.codZip = _cast(None, codZip) - self.codZip_nsprefix_ = None - self.codCountry = _cast(None, codCountry) - self.codCountry_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, CODReturnAddressType - ) - if subclass is not None: - return subclass(*args_, **kwargs_) - if CODReturnAddressType.subclass: - return CODReturnAddressType.subclass(*args_, **kwargs_) - else: - return CODReturnAddressType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_codCompany(self): - return self.codCompany - - def set_codCompany(self, codCompany): - self.codCompany = codCompany - - def get_codName(self): - return self.codName - - def set_codName(self, codName): - self.codName = codName - - def get_codAddress1(self): - return self.codAddress1 - - def set_codAddress1(self, codAddress1): - self.codAddress1 = codAddress1 - - def get_codCity(self): - return self.codCity - - def set_codCity(self, codCity): - self.codCity = codCity - - def get_codStateCode(self): - return self.codStateCode - - def set_codStateCode(self, codStateCode): - self.codStateCode = codStateCode - - def get_codZip(self): - return self.codZip - - def set_codZip(self, codZip): - self.codZip = codZip - - def get_codCountry(self): - return self.codCountry - - def set_codCountry(self, codCountry): - self.codCountry = codCountry - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CODReturnAddressType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("CODReturnAddressType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "CODReturnAddressType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="CODReturnAddressType", - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="CODReturnAddressType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="CODReturnAddressType", - ): - if self.codCompany is not None and "codCompany" not in already_processed: - already_processed.add("codCompany") - outfile.write( - " codCompany=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codCompany), input_name="codCompany" - ) - ), - ) - ) - if self.codName is not None and "codName" not in already_processed: - already_processed.add("codName") - outfile.write( - " codName=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codName), input_name="codName" - ) - ), - ) - ) - if self.codAddress1 is not None and "codAddress1" not in already_processed: - already_processed.add("codAddress1") - outfile.write( - " codAddress1=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codAddress1), input_name="codAddress1" - ) - ), - ) - ) - if self.codCity is not None and "codCity" not in already_processed: - already_processed.add("codCity") - outfile.write( - " codCity=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codCity), input_name="codCity" - ) - ), - ) - ) - if self.codStateCode is not None and "codStateCode" not in already_processed: - already_processed.add("codStateCode") - outfile.write( - " codStateCode=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codStateCode), input_name="codStateCode" - ) - ), - ) - ) - if self.codZip is not None and "codZip" not in already_processed: - already_processed.add("codZip") - outfile.write( - " codZip=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codZip), input_name="codZip" - ) - ), - ) - ) - if self.codCountry is not None and "codCountry" not in already_processed: - already_processed.add("codCountry") - outfile.write( - " codCountry=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.codCountry), input_name="codCountry" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CODReturnAddressType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("codCompany", node) - if value is not None and "codCompany" not in already_processed: - already_processed.add("codCompany") - self.codCompany = value - value = find_attr_value_("codName", node) - if value is not None and "codName" not in already_processed: - already_processed.add("codName") - self.codName = value - value = find_attr_value_("codAddress1", node) - if value is not None and "codAddress1" not in already_processed: - already_processed.add("codAddress1") - self.codAddress1 = value - value = find_attr_value_("codCity", node) - if value is not None and "codCity" not in already_processed: - already_processed.add("codCity") - self.codCity = value - value = find_attr_value_("codStateCode", node) - if value is not None and "codStateCode" not in already_processed: - already_processed.add("codStateCode") - self.codStateCode = value - value = find_attr_value_("codZip", node) - if value is not None and "codZip" not in already_processed: - already_processed.add("codZip") - self.codZip = value - value = find_attr_value_("codCountry", node) - if value is not None and "codCountry" not in already_processed: - already_processed.add("codCountry") - self.codCountry = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class CODReturnAddressType - - -class PackagesType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, type_=None, Package=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.type_ = _cast(None, type_) - self.type__nsprefix_ = None - if Package is None: - self.Package = [] - else: - self.Package = Package - self.Package_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, PackagesType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if PackagesType.subclass: - return PackagesType.subclass(*args_, **kwargs_) - else: - return PackagesType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_Package(self): - return self.Package - - def set_Package(self, Package): - self.Package = Package - - def add_Package(self, value): - self.Package.append(value) - - def insert_Package_at(self, index, value): - self.Package.insert(index, value) - - def replace_Package_at(self, index, value): - self.Package[index] = value - - def get_type(self): - return self.type_ - - def set_type(self, type_): - self.type_ = type_ - - def _hasContent(self): - if self.Package: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackagesType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("PackagesType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "PackagesType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="PackagesType" - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="PackagesType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="PackagesType", - ): - if self.type_ is not None and "type_" not in already_processed: - already_processed.add("type_") - outfile.write( - " type=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.type_), input_name="type" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackagesType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - for Package_ in self.Package: - namespaceprefix_ = ( - self.Package_nsprefix_ + ":" - if (UseCapturedNS_ and self.Package_nsprefix_) - else "" - ) - Package_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Package", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("type", node) - if value is not None and "type" not in already_processed: - already_processed.add("type") - self.type_ = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "Package": - obj_ = PackageType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Package.append(obj_) - obj_.original_tagname_ = "Package" - - -# end class PackagesType - - -class PackageType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - length=None, - width=None, - height=None, - weight=None, - type_=None, - freightClass=None, - nmfcCode=None, - insuranceAmount=None, - codAmount=None, - description=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.length = _cast(int, length) - self.length_nsprefix_ = None - self.width = _cast(int, width) - self.width_nsprefix_ = None - self.height = _cast(int, height) - self.height_nsprefix_ = None - self.weight = _cast(int, weight) - self.weight_nsprefix_ = None - self.type_ = _cast(None, type_) - self.type__nsprefix_ = None - self.freightClass = _cast(int, freightClass) - self.freightClass_nsprefix_ = None - self.nmfcCode = _cast(None, nmfcCode) - self.nmfcCode_nsprefix_ = None - self.insuranceAmount = _cast(float, insuranceAmount) - self.insuranceAmount_nsprefix_ = None - self.codAmount = _cast(float, codAmount) - self.codAmount_nsprefix_ = None - self.description = _cast(None, description) - self.description_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, PackageType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if PackageType.subclass: - return PackageType.subclass(*args_, **kwargs_) - else: - return PackageType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_length(self): - return self.length - - def set_length(self, length): - self.length = length - - def get_width(self): - return self.width - - def set_width(self, width): - self.width = width - - def get_height(self): - return self.height - - def set_height(self, height): - self.height = height - - def get_weight(self): - return self.weight - - def set_weight(self, weight): - self.weight = weight - - def get_type(self): - return self.type_ - - def set_type(self, type_): - self.type_ = type_ - - def get_freightClass(self): - return self.freightClass - - def set_freightClass(self, freightClass): - self.freightClass = freightClass - - def get_nmfcCode(self): - return self.nmfcCode - - def set_nmfcCode(self, nmfcCode): - self.nmfcCode = nmfcCode - - def get_insuranceAmount(self): - return self.insuranceAmount - - def set_insuranceAmount(self, insuranceAmount): - self.insuranceAmount = insuranceAmount - - def get_codAmount(self): - return self.codAmount - - def set_codAmount(self, codAmount): - self.codAmount = codAmount - - def get_description(self): - return self.description - - def set_description(self, description): - self.description = description - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackageType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("PackageType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "PackageType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="PackageType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="PackageType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="PackageType", - ): - if self.length is not None and "length" not in already_processed: - already_processed.add("length") - outfile.write( - ' length="%s"' - % self.gds_format_integer(self.length, input_name="length") - ) - if self.width is not None and "width" not in already_processed: - already_processed.add("width") - outfile.write( - ' width="%s"' % self.gds_format_integer(self.width, input_name="width") - ) - if self.height is not None and "height" not in already_processed: - already_processed.add("height") - outfile.write( - ' height="%s"' - % self.gds_format_integer(self.height, input_name="height") - ) - if self.weight is not None and "weight" not in already_processed: - already_processed.add("weight") - outfile.write( - ' weight="%s"' - % self.gds_format_integer(self.weight, input_name="weight") - ) - if self.type_ is not None and "type_" not in already_processed: - already_processed.add("type_") - outfile.write( - " type=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.type_), input_name="type" - ) - ), - ) - ) - if self.freightClass is not None and "freightClass" not in already_processed: - already_processed.add("freightClass") - outfile.write( - ' freightClass="%s"' - % self.gds_format_integer(self.freightClass, input_name="freightClass") - ) - if self.nmfcCode is not None and "nmfcCode" not in already_processed: - already_processed.add("nmfcCode") - outfile.write( - " nmfcCode=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.nmfcCode), input_name="nmfcCode" - ) - ), - ) - ) - if ( - self.insuranceAmount is not None - and "insuranceAmount" not in already_processed - ): - already_processed.add("insuranceAmount") - outfile.write( - ' insuranceAmount="%s"' - % self.gds_format_float( - self.insuranceAmount, input_name="insuranceAmount" - ) - ) - if self.codAmount is not None and "codAmount" not in already_processed: - already_processed.add("codAmount") - outfile.write( - ' codAmount="%s"' - % self.gds_format_float(self.codAmount, input_name="codAmount") - ) - if self.description is not None and "description" not in already_processed: - already_processed.add("description") - outfile.write( - " description=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.description), input_name="description" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PackageType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("length", node) - if value is not None and "length" not in already_processed: - already_processed.add("length") - self.length = self.gds_parse_integer(value, node, "length") - value = find_attr_value_("width", node) - if value is not None and "width" not in already_processed: - already_processed.add("width") - self.width = self.gds_parse_integer(value, node, "width") - value = find_attr_value_("height", node) - if value is not None and "height" not in already_processed: - already_processed.add("height") - self.height = self.gds_parse_integer(value, node, "height") - value = find_attr_value_("weight", node) - if value is not None and "weight" not in already_processed: - already_processed.add("weight") - self.weight = self.gds_parse_integer(value, node, "weight") - value = find_attr_value_("type", node) - if value is not None and "type" not in already_processed: - already_processed.add("type") - self.type_ = value - value = find_attr_value_("freightClass", node) - if value is not None and "freightClass" not in already_processed: - already_processed.add("freightClass") - self.freightClass = self.gds_parse_integer(value, node, "freightClass") - value = find_attr_value_("nmfcCode", node) - if value is not None and "nmfcCode" not in already_processed: - already_processed.add("nmfcCode") - self.nmfcCode = value - value = find_attr_value_("insuranceAmount", node) - if value is not None and "insuranceAmount" not in already_processed: - already_processed.add("insuranceAmount") - value = self.gds_parse_float(value, node, "insuranceAmount") - self.insuranceAmount = value - value = find_attr_value_("codAmount", node) - if value is not None and "codAmount" not in already_processed: - already_processed.add("codAmount") - value = self.gds_parse_float(value, node, "codAmount") - self.codAmount = value - value = find_attr_value_("description", node) - if value is not None and "description" not in already_processed: - already_processed.add("description") - self.description = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class PackageType - - -class PaymentType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__(self, type_=None, valueOf_=None, gds_collector_=None, **kwargs_): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.type_ = _cast(None, type_) - self.type__nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, PaymentType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if PaymentType.subclass: - return PaymentType.subclass(*args_, **kwargs_) - else: - return PaymentType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_type(self): - return self.type_ - - def set_type(self, type_): - self.type_ = type_ - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PaymentType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("PaymentType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "PaymentType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="PaymentType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="PaymentType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="PaymentType", - ): - if self.type_ is not None and "type_" not in already_processed: - already_processed.add("type_") - outfile.write( - " type=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.type_), input_name="type" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="PaymentType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("type", node) - if value is not None and "type" not in already_processed: - already_processed.add("type") - self.type_ = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class PaymentType - - -class ReferenceType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, name=None, code=None, valueOf_=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.name = _cast(None, name) - self.name_nsprefix_ = None - self.code = _cast(None, code) - self.code_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ReferenceType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ReferenceType.subclass: - return ReferenceType.subclass(*args_, **kwargs_) - else: - return ReferenceType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_name(self): - return self.name - - def set_name(self, name): - self.name = name - - def get_code(self): - return self.code - - def set_code(self, code): - self.code = code - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ReferenceType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ReferenceType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ReferenceType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="ReferenceType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ReferenceType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="ReferenceType", - ): - if self.name is not None and "name" not in already_processed: - already_processed.add("name") - outfile.write( - " name=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.name), input_name="name" - ) - ), - ) - ) - if self.code is not None and "code" not in already_processed: - already_processed.add("code") - outfile.write( - " code=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.code), input_name="code" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ReferenceType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("name", node) - if value is not None and "name" not in already_processed: - already_processed.add("name") - self.name = value - value = find_attr_value_("code", node) - if value is not None and "code" not in already_processed: - already_processed.add("code") - self.code = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class ReferenceType - - -class CustomsInvoiceType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, BillTo=None, Contact=None, Item=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.BillTo = BillTo - self.BillTo_nsprefix_ = None - self.Contact = Contact - self.Contact_nsprefix_ = None - if Item is None: - self.Item = [] - else: - self.Item = Item - self.Item_nsprefix_ = None - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_( - CurrentSubclassModule_, CustomsInvoiceType - ) - if subclass is not None: - return subclass(*args_, **kwargs_) - if CustomsInvoiceType.subclass: - return CustomsInvoiceType.subclass(*args_, **kwargs_) - else: - return CustomsInvoiceType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_BillTo(self): - return self.BillTo - - def set_BillTo(self, BillTo): - self.BillTo = BillTo - - def get_Contact(self): - return self.Contact - - def set_Contact(self, Contact): - self.Contact = Contact - - def get_Item(self): - return self.Item - - def set_Item(self, Item): - self.Item = Item - - def add_Item(self, value): - self.Item.append(value) - - def insert_Item_at(self, index, value): - self.Item.insert(index, value) - - def replace_Item_at(self, index, value): - self.Item[index] = value - - def _hasContent(self): - if self.BillTo is not None or self.Contact is not None or self.Item: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CustomsInvoiceType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("CustomsInvoiceType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "CustomsInvoiceType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, - level, - already_processed, - namespaceprefix_, - name_="CustomsInvoiceType", - ) - if self._hasContent(): - outfile.write(">%s" % (eol_,)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="CustomsInvoiceType", - pretty_print=pretty_print, - ) - showIndent(outfile, level, pretty_print) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="CustomsInvoiceType", - ): - pass - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="CustomsInvoiceType", - fromsubclass_=False, - pretty_print=True, - ): - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.BillTo is not None: - namespaceprefix_ = ( - self.BillTo_nsprefix_ + ":" - if (UseCapturedNS_ and self.BillTo_nsprefix_) - else "" - ) - self.BillTo.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="BillTo", - pretty_print=pretty_print, - ) - if self.Contact is not None: - namespaceprefix_ = ( - self.Contact_nsprefix_ + ":" - if (UseCapturedNS_ and self.Contact_nsprefix_) - else "" - ) - self.Contact.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Contact", - pretty_print=pretty_print, - ) - for Item_ in self.Item: - namespaceprefix_ = ( - self.Item_nsprefix_ + ":" - if (UseCapturedNS_ and self.Item_nsprefix_) - else "" - ) - Item_.export( - outfile, - level, - namespaceprefix_, - namespacedef_="", - name_="Item", - pretty_print=pretty_print, - ) - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - pass - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - if nodeName_ == "BillTo": - obj_ = BillToType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.BillTo = obj_ - obj_.original_tagname_ = "BillTo" - elif nodeName_ == "Contact": - obj_ = ContactType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Contact = obj_ - obj_.original_tagname_ = "Contact" - elif nodeName_ == "Item": - obj_ = ItemType.factory(parent_object_=self) - obj_.build(child_, gds_collector_=gds_collector_) - self.Item.append(obj_) - obj_.original_tagname_ = "Item" - - -# end class CustomsInvoiceType - - -class BillToType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - company=None, - name=None, - address1=None, - city=None, - state=None, - zip=None, - country=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.company = _cast(None, company) - self.company_nsprefix_ = None - self.name = _cast(None, name) - self.name_nsprefix_ = None - self.address1 = _cast(None, address1) - self.address1_nsprefix_ = None - self.city = _cast(None, city) - self.city_nsprefix_ = None - self.state = _cast(None, state) - self.state_nsprefix_ = None - self.zip = _cast(None, zip) - self.zip_nsprefix_ = None - self.country = _cast(None, country) - self.country_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, BillToType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if BillToType.subclass: - return BillToType.subclass(*args_, **kwargs_) - else: - return BillToType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_company(self): - return self.company - - def set_company(self, company): - self.company = company - - def get_name(self): - return self.name - - def set_name(self, name): - self.name = name - - def get_address1(self): - return self.address1 - - def set_address1(self, address1): - self.address1 = address1 - - def get_city(self): - return self.city - - def set_city(self, city): - self.city = city - - def get_state(self): - return self.state - - def set_state(self, state): - self.state = state - - def get_zip(self): - return self.zip - - def set_zip(self, zip): - self.zip = zip - - def get_country(self): - return self.country - - def set_country(self, country): - self.country = country - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="BillToType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("BillToType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "BillToType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="BillToType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="BillToType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="BillToType" - ): - if self.company is not None and "company" not in already_processed: - already_processed.add("company") - outfile.write( - " company=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.company), input_name="company" - ) - ), - ) - ) - if self.name is not None and "name" not in already_processed: - already_processed.add("name") - outfile.write( - " name=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.name), input_name="name" - ) - ), - ) - ) - if self.address1 is not None and "address1" not in already_processed: - already_processed.add("address1") - outfile.write( - " address1=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.address1), input_name="address1" - ) - ), - ) - ) - if self.city is not None and "city" not in already_processed: - already_processed.add("city") - outfile.write( - " city=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.city), input_name="city" - ) - ), - ) - ) - if self.state is not None and "state" not in already_processed: - already_processed.add("state") - outfile.write( - " state=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.state), input_name="state" - ) - ), - ) - ) - if self.zip is not None and "zip" not in already_processed: - already_processed.add("zip") - outfile.write( - " zip=%s" - % ( - self.gds_encode( - self.gds_format_string(quote_attrib(self.zip), input_name="zip") - ), - ) - ) - if self.country is not None and "country" not in already_processed: - already_processed.add("country") - outfile.write( - " country=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.country), input_name="country" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="BillToType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("company", node) - if value is not None and "company" not in already_processed: - already_processed.add("company") - self.company = value - value = find_attr_value_("name", node) - if value is not None and "name" not in already_processed: - already_processed.add("name") - self.name = value - value = find_attr_value_("address1", node) - if value is not None and "address1" not in already_processed: - already_processed.add("address1") - self.address1 = value - value = find_attr_value_("city", node) - if value is not None and "city" not in already_processed: - already_processed.add("city") - self.city = value - value = find_attr_value_("state", node) - if value is not None and "state" not in already_processed: - already_processed.add("state") - self.state = value - value = find_attr_value_("zip", node) - if value is not None and "zip" not in already_processed: - already_processed.add("zip") - self.zip = value - value = find_attr_value_("country", node) - if value is not None and "country" not in already_processed: - already_processed.add("country") - self.country = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class BillToType - - -class ContactType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, name=None, phone=None, valueOf_=None, gds_collector_=None, **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.name = _cast(None, name) - self.name_nsprefix_ = None - self.phone = _cast(None, phone) - self.phone_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ContactType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ContactType.subclass: - return ContactType.subclass(*args_, **kwargs_) - else: - return ContactType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_name(self): - return self.name - - def set_name(self, name): - self.name = name - - def get_phone(self): - return self.phone - - def set_phone(self, phone): - self.phone = phone - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ContactType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ContactType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ContactType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="ContactType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ContactType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, - outfile, - level, - already_processed, - namespaceprefix_="", - name_="ContactType", - ): - if self.name is not None and "name" not in already_processed: - already_processed.add("name") - outfile.write( - " name=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.name), input_name="name" - ) - ), - ) - ) - if self.phone is not None and "phone" not in already_processed: - already_processed.add("phone") - outfile.write( - " phone=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.phone), input_name="phone" - ) - ), - ) - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ContactType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("name", node) - if value is not None and "name" not in already_processed: - already_processed.add("name") - self.name = value - value = find_attr_value_("phone", node) - if value is not None and "phone" not in already_processed: - already_processed.add("phone") - self.phone = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class ContactType - - -class ItemType(GeneratedsSuper): - __hash__ = GeneratedsSuper.__hash__ - subclass = None - superclass = None - - def __init__( - self, - code=None, - description=None, - originCountry=None, - quantity=None, - unitPrice=None, - valueOf_=None, - gds_collector_=None, - **kwargs_ - ): - self.gds_collector_ = gds_collector_ - self.gds_elementtree_node_ = None - self.original_tagname_ = None - self.parent_object_ = kwargs_.get("parent_object_") - self.ns_prefix_ = None - self.code = _cast(None, code) - self.code_nsprefix_ = None - self.description = _cast(None, description) - self.description_nsprefix_ = None - self.originCountry = _cast(None, originCountry) - self.originCountry_nsprefix_ = None - self.quantity = _cast(int, quantity) - self.quantity_nsprefix_ = None - self.unitPrice = _cast(float, unitPrice) - self.unitPrice_nsprefix_ = None - self.valueOf_ = valueOf_ - - def factory(*args_, **kwargs_): - if CurrentSubclassModule_ is not None: - subclass = getSubclassFromModule_(CurrentSubclassModule_, ItemType) - if subclass is not None: - return subclass(*args_, **kwargs_) - if ItemType.subclass: - return ItemType.subclass(*args_, **kwargs_) - else: - return ItemType(*args_, **kwargs_) - - factory = staticmethod(factory) - - def get_ns_prefix_(self): - return self.ns_prefix_ - - def set_ns_prefix_(self, ns_prefix): - self.ns_prefix_ = ns_prefix - - def get_code(self): - return self.code - - def set_code(self, code): - self.code = code - - def get_description(self): - return self.description - - def set_description(self, description): - self.description = description - - def get_originCountry(self): - return self.originCountry - - def set_originCountry(self, originCountry): - self.originCountry = originCountry - - def get_quantity(self): - return self.quantity - - def set_quantity(self, quantity): - self.quantity = quantity - - def get_unitPrice(self): - return self.unitPrice - - def set_unitPrice(self, unitPrice): - self.unitPrice = unitPrice - - def get_valueOf_(self): - return self.valueOf_ - - def set_valueOf_(self, valueOf_): - self.valueOf_ = valueOf_ - - def _hasContent(self): - if 1 if type(self.valueOf_) in [int, float] else self.valueOf_: - return True - else: - return False - - def export( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ItemType", - pretty_print=True, - ): - imported_ns_def_ = GenerateDSNamespaceDefs_.get("ItemType") - if imported_ns_def_ is not None: - namespacedef_ = imported_ns_def_ - if pretty_print: - eol_ = "\n" - else: - eol_ = "" - if self.original_tagname_ is not None and name_ == "ItemType": - name_ = self.original_tagname_ - if UseCapturedNS_ and self.ns_prefix_: - namespaceprefix_ = self.ns_prefix_ + ":" - showIndent(outfile, level, pretty_print) - outfile.write( - "<%s%s%s" - % ( - namespaceprefix_, - name_, - namespacedef_ and " " + namespacedef_ or "", - ) - ) - already_processed = set() - self._exportAttributes( - outfile, level, already_processed, namespaceprefix_, name_="ItemType" - ) - if self._hasContent(): - outfile.write(">") - outfile.write(self.convert_unicode(self.valueOf_)) - self._exportChildren( - outfile, - level + 1, - namespaceprefix_, - namespacedef_, - name_="ItemType", - pretty_print=pretty_print, - ) - outfile.write("%s" % (namespaceprefix_, name_, eol_)) - else: - outfile.write("/>%s" % (eol_,)) - - def _exportAttributes( - self, outfile, level, already_processed, namespaceprefix_="", name_="ItemType" - ): - if self.code is not None and "code" not in already_processed: - already_processed.add("code") - outfile.write( - " code=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.code), input_name="code" - ) - ), - ) - ) - if self.description is not None and "description" not in already_processed: - already_processed.add("description") - outfile.write( - " description=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.description), input_name="description" - ) - ), - ) - ) - if self.originCountry is not None and "originCountry" not in already_processed: - already_processed.add("originCountry") - outfile.write( - " originCountry=%s" - % ( - self.gds_encode( - self.gds_format_string( - quote_attrib(self.originCountry), input_name="originCountry" - ) - ), - ) - ) - if self.quantity is not None and "quantity" not in already_processed: - already_processed.add("quantity") - outfile.write( - ' quantity="%s"' - % self.gds_format_integer(self.quantity, input_name="quantity") - ) - if self.unitPrice is not None and "unitPrice" not in already_processed: - already_processed.add("unitPrice") - outfile.write( - ' unitPrice="%s"' - % self.gds_format_float(self.unitPrice, input_name="unitPrice") - ) - - def _exportChildren( - self, - outfile, - level, - namespaceprefix_="", - namespacedef_="", - name_="ItemType", - fromsubclass_=False, - pretty_print=True, - ): - pass - - def build(self, node, gds_collector_=None): - self.gds_collector_ = gds_collector_ - if SaveElementTreeNode: - self.gds_elementtree_node_ = node - already_processed = set() - self.ns_prefix_ = node.prefix - self._buildAttributes(node, node.attrib, already_processed) - self.valueOf_ = get_all_text_(node) - for child in node: - nodeName_ = Tag_pattern_.match(child.tag).groups()[-1] - self._buildChildren(child, node, nodeName_, gds_collector_=gds_collector_) - return self - - def _buildAttributes(self, node, attrs, already_processed): - value = find_attr_value_("code", node) - if value is not None and "code" not in already_processed: - already_processed.add("code") - self.code = value - value = find_attr_value_("description", node) - if value is not None and "description" not in already_processed: - already_processed.add("description") - self.description = value - value = find_attr_value_("originCountry", node) - if value is not None and "originCountry" not in already_processed: - already_processed.add("originCountry") - self.originCountry = value - value = find_attr_value_("quantity", node) - if value is not None and "quantity" not in already_processed: - already_processed.add("quantity") - self.quantity = self.gds_parse_integer(value, node, "quantity") - value = find_attr_value_("unitPrice", node) - if value is not None and "unitPrice" not in already_processed: - already_processed.add("unitPrice") - value = self.gds_parse_float(value, node, "unitPrice") - self.unitPrice = value - - def _buildChildren( - self, child_, node, nodeName_, fromsubclass_=False, gds_collector_=None - ): - pass - - -# end class ItemType - - -GDSClassesMapping = {} - - -USAGE_TEXT = """ -Usage: python .py [ -s ] -""" - - -def usage(): - print(USAGE_TEXT) - sys.exit(1) - - -def get_root_tag(node): - tag = Tag_pattern_.match(node.tag).groups()[-1] - prefix_tag = TagNamePrefix + tag - rootClass = GDSClassesMapping.get(prefix_tag) - if rootClass is None: - rootClass = globals().get(prefix_tag) - return tag, rootClass - - -def get_required_ns_prefix_defs(rootNode): - """Get all name space prefix definitions required in this XML doc. - Return a dictionary of definitions and a char string of definitions. - """ - nsmap = { - prefix: uri - for node in rootNode.iter() - for (prefix, uri) in node.nsmap.items() - if prefix is not None - } - namespacedefs = " ".join( - ['xmlns:{}="{}"'.format(prefix, uri) for prefix, uri in nsmap.items()] - ) - return nsmap, namespacedefs - - -def parse(inFileName, silence=False, print_warnings=True): - global CapturedNsmap_ - gds_collector = GdsCollector_() - parser = None - doc = parsexml_(inFileName, parser) - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - CapturedNsmap_, namespacedefs = get_required_ns_prefix_defs(rootNode) - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export( - sys.stdout, 0, name_=rootTag, namespacedef_=namespacedefs, pretty_print=True - ) - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseEtree( - inFileName, - silence=False, - print_warnings=True, - mapping=None, - reverse_mapping=None, - nsmap=None, -): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if mapping is None: - mapping = {} - if reverse_mapping is None: - reverse_mapping = {} - rootElement = rootObj.to_etree( - None, - name_=rootTag, - mapping_=mapping, - reverse_mapping_=reverse_mapping, - nsmap_=nsmap, - ) - reverse_node_mapping = rootObj.gds_reverse_node_mapping(mapping) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - content = etree_.tostring( - rootElement, pretty_print=True, xml_declaration=True, encoding="utf-8" - ) - sys.stdout.write(str(content)) - sys.stdout.write("\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj, rootElement, mapping, reverse_node_mapping - - -def parseString(inString, silence=False, print_warnings=True): - """Parse a string, create the object tree, and export it. - - Arguments: - - inString -- A string. This XML fragment should not start - with an XML declaration containing an encoding. - - silence -- A boolean. If False, export the object. - Returns -- The root object in the tree. - """ - parser = None - rootNode = parsexmlstring_(inString, parser) - gds_collector = GdsCollector_() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - if not SaveElementTreeNode: - rootNode = None - if not silence: - sys.stdout.write('\n') - rootObj.export(sys.stdout, 0, name_=rootTag, namespacedef_="") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def parseLiteral(inFileName, silence=False, print_warnings=True): - parser = None - doc = parsexml_(inFileName, parser) - gds_collector = GdsCollector_() - rootNode = doc.getroot() - rootTag, rootClass = get_root_tag(rootNode) - if rootClass is None: - rootTag = "Freightcom" - rootClass = Freightcom - rootObj = rootClass.factory() - rootObj.build(rootNode, gds_collector_=gds_collector) - # Enable Python to collect the space used by the DOM. - if not SaveElementTreeNode: - doc = None - rootNode = None - if not silence: - sys.stdout.write("#from shipping_request import *\n\n") - sys.stdout.write("import shipping_request as model_\n\n") - sys.stdout.write("rootObj = model_.rootClass(\n") - rootObj.exportLiteral(sys.stdout, 0, name_=rootTag) - sys.stdout.write(")\n") - if print_warnings and len(gds_collector.get_messages()) > 0: - separator = ("-" * 50) + "\n" - sys.stderr.write(separator) - sys.stderr.write( - "----- Warnings -- count: {} -----\n".format( - len(gds_collector.get_messages()), - ) - ) - gds_collector.write_messages(sys.stderr) - sys.stderr.write(separator) - return rootObj - - -def main(): - args = sys.argv[1:] - if len(args) == 1: - parse(args[0]) - else: - usage() - - -if __name__ == "__main__": - # import pdb; pdb.set_trace() - main() - -RenameMappings_ = {} - -# -# Mapping of namespaces to types defined in them -# and the file in which each is defined. -# simpleTypes are marked "ST" and complexTypes "CT". -NamespaceToDefMappings_ = {"http://www.freightcom.net/XMLSchema": []} - -__all__ = [ - "BillToType", - "CODReturnAddressType", - "CODType", - "ContactType", - "CustomsInvoiceType", - "Freightcom", - "FromType", - "ItemType", - "PackageType", - "PackagesType", - "PaymentType", - "ReferenceType", - "ShippingRequestType", - "ToType", -] + +@s(auto_attribs=True) +class CustomsInvoiceDetailsType: + tax_recipient: Optional[TaxRecipientType] = JStruct[TaxRecipientType] + products: List[ProductType] = JList[ProductType] + + +@s(auto_attribs=True) +class CustomsInvoiceType: + source: Optional[str] = None + broker: Optional[BrokerType] = JStruct[BrokerType] + details: Optional[CustomsInvoiceDetailsType] = JStruct[CustomsInvoiceDetailsType] + + +@s(auto_attribs=True) +class ReadyType: + hour: Optional[int] = None + minute: Optional[int] = None + + +@s(auto_attribs=True) +class DestinationType: + name: Optional[str] = None + address: Optional[AddressType] = JStruct[AddressType] + residential: Optional[bool] = None + tailgate_required: Optional[bool] = None + instructions: Optional[str] = None + contact_name: Optional[str] = None + phone_number: Optional[NumberType] = JStruct[NumberType] + email_addresses: List[str] = [] + receives_email_updates: Optional[bool] = None + ready_at: Optional[ReadyType] = JStruct[ReadyType] + ready_until: Optional[ReadyType] = JStruct[ReadyType] + signature_requirement: Optional[str] = None + + +@s(auto_attribs=True) +class DateType: + year: Optional[int] = None + month: Optional[int] = None + day: Optional[int] = None + + +@s(auto_attribs=True) +class InsuranceType: + type: Optional[str] = None + total_cost: Optional[TotalCostType] = JStruct[TotalCostType] + + +@s(auto_attribs=True) +class CourierpakMeasurementsType: + weight: Optional[WeightType] = JStruct[WeightType] + + +@s(auto_attribs=True) +class CourierpakType: + measurements: Optional[CourierpakMeasurementsType] = JStruct[CourierpakMeasurementsType] + description: Optional[str] = None + + +@s(auto_attribs=True) +class DangerousGoodsDetailsType: + packaging_group: Optional[str] = None + goods_class: Optional[str] = None + description: Optional[str] = None + united_nations_number: Optional[str] = None + emergency_contact_name: Optional[str] = None + emergency_contact_phone_number: Optional[NumberType] = JStruct[NumberType] + + +@s(auto_attribs=True) +class CuboidType: + unit: Optional[str] = None + l: Optional[int] = None + w: Optional[int] = None + h: Optional[int] = None + + +@s(auto_attribs=True) +class PackageMeasurementsType: + weight: Optional[WeightType] = JStruct[WeightType] + cuboid: Optional[CuboidType] = JStruct[CuboidType] + + +@s(auto_attribs=True) +class PackageType: + measurements: Optional[PackageMeasurementsType] = JStruct[PackageMeasurementsType] + description: Optional[str] = None + + +@s(auto_attribs=True) +class InBondDetailsType: + type: Optional[str] = None + name: Optional[str] = None + address: Optional[str] = None + contact_method: Optional[str] = None + contact_email_address: Optional[str] = None + contact_phone_number: Optional[NumberType] = JStruct[NumberType] + + +@s(auto_attribs=True) +class PalletServiceDetailsType: + limited_access_delivery_type: Optional[str] = None + limited_access_delivery_other_name: Optional[str] = None + in_bond: Optional[bool] = None + in_bond_details: Optional[InBondDetailsType] = JStruct[InBondDetailsType] + appointment_delivery: Optional[bool] = None + protect_from_freeze: Optional[bool] = None + threshold_pickup: Optional[bool] = None + threshold_delivery: Optional[bool] = None + + +@s(auto_attribs=True) +class PalletType: + measurements: Optional[PackageMeasurementsType] = JStruct[PackageMeasurementsType] + description: Optional[str] = None + freight_class: Optional[str] = None + nmfc: Optional[str] = None + contents_type: Optional[str] = None + num_pieces: Optional[int] = None + + +@s(auto_attribs=True) +class PackagingPropertiesType: + pallet_type: Optional[str] = None + has_stackable_pallets: Optional[bool] = None + dangerous_goods: Optional[str] = None + dangerous_goods_details: Optional[DangerousGoodsDetailsType] = JStruct[DangerousGoodsDetailsType] + pallets: List[PalletType] = JList[PalletType] + packages: List[PackageType] = JList[PackageType] + courierpaks: List[CourierpakType] = JList[CourierpakType] + includes_return_label: Optional[bool] = None + special_handling_required: Optional[bool] = None + has_dangerous_goods: Optional[bool] = None + pallet_service_details: Optional[PalletServiceDetailsType] = JStruct[PalletServiceDetailsType] + + +@s(auto_attribs=True) +class ShippingRequestDetailsType: + origin: Optional[DestinationType] = JStruct[DestinationType] + destination: Optional[DestinationType] = JStruct[DestinationType] + expected_ship_date: Optional[DateType] = JStruct[DateType] + packaging_type: Optional[str] = None + packaging_properties: Optional[PackagingPropertiesType] = JStruct[PackagingPropertiesType] + insurance: Optional[InsuranceType] = JStruct[InsuranceType] + reference_codes: List[str] = [] + + +@s(auto_attribs=True) +class DispatchDetailsType: + date: Optional[DateType] = JStruct[DateType] + ready_at: Optional[ReadyType] = JStruct[ReadyType] + ready_until: Optional[ReadyType] = JStruct[ReadyType] + + +@s(auto_attribs=True) +class PickupDetailsType: + pre_scheduled_pickup: Optional[bool] = None + date: Optional[DateType] = JStruct[DateType] + ready_at: Optional[ReadyType] = JStruct[ReadyType] + ready_until: Optional[ReadyType] = JStruct[ReadyType] + pickup_location: Optional[str] = None + contact_name: Optional[str] = None + contact_phone_number: Optional[NumberType] = JStruct[NumberType] + + +@s(auto_attribs=True) +class ShippingRequestType: + unique_id: Optional[str] = None + payment_method_id: Optional[str] = None + service_id: Optional[str] = None + details: Optional[ShippingRequestDetailsType] = JStruct[ShippingRequestDetailsType] + customs_invoice: Optional[CustomsInvoiceType] = JStruct[CustomsInvoiceType] + pickup_details: Optional[PickupDetailsType] = JStruct[PickupDetailsType] + dispatch_details: Optional[DispatchDetailsType] = JStruct[DispatchDetailsType] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_response.py b/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_response.py new file mode 100644 index 0000000000..3f0b5613ac --- /dev/null +++ b/modules/connectors/freightcom/karrio/schemas/freightcom/shipping_response.py @@ -0,0 +1,224 @@ +from attr import s +from typing import Optional, List +from jstruct import JStruct, JList + + +@s(auto_attribs=True) +class AddressType: + address_line_1: Optional[str] = None + address_line_2: Optional[str] = None + unit_number: Optional[str] = None + city: Optional[str] = None + region: Optional[str] = None + country: Optional[str] = None + postal_code: Optional[str] = None + + +@s(auto_attribs=True) +class PhoneNumberType: + number: Optional[str] = None + extension: Optional[int] = None + + +@s(auto_attribs=True) +class ReadyType: + hour: Optional[int] = None + minute: Optional[int] = None + + +@s(auto_attribs=True) +class DestinationType: + name: Optional[str] = None + address: Optional[AddressType] = JStruct[AddressType] + residential: Optional[bool] = None + tailgate_required: Optional[bool] = None + instructions: Optional[str] = None + contact_name: Optional[str] = None + phone_number: Optional[PhoneNumberType] = JStruct[PhoneNumberType] + email_addresses: List[str] = [] + receives_email_updates: Optional[bool] = None + ready_at: Optional[ReadyType] = JStruct[ReadyType] + ready_until: Optional[ReadyType] = JStruct[ReadyType] + signature_requirement: Optional[str] = None + + +@s(auto_attribs=True) +class ExpectedShipDateType: + year: Optional[int] = None + month: Optional[int] = None + day: Optional[int] = None + + +@s(auto_attribs=True) +class BaseType: + currency: Optional[str] = None + value: Optional[int] = None + + +@s(auto_attribs=True) +class InsuranceType: + type: Optional[str] = None + total_cost: Optional[BaseType] = JStruct[BaseType] + + +@s(auto_attribs=True) +class WeightType: + unit: Optional[str] = None + value: Optional[float] = None + + +@s(auto_attribs=True) +class CourierpakMeasurementsType: + weight: Optional[WeightType] = JStruct[WeightType] + + +@s(auto_attribs=True) +class CourierpakType: + measurements: Optional[CourierpakMeasurementsType] = JStruct[CourierpakMeasurementsType] + description: Optional[str] = None + + +@s(auto_attribs=True) +class DangerousGoodsDetailsType: + packaging_group: Optional[str] = None + goods_class: Optional[str] = None + description: Optional[str] = None + united_nations_number: Optional[str] = None + emergency_contact_name: Optional[str] = None + emergency_contact_phone_number: Optional[PhoneNumberType] = JStruct[PhoneNumberType] + + +@s(auto_attribs=True) +class CuboidType: + unit: Optional[str] = None + l: Optional[int] = None + w: Optional[int] = None + h: Optional[int] = None + + +@s(auto_attribs=True) +class PackageMeasurementsType: + weight: Optional[WeightType] = JStruct[WeightType] + cuboid: Optional[CuboidType] = JStruct[CuboidType] + + +@s(auto_attribs=True) +class PackageType: + measurements: Optional[PackageMeasurementsType] = JStruct[PackageMeasurementsType] + description: Optional[str] = None + + +@s(auto_attribs=True) +class InBondDetailsType: + type: Optional[str] = None + name: Optional[str] = None + address: Optional[str] = None + contact_method: Optional[str] = None + contact_email_address: Optional[str] = None + contact_phone_number: Optional[PhoneNumberType] = JStruct[PhoneNumberType] + + +@s(auto_attribs=True) +class PalletServiceDetailsType: + limited_access_delivery_type: Optional[str] = None + limited_access_delivery_other_name: Optional[str] = None + in_bond: Optional[bool] = None + in_bond_details: Optional[InBondDetailsType] = JStruct[InBondDetailsType] + appointment_delivery: Optional[bool] = None + protect_from_freeze: Optional[bool] = None + threshold_pickup: Optional[bool] = None + threshold_delivery: Optional[bool] = None + + +@s(auto_attribs=True) +class PalletType: + measurements: Optional[PackageMeasurementsType] = JStruct[PackageMeasurementsType] + description: Optional[str] = None + freight_class: Optional[str] = None + nmfc: Optional[str] = None + contents_type: Optional[str] = None + num_pieces: Optional[int] = None + + +@s(auto_attribs=True) +class PackagingPropertiesType: + pallet_type: Optional[str] = None + has_stackable_pallets: Optional[bool] = None + dangerous_goods: Optional[str] = None + dangerous_goods_details: Optional[DangerousGoodsDetailsType] = JStruct[DangerousGoodsDetailsType] + pallets: List[PalletType] = JList[PalletType] + packages: List[PackageType] = JList[PackageType] + courierpaks: List[CourierpakType] = JList[CourierpakType] + includes_return_label: Optional[bool] = None + special_handling_required: Optional[bool] = None + has_dangerous_goods: Optional[bool] = None + pallet_service_details: Optional[PalletServiceDetailsType] = JStruct[PalletServiceDetailsType] + + +@s(auto_attribs=True) +class DetailsType: + origin: Optional[DestinationType] = JStruct[DestinationType] + destination: Optional[DestinationType] = JStruct[DestinationType] + expected_ship_date: Optional[ExpectedShipDateType] = JStruct[ExpectedShipDateType] + packaging_type: Optional[str] = None + packaging_properties: Optional[PackagingPropertiesType] = JStruct[PackagingPropertiesType] + insurance: Optional[InsuranceType] = JStruct[InsuranceType] + reference_codes: List[str] = [] + + +@s(auto_attribs=True) +class LabelType: + size: Optional[str] = None + format: Optional[str] = None + url: Optional[str] = None + padded: Optional[bool] = None + + +@s(auto_attribs=True) +class SurchargeType: + type: Optional[str] = None + amount: Optional[BaseType] = JStruct[BaseType] + + +@s(auto_attribs=True) +class RateType: + carrier_name: Optional[str] = None + service_name: Optional[str] = None + service_id: Optional[str] = None + valid_until: Optional[ExpectedShipDateType] = JStruct[ExpectedShipDateType] + total: Optional[BaseType] = JStruct[BaseType] + base: Optional[BaseType] = JStruct[BaseType] + surcharges: List[SurchargeType] = JList[SurchargeType] + taxes: List[SurchargeType] = JList[SurchargeType] + transit_time_days: Optional[int] = None + transit_time_not_available: Optional[bool] = None + + +@s(auto_attribs=True) +class TransportDataType: + pass + + +@s(auto_attribs=True) +class ShipmentType: + id: Optional[str] = None + unique_id: Optional[str] = None + state: Optional[str] = None + transaction_number: Optional[str] = None + primary_tracking_number: Optional[str] = None + tracking_numbers: List[str] = [] + tracking_url: Optional[str] = None + return_tracking_number: Optional[str] = None + bol_number: Optional[str] = None + pickup_confirmation_number: Optional[str] = None + details: Optional[DetailsType] = JStruct[DetailsType] + transport_data: Optional[TransportDataType] = JStruct[TransportDataType] + labels: List[LabelType] = JList[LabelType] + customs_invoice_url: Optional[str] = None + rate: Optional[RateType] = JStruct[RateType] + order_source: Optional[str] = None + + +@s(auto_attribs=True) +class ShippingResponseType: + shipment: Optional[ShipmentType] = JStruct[ShipmentType] diff --git a/modules/connectors/freightcom/karrio/schemas/freightcom/tracking_response.py b/modules/connectors/freightcom/karrio/schemas/freightcom/tracking_response.py new file mode 100644 index 0000000000..f1fceca3e7 --- /dev/null +++ b/modules/connectors/freightcom/karrio/schemas/freightcom/tracking_response.py @@ -0,0 +1,23 @@ +from attr import s +from typing import Optional, List +from jstruct import JStruct, JList + + +@s(auto_attribs=True) +class WhereType: + city: Optional[str] = None + region: Optional[str] = None + country: Optional[str] = None + + +@s(auto_attribs=True) +class EventType: + type: Optional[str] = None + when: Optional[str] = None + where: Optional[WhereType] = JStruct[WhereType] + message: Optional[str] = None + + +@s(auto_attribs=True) +class TrackingResponseType: + events: List[EventType] = JList[EventType] diff --git a/modules/connectors/freightcom/schemas/error_response.json b/modules/connectors/freightcom/schemas/error_response.json new file mode 100644 index 0000000000..0959a23996 --- /dev/null +++ b/modules/connectors/freightcom/schemas/error_response.json @@ -0,0 +1,4 @@ +{ +"message": "string", + "data": {"services":"invalid-syntax"} +} diff --git a/modules/connectors/freightcom/schemas/pickup_request.json b/modules/connectors/freightcom/schemas/pickup_request.json new file mode 100644 index 0000000000..7c5b184cc5 --- /dev/null +++ b/modules/connectors/freightcom/schemas/pickup_request.json @@ -0,0 +1,39 @@ +{ + "pickup_details": { + "pre_scheduled_pickup": true, + "date": { + "year": 2006, + "month": 6, + "day": 7 + }, + "ready_at": { + "hour": 15, + "minute": 6 + }, + "ready_until": { + "hour": 15, + "minute": 6 + }, + "pickup_location": "string", + "contact_name": "string", + "contact_phone_number": { + "number": "5554447777", + "extension": "123" + } + }, + "dispatch_details": { + "date": { + "year": 2006, + "month": 6, + "day": 7 + }, + "ready_at": { + "hour": 15, + "minute": 6 + }, + "ready_until": { + "hour": 15, + "minute": 6 + } + } +} diff --git a/modules/connectors/freightcom/schemas/rate_request.json b/modules/connectors/freightcom/schemas/rate_request.json new file mode 100644 index 0000000000..55b90a3fe7 --- /dev/null +++ b/modules/connectors/freightcom/schemas/rate_request.json @@ -0,0 +1,171 @@ +{ + "services": [ + "string" + ], + "excluded_services": [ + "string" + ], + "details": { + "origin": { + "name": "Philip J Fry", + "address": { + "address_line_1": "200 University Avenue West", + "address_line_2": "string", + "unit_number": "42a", + "city": "Waterloo", + "region": "ON", + "country": "CA", + "postal_code": "string" + }, + "residential": true, + "tailgate_required": true, + "instructions": "string", + "contact_name": "string", + "phone_number": { + "number": "5554447777", + "extension": "123" + }, + "email_addresses": [ + "user@example.com" + ], + "receives_email_updates": true + }, + "destination": { + "name": "Philip J Fry", + "address": { + "address_line_1": "200 University Avenue West", + "address_line_2": "string", + "unit_number": "42a", + "city": "Waterloo", + "region": "ON", + "country": "CA", + "postal_code": "string" + }, + "residential": true, + "tailgate_required": true, + "instructions": "string", + "contact_name": "string", + "phone_number": { + "number": "5554447777", + "extension": "123" + }, + "email_addresses": [ + "user@example.com" + ], + "receives_email_updates": true, + "ready_at": { + "hour": 15, + "minute": 6 + }, + "ready_until": { + "hour": 15, + "minute": 6 + }, + "signature_requirement": "not-required" + }, + "expected_ship_date": { + "year": 2006, + "month": 6, + "day": 7 + }, + "packaging_type": "pallet", + "packaging_properties": { + "pallet_type": "ltl", + "has_stackable_pallets": true, + "dangerous_goods": "limited-quantity", + "dangerous_goods_details": { + "packaging_group": "string", + "goods_class": "string", + "description": "string", + "united_nations_number": "string", + "emergency_contact_name": "string", + "emergency_contact_phone_number": { + "number": "5554447777", + "extension": "123" + } + }, + "pallets": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + }, + "cuboid": { + "unit": "ft", + "l": 5, + "w": 5, + "h": 5 + } + }, + "description": "string", + "freight_class": "string", + "nmfc": "string", + "contents_type": "string", + "num_pieces": 0 + } + ], + "packages": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + }, + "cuboid": { + "unit": "ft", + "l": 5, + "w": 5, + "h": 5 + } + }, + "description": "string" + } + ], + "courierpaks": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + } + }, + "description": "string" + } + ], + "includes_return_label": false, + "special_handling_required": false, + "has_dangerous_goods": false, + "pallet_service_details": { + "limited_access_delivery_type": "string", + "limited_access_delivery_other_name": "string", + "in_bond": true, + "in_bond_details": { + "type": "immediate-exportation", + "name": "string", + "address": "string", + "contact_method": "email-address", + "contact_email_address": "string", + "contact_phone_number": { + "number": "5554447777", + "extension": "123" + } + }, + "appointment_delivery": true, + "protect_from_freeze": true, + "threshold_pickup": true, + "threshold_delivery": true + }, + "insurance": { + "type": "internal", + "total_cost": { + "currency": "CAD", + "value": "4250" + } + } + }, + "reference_codes": [ + "string" + ] + } +} diff --git a/modules/connectors/freightcom/schemas/rate_response.json b/modules/connectors/freightcom/schemas/rate_response.json new file mode 100644 index 0000000000..db82e35dd3 --- /dev/null +++ b/modules/connectors/freightcom/schemas/rate_response.json @@ -0,0 +1,47 @@ +{ + "status": { + "done": true, + "total": 0, + "complete": 0 + }, + "rates": [ + { + "carrier_name": "string", + "service_name": "string", + "service_id": "string", + "valid_until": { + "year": 2006, + "month": 6, + "day": 7 + }, + "total": { + "currency": "CAD", + "value": "4250" + }, + "base": { + "currency": "CAD", + "value": "4250" + }, + "surcharges": [ + { + "type": "fuel", + "amount": { + "currency": "CAD", + "value": "4250" + } + } + ], + "taxes": [ + { + "type": "fuel", + "amount": { + "currency": "CAD", + "value": "4250" + } + } + ], + "transit_time_days": 5, + "transit_time_not_available": true + } + ] +} diff --git a/modules/connectors/freightcom/schemas/shipping_request.json b/modules/connectors/freightcom/schemas/shipping_request.json new file mode 100644 index 0000000000..15a543f41e --- /dev/null +++ b/modules/connectors/freightcom/schemas/shipping_request.json @@ -0,0 +1,267 @@ +{ + "unique_id": "string", + "payment_method_id": "string", + "service_id": "string", + "details": { + "origin": { + "name": "Philip J Fry", + "address": { + "address_line_1": "200 University Avenue West", + "address_line_2": "string", + "unit_number": "42a", + "city": "Waterloo", + "region": "ON", + "country": "CA", + "postal_code": "string" + }, + "residential": true, + "tailgate_required": true, + "instructions": "string", + "contact_name": "string", + "phone_number": { + "number": "5554447777", + "extension": "123" + }, + "email_addresses": [ + "user@example.com" + ], + "receives_email_updates": true + }, + "destination": { + "name": "Philip J Fry", + "address": { + "address_line_1": "200 University Avenue West", + "address_line_2": "string", + "unit_number": "42a", + "city": "Waterloo", + "region": "ON", + "country": "CA", + "postal_code": "string" + }, + "residential": true, + "tailgate_required": true, + "instructions": "string", + "contact_name": "string", + "phone_number": { + "number": "5554447777", + "extension": "123" + }, + "email_addresses": [ + "user@example.com" + ], + "receives_email_updates": true, + "ready_at": { + "hour": 15, + "minute": 6 + }, + "ready_until": { + "hour": 15, + "minute": 6 + }, + "signature_requirement": "not-required" + }, + "expected_ship_date": { + "year": 2006, + "month": 6, + "day": 7 + }, + "packaging_type": "pallet", + "packaging_properties": { + "pallet_type": "ltl", + "has_stackable_pallets": true, + "dangerous_goods": "limited-quantity", + "dangerous_goods_details": { + "packaging_group": "string", + "goods_class": "string", + "description": "string", + "united_nations_number": "string", + "emergency_contact_name": "string", + "emergency_contact_phone_number": { + "number": "5554447777", + "extension": "123" + } + }, + "pallets": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + }, + "cuboid": { + "unit": "ft", + "l": 5, + "w": 5, + "h": 5 + } + }, + "description": "string", + "freight_class": "string", + "nmfc": "string", + "contents_type": "string", + "num_pieces": 0 + } + ], + "packages": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + }, + "cuboid": { + "unit": "ft", + "l": 5, + "w": 5, + "h": 5 + } + }, + "description": "string" + } + ], + "courierpaks": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + } + }, + "description": "string" + } + ], + "includes_return_label": false, + "special_handling_required": false, + "has_dangerous_goods": false, + "pallet_service_details": { + "limited_access_delivery_type": "construction-site", + "limited_access_delivery_other_name": "string", + "in_bond": true, + "in_bond_details": { + "type": "immediate-exportation", + "name": "string", + "address": "string", + "contact_method": "email-address", + "contact_email_address": "string", + "contact_phone_number": { + "number": "5554447777", + "extension": "123" + } + }, + "appointment_delivery": true, + "protect_from_freeze": true, + "threshold_pickup": true, + "threshold_delivery": true + } + }, + "insurance": { + "type": "internal", + "total_cost": { + "currency": "CAD", + "value": "4250" + } + }, + "reference_codes": [ + "string" + ] + }, + "customs_invoice": { + "source": "details", + "broker": { + "use_carrier": true, + "name": "string", + "account_number": "string", + "phone_number": { + "number": "5554447777", + "extension": "123" + }, + "fax_number": { + "number": "5554447777", + "extension": "123" + }, + "email_address": "string", + "usmca_number": "string", + "fda_number": "string" + }, + "details": { + "tax_recipient": { + "type": "shipper", + "shipper_tax_identifier": "string", + "receiver_tax_identifier": "string", + "third_party_tax_identifier": "string", + "other_tax_identifier": "string", + "name": "string", + "address": { + "address_line_1": "200 University Avenue West", + "address_line_2": "string", + "unit_number": "42a", + "city": "Waterloo", + "region": "ON", + "country": "CA", + "postal_code": "string" + }, + "phone_number": { + "number": "5554447777", + "extension": "123" + }, + "reason_for_export": "gift", + "additional_remarks": "string", + "comments": "string" + }, + "products": [ + { + "product_name": "string", + "weight": { + "unit": "lb", + "value": 2.95 + }, + "hs_code": "string", + "country_of_origin": "CA", + "num_units": 1, + "unit_price": { + "currency": "CAD", + "value": "4250" + }, + "description": "string" + } + ] + } + }, + "pickup_details": { + "pre_scheduled_pickup": true, + "date": { + "year": 2006, + "month": 6, + "day": 7 + }, + "ready_at": { + "hour": 15, + "minute": 6 + }, + "ready_until": { + "hour": 15, + "minute": 6 + }, + "pickup_location": "string", + "contact_name": "string", + "contact_phone_number": { + "number": "5554447777", + "extension": "123" + } + }, + "dispatch_details": { + "date": { + "year": 2006, + "month": 6, + "day": 7 + }, + "ready_at": { + "hour": 15, + "minute": 6 + }, + "ready_until": { + "hour": 15, + "minute": 6 + } + } +} diff --git a/modules/connectors/freightcom/schemas/shipping_response.json b/modules/connectors/freightcom/schemas/shipping_response.json new file mode 100644 index 0000000000..7a32f87abb --- /dev/null +++ b/modules/connectors/freightcom/schemas/shipping_response.json @@ -0,0 +1,228 @@ +{ + "shipment": { + "id": "string", + "unique_id": "string", + "state": "draft", + "transaction_number": "string", + "primary_tracking_number": "string", + "tracking_numbers": [ + "string" + ], + "tracking_url": "string", + "return_tracking_number": "string", + "bol_number": "string", + "pickup_confirmation_number": "string", + "details": { + "origin": { + "name": "Philip J Fry", + "address": { + "address_line_1": "200 University Avenue West", + "address_line_2": "string", + "unit_number": "42a", + "city": "Waterloo", + "region": "ON", + "country": "CA", + "postal_code": "string" + }, + "residential": true, + "tailgate_required": true, + "instructions": "string", + "contact_name": "string", + "phone_number": { + "number": "5554447777", + "extension": "123" + }, + "email_addresses": [ + "user@example.com" + ], + "receives_email_updates": true + }, + "destination": { + "name": "Philip J Fry", + "address": { + "address_line_1": "200 University Avenue West", + "address_line_2": "string", + "unit_number": "42a", + "city": "Waterloo", + "region": "ON", + "country": "CA", + "postal_code": "string" + }, + "residential": true, + "tailgate_required": true, + "instructions": "string", + "contact_name": "string", + "phone_number": { + "number": "5554447777", + "extension": "123" + }, + "email_addresses": [ + "user@example.com" + ], + "receives_email_updates": true, + "ready_at": { + "hour": 15, + "minute": 6 + }, + "ready_until": { + "hour": 15, + "minute": 6 + }, + "signature_requirement": "not-required" + }, + "expected_ship_date": { + "year": 2006, + "month": 6, + "day": 7 + }, + "packaging_type": "pallet", + "packaging_properties": { + "pallet_type": "ltl", + "has_stackable_pallets": true, + "dangerous_goods": "limited-quantity", + "dangerous_goods_details": { + "packaging_group": "string", + "goods_class": "string", + "description": "string", + "united_nations_number": "string", + "emergency_contact_name": "string", + "emergency_contact_phone_number": { + "number": "5554447777", + "extension": "123" + } + }, + "pallets": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + }, + "cuboid": { + "unit": "ft", + "l": 5, + "w": 5, + "h": 5 + } + }, + "description": "string", + "freight_class": "string", + "nmfc": "string", + "contents_type": "string", + "num_pieces": 0 + } + ], + "packages": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + }, + "cuboid": { + "unit": "ft", + "l": 5, + "w": 5, + "h": 5 + } + }, + "description": "string" + } + ], + "courierpaks": [ + { + "measurements": { + "weight": { + "unit": "lb", + "value": 2.95 + } + }, + "description": "string" + } + ], + "includes_return_label": false, + "special_handling_required": false, + "has_dangerous_goods": false, + "pallet_service_details": { + "limited_access_delivery_type": "construction-site", + "limited_access_delivery_other_name": "string", + "in_bond": true, + "in_bond_details": { + "type": "immediate-exportation", + "name": "string", + "address": "string", + "contact_method": "email-address", + "contact_email_address": "string", + "contact_phone_number": { + "number": "5554447777", + "extension": "123" + } + }, + "appointment_delivery": true, + "protect_from_freeze": true, + "threshold_pickup": true, + "threshold_delivery": true + } + }, + "insurance": { + "type": "internal", + "total_cost": { + "currency": "CAD", + "value": "4250" + } + }, + "reference_codes": [ + "string" + ] + }, + "transport_data": {}, + "labels": [ + { + "size": "letter", + "format": "pdf", + "url": "string", + "padded": true + } + ], + "customs_invoice_url": "string", + "rate": { + "carrier_name": "string", + "service_name": "string", + "service_id": "string", + "valid_until": { + "year": 2006, + "month": 6, + "day": 7 + }, + "total": { + "currency": "CAD", + "value": "4250" + }, + "base": { + "currency": "CAD", + "value": "4250" + }, + "surcharges": [ + { + "type": "fuel", + "amount": { + "currency": "CAD", + "value": "4250" + } + } + ], + "taxes": [ + { + "type": "fuel", + "amount": { + "currency": "CAD", + "value": "4250" + } + } + ], + "transit_time_days": 5, + "transit_time_not_available": true + }, + "order_source": "string" + } +} diff --git a/modules/connectors/freightcom/schemas/tracking_response.json b/modules/connectors/freightcom/schemas/tracking_response.json new file mode 100644 index 0000000000..b0310d62f0 --- /dev/null +++ b/modules/connectors/freightcom/schemas/tracking_response.json @@ -0,0 +1,14 @@ +{ + "events": [ + { + "type": "label-created", + "when": "string", + "where": { + "city": "string", + "region": "string", + "country": "string" + }, + "message": "string" + } + ] +} diff --git a/modules/connectors/freightcom/tests/freightcom/fixture.py b/modules/connectors/freightcom/tests/freightcom/fixture.py index becebb7dd7..4c631bc6bb 100644 --- a/modules/connectors/freightcom/tests/freightcom/fixture.py +++ b/modules/connectors/freightcom/tests/freightcom/fixture.py @@ -1,8 +1,19 @@ import karrio +import karrio.lib as lib +cached_payment_method_id = { + f"payment|freightcom|net_terms|api_key": dict( + id="string", + type= "net-terms", + label="Net Terms" + ) +} gateway = karrio.gateway["freightcom"].create( dict( - username="username", - password="password", - ) + api_key="api_key", + config=dict( + payment_method_type="net_terms" + ) + ), + cache=lib.Cache(**cached_payment_method_id), ) diff --git a/modules/connectors/freightcom/tests/freightcom/test_rate.py b/modules/connectors/freightcom/tests/freightcom/test_rate.py index 53bde5553c..ffd6efce97 100644 --- a/modules/connectors/freightcom/tests/freightcom/test_rate.py +++ b/modules/connectors/freightcom/tests/freightcom/test_rate.py @@ -1,168 +1,421 @@ +import datetime import unittest -from unittest.mock import patch -from karrio.core.utils import DP -from karrio.core.models import RateRequest -from karrio.core.errors import FieldError -from karrio import Rating +from unittest.mock import patch, ANY from .fixture import gateway +# from tests import logger + +import karrio +import karrio.lib as lib +import karrio.core.models as models class TestFreightcomRating(unittest.TestCase): def setUp(self): self.maxDiff = None - self.RateRequest = RateRequest(**RatePayload) + self.RateRequest = models.RateRequest(**RatePayload) def test_create_rate_request(self): request = gateway.mapper.create_rate_request(self.RateRequest) + self.assertEqual(request.serialize(), RateRequest) - self.assertEqual(request.serialize(), RateRequestXML) + def test_get_rate(self): + with patch("karrio.mappers.freightcom.proxy.lib.request") as mock: + mock.return_value = "{}" + karrio.Rating.fetch(self.RateRequest).from_(gateway) - def test_create_rate_request_from_package_preset_missing_weight(self): - with self.assertRaises(FieldError): - gateway.mapper.create_rate_request( - RateRequest(**RateWithPresetMissingDimensionPayload) + self.assertEqual( + mock.call_args[1]["url"], + f"{gateway.settings.server_url}/rate", ) - @patch("karrio.mappers.freightcom.proxy.http", return_value="") - def test_get_rates(self, http_mock): - Rating.fetch(self.RateRequest).from_(gateway) - - url = http_mock.call_args[1]["url"] - self.assertEqual(url, gateway.proxy.settings.server_url) - def test_parse_rate_response(self): - with patch("karrio.mappers.freightcom.proxy.http") as mock: - mock.return_value = RateResponseXml - parsed_response = Rating.fetch(self.RateRequest).from_(gateway).parse() - - self.assertListEqual(DP.to_dict(parsed_response), ParsedQuoteResponse) - - def test_parse_rate_response_error(self): - with patch("karrio.mappers.freightcom.proxy.http") as mock: - mock.return_value = RateErrorResponseXML - parsed_response = Rating.fetch(self.RateRequest).from_(gateway).parse() - - self.assertListEqual(DP.to_dict(parsed_response), ParsedRateError) + with patch("karrio.mappers.freightcom.proxy.lib.request") as mock: + mock.return_value = RateResponse + parsed_response = karrio.Rating.fetch(self.RateRequest).from_(gateway).parse() + self.assertListEqual(lib.to_dict(parsed_response), ParsedRateResponse) if __name__ == "__main__": unittest.main() + RatePayload = { - "shipper": {"postal_code": "H8Z2Z3", "country_code": "CA"}, - "recipient": {"postal_code": "H8Z2V4", "country_code": "CA"}, + "shipper": { + "company_name": "Test Company - From", + "address_line1": "9, Van Der Graaf Court", + "city": "Brampton", + "postal_code": "L4T3T1", + "country_code": "CA", + "state_code": "ON", + "email": "shipper@example.com", + "phone_number": "(123) 114 1499" + }, + "recipient": { + "company_name": "Test Company - Destination", + "address_line1": "1410 Fall River Rd", + "city": "Fall River", + "country_code": "CA", + "postal_code": "B2T1J1", + "residential": "true", + "state_code": "NS", + "email": "recipient@example.com", + "phone_number": "(999) 999 9999" + }, "parcels": [ { - "height": 3, - "length": 10, - "width": 3, - "weight": 4.0, + "height": 50, + "length": 50, + "weight": 20, + "width": 12, + "dimension_unit": "CM", + "weight_unit": "KG", + "description": "Package 1 Description" + }, + { + "height": 30, + "length": 50, + "weight": 20, + "width": 12, "dimension_unit": "CM", "weight_unit": "KG", + "description": "Package 2 Description" } ], - "services": ["freightcom_central_transport"], -} - -RateWithPresetMissingDimensionPayload = { - "shipper": {"postal_code": "H8Z2Z3", "country_code": "CA"}, - "recipient": {"postal_code": "H8Z2V4", "country_code": "CA"}, - "parcels": [{}], + "reference": "REF-001", + "options": { + "email_notification": True, + "shipping_date": datetime.datetime(2025, 2, 25, 1,0).strftime("%Y-%m-%dT%H:%M"), + } } -ParsedQuoteResponse = [ - [ - { - "carrier_id": "freightcom", - "carrier_name": "freightcom", - "currency": "CAD", - "extra_charges": [ - {"amount": 177.0, "currency": "CAD", "name": "Base charge"} - ], - "meta": { - "rate_provider": "Freightcom", - "service_name": "central_transport", - }, - "service": "freightcom_central_transport", - "total_charge": 177.0, - "transit_days": 1, +ParsedRateResponse = [ + [ + { + "carrier_id": "freightcom", + "carrier_name": "freightcom", + "currency": "CAD", + "extra_charges": [ + { + "amount": 33.68, + "currency": "CAD", + "name": "Base charge" }, { - "carrier_id": "freightcom", - "carrier_name": "freightcom", - "currency": "CAD", - "extra_charges": [ - {"amount": 28.65, "currency": "CAD", "name": "Base charge"} - ], - "meta": {"rate_provider": "Freightcom", "service_name": "estes"}, - "service": "freightcom_estes", - "total_charge": 28.65, - "transit_days": 1, + "amount": 10.01, + "currency": "CAD", + "name": "fuel" }, { - "carrier_id": "freightcom", - "carrier_name": "freightcom", - "currency": "CAD", - "extra_charges": [ - {"amount": 46.27, "currency": "CAD", "name": "Base charge"}, - {"amount": 6.25, "currency": "CAD", "name": "Fuel surcharge"}, - ], - "meta": {"rate_provider": "Freightcom", "service_name": "usf_holland"}, - "service": "freightcom_usf_holland", - "total_charge": 52.52, - "transit_days": 0, + "amount": 0.51, + "currency": "CAD", + "name": "carbon-surcharge" + }, + { + "amount": 2.18, + "currency": "CAD", + "name": "residential-delivery" }, - ], - [ { - "carrier_id": "freightcom", - "carrier_name": "freightcom", - "code": "CarrierErrorMessage", - "message": "Polaris:Military Base Delivery,Saturday Pickup,Construction Site,BORDER FEE,Homeland Security,Limited Access,Saturday Delivery,Sort and Segregate Charge,Pier Charge", + "amount": 6.96, + "currency": "CAD", + "name": "tax-hst-ns" } - ], -] - -ParsedRateError = [ - [], - [ - { - "code": "Error", - "carrier_id": "freightcom", - "carrier_name": "freightcom", - "message": "Required field: company is missing.", + ], + "meta": { + "rate_provider": "canpar", + "service_name": "freightcom_canpar_ground" + }, + "service": "freightcom_canpar_ground", + "total_charge": 53.34, + "transit_days": 2 + }, + { + "carrier_id": "freightcom", + "carrier_name": "freightcom", + "currency": "CAD", + "extra_charges": [ + { + "amount": 40.87, + "currency": "CAD", + "name": "Base charge" + }, + { + "amount": 12.54, + "currency": "CAD", + "name": "fuel" + }, + { + "amount": 2.78, + "currency": "CAD", + "name": "residential-delivery" + }, + { + "amount": 8.43, + "currency": "CAD", + "name": "tax-hst-ns" } - ], + ], + "meta": { + "rate_provider": "fedex", + "service_name": "freightcom_fedex_ground" + }, + "service": "freightcom_fedex_ground", + "total_charge": 64.62, + "transit_days": 2 + }, + { + "carrier_id": "freightcom", + "carrier_name": "freightcom", + "currency": "CAD", + "extra_charges": [ + { + "amount": 41.34, + "currency": "CAD", + "name": "Base charge" + }, + { + "amount": 11.24, + "currency": "CAD", + "name": "fuel" + }, + { + "amount": 7.89, + "currency": "CAD", + "name": "tax-hst-ns" + } + ], + "meta": { + "rate_provider": "purolator", + "service_name": "freightcom_purolator_ground" + }, + "service": "freightcom_purolator_ground", + "total_charge": 60.47, + "transit_days": 3 + } + ], + [] ] -RateRequestXML = f""" - - - - - - - - -""" -RateErrorResponseXML = f""" - - - - -""" +RateRequest = { + "details": { + "destination": { + "address": { + "address_line_1": "1410 Fall River Rd", + "city": "Fall River", + "country": "CA", + "postal_code": "B2T1J1", + "region": "NS", + }, + "email_addresses": ["recipient@example.com"], + 'name': 'Test Company - Destination', + "phone_number": {"number": "(999) 999 9999"}, + "ready_at": { + "hour": 10, "minute": 0 + }, + "ready_until": { + "hour": 17, "minute": 0 + }, + "receives_email_updates": True, + "residential": False, + "signature_requirement": "not-required" + }, + "origin": { + "address": { + "address_line_1": "9, Van Der Graaf Court", + "city": "Brampton", + "country": "CA", + "postal_code": "L4T3T1", + "region": "ON", + }, + "name": "Test Company - From", + "email_addresses": ["shipper@example.com"], + "phone_number": {"number": "(123) 114 1499"}, + "residential": False + }, + "expected_ship_date": {"day": 25, "month": 2, "year": 2025}, + "packaging_type": "package", + "packaging_properties": { + "packages": [ + { + "description": "Package 1 Description", + "measurements": { + "cuboid": { + "h": 50.0, + "l": 50.0, + "unit": "cm", + "w": 12.0 + }, + "weight": { + "unit": "kg", + "value": 20.0 + } + } + }, + { + "description": "Package 2 Description", + "measurements": { + "cuboid": { + "h": 30.0, + "l": 50.0, + "unit": "cm", + "w": 12.0 + }, + "weight": { + "unit": "kg", + "value": 20.0 + } + } + } + ], + }, + "reference_codes": ["REF-001"] + } +} -RateResponseXml = """ - - - - - - - - - - - +RateResponse = """ +{ + "status": { + "done": true, + "total": 99, + "complete": 99 + }, + "rates": [ + { + "service_id": "canpar.ground", + "valid_until": { + "year": 2025, + "month": 3, + "day": 3 + }, + "total": { + "value": "5334", + "currency": "CAD" + }, + "base": { + "value": "3368", + "currency": "CAD" + }, + "surcharges": [ + { + "type": "fuel", + "amount": { + "value": "1001", + "currency": "CAD" + } + }, + { + "type": "carbon-surcharge", + "amount": { + "value": "51", + "currency": "CAD" + } + }, + { + "type": "residential-delivery", + "amount": { + "value": "218", + "currency": "CAD" + } + } + ], + "taxes": [ + { + "type": "tax-hst-ns", + "amount": { + "value": "696", + "currency": "CAD" + } + } + ], + "transit_time_days": 2, + "transit_time_not_available": false, + "carrier_name": "Canpar", + "service_name": "Ground" + }, + { + "service_id": "fedex-courier.ground", + "valid_until": { + "year": 2025, + "month": 3, + "day": 3 + }, + "total": { + "value": "6462", + "currency": "CAD" + }, + "base": { + "value": "4087", + "currency": "CAD" + }, + "surcharges": [ + { + "type": "fuel", + "amount": { + "value": "1254", + "currency": "CAD" + } + }, + { + "type": "residential-delivery", + "amount": { + "value": "278", + "currency": "CAD" + } + } + ], + "taxes": [ + { + "type": "tax-hst-ns", + "amount": { + "value": "843", + "currency": "CAD" + } + } + ], + "transit_time_days": 2, + "transit_time_not_available": false, + "carrier_name": "FedEx Courier", + "service_name": "Ground" + }, + { + "service_id": "purolatorcourier.ground", + "valid_until": { + "year": 2025, + "month": 3, + "day": 3 + }, + "total": { + "value": "6047", + "currency": "CAD" + }, + "base": { + "value": "4134", + "currency": "CAD" + }, + "surcharges": [ + { + "type": "fuel", + "amount": { + "value": "1124", + "currency": "CAD" + } + } + ], + "taxes": [ + { + "type": "tax-hst-ns", + "amount": { + "value": "789", + "currency": "CAD" + } + } + ], + "transit_time_days": 3, + "transit_time_not_available": false, + "carrier_name": "Purolator", + "service_name": "Ground" + } + ] +} """ diff --git a/modules/connectors/freightcom/tests/freightcom/test_shipment.py b/modules/connectors/freightcom/tests/freightcom/test_shipment.py index cb6ca3da2f..8330d3f817 100644 --- a/modules/connectors/freightcom/tests/freightcom/test_shipment.py +++ b/modules/connectors/freightcom/tests/freightcom/test_shipment.py @@ -1,133 +1,149 @@ +import datetime import unittest from unittest.mock import patch, ANY from .fixture import gateway +# from tests import logger import karrio -from karrio.core.utils import DP -from karrio.core.models import ShipmentRequest, ShipmentCancelRequest +import karrio.lib as lib +import karrio.core.models as models -class TestFreightcomShipment(unittest.TestCase): +class TestFreightcomShipping(unittest.TestCase): def setUp(self): self.maxDiff = None - self.ShipmentRequest = ShipmentRequest(**shipment_data) - self.ShipmentCancelRequest = ShipmentCancelRequest(**shipment_cancel_data) + self.ShipmentRequest = models.ShipmentRequest(**ShipmentPayload) + self.ShipmentCancelRequest = models.ShipmentCancelRequest(**ShipmentCancelPayload) def test_create_shipment_request(self): request = gateway.mapper.create_shipment_request(self.ShipmentRequest) - - self.assertEqual(request.serialize(), ShipmentRequestXML) + self.assertEqual(request.serialize(), ShipmentRequest) def test_create_cancel_shipment_request(self): request = gateway.mapper.create_cancel_shipment_request( self.ShipmentCancelRequest ) - - self.assertEqual(request.serialize(), ShipmentCancelRequestXML) + self.assertEqual(request.serialize(), ShipmentCancelRequest) def test_create_shipment(self): - with patch("karrio.mappers.freightcom.proxy.http") as mock: - mock.return_value = "" + with patch("karrio.mappers.freightcom.proxy.lib.request") as mock: + mock.return_value = "{}" karrio.Shipment.create(self.ShipmentRequest).from_(gateway) - url = mock.call_args[1]["url"] - self.assertEqual(url, gateway.settings.server_url) + self.assertEqual( + mock.call_args[1]["url"], + f"{gateway.settings.server_url}/shipment", + ) def test_cancel_shipment(self): - with patch("karrio.mappers.freightcom.proxy.http") as mock: - mock.return_value = "" + with patch("karrio.mappers.freightcom.proxy.lib.request") as mock: + mock.return_value = "{}" karrio.Shipment.cancel(self.ShipmentCancelRequest).from_(gateway) - url = mock.call_args[1]["url"] - self.assertEqual(url, gateway.settings.server_url) + self.assertEqual( + mock.call_args[1]["url"], + f"{gateway.settings.server_url}/shipment/{self.ShipmentCancelRequest.shipment_identifier}", + ) def test_parse_shipment_response(self): - with patch("karrio.mappers.freightcom.proxy.http") as mock: - mock.return_value = ShipmentResponseXML - parsed_response = ( - karrio.Shipment.create(self.ShipmentRequest).from_(gateway).parse() - ) + with patch("karrio.mappers.freightcom.proxy.lib.request") as mock: + mock.return_value = ShipmentResponse + response = karrio.Shipment.create(self.ShipmentRequest).from_(gateway) + + with patch("karrio.providers.freightcom.utils.request") as mock: + mock.return_value = "" + parsed_response = response.parse() + print(parsed_response) - self.assertEqual(DP.to_dict(parsed_response), ParsedShipmentResponse) + self.assertListEqual(lib.to_dict(parsed_response), ParsedShipmentResponse) def test_parse_cancel_shipment_response(self): - with patch("karrio.mappers.freightcom.proxy.http") as mock: - mock.return_value = ShipmentCancelResponseXML + with patch("karrio.mappers.freightcom.proxy.lib.request") as mock: + mock.return_value = ShipmentCancelResponse parsed_response = ( - karrio.Shipment.cancel(self.ShipmentCancelRequest) - .from_(gateway) - .parse() + karrio.Shipment.cancel(self.ShipmentCancelRequest).from_(gateway).parse() ) - - self.assertEqual( - DP.to_dict(parsed_response), DP.to_dict(ParsedCancelShipmentResponse) + self.assertListEqual( + lib.to_dict(parsed_response), ParsedCancelShipmentResponse ) if __name__ == "__main__": unittest.main() -shipment_cancel_data = {"shipment_identifier": "383363"} -shipment_data = { +ShipmentPayload = { "shipper": { - "company_name": "CGI", - "address_line1": "502 MAIN ST N", - "city": "MONTREAL", - "postal_code": "H2B1A0", + "company_name": "Test Company - From", + "address_line1": "9, Van Der Graaf Court", + "city": "Brampton", + "postal_code": "L4T3T1", "country_code": "CA", - "person_name": "Bob", - "phone_number": "1 (450) 823-8432", - "state_code": "QC", + "state_code": "ON", + "email": "shipper@example.com", + "phone_number": "(123) 114 1499" }, "recipient": { - "company_name": "CGI", - "address_line1": "23 jardin private", - "city": "Ottawa", - "postal_code": "K1K4T3", + "company_name": "Test Company - Destination", + "address_line1": "1410 Fall River Rd", + "city": "Fall River", "country_code": "CA", - "person_name": "Jain", - "state_code": "ON", + "postal_code": "B2T1J1", + "residential": "true", + "state_code": "NS", + "email": "recipient@example.com", + "phone_number": "(999) 999 9999" }, "parcels": [ { - "height": 9, - "length": 6, + "height": 50, + "length": 50, + "weight": 20, "width": 12, - "weight": 20.0, "dimension_unit": "CM", "weight_unit": "KG", + "description": "Package 1 Description" + }, + { + "height": 30, + "length": 50, + "weight": 20, + "width": 12, + "dimension_unit": "CM", + "weight_unit": "KG", + "description": "Package 2 Description" } ], - "service": "freightcom_central_transport", - "options": {"cash_on_delivery": 10.5, "insurance": 70.0}, + "service": "freightcom_canpar_ground", + "options": { + "signature_confirmation": True, + "shipping_date": datetime.datetime(2025, 2, 25, 1, 0).strftime("%Y-%m-%dT%H:%M"), + }, + "reference": "#Order 11111", +} + +ShipmentCancelPayload = { + "shipment_identifier": "shipment_id", } ParsedShipmentResponse = [ { "carrier_id": "freightcom", "carrier_name": "freightcom", - "docs": {"label": ANY, "invoice": ANY}, - "meta": {"rate_provider": "Freightcom", "service_name": "central_transport"}, - "selected_rate": { - "carrier_id": "freightcom", - "carrier_name": "freightcom", - "currency": "CAD", - "extra_charges": [ - {"amount": 30.74, "currency": "CAD", "name": "Base charge"}, - {"amount": 1.08, "currency": "CAD", "name": "Other"}, - ], - "meta": { - "rate_provider": "Freightcom", - "service_name": "central_transport", - }, - "service": "freightcom_central_transport", - "total_charge": 31.82, - "transit_days": 0, + "docs": {}, + 'label_type': 'PDF', + "meta": { + 'carrier_tracking_link': 'https://www.ups.com/WebTracking?trackingNumber=1ZXXXXXXXXXXXXXXXX', + 'freightcom_service_id': 'ups.standard', + 'freightcom_unique_id': '38a8b937-4262-497b-8f5c-b9d9d4c6bae6', + 'rate_provider': 'ups', + 'service_name': 'freightcom_ups_standard', + 'tracking_numbers': ['1ZXXXXXXXXXXXXXXXX'] + }, + + "shipment_identifier": "uQeh1XwbVIbIyP9mEPtVM2puAFZYmAYA", + "tracking_number": "1ZXXXXXXXXXXXXXXXX" }, - "shipment_identifier": "181004", - "tracking_number": "052800410000484", - }, [], ] @@ -141,61 +157,277 @@ def test_parse_cancel_shipment_response(self): [], ] +ShipmentRequest = { + "details": { + "destination": { + "address": { + "address_line_1": "1410 Fall River Rd", + "city": "Fall River", + "country": "CA", + "postal_code": "B2T1J1", + "region": "NS", + }, + "email_addresses": ["recipient@example.com"], + 'name': 'Test Company - Destination', + "phone_number": {"number": "(999) 999 9999"}, + "ready_at": { + "hour": 10, "minute": 0 + }, + "ready_until": { + "hour": 17, "minute": 0 + }, + "receives_email_updates": True, + "residential": False, + "signature_requirement": "required" + }, + "origin": { + "address": { + "address_line_1": "9, Van Der Graaf Court", + "city": "Brampton", + "country": "CA", + "postal_code": "L4T3T1", + "region": "ON", + }, + "name": "Test Company - From", + "email_addresses": ["shipper@example.com"], + "phone_number": {"number": "(123) 114 1499"}, + "residential": False + }, + "expected_ship_date": {"day": 25, "month": 2, "year": 2025}, + "packaging_type": "package", + "packaging_properties": { + "packages": [ + { + "description": "Package 1 Description", + "measurements": { + "cuboid": { + "h": 50.0, + "l": 50.0, + "unit": "cm", + "w": 12.0 + }, + "weight": { + "unit": "kg", + "value": 20.0 + } + } + }, + { + "description": "Package 2 Description", + "measurements": { + "cuboid": { + "h": 30.0, + "l": 50.0, + "unit": "cm", + "w": 12.0 + }, + "weight": { + "unit": "kg", + "value": 20.0 + } + } + } + ], + }, + "reference_codes": ["#Order 11111"] + }, + 'payment_method_id': 'string', + "service_id": "canpar.ground", + "unique_id": ANY +} -ShipmentRequestXML = """ - - - - - - - - - - - -""" +ShipmentCancelRequest = "shipment_id" -ShipmentResponseXML = """ - - - - - - - - [base-64 encoded String] - [base-64 encoded String] - - - - - - - - - - - -""" -ShipmentCancelRequestXML = """ - - - - +ShipmentResponse = """ +{ +"shipment": { + "id": "uQeh1XwbVIbIyP9mEPtVM2puAFZYmAYA", + "unique_id": "38a8b937-4262-497b-8f5c-b9d9d4c6bae6", + "state": "waiting-for-scheduling", + "transaction_number": "19989362", + "primary_tracking_number": "1ZXXXXXXXXXXXXXXXX", + "tracking_numbers": [ + "1ZXXXXXXXXXXXXXXXX", + "1ZXXXXXXXXXXXXXXXX" + ], + "tracking_url": "https://www.ups.com/WebTracking?trackingNumber=1ZXXXXXXXXXXXXXXXX", + "return_tracking_number": "", + "bolnumber": "", + "pickup_confirmation_number": "", + "details": { + "id": "HNrzG2iRHKJ6XN0CQwYgKBQnABvx2Yi5", + "expected_ship_date": { + "year": 2025, + "month": 2, + "day": 12 + }, + "origin": { + "searchable_id": "", + "name": "Cheques Plus", + "address": { + "address_line1": "4054 Rue Alfred Laliberté", + "address_line2": "", + "unit_number": "", + "city": "Boisbriand", + "region": "QC", + "country": "CA", + "postal_code": "J7H 1P8", + "validated": false + }, + "residential": false, + "business_type": "", + "tailgate_required": false, + "instructions": "", + "contact_name": "Shipping", + "phone_number": { + "number": "+1 450-323-6247", + "extension": "" + }, + "email_addresses": [ + "sales@chequesplus.com" + ], + "receives_email_updates": false, + "address_book_contact_id": "" + }, + "destination": { + "searchable_id": "", + "name": "ASAP Cheques", + "address": { + "address_line1": "623 Fortune Crescent #100", + "address_line2": "", + "unit_number": "", + "city": "Kingston", + "region": "ON", + "country": "CA", + "postal_code": "K7P 0L5", + "validated": false + }, + "residential": false, + "business_type": "", + "tailgate_required": false, + "instructions": "", + "contact_name": "ASAP Cheques Kingston", + "phone_number": { + "number": "+1 888-324-3783", + "extension": "" + }, + "email_addresses": [ + "admin@shipngo.ca" + ], + "receives_email_updates": false, + "address_book_contact_id": "", + "ready_at": { + "hour": 10, + "minute": 0, + "populated": true + }, + "ready_until": { + "hour": 17, + "minute": 0, + "populated": true + }, + "signature_requirement": "not-required" + }, + "alternate_destination": null, + "reference_codes": [ + "ss" + ], + "packaging_type": "package", + "packaging_properties": { + "packages": [ + { + "measurements": { + "cuboid": { + "l": 10, + "w": 20, + "h": 18.2, + "unit": "cm" + }, + "weight": { + "value": 1, + "unit": "kg" + } + }, + "description": "N/A", + "special_handling_required": false + }, + { + "measurements": { + "cuboid": { + "l": 10, + "w": 33.7, + "h": 18.2, + "unit": "cm" + }, + "weight": { + "value": 1, + "unit": "kg" + } + }, + "description": "N/A", + "special_handling_required": false + } + ], + "includes_return_label": false + }, + "insurance": null, + "billing_contact": null + }, + "transport_data": null, + "labels": [ + { + "size": "letter", + "format": "pdf", + "url": "https://s3.us-east-2.amazonaws.com/ssd-test-external/labels/uQeh1XwbVIbIyP9mEPtVM2puAFZYmAYA/yRWNRmUkCGMKIZOjMHNUSy9JlXPYjvVb/shipping-label-19989362-letter.pdf", + "padded": false + }, + { + "size": "a6", + "format": "zpl", + "url": "https://s3.us-east-2.amazonaws.com/ssd-test-external/labels/uQeh1XwbVIbIyP9mEPtVM2puAFZYmAYA/yRWNRmUkCGMKIZOjMHNUSy9JlXPYjvVb/shipping-label-19989362-a6.zpl", + "padded": false + }, + { + "size": "a6", + "format": "pdf", + "url": "https://s3.us-east-2.amazonaws.com/ssd-test-external/labels/uQeh1XwbVIbIyP9mEPtVM2puAFZYmAYA/yRWNRmUkCGMKIZOjMHNUSy9JlXPYjvVb/shipping-label-19989362-a6.pdf", + "padded": false + }, + { + "size": "a6", + "format": "pdf", + "url": "https://s3.us-east-2.amazonaws.com/ssd-test-external/labels/uQeh1XwbVIbIyP9mEPtVM2puAFZYmAYA/yRWNRmUkCGMKIZOjMHNUSy9JlXPYjvVb/shipping-label-19989362-a6-w-padding.pdf", + "padded": true + } + ], + "customs_invoice_url": "", + "rate": { + "service_id": "ups.standard", + "valid_until": { + "year": 2025, + "month": 2, + "day": 20 + }, + "total": { + "value": "1779", + "currency": "CAD" + }, + "base": { + "value": "1779", + "currency": "CAD" + }, + "surcharges": [], + "taxes": [], + "transit_time_days": 1, + "transit_time_not_available": false, + "carrier_name": "UPS", + "service_name": "Standard" + }, + "order_source": "Api" + } +} """ -ShipmentCancelResponseXML = """ - - - - - +ShipmentCancelResponse = """{} """ diff --git a/modules/connectors/freightcom/vendor/documentation/Freightcom API v3.2.3.pdf b/modules/connectors/freightcom/vendor/documentation/Freightcom API v3.2.3.pdf deleted file mode 100644 index 9b119dce2a..0000000000 Binary files a/modules/connectors/freightcom/vendor/documentation/Freightcom API v3.2.3.pdf and /dev/null differ diff --git a/modules/connectors/freightcom/vendor/sample/sample_quote_reply.xml b/modules/connectors/freightcom/vendor/sample/sample_quote_reply.xml deleted file mode 100644 index 31da0921f4..0000000000 --- a/modules/connectors/freightcom/vendor/sample/sample_quote_reply.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/sample/sample_quote_request.xml b/modules/connectors/freightcom/vendor/sample/sample_quote_request.xml deleted file mode 100644 index b0398cdfb3..0000000000 --- a/modules/connectors/freightcom/vendor/sample/sample_quote_request.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/sample/sample_shipment_cancel_reply.xml b/modules/connectors/freightcom/vendor/sample/sample_shipment_cancel_reply.xml deleted file mode 100644 index 0b03069080..0000000000 --- a/modules/connectors/freightcom/vendor/sample/sample_shipment_cancel_reply.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/sample/sample_shipment_cancel_request.xml b/modules/connectors/freightcom/vendor/sample/sample_shipment_cancel_request.xml deleted file mode 100644 index 38068e493b..0000000000 --- a/modules/connectors/freightcom/vendor/sample/sample_shipment_cancel_request.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/sample/sample_shipping_reply.xml b/modules/connectors/freightcom/vendor/sample/sample_shipping_reply.xml deleted file mode 100644 index 6d4ce49da2..0000000000 --- a/modules/connectors/freightcom/vendor/sample/sample_shipping_reply.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - [base-64 encoded String] - [base-64 encoded String] - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/sample/sample_shipping_request.xml b/modules/connectors/freightcom/vendor/sample/sample_shipping_request.xml deleted file mode 100644 index 686816c876..0000000000 --- a/modules/connectors/freightcom/vendor/sample/sample_shipping_request.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/connectors/freightcom/vendor/schemas/error.xsd b/modules/connectors/freightcom/vendor/schemas/error.xsd deleted file mode 100644 index 41443010d9..0000000000 --- a/modules/connectors/freightcom/vendor/schemas/error.xsd +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/schemas/quote_reply.xsd b/modules/connectors/freightcom/vendor/schemas/quote_reply.xsd deleted file mode 100644 index d1cb551e09..0000000000 --- a/modules/connectors/freightcom/vendor/schemas/quote_reply.xsd +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/schemas/quote_request.xsd b/modules/connectors/freightcom/vendor/schemas/quote_request.xsd deleted file mode 100644 index 341c301ccf..0000000000 --- a/modules/connectors/freightcom/vendor/schemas/quote_request.xsd +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/schemas/shipment_cancel_reply.xsd b/modules/connectors/freightcom/vendor/schemas/shipment_cancel_reply.xsd deleted file mode 100644 index 69e896328a..0000000000 --- a/modules/connectors/freightcom/vendor/schemas/shipment_cancel_reply.xsd +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/schemas/shipment_cancel_request.xsd b/modules/connectors/freightcom/vendor/schemas/shipment_cancel_request.xsd deleted file mode 100644 index 0b900a395f..0000000000 --- a/modules/connectors/freightcom/vendor/schemas/shipment_cancel_request.xsd +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/schemas/shipping_reply.xsd b/modules/connectors/freightcom/vendor/schemas/shipping_reply.xsd deleted file mode 100644 index 584b8c86f2..0000000000 --- a/modules/connectors/freightcom/vendor/schemas/shipping_reply.xsd +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/connectors/freightcom/vendor/schemas/shipping_request.xsd b/modules/connectors/freightcom/vendor/schemas/shipping_request.xsd deleted file mode 100644 index a5d9cedea3..0000000000 --- a/modules/connectors/freightcom/vendor/schemas/shipping_request.xsd +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/core/karrio/server/providers/extension/models/freightcom.py b/modules/core/karrio/server/providers/extension/models/freightcom.py index 751ac61857..c83e5c5dbb 100644 --- a/modules/core/karrio/server/providers/extension/models/freightcom.py +++ b/modules/core/karrio/server/providers/extension/models/freightcom.py @@ -10,9 +10,6 @@ class Meta: verbose_name = "Freightcom Settings" verbose_name_plural = "Freightcom Settings" - username = models.CharField(max_length=200) - password = models.CharField(max_length=200) - @property def carrier_name(self) -> str: return self.CARRIER_NAME