-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from PurplShip/IntegrateAustraliaPost
WIP: integrating Australia post mapper
- Loading branch information
Showing
40 changed files
with
901 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .aups_client import AustraliaPostClient | ||
from .aups_mapper import AustraliaPostMapper | ||
from .aups_proxy import AustraliaPostProxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""PurplShip Australia post client settings.""" | ||
|
||
import attr | ||
from purplship.domain.client import Client | ||
|
||
|
||
@attr.s(auto_attribs=True) | ||
class AustraliaPostClient(Client): | ||
"""Australia post connection settings.""" | ||
|
||
username: str | ||
password: str | ||
account_number: str | ||
carrier_name: str = "AustraliaPost" | ||
server_url: str = "https://digitalapi.auspost.com.au/shipping/v1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Tuple, List | ||
from purplship.domain.mapper import Mapper | ||
from purplship.domain.Types import ( | ||
RateRequest, | ||
TrackingRequest, | ||
Error, | ||
QuoteDetails, | ||
TrackingDetails | ||
) | ||
from .partials import ( | ||
AustraliaPostRateMapperPartial, | ||
AustraliaPostTrackMapperPartial, | ||
) | ||
from pyaups.shipping_price_request import ShippingPriceRequest | ||
|
||
|
||
class AustraliaPostMapper( | ||
Mapper, | ||
AustraliaPostRateMapperPartial, | ||
AustraliaPostTrackMapperPartial, | ||
): | ||
def create_quote_request(self, payload: RateRequest) -> ShippingPriceRequest: | ||
return self.create_shipping_price_request(payload) | ||
|
||
def create_tracking_request(self, payload: TrackingRequest) -> List[str]: | ||
return self.create_track_items_request(payload) | ||
|
||
def parse_quote_response(self, response: dict) -> Tuple[List[QuoteDetails], List[Error]]: | ||
return self.parse_shipping_price_response(response) | ||
|
||
def parse_tracking_response(self, response: dict) -> Tuple[List[TrackingDetails], List[Error]]: | ||
return self.parse_track_items_response(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .rate import AustraliaPostMapperPartial as AustraliaPostRateMapperPartial | ||
from .track import AustraliaPostMapperPartial as AustraliaPostTrackMapperPartial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing import Tuple, List | ||
from purplship.mappers.aups import AustraliaPostClient | ||
from purplship.domain.Types import ( | ||
RateRequest, | ||
TrackingRequest, | ||
Error, | ||
TrackingDetails, | ||
QuoteDetails | ||
) | ||
from pyaups.shipping_price_request import ShippingPriceRequest | ||
from pyaups.shipping_price_response import Errors | ||
|
||
|
||
class AustraliaPostCapabilities: | ||
""" | ||
AustraliaPost native service request types | ||
""" | ||
|
||
""" Requests """ | ||
|
||
def create_shipping_price_request(self, payload: RateRequest) -> ShippingPriceRequest: | ||
pass | ||
|
||
def create_track_items_request(self, payload: TrackingRequest) -> List[str]: | ||
pass | ||
|
||
""" Replys """ | ||
|
||
def parse_shipping_price_response(self, response: dict) -> Tuple[List[QuoteDetails], List[Error]]: | ||
pass | ||
|
||
def parse_track_items_response(self, response: dict) -> Tuple[List[TrackingDetails], List[Error]]: | ||
pass | ||
|
||
|
||
class AustraliaPostMapperBase(AustraliaPostCapabilities): | ||
""" | ||
AustraliaPost mapper base class | ||
""" | ||
|
||
def __init__(self, client: AustraliaPostClient): | ||
self.client: AustraliaPostClient = client | ||
|
||
def parse_error_response(self, response: dict) -> List[Error]: | ||
if 'errors' in response: | ||
errorResponse: Errors = Errors(**response) | ||
return [ | ||
Error( | ||
message=error.message, | ||
carrier=self.client.carrier_name, | ||
code=error.code | ||
) for error in errorResponse.errors | ||
] | ||
return [] |
Oops, something went wrong.