-
-
Notifications
You must be signed in to change notification settings - Fork 110
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 #454 from karrioapi/patch-2023.9.5
[patch] 2023.9.5
- Loading branch information
Showing
31 changed files
with
192 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2023.9.4 | ||
2023.9.5 |
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
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
44 changes: 27 additions & 17 deletions
44
modules/connectors/easypost/karrio/providers/easypost/error.py
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 |
---|---|---|
@@ -1,21 +1,31 @@ | ||
from karrio.schemas.easypost.error_response import Error | ||
from karrio.core.utils import DP | ||
from karrio.core.models import Message | ||
from karrio.providers.easypost.utils import Settings | ||
import typing | ||
import karrio.lib as lib | ||
import karrio.core.models as models | ||
import karrio.providers.easypost.utils as provider_utils | ||
|
||
|
||
def parse_error_response( | ||
response: dict, settings: Settings, details: dict = None | ||
) -> Message: | ||
error = DP.to_object(Error, response.get("error")) | ||
response: dict, settings: provider_utils.Settings, **kwargs | ||
) -> typing.List[models.Message]: | ||
errors = [ | ||
*response.get("messages", []), | ||
*([response.get("error")] if "error" in response else []), | ||
] | ||
|
||
return Message( | ||
carrier_id=settings.carrier_id, | ||
carrier_name=settings.carrier_name, | ||
code=error.code, | ||
message=error.message, | ||
details={ | ||
"errors": error.errors or [], | ||
**(details or {}), | ||
}, | ||
) | ||
return [ | ||
models.Message( | ||
carrier_id=settings.carrier_id, | ||
carrier_name=settings.carrier_name, | ||
code=(error.get("code") or error.get("type")), | ||
message=error.get("message"), | ||
details=lib.to_dict( | ||
{ | ||
"errors": error.get("errors"), | ||
"carrier": error.get("carrier"), | ||
"carrier_account_id": error.get("carrier_account_id"), | ||
**kwargs, | ||
} | ||
), | ||
) | ||
for error in errors | ||
] |
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
Oops, something went wrong.