karrio-easypost 2025.5.6__py3-none-any.whl → 2026.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,6 +55,23 @@ def _extract_details(
55
55
  join=True,
56
56
  separator=", ",
57
57
  ),
58
+ timestamp=lib.fiso_timestamp(event.get("datetime"), current_format="%Y-%m-%dT%H:%M:%SZ"),
59
+ status=next(
60
+ (
61
+ s.name
62
+ for s in list(provider_units.TrackingStatus)
63
+ if event.get("status") in s.value
64
+ ),
65
+ None,
66
+ ),
67
+ reason=next(
68
+ (
69
+ r.name
70
+ for r in list(provider_units.TrackingIncidentReason)
71
+ if event.get("status") in r.value
72
+ ),
73
+ None,
74
+ ),
58
75
  )
59
76
  for event in events
60
77
  if event.get("datetime") is not None
@@ -5,6 +5,16 @@ import karrio.core.units as units
5
5
  import karrio.core.models as models
6
6
 
7
7
 
8
+ # EasyPost API carrier name normalization mapping
9
+ # Maps EasyPost's carrier variations to Karrio's standard CarrierId enum names
10
+ CARRIER_NAME_NORMALIZATION = {
11
+ "UPSDAP": "UPS",
12
+ "UPS DAP": "UPS",
13
+ "FedExDefault": "FedEx",
14
+ "FedEx Default": "FedEx",
15
+ }
16
+
17
+
8
18
  class LabelType(lib.Enum):
9
19
  PDF = "PDF"
10
20
  ZPL = "ZPL"
@@ -862,13 +872,38 @@ class Service(lib.StrEnum):
862
872
 
863
873
  @staticmethod
864
874
  def info(serviceName, carrier):
865
- rate_provider = CarrierId.map(carrier).name_or_key
866
- service = Service.map(serviceName)
875
+ # Normalize carrier name to handle EasyPost API variations
876
+ normalized_carrier = CARRIER_NAME_NORMALIZATION.get(carrier, carrier)
877
+ rate_provider = CarrierId.map(normalized_carrier).name_or_key
878
+
879
+ # Try carrier-qualified lookup first to avoid service name collisions
880
+ service_code = None
881
+ carrier_enum = CarrierId.map(normalized_carrier)
882
+
883
+ if carrier_enum.name and serviceName:
884
+ # Construct carrier-qualified service code: easypost_{carrier}_{service}
885
+ carrier_code = carrier_enum.name
886
+ service_snake = lib.to_snake_case(serviceName)
887
+ qualified_service_name = f"easypost_{carrier_code}_{service_snake}"
888
+
889
+ # Check if the qualified service exists
890
+ # Note: We cannot use Service.map() because Python enums with duplicate
891
+ # values create aliases, so Service.easypost_usps_priority and
892
+ # Service.easypost_canadapost_priority are the SAME object (both = 'Priority')
893
+ if hasattr(Service, qualified_service_name):
894
+ service_code = qualified_service_name
895
+
896
+ # Fallback to original behavior if qualified lookup fails
897
+ if not service_code:
898
+ service = Service.map(serviceName)
899
+ service_code = service.name_or_key
900
+
901
+ # Format the service name for display
867
902
  service_name = re.sub(
868
- r"((?<=[a-z])[A-Z]|(?<!\A)[A-Z](?=[a-z]))", r" \1", service.name_or_key
903
+ r"((?<=[a-z])[A-Z]|(?<!\A)[A-Z](?=[a-z]))", r" \1", service_code
869
904
  ).replace("easypost_", "")
870
905
 
871
- return rate_provider, service.name_or_key, service_name
906
+ return rate_provider, service_code, service_name
872
907
 
873
908
 
874
909
  class CarrierId(lib.StrEnum):
@@ -941,6 +976,24 @@ class CarrierId(lib.StrEnum):
941
976
  return {key: enum.value for key, enum in CarrierId.__members__.items()}
942
977
 
943
978
 
979
+ class TrackingStatus(lib.Enum):
980
+ on_hold = ["pre_transit", "unknown"]
981
+ delivered = ["delivered"]
982
+ in_transit = ["in_transit"]
983
+ out_for_delivery = ["out_for_delivery"]
984
+ ready_for_pickup = ["available_for_pickup"]
985
+ delivery_failed = ["failure", "error", "return_to_sender"]
986
+ cancelled = ["cancelled"]
987
+
988
+
989
+ class TrackingIncidentReason(lib.Enum):
990
+ """Maps EasyPost exception codes to normalized TrackingIncidentReason."""
991
+ carrier_damaged_parcel = ["damaged"]
992
+ consignee_refused = ["refused"]
993
+ consignee_not_home = ["not_home"]
994
+ unknown = []
995
+
996
+
944
997
  class ShippingOption(lib.Enum):
945
998
  easypost_additional_handling = lib.OptionEnum("additional_handling", bool)
