Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add error level flag #657

Open
jacobshilitz opened this issue Aug 26, 2024 · 2 comments
Open

feat: add error level flag #657

jacobshilitz opened this issue Aug 26, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@jacobshilitz
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Some carriers return notes and warnings which are not errors, but they can be useful.
for example, FedEx we disabled the "note" type messages because it was not an error, see commit 4d2a07b.

Describe the solution you'd like
Add a level to message object that indicates whether it's an error or just a notice.
and add support for all the carriers

I thought it can maybe also be a setting in the user or in the API in each call, what errors should be suppressed

@danh91 danh91 added the enhancement New feature or request label Aug 29, 2024
@jacobshilitz
Copy link
Collaborator Author

jacobshilitz commented Aug 30, 2024

@danh91 can you give some input on how you would like this to be implemented?

@danh91
Copy link
Member

danh91 commented Aug 30, 2024

Hi @jacobshilitz,

Yes, adding an optional level field to the Message type is the way to go.

class Message:
"""Karrio unified Message data type."""
carrier_name: str
carrier_id: str
message: Union[str, Any] = None
code: str = None
details: Dict = None

So that every carrier integration can adopt it progressively on there error parsing functions.

e.g. fedex

pass the level to the Message type

return [
models.Message(
carrier_name=settings.carrier_name,
carrier_id=settings.carrier_id,
code=error.get("code"),
message=error.get("message"),
details=lib.to_dict(
{
**details,
"tracking_number": error.get("tracking_number"),
}
),
)
for error in errors
]

The only thing is we need to standardize the levels with an enum like

class MessageLevelEnum(Enum):
   note
   warning
   error

The enum can be in the sdk/karrio/core/units.py file.

These are the ones I have seen in general. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants
@danh91 @jacobshilitz and others