@@ -14,7 +14,9 @@ partial interface IOtsOperations
1414partial class OtsOperations
1515{
1616 Lazy < IControlOperations > _control ;
17- public IControlOperations Control => ( _control ??= client . Defer < IControlOperations > ( c => new ControlOperations ( path + "/control" , c ) ) ) . Value ;
17+ public IControlOperations Control
18+ => ( _control ??= _client . Defer < IControlOperations > (
19+ c => new ControlOperations ( _path + "/control" , c ) ) ) . Value ;
1820}
1921
2022public interface IControlOperations
@@ -26,12 +28,14 @@ public interface IControlOperations
2628 /// <param name="projectAlias">The project alias.</param>
2729 /// <param name="websiteUrl">The website URL.</param>
2830 /// <param name="userAgent">The user agent.</param>
31+ /// <param name="state">The state identity, which controls which tests apply. Default is <see cref="State.Normal"/></param>
2932 /// <param name="cancellationToken">The cancellation token.</param>
3033 /// <returns>The WebTrends response.</returns>
3134 Task < WebTrendsResponse < Project > > GetProjectAsync (
3235 string projectAlias ,
3336 string ? websiteUrl = null ,
3437 string ? userAgent = null ,
38+ State ? state = null ,
3539 CancellationToken cancellationToken = default ) ;
3640
3741 /// <summary>
@@ -44,50 +48,58 @@ Task<WebTrendsResponse<Project>> GetProjectAsync(
4448 Task < WebTrendsResponse < Project [ ] > > GetProjectsAsync (
4549 string ? websiteUrl = null ,
4650 string ? userAgent = null ,
51+ State ? state = State . Normal ,
4752 CancellationToken cancellationToken = default ) ;
4853}
4954
5055public class ControlOperations ( PathString path , ApiClient client ) : IControlOperations
5156{
57+ readonly PathString _path = path ;
58+ readonly ApiClient _client = client ;
59+
5260 public async Task < WebTrendsResponse < Project > > GetProjectAsync (
5361 string projectAlias ,
5462 string ? websiteUrl = null ,
5563 string ? userAgent = null ,
64+ State ? state = null ,
5665 CancellationToken cancellationToken = default )
5766 {
5867 Ensure . IsNotNullOrEmpty ( projectAlias , nameof ( projectAlias ) ) ;
5968
60- var operationPath = path + $ "/{ client . Settings . AccountId } -{ projectAlias } ";
69+ var operationPath = _path + $ "/{ _client . Settings . AccountId } -{ projectAlias } ";
6170
6271 var request = new WebTrendsRequest < OtsRequest > (
6372 HttpMethod . Post ,
6473 operationPath ,
65- CreateOtsRequest ( websiteUrl ) ,
66- BuildQuery ( client . Settings ) ,
74+ CreateOtsRequest ( websiteUrl , state ) ,
75+ BuildQuery ( _client . Settings ) ,
6776 userAgent ) ;
6877
69- return await client . FetchSingleAsync < OtsRequest , Project , ProjectBody > ( request , cancellationToken ) . ConfigureAwait ( false ) ;
78+ return await _client . FetchSingleAsync < OtsRequest , Project , ProjectBody > ( request , cancellationToken ) . ConfigureAwait ( false ) ;
7079 }
7180
7281 public async Task < WebTrendsResponse < Project [ ] > > GetProjectsAsync (
7382 string ? websiteUrl = null ,
7483 string ? userAgent = null ,
84+ State ? state = null ,
7585 CancellationToken cancellationToken = default )
7686 {
77- var operationPath = path + $ "/{ client . Settings . AccountId } ";
87+ var operationPath = _path + $ "/{ _client . Settings . AccountId } ";
7888
7989 var request = new WebTrendsRequest < OtsRequest > (
8090 HttpMethod . Post ,
8191 operationPath ,
82- CreateOtsRequest ( websiteUrl ) ,
83- BuildQuery ( client . Settings ) ,
92+ CreateOtsRequest ( websiteUrl , state ) ,
93+ BuildQuery ( _client . Settings ) ,
8494 userAgent ) ;
8595
86- return await client . FetchManyAsync < OtsRequest , Project , ProjectBody > ( request , cancellationToken ) . ConfigureAwait ( false ) ;
96+ return await _client . FetchManyAsync < OtsRequest , Project , ProjectBody > ( request , cancellationToken ) . ConfigureAwait ( false ) ;
8797 }
8898
89- OtsRequest CreateOtsRequest ( string ? websiteUrl )
90- => new OtsRequest ( websiteUrl is { Length : > 0 } ? websiteUrl : client . Settings . WebsiteUrl ) ;
99+ OtsRequest CreateOtsRequest ( string ? websiteUrl , State ? state )
100+ => new OtsRequest (
101+ websiteUrl is { Length : > 0 } ? websiteUrl : _client . Settings . WebsiteUrl ,
102+ state . GetValueOrDefault ( _client . Settings . State ) . ToString ( ) . ToLower ( ) ) ;
91103
92104 QueryString BuildQuery ( WebTrendsSettings settings )
93105 => new QueryStringBuilder ( )
0 commit comments