team-telnyx / telnyx-php

PHP SDK for the Telnyx API
MIT License
32 stars 26 forks source link

"meta" is being looked for incorrectly instead of "metadata" in API response #32

Closed Jedibassist closed 4 years ago

Jedibassist commented 4 years ago

After hours of scratching my head when the example listed here (https://developers.telnyx.com/docs/api/v2/numbers/Number-Search#listAvailablePhoneNumbers) did not work, I took a look at the code here.

I noticed this note on the previous commit:

"meta" is not present in API responses, "metadata" is.

I added this line back into All.php to fix the issue and force the type for now: $response->json['record_type'] = 'list';

There appear to be several files where "meta" is looked for instead of "metadata" - either this code needs to be updated or the API response does.

weroh commented 4 years ago

Hey Jedi, Sorry you had to dig around for so long. You're right. The correct node is "meta" and not "metadata". So your workaround is sufficient if you aren't using paging features.

If you are using paging features, then check this out. The code which is supposed to detect the type of class returned is within util.php line 120. So you can also replace that line with this and that should solve your problem until we have a more permanent fix for you: } elseif (isset($resp['meta']) || isset($resp['metadata']) || isset($resp['data'][0])) {

Hope that helps!

weroh commented 4 years ago

Just FYI, the latest commit includes the Util.php fix.

weroh commented 4 years ago

Closing this issue. Thanks!