Repository URL to install this package:
|
Version:
0.4.190 ▾
|
lib-py-b2b
/
carrier.py
|
|---|
from .profile import Profile
from enum import Enum
from aws_xray_sdk.core import xray_recorder
class CarrierType(Enum):
FEDEX_SHIP_MGR = 'FEDEX_SHIP_MGR'
FEDEX_API = 'FEDEX_API'
UPS = 'UPS'
@property
def label_print_support(self):
if self.name == 'FEDEX_API':
return True
else:
return False
class CarrierIntegration:
@staticmethod
@xray_recorder.capture()
def get_carrier( profile: Profile, carrier_type: CarrierType=None, container_support = False):
if carrier_type:
_carrier_type = carrier_type
else:
_carrier_type = profile.fulfillment_config.get_carrier_type()
if _carrier_type == CarrierType.FEDEX_SHIP_MGR:
if container_support:
from .fedex_ship_mgr_container import FedexShipManagerContainer
return FedexShipManagerContainer(profile)
else:
from .fedex_ship_mgr import FedexShipManager
return FedexShipManager(profile)
elif _carrier_type == CarrierType.FEDEX_API:
from .fedex_api import FedexAPI
return FedexAPI(profile)
else:
return None
pass
def __init__(self, profile):
self.profile = profile
def track_shipment(self, fulfillment):
pass
def get_shipping_rates(self, fulfillment):
pass
def remove_shipment(self, fulfillment):
pass
def create_shipment(self, fulfillment):
pass
def print_labels(self, fulfillment):
pass
class TrackingUrl:
@staticmethod
def url_for(tracking_number, carrier: CarrierType):
if carrier in (CarrierType.FEDEX_SHIP_MGR, CarrierType.FEDEX_API):
return f"https://www.fedex.com/apps/fedextrack/?action=track&tracknumbers={str(tracking_number)}"
return f"https://www.fedex.com/apps/fedextrack/?action=track&tracknumbers={str(tracking_number)}"