-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Communication] - PhoneNumberAdministrationClient - fix next page #17283
Changes from 12 commits
d36bcf5
4fae158
79b322e
b8f6abb
ae7d46f
cc41d52
533d05b
101a251
436975c
6d4dbd5
4131466
7f7b424
0fff2cb
ee20b85
ee4ac2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,10 +65,13 @@ public virtual AsyncPageable<AcquiredPhoneNumber> GetAllPhoneNumbersAsync(string | |
|
||
try | ||
{ | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async s => | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async nextLink => | ||
{ | ||
Response<AcquiredPhoneNumbers> response = await RestClient.GetAllPhoneNumbersAsync(locale, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
return Page.FromValues(response.Value.PhoneNumbers, continuationToken: null!, response.GetRawResponse()); | ||
Response<AcquiredPhoneNumbers> response = string.IsNullOrEmpty(nextLink) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can just do the null check instead |
||
? await RestClient.GetAllPhoneNumbersAsync(locale, skip: null, take: null, cancellationToken).ConfigureAwait(false) | ||
: await RestClient.GetAllPhoneNumbersNextPageAsync(nextLink, locale, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
|
||
return Page.FromValues(response.Value.PhoneNumbers, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
|
@@ -89,8 +92,14 @@ public virtual Pageable<AcquiredPhoneNumber> GetAllPhoneNumbers(string? locale = | |
|
||
try | ||
{ | ||
Response<AcquiredPhoneNumbers> response = RestClient.GetAllPhoneNumbers(locale, skip: null, take: null, cancellationToken); | ||
return PageResponseEnumerator.CreateEnumerable(s => Page.FromValues(response.Value.PhoneNumbers, continuationToken: null!, response.GetRawResponse())); | ||
return PageResponseEnumerator.CreateEnumerable(nextLink => | ||
{ | ||
Response<AcquiredPhoneNumbers> response = string.IsNullOrEmpty(nextLink) | ||
? RestClient.GetAllPhoneNumbers(locale, skip: null, take: null, cancellationToken) | ||
: RestClient.GetAllPhoneNumbersNextPage(nextLink, locale, skip: null, take: null, cancellationToken); | ||
|
||
return Page.FromValues(response.Value.PhoneNumbers, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
@@ -229,10 +238,13 @@ public virtual AsyncPageable<PhoneNumberCountry> GetAllSupportedCountriesAsync(s | |
scope.Start(); | ||
try | ||
{ | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async s => | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async nextLink => | ||
{ | ||
Response<PhoneNumberCountries> response = await RestClient.GetAllSupportedCountriesAsync(locale, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
return Page.FromValues(response.Value.Countries, continuationToken: null!, response.GetRawResponse()); | ||
Response<PhoneNumberCountries> response = string.IsNullOrEmpty(nextLink) | ||
? await RestClient.GetAllSupportedCountriesAsync(locale, skip: null, take: null, cancellationToken).ConfigureAwait(false) | ||
: await RestClient.GetAllSupportedCountriesNextPageAsync(nextLink, locale, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
|
||
return Page.FromValues(response.Value.Countries, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
|
@@ -252,8 +264,14 @@ public virtual Pageable<PhoneNumberCountry> GetAllSupportedCountries(string? loc | |
scope.Start(); | ||
try | ||
{ | ||
Response<PhoneNumberCountries> response = RestClient.GetAllSupportedCountries(locale, skip: null, take: null, cancellationToken); | ||
return PageResponseEnumerator.CreateEnumerable(s => Page.FromValues(response.Value.Countries, continuationToken: null!, response.GetRawResponse())); | ||
return PageResponseEnumerator.CreateEnumerable(nextLink => | ||
{ | ||
Response<PhoneNumberCountries> response = string.IsNullOrEmpty(nextLink) | ||
? RestClient.GetAllSupportedCountries(locale, skip: null, take: null, cancellationToken) | ||
: RestClient.GetAllSupportedCountriesNextPage(nextLink, locale, skip: null, take: null, cancellationToken); | ||
|
||
return Page.FromValues(response.Value.Countries, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
@@ -390,10 +408,13 @@ public virtual AsyncPageable<PhonePlanGroup> GetPhonePlanGroupsAsync(string coun | |
scope.Start(); | ||
try | ||
{ | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async s => | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async nextLink => | ||
{ | ||
Response<PhonePlanGroups> response = await RestClient.GetPhonePlanGroupsAsync(countryCode, locale, includeRateInformation, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
return Page.FromValues(response.Value.PhonePlanGroupsValue, continuationToken: null!, response.GetRawResponse()); | ||
Response<PhonePlanGroups> response = string.IsNullOrEmpty(nextLink) | ||
? await RestClient.GetPhonePlanGroupsAsync(countryCode, locale, includeRateInformation, skip: null, take: null, cancellationToken).ConfigureAwait(false) | ||
: await RestClient.GetPhonePlanGroupsNextPageAsync(nextLink, countryCode, locale, includeRateInformation, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
|
||
return Page.FromValues(response.Value.PhonePlanGroupsValue, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
|
@@ -415,8 +436,14 @@ public virtual Pageable<PhonePlanGroup> GetPhonePlanGroups(string countryCode, s | |
scope.Start(); | ||
try | ||
{ | ||
Response<PhonePlanGroups> response = RestClient.GetPhonePlanGroups(countryCode, locale, includeRateInformation, skip: null, take: null, cancellationToken); | ||
return PageResponseEnumerator.CreateEnumerable(s => Page.FromValues(response.Value.PhonePlanGroupsValue, continuationToken: null!, response.GetRawResponse())); | ||
return PageResponseEnumerator.CreateEnumerable(nextLink => | ||
{ | ||
Response<PhonePlanGroups> response = string.IsNullOrEmpty(nextLink) | ||
? RestClient.GetPhonePlanGroups(countryCode, locale, includeRateInformation, skip: null, take: null, cancellationToken) | ||
: RestClient.GetPhonePlanGroupsNextPage(nextLink, countryCode, locale, includeRateInformation, skip: null, take: null, cancellationToken); | ||
|
||
return Page.FromValues(response.Value.PhonePlanGroupsValue, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
@@ -437,10 +464,13 @@ public virtual AsyncPageable<PhonePlan> GetPhonePlansAsync(string countryCode, s | |
scope.Start(); | ||
try | ||
{ | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async s => | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async nextLink => | ||
{ | ||
Response<PhonePlansResponse> response = await RestClient.GetPhonePlansAsync(countryCode, phonePlanGroupId, locale, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
return Page.FromValues(response.Value.PhonePlans, continuationToken: null!, response.GetRawResponse()); | ||
Response<PhonePlansResponse> response = string.IsNullOrEmpty(nextLink) | ||
? await RestClient.GetPhonePlansAsync(countryCode, phonePlanGroupId, locale, skip: null, take: null, cancellationToken).ConfigureAwait(false) | ||
: await RestClient.GetPhonePlansNextPageAsync(nextLink, countryCode, phonePlanGroupId, locale, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
|
||
return Page.FromValues(response.Value.PhonePlans, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
|
@@ -462,8 +492,14 @@ public virtual Pageable<PhonePlan> GetPhonePlans(string countryCode, string phon | |
scope.Start(); | ||
try | ||
{ | ||
Response<PhonePlansResponse> response = RestClient.GetPhonePlans(countryCode, phonePlanGroupId, locale, skip: null, take: null, cancellationToken); | ||
return PageResponseEnumerator.CreateEnumerable(s => Page.FromValues(response.Value.PhonePlans, continuationToken: null!, response.GetRawResponse())); | ||
return PageResponseEnumerator.CreateEnumerable(nextLink => | ||
{ | ||
Response<PhonePlansResponse> response = string.IsNullOrEmpty(nextLink) | ||
? RestClient.GetPhonePlans(countryCode, phonePlanGroupId, locale, skip: null, take: null, cancellationToken) | ||
: RestClient.GetPhonePlansNextPage(nextLink, countryCode, phonePlanGroupId, locale, skip: null, take: null, cancellationToken); | ||
|
||
return Page.FromValues(response.Value.PhonePlans, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
@@ -649,10 +685,12 @@ public virtual AsyncPageable<PhoneNumberEntity> GetAllReleasesAsync(Cancellation | |
scope.Start(); | ||
try | ||
{ | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async s => | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async nextLink => | ||
{ | ||
Response<PhoneNumberEntities> response = await RestClient.GetAllReleasesAsync(skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
return Page.FromValues(response.Value.Entities, continuationToken: null!, response.GetRawResponse()); | ||
Response<PhoneNumberEntities> response = string.IsNullOrEmpty(nextLink) | ||
? await RestClient.GetAllReleasesAsync(skip: null, take: null, cancellationToken).ConfigureAwait(false) | ||
: await RestClient.GetAllReleasesNextPageAsync(nextLink, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
return Page.FromValues(response.Value.Entities, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
|
@@ -671,8 +709,14 @@ public virtual Pageable<PhoneNumberEntity> GetAllReleases(CancellationToken canc | |
scope.Start(); | ||
try | ||
{ | ||
Response<PhoneNumberEntities> response = RestClient.GetAllReleases(skip: null, take: null, cancellationToken); | ||
return PageResponseEnumerator.CreateEnumerable(s => Page.FromValues(response.Value.Entities, continuationToken: null!, response.GetRawResponse())); | ||
return PageResponseEnumerator.CreateEnumerable(nextLink => | ||
{ | ||
Response<PhoneNumberEntities> response = string.IsNullOrEmpty(nextLink) | ||
? RestClient.GetAllReleases(skip: null, take: null, cancellationToken) | ||
: RestClient.GetAllReleasesNextPage(nextLink, skip: null, take: null, cancellationToken); | ||
|
||
return Page.FromValues(response.Value.Entities, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
@@ -776,10 +820,13 @@ public virtual AsyncPageable<PhoneNumberEntity> GetAllReservationsAsync(Cancella | |
scope.Start(); | ||
try | ||
{ | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async s => | ||
return PageResponseEnumerator.CreateAsyncEnumerable(async nextLink => | ||
{ | ||
Response<PhoneNumberEntities> response = await RestClient.GetAllSearchesAsync(skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
return Page.FromValues(response.Value.Entities, continuationToken: null!, response.GetRawResponse()); | ||
Response<PhoneNumberEntities> response = string.IsNullOrEmpty(nextLink) | ||
? await RestClient.GetAllSearchesAsync(skip: null, take: null, cancellationToken).ConfigureAwait(false) | ||
: await RestClient.GetAllSearchesNextPageAsync(nextLink, skip: null, take: null, cancellationToken).ConfigureAwait(false); | ||
|
||
return Page.FromValues(response.Value.Entities, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
|
@@ -798,8 +845,14 @@ public virtual Pageable<PhoneNumberEntity> GetAllReservations(CancellationToken | |
scope.Start(); | ||
try | ||
{ | ||
Response<PhoneNumberEntities> response = RestClient.GetAllSearches(skip: null, take: null, cancellationToken); | ||
return PageResponseEnumerator.CreateEnumerable(s => Page.FromValues(response.Value.Entities, continuationToken: null!, response.GetRawResponse())); | ||
return PageResponseEnumerator.CreateEnumerable(nextLink => | ||
{ | ||
Response<PhoneNumberEntities> response = string.IsNullOrEmpty(nextLink) | ||
? RestClient.GetAllSearches(skip: null, take: null, cancellationToken) | ||
: RestClient.GetAllSearchesNextPage(nextLink, skip: null, take: null, cancellationToken); | ||
|
||
return Page.FromValues(response.Value.Entities, response.Value.NextLink, response.GetRawResponse()); | ||
}); | ||
} | ||
catch (Exception ex) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,17 @@ public async Task GetAllPhoneNumbers() | |
Assert.IsNotNull(numbers); | ||
} | ||
|
||
[Test] | ||
public async Task GetAllReservations() | ||
{ | ||
var client = CreateClient(); | ||
|
||
var reservationsPagable = client.GetAllReservationsAsync(); | ||
var reservations = await reservationsPagable.ToEnumerableAsync(); | ||
|
||
Assert.IsNotEmpty(reservations); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we guarantee that this is not empty on a fresh created resource and where we can't guarantee the order in which the tests execute? Consider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added CreateReservation step to the test so there will be at least one reservation |
||
} | ||
|
||
[Test] | ||
[TestCase(null, null)] | ||
[TestCase("en-US", null)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this 👍