diff --git a/src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs b/src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs
index 6ac86fcf4..62d981f64 100644
--- a/src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs
+++ b/src/Twilio/Clients/BearerToken/TwilioOrgsTokenRestClient.cs
@@ -236,7 +236,7 @@ public bool isTokenExpired(string token){
///
/// request to make
/// Task that resolves to the response of the request
- public async Task RequestAsync(TokenRequest request)
+ public async Task RequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default)
{
request.SetAuth(_accessToken);
@@ -252,7 +252,7 @@ public async Task RequestAsync(TokenRequest request)
Response response;
try
{
- response = await HttpClient.MakeRequestAsync(request);
+ response = await HttpClient.MakeRequestAsync(request, cancellationToken);
}
catch (Exception clientException)
{
diff --git a/src/Twilio/Clients/ITwilioRestClient.cs b/src/Twilio/Clients/ITwilioRestClient.cs
index 496c03f9f..aaf318cc3 100644
--- a/src/Twilio/Clients/ITwilioRestClient.cs
+++ b/src/Twilio/Clients/ITwilioRestClient.cs
@@ -37,7 +37,7 @@ public interface ITwilioRestClient
///
/// Request to make
/// response of the request
- System.Threading.Tasks.Task RequestAsync(Request request);
+ System.Threading.Tasks.Task RequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default);
#endif
}
}
diff --git a/src/Twilio/Clients/TwilioRestClient.cs b/src/Twilio/Clients/TwilioRestClient.cs
index 55d6871e1..bcf9d6614 100644
--- a/src/Twilio/Clients/TwilioRestClient.cs
+++ b/src/Twilio/Clients/TwilioRestClient.cs
@@ -169,7 +169,7 @@ public Response Request(Request request)
///
/// request to make
/// Task that resolves to the response of the request
- public async Task RequestAsync(Request request)
+ public async Task RequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default)
{
if(_username != null && _password != null){
request.SetAuth(_username, _password);
@@ -190,7 +190,7 @@ public async Task RequestAsync(Request request)
Response response;
try
{
- response = await HttpClient.MakeRequestAsync(request);
+ response = await HttpClient.MakeRequestAsync(request, cancellationToken);
}
catch (Exception clientException)
{
diff --git a/src/Twilio/Http/BearerToken/SystemNetTokenHttpClient.cs b/src/Twilio/Http/BearerToken/SystemNetTokenHttpClient.cs
index dfbc84369..38c0a004b 100644
--- a/src/Twilio/Http/BearerToken/SystemNetTokenHttpClient.cs
+++ b/src/Twilio/Http/BearerToken/SystemNetTokenHttpClient.cs
@@ -60,7 +60,7 @@ public override Response MakeRequest(TokenRequest request)
///
/// Twilio response
/// Task that resolves to the response
- public override async Task MakeRequestAsync(TokenRequest request)
+ public override async Task MakeRequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default)
{
var httpRequest = BuildHttpRequest(request);
if (!Equals(request.Method, HttpMethod.Get))
@@ -81,7 +81,7 @@ public override async Task MakeRequestAsync(TokenRequest request)
this.LastRequest = request;
this.LastResponse = null;
- var httpResponse = await _httpClient.SendAsync(httpRequest).ConfigureAwait(false);
+ var httpResponse = await _httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
var reader = new StreamReader(await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false));
// Create and return a new Response. Keep a reference to the last
diff --git a/src/Twilio/Http/BearerToken/TokenHttpClient.cs b/src/Twilio/Http/BearerToken/TokenHttpClient.cs
index 45e5ea866..ded49ca83 100644
--- a/src/Twilio/Http/BearerToken/TokenHttpClient.cs
+++ b/src/Twilio/Http/BearerToken/TokenHttpClient.cs
@@ -36,7 +36,7 @@ public abstract class TokenHttpClient
/// request to make
/// throws exception on network or connection errors.
/// response of the request
- public abstract System.Threading.Tasks.Task MakeRequestAsync(TokenRequest request);
+ public abstract System.Threading.Tasks.Task MakeRequestAsync(TokenRequest request, System.Threading.CancellationToken cancellationToken = default);
#endif
}
diff --git a/src/Twilio/Http/HttpClient.cs b/src/Twilio/Http/HttpClient.cs
index 674ab133e..aa6089d7e 100644
--- a/src/Twilio/Http/HttpClient.cs
+++ b/src/Twilio/Http/HttpClient.cs
@@ -34,7 +34,7 @@ public abstract class HttpClient
/// request to make
/// throws exception on network or connection errors.
/// response of the request
- public abstract System.Threading.Tasks.Task MakeRequestAsync(Request request);
+ public abstract System.Threading.Tasks.Task MakeRequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default);
#endif
///
diff --git a/src/Twilio/Http/SystemNetHttpClient.cs b/src/Twilio/Http/SystemNetHttpClient.cs
index 6cf90571e..a0f2ccc36 100644
--- a/src/Twilio/Http/SystemNetHttpClient.cs
+++ b/src/Twilio/Http/SystemNetHttpClient.cs
@@ -58,7 +58,7 @@ public override Response MakeRequest(Request request)
///
/// Twilio response
/// Task that resolves to the response
- public override async Task MakeRequestAsync(Request request)
+ public override async Task MakeRequestAsync(Request request, System.Threading.CancellationToken cancellationToken = default)
{
var httpRequest = BuildHttpRequest(request);
if (!Equals(request.Method, HttpMethod.Get))
@@ -76,7 +76,7 @@ public override async Task MakeRequestAsync(Request request)
this.LastRequest = request;
this.LastResponse = null;
- var httpResponse = await _httpClient.SendAsync(httpRequest).ConfigureAwait(false);
+ var httpResponse = await _httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
var reader = new StreamReader(await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false));
// Create and return a new Response. Keep a reference to the last
diff --git a/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs b/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs
index 1b7405a36..452cd6136 100644
--- a/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs
+++ b/src/Twilio/Rest/Accounts/V1/AuthTokenPromotionResource.cs
@@ -66,11 +66,12 @@ public static AuthTokenPromotionResource Update(UpdateAuthTokenPromotionOptions
/// Client to make requests to Twilio
/// Task that resolves to A single instance of AuthTokenPromotion
#if !NET35
- public static async System.Threading.Tasks.Task UpdateAsync(UpdateAuthTokenPromotionOptions options,
- ITwilioRestClient client = null)
+ public static async System.Threading.Tasks.Task UpdateAsync(UpdateAuthTokenPromotionOptions options,
+ ITwilioRestClient client = null,
+ System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
- var response = await client.RequestAsync(BuildUpdateRequest(options, client));
+ var response = await client.RequestAsync(BuildUpdateRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
@@ -90,10 +91,11 @@ public static AuthTokenPromotionResource Update(
/// Client to make requests to Twilio
/// Task that resolves to A single instance of AuthTokenPromotion
public static async System.Threading.Tasks.Task UpdateAsync(
- ITwilioRestClient client = null)
+ ITwilioRestClient client = null,
+ System.Threading.CancellationToken cancellationToken = default)
{
var options = new UpdateAuthTokenPromotionOptions(){ };
- return await UpdateAsync(options, client);
+ return await UpdateAsync(options, client, cancellationToken);
}
#endif
diff --git a/src/Twilio/Rest/Accounts/V1/BulkConsentsResource.cs b/src/Twilio/Rest/Accounts/V1/BulkConsentsResource.cs
index ee76ff29b..29d1879d6 100644
--- a/src/Twilio/Rest/Accounts/V1/BulkConsentsResource.cs
+++ b/src/Twilio/Rest/Accounts/V1/BulkConsentsResource.cs
@@ -66,10 +66,10 @@ public static BulkConsentsResource Create(CreateBulkConsentsOptions options, ITw
/// Create BulkConsents parameters
/// Client to make requests to Twilio
/// Task that resolves to A single instance of BulkConsents
- public static async System.Threading.Tasks.Task CreateAsync(CreateBulkConsentsOptions options, ITwilioRestClient client = null)
+ public static async System.Threading.Tasks.Task CreateAsync(CreateBulkConsentsOptions options, ITwilioRestClient client = null, System.Threading.CancellationToken cancellationToken = default)
{
client = client ?? TwilioClient.GetRestClient();
- var response = await client.RequestAsync(BuildCreateRequest(options, client));
+ var response = await client.RequestAsync(BuildCreateRequest(options, client), cancellationToken);
return FromJson(response.Content);
}
#endif
@@ -93,10 +93,11 @@ public static BulkConsentsResource Create(
/// Task that resolves to A single instance of BulkConsents
public static async System.Threading.Tasks.Task CreateAsync(
List