twilio / twilio-csharp

Twilio C#/.NET Helper Library for .NET6+.
MIT License
677 stars 301 forks source link

TrustProductsChannelEndpointAssignmentResource.ReadAsync() doesn't load entities fully #742

Open JakubHolovsky opened 7 months ago

JakubHolovsky commented 7 months ago

Issue Summary

When we try to load TrustProduct Channel Endpoint Assignments with limit 1000 it only fully loads 67 records out of 130. If we do a foreach through it - it results in an inconsistent behavior where we cannot rely on the data properties.

We have to resort in doing "ToList()" on the result set to get all the entities fully loaded.

Code Snippet


var incomingPhoneNumbers = await IncomingPhoneNumberResource.ReadAsync(limit: 1000, client: twilioRestClient);

var trustProductAssignments = await TrustProductsChannelEndpointAssignmentResource.ReadAsync(
    new ReadTrustProductsChannelEndpointAssignmentOptions(shakenStirTrustProductSid)
    {
        Limit = 1000
    }, twilioRestClient);

foreach (var number in incomingPhoneNumbers)
{
    if (trusthubAssignments != null && trusthubAssignments.Select(n => n.ChannelEndpointSid).Contains(number.Sid))
        {
             continue; // this will not execute correctly because trusthubAssignments entity is not loaded fully
        }

}

// IF we do this the entities get fully loaded and we don't have the issue - note that this issue is only with TrustProductsChannelEndpointAssignmentResource:

var trustProductAssignments = (await TrustProductsChannelEndpointAssignmentResource.ReadAsync(
    new ReadTrustProductsChannelEndpointAssignmentOptions(shakenStirTrustProductSid)
    {
        Limit = 1000
    }, twilioRestClient)).ToList();

Technical details:

sbansla commented 7 months ago

Hi, I will check this issue.