@@ -448,7 +448,7 @@ namespace {{packageName}}.Client
448
448
}
449
449
450
450
{{#supportsAsync}}
451
- private async Task<ApiResponse<T>> ExecAsync<T>(RestRequest req, IReadableConfiguration configuration)
451
+ private async Task<ApiResponse<T>> ExecAsync<T>(RestRequest req, IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken) )
452
452
{
453
453
RestClient client = new RestClient(_baseUrl);
454
454
@@ -479,7 +479,7 @@ namespace {{packageName}}.Client
479
479
480
480
InterceptRequest(req);
481
481
482
- var response = await client.ExecuteAsync<T>(req);
482
+ var response = await client.ExecuteAsync<T>(req, cancellationToken );
483
483
484
484
InterceptResponse(req, response);
485
485
@@ -526,11 +526,12 @@ namespace {{packageName}}.Client
526
526
/// <param name="options">The additional request options.</param>
527
527
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
528
528
/// GlobalConfiguration has been done before calling this method.</param>
529
+ /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
529
530
/// <returns>A Task containing ApiResponse</returns>
530
- public Task<ApiResponse<T>> GetAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
531
+ public Task<ApiResponse<T>> GetAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken) )
531
532
{
532
533
var config = configuration ?? GlobalConfiguration.Instance;
533
- return ExecAsync<T>(NewRequest(HttpMethod.Get, path, options, config), config);
534
+ return ExecAsync<T>(NewRequest(HttpMethod.Get, path, options, config), config, cancellationToken );
534
535
}
535
536
536
537
/// <summary>
@@ -540,11 +541,12 @@ namespace {{packageName}}.Client
540
541
/// <param name="options">The additional request options.</param>
541
542
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
542
543
/// GlobalConfiguration has been done before calling this method.</param>
544
+ /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
543
545
/// <returns>A Task containing ApiResponse</returns>
544
- public Task<ApiResponse<T>> PostAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
546
+ public Task<ApiResponse<T>> PostAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken) )
545
547
{
546
548
var config = configuration ?? GlobalConfiguration.Instance;
547
- return ExecAsync<T>(NewRequest(HttpMethod.Post, path, options, config), config);
549
+ return ExecAsync<T>(NewRequest(HttpMethod.Post, path, options, config), config, cancellationToken );
548
550
}
549
551
550
552
/// <summary>
@@ -554,11 +556,12 @@ namespace {{packageName}}.Client
554
556
/// <param name="options">The additional request options.</param>
555
557
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
556
558
/// GlobalConfiguration has been done before calling this method.</param>
559
+ /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
557
560
/// <returns>A Task containing ApiResponse</returns>
558
- public Task<ApiResponse<T>> PutAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
561
+ public Task<ApiResponse<T>> PutAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken) )
559
562
{
560
563
var config = configuration ?? GlobalConfiguration.Instance;
561
- return ExecAsync<T>(NewRequest(HttpMethod.Put, path, options, config), config);
564
+ return ExecAsync<T>(NewRequest(HttpMethod.Put, path, options, config), config, cancellationToken );
562
565
}
563
566
564
567
/// <summary>
@@ -568,11 +571,12 @@ namespace {{packageName}}.Client
568
571
/// <param name="options">The additional request options.</param>
569
572
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
570
573
/// GlobalConfiguration has been done before calling this method.</param>
574
+ /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
571
575
/// <returns>A Task containing ApiResponse</returns>
572
- public Task<ApiResponse<T>> DeleteAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
576
+ public Task<ApiResponse<T>> DeleteAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken) )
573
577
{
574
578
var config = configuration ?? GlobalConfiguration.Instance;
575
- return ExecAsync<T>(NewRequest(HttpMethod.Delete, path, options, config), config);
579
+ return ExecAsync<T>(NewRequest(HttpMethod.Delete, path, options, config), config, cancellationToken );
576
580
}
577
581
578
582
/// <summary>
@@ -582,11 +586,12 @@ namespace {{packageName}}.Client
582
586
/// <param name="options">The additional request options.</param>
583
587
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
584
588
/// GlobalConfiguration has been done before calling this method.</param>
589
+ /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
585
590
/// <returns>A Task containing ApiResponse</returns>
586
- public Task<ApiResponse<T>> HeadAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
591
+ public Task<ApiResponse<T>> HeadAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken) )
587
592
{
588
593
var config = configuration ?? GlobalConfiguration.Instance;
589
- return ExecAsync<T>(NewRequest(HttpMethod.Head, path, options, config), config);
594
+ return ExecAsync<T>(NewRequest(HttpMethod.Head, path, options, config), config, cancellationToken );
590
595
}
591
596
592
597
/// <summary>
@@ -596,11 +601,12 @@ namespace {{packageName}}.Client
596
601
/// <param name="options">The additional request options.</param>
597
602
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
598
603
/// GlobalConfiguration has been done before calling this method.</param>
604
+ /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
599
605
/// <returns>A Task containing ApiResponse</returns>
600
- public Task<ApiResponse<T>> OptionsAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
606
+ public Task<ApiResponse<T>> OptionsAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken) )
601
607
{
602
608
var config = configuration ?? GlobalConfiguration.Instance;
603
- return ExecAsync<T>(NewRequest(HttpMethod.Options, path, options, config), config);
609
+ return ExecAsync<T>(NewRequest(HttpMethod.Options, path, options, config), config, cancellationToken );
604
610
}
605
611
606
612
/// <summary>
@@ -610,11 +616,12 @@ namespace {{packageName}}.Client
610
616
/// <param name="options">The additional request options.</param>
611
617
/// <param name="configuration">A per-request configuration object. It is assumed that any merge with
612
618
/// GlobalConfiguration has been done before calling this method.</param>
619
+ /// <param name="cancellationToken">Token that enables callers to cancel the request.</param>
613
620
/// <returns>A Task containing ApiResponse</returns>
614
- public Task<ApiResponse<T>> PatchAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null)
621
+ public Task<ApiResponse<T>> PatchAsync<T>(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken) )
615
622
{
616
623
var config = configuration ?? GlobalConfiguration.Instance;
617
- return ExecAsync<T>(NewRequest(HttpMethod.Patch, path, options, config), config);
624
+ return ExecAsync<T>(NewRequest(HttpMethod.Patch, path, options, config), config, cancellationToken );
618
625
}
619
626
#endregion IAsynchronousClient
620
627
{{/supportsAsync}}
0 commit comments