twilio / twilio-go

A Go package for communicating with the Twilio API.
MIT License
278 stars 40 forks source link

ListCall does not return ListCallResponse #146

Closed zxr90 closed 2 years ago

zxr90 commented 2 years ago

Issue Summary

I'm using the ListCall api to retrieve calls related to a parent sid.

  1. ListCalldoes not return ListCallResponse
  2. ListCall throws an error if no call resources related to a parent sid is found
  3. PageCall is the one that returns ListCallResponse. see https://github.com/twilio/twilio-go/blob/main/rest/api/v2010/accounts_calls.go
  4. Your documentation states that ListCall will return ListCallResponse https://github.com/twilio/twilio-go/blob/main/rest/api/v2010/docs/AccountsCallsApi.md#listcall

I believe PageCall is the one I should be using, so is the documentation wrong?

Steps to Reproduce

Code Snippet

import (
        "github.com/twilio/twilio-go/client"
    apiv2010 "github.com/twilio/twilio-go/rest/api/v2010"
)
defaultClient := &client.Client{
    Credentials: client.NewCredentials(creds.AccountSID, creds.AuthToken),
}
defaultClient.SetAccountSid(creds.AccountSID)
client := apiv2010.NewApiServiceWithClient(defaultClient)
resp, err := client.ListCall(&apiv2010.ListCallParams{
    ParentCallSid: &sid,
})

Exception/Log

# paste exception/log here
could not retrieve payload from response

Technical details:

childish-sambino commented 2 years ago

The markdown doc is incorrect and needs to be corrected. The proper return type is []ApiV2010Call: https://github.com/twilio/twilio-go/blob/5cc1198dc1ab60f055176b1c5832dc080d1794a7/rest/api/v2010/accounts_calls.go?rgh-link-date=2022-03-10T14%3A53%3A45Z#L608

For the error you're seeing, I was able to recreate it. Looks like the pagination logic doesn't like empty result sets and needs a fix.

This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

zxr90 commented 2 years ago

thanks for quick response. If I have time I might take a look.