Twilio returns usage as a string, which can be parsed to an integer or decimal type depending on the usage_unit. Using Twilio's Python client to fetch usage records, it was clear that the string value sometimes mapped to an int and a double in others for different corresponding usage_unit values. It is safer to just return the string and let the caller convert it to the expected value.
Twilio returns
usage
as a string, which can be parsed to an integer or decimal type depending on theusage_unit
. Using Twilio's Python client to fetch usage records, it was clear that the string value sometimes mapped to anint
and adouble
in others for different correspondingusage_unit
values. It is safer to just return the string and let the caller convert it to the expected value.