946
999
  easypost_address_validation_level = lib.OptionEnum("address_validation_level")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: karrio_easypost
3
- Version: 2025.5.6
3
+ Version: 2026.1
4
4
  Summary: Karrio - EasyPost Shipping extension
5
5
  Author-email: karrio <hello@karrio.io>
6
6
  License-Expression: LGPL-3.0
@@ -6,8 +6,8 @@ karrio/plugins/easypost/__init__.py,sha256=UwD6JC4LkF47ZodzuHvaq8l__713e_aCLTej3
6
6
  karrio/providers/easypost/__init__.py,sha256=v89eaMBV-Kn7Za7WzrXpSkKfFG2HSRB0SXByoI2hOec,333
7
7
  karrio/providers/easypost/error.py,sha256=GrONkEpEi8ujKNvd4I9Z9xGfqFrc4QE2wOkoMJOFEjk,953
8
8
  karrio/providers/easypost/rate.py,sha256=_uJ_9PgB5AM_oMDjAsY_wFd_DUz-zm_zu4qPkSyZHTY,7710
9
- karrio/providers/easypost/tracking.py,sha256=hWjYA7rKBQgqLcXB2X1gOjRLLrBXk-VateE5UpjbFWg,4245
10
- karrio/providers/easypost/units.py,sha256=Cw_yhRnBDWejKmQ3qWxq3Jo-RcLYw7kAbsZHRuOkt30,52724
9
+ karrio/providers/easypost/tracking.py,sha256=DvjNyjLDFHDZ9Iu9zJjZwxOBCb8rXz3uBtwu8dlAmxg,4913
10
+ karrio/providers/easypost/units.py,sha256=4VrHtGONrsqDv7zwWu_GC37N_V8RjXV1gf3tAUR_yV0,54794
11
11
  karrio/providers/easypost/utils.py,sha256=rJ1uxvaOXcwCAbPmiklk0UoJwhbix0sjVc6jV1BWbtQ,774
12
12
  karrio/providers/easypost/shipment/__init__.py,sha256=oEO3ToyRIVyE5mcc_exdZRpM6WMu6PMD2UpdkUJrKqI,232
13
13
  karrio/providers/easypost/shipment/cancel.py,sha256=QEIkm4aPwzOyFMV4fvx_7b8VErwIhcBGl9ZszQM5nsM,1010
@@ -18,9 +18,9 @@ karrio/schemas/easypost/shipment_purchase.py,sha256=xNQWUKV6aYFFdTn7xLCjjtya0h-o
18
18
  karrio/schemas/easypost/shipment_request.py,sha256=7HirvgDktcppvHlEeMz49ryK6sPWIBP-c1_1xE3y8ow,2858
19
19
  karrio/schemas/easypost/shipments_response.py,sha256=KgWbIoPvI1NoQOGoV30-K3Dl6JFkKdAS3B3yHQfb6R4,8957
20
20
  karrio/schemas/easypost/trackers_response.py,sha256=Q0Z74hKZYLDmfKh7lzxM7cfe3x-z-LXve94d7s3r9Kw,2915
21
- karrio_easypost-2025.5.6.dist-info/licenses/LICENSE,sha256=qvVLDB3Y1leH0p_1m30RxZrOGOx8F9O5eZIwdyVzcuQ,7651
22
- karrio_easypost-2025.5.6.dist-info/METADATA,sha256=pizi_mBsM8mkXzG5SNQdE3Bp81NnKkoL1ECN8-z3GuA,1040
23
- karrio_easypost-2025.5.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- karrio_easypost-2025.5.6.dist-info/entry_points.txt,sha256=mArG7sxxZUl07ycYJn7BGzz1uv-hZPVROniK64EbUz4,61
25
- karrio_easypost-2025.5.6.dist-info/top_level.txt,sha256=FZCY8Nwft8oEGHdl--xku8P3TrnOxu5dETEU_fWpRSM,20
26
- karrio_easypost-2025.5.6.dist-info/RECORD,,
21
+ karrio_easypost-2026.1.dist-info/licenses/LICENSE,sha256=qvVLDB3Y1leH0p_1m30RxZrOGOx8F9O5eZIwdyVzcuQ,7651
22
+ karrio_easypost-2026.1.dist-info/METADATA,sha256=kC4Ul6Oj0myt8ejS_68bP0tQHbqBENKX5XWfuaGTQGo,1038
23
+ karrio_easypost-2026.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ karrio_easypost-2026.1.dist-info/entry_points.txt,sha256=mArG7sxxZUl07ycYJn7BGzz1uv-hZPVROniK64EbUz4,61
25
+ karrio_easypost-2026.1.dist-info/top_level.txt,sha256=FZCY8Nwft8oEGHdl--xku8P3TrnOxu5dETEU_fWpRSM,20
26
+ karrio_easypost-2026.1.dist-info/RECORD,,