@@ -14,7 +14,9 @@ partial interface IOtsOperations
14
14
partial class OtsOperations
15
15
{
16
16
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 ;
18
20
}
19
21
20
22
public interface IControlOperations
@@ -26,12 +28,14 @@ public interface IControlOperations
26
28
/// <param name="projectAlias">The project alias.</param>
27
29
/// <param name="websiteUrl">The website URL.</param>
28
30
/// <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>
29
32
/// <param name="cancellationToken">The cancellation token.</param>
30
33
/// <returns>The WebTrends response.</returns>
31
34
Task < WebTrendsResponse < Project > > GetProjectAsync (
32
35
string projectAlias ,
33
36
string ? websiteUrl = null ,
34
37
string ? userAgent = null ,
38
+ State ? state = null ,
35
39
CancellationToken cancellationToken = default ) ;
36
40
37
41
/// <summary>
@@ -44,50 +48,58 @@ Task<WebTrendsResponse<Project>> GetProjectAsync(
44
48
Task < WebTrendsResponse < Project [ ] > > GetProjectsAsync (
45
49
string ? websiteUrl = null ,
46
50
string ? userAgent = null ,
51
+ State ? state = State . Normal ,
47
52
CancellationToken cancellationToken = default ) ;
48
53
}
49
54
50
55
public class ControlOperations ( PathString path , ApiClient client ) : IControlOperations
51
56
{
57
+ readonly PathString _path = path ;
58
+ readonly ApiClient _client = client ;
59
+
52
60
public async Task < WebTrendsResponse < Project > > GetProjectAsync (
53
61
string projectAlias ,
54
62
string ? websiteUrl = null ,
55
63
string ? userAgent = null ,
64
+ State ? state = null ,
56
65
CancellationToken cancellationToken = default )
57
66
{
58
67
Ensure . IsNotNullOrEmpty ( projectAlias , nameof ( projectAlias ) ) ;
59
68
60
- var operationPath = path + $ "/{ client . Settings . AccountId } -{ projectAlias } ";
69
+ var operationPath = _path + $ "/{ _client . Settings . AccountId } -{ projectAlias } ";
61
70
62
71
var request = new WebTrendsRequest < OtsRequest > (
63
72
HttpMethod . Post ,
64
73
operationPath ,
65
- CreateOtsRequest ( websiteUrl ) ,
66
- BuildQuery ( client . Settings ) ,
74
+ CreateOtsRequest ( websiteUrl , state ) ,
75
+ BuildQuery ( _client . Settings ) ,
67
76
userAgent ) ;
68
77
69
- return await client . FetchSingleAsync < OtsRequest , Project , ProjectBody > ( request , cancellationToken ) . ConfigureAwait ( false ) ;
78
+ return await _client . FetchSingleAsync < OtsRequest , Project , ProjectBody > ( request , cancellationToken ) . ConfigureAwait ( false ) ;
70
79
}
71
80
72
81
public async Task < WebTrendsResponse < Project [ ] > > GetProjectsAsync (
73
82
string ? websiteUrl = null ,
74
83
string ? userAgent = null ,
84
+ State ? state = null ,
75
85
CancellationToken cancellationToken = default )
76
86
{
77
- var operationPath = path + $ "/{ client . Settings . AccountId } ";
87
+ var operationPath = _path + $ "/{ _client . Settings . AccountId } ";
78
88
79
89
var request = new WebTrendsRequest < OtsRequest > (
80
90
HttpMethod . Post ,
81
91
operationPath ,
82
- CreateOtsRequest ( websiteUrl ) ,
83
- BuildQuery ( client . Settings ) ,
92
+ CreateOtsRequest ( websiteUrl , state ) ,
93
+ BuildQuery ( _client . Settings ) ,
84
94
userAgent ) ;
85
95
86
- return await client . FetchManyAsync < OtsRequest , Project , ProjectBody > ( request , cancellationToken ) . ConfigureAwait ( false ) ;
96
+ return await _client . FetchManyAsync < OtsRequest , Project , ProjectBody > ( request , cancellationToken ) . ConfigureAwait ( false ) ;
87
97
}
88
98
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 ( ) ) ;
91
103
92
104
QueryString BuildQuery ( WebTrendsSettings settings )
93
105
=> new QueryStringBuilder ( )
0 commit comments