-
Notifications
You must be signed in to change notification settings - Fork 549
Description
When using the Twilio pricing api the response returns snake_case properties.
{
"url": "https://pricing.twilio.com/v1/PhoneNumbers/Countries/US",
"country": "United States",
"price_unit": "USD",
"phone_number_prices": [
{
"number_type": "local",
"base_price": "1.15",
"current_price": "1.15"
},
{
"number_type": "toll free",
"base_price": "2.15",
"current_price": "2.15"
}
],
"iso_country": "US"
}However when using the Twilio Node SDK (v1) endpoint as such
const response = await ctx.twilio.pricing.v1.phoneNumbers
.countries("US")
.fetch((err, result) => result?.toJSON())A mixed casing response is received, properties as shown below.
{
country: 'United States',
isoCountry: 'US',
phoneNumberPrices: [
{ number_type: 'local', base_price: '1.15', current_price: '1.15' },
{
number_type: 'toll free',
base_price: '2.15',
current_price: '2.15'
}
],
priceUnit: 'USD',
url: 'https://pricing.twilio.com/v1/PhoneNumbers/Countries/US'
}Notice how number_type is snake_case whereas phoneNumberPrices is camelCase, this is incorrect as the SDK expects camelCase property names as shown below.
twilio-node/src/rest/pricing/v1/phoneNumber/country.ts
Lines 23 to 27 in a23ee16
| export class PricingV1PhoneNumberPhoneNumberCountryInstancePhoneNumberPrices { | |
| "basePrice"?: number; | |
| "currentPrice"?: number; | |
| "numberType"?: string; | |
| } |
Please either update to correctly camelCase all property names, or update PricingV1PhoneNumberPhoneNumberCountryInstancePhoneNumberPrices to correctly reflect the snake_case response to allow for correct property access in Typescript.
e.g.
response.phoneNumberPrices[0].numberType <-- this is currently not possible with the current typings