Skip to content

Commit

Permalink
feat: Consolidate Eshipper carrier and service data mapping with live…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
danh91 committed Oct 1, 2024
1 parent d70733d commit ba0c4a6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 436 deletions.
14 changes: 11 additions & 3 deletions modules/connectors/eshipper/karrio/providers/eshipper/rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,27 @@ def rate_request(
shipper = lib.to_address(payload.shipper)
recipient = lib.to_address(payload.recipient)
packages = lib.to_packages(payload.parcels)
services = lib.to_services(payload.services, provider_units.ShippingService)
options = lib.to_shipping_options(
payload.options,
package_options=packages.options,
)
services = lib.to_services(payload.services, provider_units.ShippingService)
print(services, "<<<")
service_id = lib.identity(
options.eshipper_service_id.state
or provider_units.ShippingService.service_id(
services.first,
test_mode=settings.test_mode,
)
)

request = eshipper.RateRequestType(
scheduledShipDate=lib.fdatetime(
lib.to_next_business_datetime(
options.shipping_date.state or datetime.datetime.now(),
current_format="%Y-%m-%dT%H:%M",
),
output_format="%Y-%m-%dT%H:%M:%S.%fZ", # 2024-09-30T09:10:29.195Z
output_format="%Y-%m-%d %H:%M",
),
raterequestfrom=eshipper.FromType(
attention=shipper.contact,
Expand Down Expand Up @@ -178,7 +186,7 @@ def rate_request(
insidePickup=options.eshipper_inside_pickup.state,
saturdayPickupRequired=options.eshipper_saturday_pickup_required.state,
stackable=options.eshipper_stackable.state,
serviceId=getattr(services.first, "value", None),
serviceId=service_id,
thirdPartyBilling=None,
commodityType=None,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def shipment_request(
options.shipping_date.state or datetime.datetime.now(),
current_format="%Y-%m-%dT%H:%M",
),
output_format="%Y-%m-%dT%H:%M:%S.%fZ", # 2024-09-30T09:10:29.195Z
output_format="%Y-%m-%d %H:%M",
),
shippingrequestfrom=eshipper.FromType(
attention=shipper.contact,
Expand Down
Loading

0 comments on commit ba0c4a6

Please sign in to comment.