Skip to content

Commit

Permalink
Merge pull request #64 from PurplShip/rename-carrier-identifiers
Browse files Browse the repository at this point in the history
Rename carrier identifiers
  • Loading branch information
danh91 authored Jun 6, 2020
2 parents 86a9402 + 30e38cb commit bc6daa7
Show file tree
Hide file tree
Showing 84 changed files with 244 additions and 231 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@

## Introduction

PurplShip is a system for connecting multiple supply chain carriers API.
PurplShip is a system for connecting multiple logistics carriers API.

In addition to providing a unified and simplified interface across logistics carriers APIs, PurplShip offers a framework to facilitate the full access of advanced and specific carriers capabilities while simplifying the addition of new carrier APIs.
In addition to providing a unified and simplified interface across logistics carriers APIs,
PurplShip offers a framework to facilitate the full access of advanced and specific carriers capabilities
while simplifying the addition of new carrier APIs.

With PurplShip you can:

- Integrate multiple carriers web services: DHL, FedEx, UPS, USPS, Canada Post and more with ease
- Use a modern and intuitive, unified API across carriers


## Integration

PurplShip has two layers

- **PurplShip SDK** for an integration as a Python library. *[documentation](#Documentation) bellow*
- **PurplShip Server** for a self-hosted private cloud REST API. *documentation and usage can be found at [docs.purplship.com](https://docs.purplship.com)*

## License

Please see [LICENSE.md](https://github.com/PurplShip/purplship/blob/master/LICENSE) for licensing details.
Expand Down Expand Up @@ -78,11 +87,11 @@ This instruction will get you started with `purplship.package` and the support f
-f https://git.io/purplship
# core packages
purplship==2020.6.0
purplship.package==2020.6.0
purplship==2020.6.1
purplship.package==2020.6.1
# carriers
purplship.canadapost==2020.6.0
purplship.canadapost==2020.6.1
```

<details>
Expand All @@ -91,10 +100,10 @@ purplship.canadapost==2020.6.0
You can add additional carriers you desire to work with

```text
purplship.dhl==2020.6.0
purplship.fedex==2020.6.0
purplship.purolator==2020.6.0
purplship.ups==2020.6.0
purplship.dhl==2020.6.1
purplship.fedex==2020.6.1
purplship.purolator==2020.6.1
purplship.ups==2020.6.1
```

</details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def extract(errors: List[Message], message_node: Element) -> List[Message]:
Message(
code=message.code,
message=message.description,
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
)
]

Expand Down
4 changes: 2 additions & 2 deletions extensions/canadapost/purplship/carriers/canadapost/rating.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def _extract_quote(price_quote_node: Element, settings: Settings) -> RateDetails
for d in price_quote.price_details.adjustments.adjustment
]
return RateDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
currency=currency,
estimated_delivery=format_date(
price_quote.service_standard.expected_delivery_date
Expand Down Expand Up @@ -86,7 +86,7 @@ def mailing_scenario_request(
"""
if payload.shipper.country_code and payload.shipper.country_code != Country.CA.name:
raise OriginNotServicedError(
payload.shipper.country_code, settings.carrier_name
payload.shipper.country_code, settings.carrier_id
)

parcel_preset = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def _extract_shipment(response: Element, settings: Settings) -> ShipmentDetails:
info.build(info_node)

return ShipmentDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=info.tracking_pin,
label=label.text if len(errors) == 0 else None,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def _extract_shipment(response: Element, settings: Settings) -> ShipmentDetails:
info.build(info_node)

return ShipmentDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=info.tracking_pin,
label=label.text if len(errors) == 0 else None,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def _extract_tracking(pin_summary_node: Element, settings: Settings) -> Tracking
pin_summary_ = pin_summary()
pin_summary_.build(pin_summary_node)
return TrackingDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=pin_summary_.pin,
events=[
TrackingEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Settings(BaseSettings):
id: str = None

@property
def carrier(self):
def carrier_name(self):
return "canadapost"

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class Settings(BaseSettings):
contract_id: str = None
id: str = None
test: bool = False
carrier_name: str = "CanadaPost"
carrier_id: str = "canadapost"
2 changes: 1 addition & 1 deletion extensions/canadapost/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_namespace_packages

setup(name='purplship.canadapost',
version='2020.6.0',
version='2020.6.1',
description='Multi-carrier shipping API integration with python',
url='https://github.com/PurplShip/purplship',
author='PurplShip',
Expand Down
2 changes: 1 addition & 1 deletion extensions/dhl/purplship/carriers/dhl/book_pickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def _extract_pickup(response: Element, settings: Settings) -> PickupDetails:
else None
)
return PickupDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
confirmation_number=str(pickup.ConfirmationNumber[0]),
pickup_date=format_date(pickup.NextPickupDate),
pickup_charge=pickup_charge,
Expand Down
2 changes: 1 addition & 1 deletion extensions/dhl/purplship/carriers/dhl/dct_quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def _extract_quote(qtdshp_node: Element, settings: Settings) -> RateDetails:
qtdshp.LocalProductName,
)
return RateDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
currency=qtdshp.CurrencyCode,
estimated_delivery=format_date(delivery_date),
service=service_name,
Expand Down
2 changes: 1 addition & 1 deletion extensions/dhl/purplship/carriers/dhl/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def extract(errors: List[Message], condition_node: Element) -> List[Message]:
Message(
code=condition.ConditionCode,
message=condition.ConditionData,
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
)
]

Expand Down
2 changes: 1 addition & 1 deletion extensions/dhl/purplship/carriers/dhl/modify_pickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def _extract_pickup(response: Element, settings: Settings) -> PickupDetails:
else None
)
return PickupDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
confirmation_number=str(pickup.ConfirmationNumber[0]),
pickup_date=format_date(pickup.NextPickupDate)
if pickup.NextPickupDate is not None
Expand Down
2 changes: 1 addition & 1 deletion extensions/dhl/purplship/carriers/dhl/ship_val.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def _extract_shipment(shipment_node, settings: Settings) -> Optional[ShipmentDet
label = encodebytes(cast(LabelImage, label_image).OutputImage).decode("utf-8")

return ShipmentDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=shipment.AirwayBillNumber,
label=label,
)
Expand Down
2 changes: 1 addition & 1 deletion extensions/dhl/purplship/carriers/dhl/tracking_known.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def _extract_tracking(
return None

return TrackingDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=info.AWBNumber,
events=list(
map(
Expand Down
4 changes: 2 additions & 2 deletions extensions/dhl/purplship/carriers/dhl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Settings(BaseSettings):
id: str = None

@property
def carrier(self):
return "dhl"
def carrier_name(self):
return "dhl_express"

@property
def server_url(self):
Expand Down
2 changes: 1 addition & 1 deletion extensions/dhl/purplship/freight/mappers/dhl/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class Settings(BaseSettings):
account_number: str = None
id: str = None
test: bool = False
carrier_name: str = "DHL Freight"
carrier_id: str = "dhl_freight"
2 changes: 1 addition & 1 deletion extensions/dhl/purplship/package/mappers/dhl/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class Settings(BaseSettings):
account_number: str = None
id: str = None
test: bool = False
carrier_name: str = "DHL"
carrier_id: str = "dhl_express"
2 changes: 1 addition & 1 deletion extensions/dhl/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


setup(name='purplship.dhl',
version='2020.6.0',
version='2020.6.1',
description='Multi-carrier shipping API integration with python',
url='https://github.com/PurplShip/purplship',
author='PurplShip',
Expand Down
2 changes: 1 addition & 1 deletion extensions/fedex/purplship/carriers/fedex/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def extract(messages: List[Message], notification_node: Element) -> List[Message
Message(
code=notification.Code,
message=notification.Message,
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
)
)
return messages
Expand Down
2 changes: 1 addition & 1 deletion extensions/fedex/purplship/carriers/fedex/package/rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def _extract_rate(detail_node: Element, settings: Settings) -> Optional[RateDeta
]

return RateDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
service=service,
currency=currency,
base_charge=decimal(shipment_rate.TotalBaseCharge.Amount),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def _extract_shipment(
)

return ShipmentDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=tracking_number,
label=label,
)
Expand Down
2 changes: 1 addition & 1 deletion extensions/fedex/purplship/carriers/fedex/track_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def _extract_tracking(
if track_detail.Notification.Severity == "ERROR":
return None
return TrackingDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=track_detail.TrackingNumber,
events=list(
map(
Expand Down
2 changes: 1 addition & 1 deletion extensions/fedex/purplship/carriers/fedex/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Settings(BaseSettings):
id: str = None

@property
def carrier(self):
def carrier_name(self):
return "fedex"

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class Settings(BaseSettings):
account_number: str = None
id: str = None
test: bool = False
carrier_name: str = "FedEx Freight"
carrier_id: str = "fedex_freight"
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class Settings(BaseSettings):
account_number: str
id: str = None
test: bool = False
carrier_name: str = "FedEx"
carrier_id: str = "fedex"
2 changes: 1 addition & 1 deletion extensions/fedex/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


setup(name='purplship.fedex',
version='2020.6.0',
version='2020.6.1',
description='Multi-carrier shipping API integration with python',
url='https://github.com/PurplShip/purplship',
author='PurplShip',
Expand Down
2 changes: 1 addition & 1 deletion extensions/freight/purplship/freight/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def deserialize():
[
Message(
code="500",
carrier=gateway.settings.carrier,
carrier_name=gateway.settings.carrier_name,
carrier_id=gateway.settings.carrier_id,
message=f"{error}",
)
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/freight/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


setup(name='purplship.freight',
version='2020.6.0',
version='2020.6.1',
description='Multi-carrier shipping API integration with python',
url='https://github.com/PurplShip/purplship',
author='PurplShip',
Expand Down
2 changes: 1 addition & 1 deletion extensions/package/purplship/package/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def abort(error: Exception, gateway: Gateway):
[
Message(
code="500",
carrier=gateway.settings.carrier,
carrier_name=gateway.settings.carrier_name,
carrier_id=gateway.settings.carrier_id,
message=f"{error}",
)
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


setup(name='purplship.package',
version='2020.6.0',
version='2020.6.1',
description='Multi-carrier shipping API integration with python',
url='https://github.com/PurplShip/purplship',
author='PurplShip',
Expand Down
6 changes: 3 additions & 3 deletions extensions/purolator/purplship/carriers/purolator/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def _extract_error(error_node: Element, settings: Settings) -> Message:
return Message(
code=error.Code,
message=error.Description,
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
details=dict(AdditionalInformation=error.AdditionalInformation)
if error.AdditionalInformation is not None
else None,
Expand All @@ -35,6 +35,6 @@ def _extract_fault(fault_node: Element, settings: Settings) -> Message:
return Message(
code=error.faultcode,
message=error.faultstring,
carrier=settings.carrier,
carrier_name=settings.carrier_name
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id
)
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def _extract_rate(estimate_node: Element, settings: Settings) -> RateDetails:
(p.name for p in Product if p.value in estimate.ServiceID), estimate.ServiceID
)
return RateDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
service=service,
currency=currency,
base_charge=decimal(estimate.BasePrice),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def _extract_shipment(response: Element, settings: Settings) -> ShipmentDetails:
)

return ShipmentDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=cast(PIN, shipment.ShipmentPIN).Value,
label=label,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def _extract_tracking(node: Element, settings: Settings) -> TrackingDetails:
track = TrackingInformation()
track.build(node)
return TrackingDetails(
carrier=settings.carrier,
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
tracking_number=str(track.PIN.Value),
events=[
TrackingEvent(
Expand Down
Loading

0 comments on commit bc6daa7

Please sign in to comment.