When rating to certain countries with USPS International (try Taiwan as an example), an exception is generated:
ERROR:karrio.api.interface:time data '3 - 5 business days to many major markets' does not match format '%m/%d/%Y'
Traceback (most recent call last):
File "/home/me/karrioship/karrio/sdk/core/karrio/api/interface.py", line 62, in wrapper
return func(*args, **kwargs)
File "/home/me/karrioship/karrio/sdk/core/karrio/api/interface.py", line 301, in deserialize
return gateway.mapper.parse_rate_response(response)
File "/home/me/karrioship/karrio/sdk/extensions/usps_international/karrio/mappers/usps_international/mapper.py", line 102, in parse_rate_response
return parse_rate_response(response.deserialize(), self.settings)
File "/home/me/karrioship/karrio/sdk/extensions/usps_international/karrio/providers/usps_international/rate.py", line 23, in parse_rate_response
quotes: typing.List[models.RateDetails] = [
File "/home/me/karrioship/karrio/sdk/extensions/usps_international/karrio/providers/usps_international/rate.py", line 24, in <listcomp>
_extract_details(package, settings)
File "/home/me/karrioship/karrio/sdk/extensions/usps_international/karrio/providers/usps_international/rate.py", line 35, in _extract_details
delivery_date = lib.to_date(postage.GuaranteeAvailability, "%m/%d/%Y")
File "/home/me/karrioship/karrio/sdk/core/karrio/lib.py", line 176, in to_date
return utils.DF.date(
File "/home/me/karrioship/karrio/sdk/core/karrio/core/utils/datetime.py", line 31, in date
return datetime.strptime(str(date_value), current_format)
File "/usr/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/lib/python3.9/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '3 - 5 business days to many major markets' does not match format '%m/%d/%Y'
This is because the GuaranteeAvailability field is being mapped to a date in rate.py like:
delivery_date = lib.to_date(postage.GuaranteeAvailability, "%m/%d/%Y")
But according to the USPS documentation:
If an estimated scheduled delivery date is available, the format will beMM/DD/YYYYe.g.,01/29/2014. If an estimated scheduled delivery date is not available, the format will be a String.e.g.,3 - 5 business days to many major markets
So rate.py needs to be adjusted to either keep it just as a string, or detect if USPS is returning a date and if so, use the date, otherwise keep it a string.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too