@@ -95,6 +95,47 @@ public async Task<CreateApiResourceResponse> CreateApiResource(CreateApiResource
9595 return response ;
9696 }
9797
98+ /// <summary>
99+ /// Creates the API scope.
100+ /// </summary>
101+ /// <param name="createApiScopeRequest">The create API scope request.</param>
102+ /// <param name="cancellationToken">The cancellation token.</param>
103+ /// <returns></returns>
104+ public async Task < CreateApiScopeResponse > CreateApiScope ( CreateApiScopeRequest createApiScopeRequest ,
105+ CancellationToken cancellationToken )
106+ {
107+ CreateApiScopeResponse response = null ;
108+ String requestUri = this . BuildRequestUrl ( "/api/apiscopes" ) ;
109+
110+ try
111+ {
112+ String requestSerialised = JsonConvert . SerializeObject ( createApiScopeRequest ) ;
113+
114+ StringContent httpContent = new StringContent ( requestSerialised , Encoding . UTF8 , "application/json" ) ;
115+
116+ // Add the access token to the client headers
117+ //this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
118+
119+ // Make the Http Call here
120+ HttpResponseMessage httpResponse = await this . HttpClient . PostAsync ( requestUri , httpContent , cancellationToken ) ;
121+
122+ // Process the response
123+ String content = await this . HandleResponse ( httpResponse , cancellationToken ) ;
124+
125+ // call was successful so now deserialise the body to the response object
126+ response = JsonConvert . DeserializeObject < CreateApiScopeResponse > ( content ) ;
127+ }
128+ catch ( Exception ex )
129+ {
130+ // An exception has occurred, add some additional information to the message
131+ Exception exception = new Exception ( $ "Error creating api scope { createApiScopeRequest . Name } .", ex ) ;
132+
133+ throw exception ;
134+ }
135+
136+ return response ;
137+ }
138+
98139 /// <summary>
99140 /// Creates the client.
100141 /// </summary>
@@ -331,6 +372,78 @@ public async Task<List<ApiResourceDetails>> GetApiResources(CancellationToken ca
331372 return response ;
332373 }
333374
375+ /// <summary>
376+ /// Gets the API scope.
377+ /// </summary>
378+ /// <param name="apiScopeName">Name of the API scope.</param>
379+ /// <param name="cancellationToken">The cancellation token.</param>
380+ /// <returns></returns>
381+ public async Task < ApiScopeDetails > GetApiScope ( String apiScopeName ,
382+ CancellationToken cancellationToken )
383+ {
384+ ApiScopeDetails response = null ;
385+ String requestUri = this . BuildRequestUrl ( $ "/api/apiscopes/{ apiScopeName } ") ;
386+
387+ try
388+ {
389+ // Add the access token to the client headers
390+ //this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
391+
392+ // Make the Http Call here
393+ HttpResponseMessage httpResponse = await this . HttpClient . GetAsync ( requestUri , cancellationToken ) ;
394+
395+ // Process the response
396+ String content = await this . HandleResponse ( httpResponse , cancellationToken ) ;
397+
398+ // call was successful so now deserialise the body to the response object
399+ response = JsonConvert . DeserializeObject < ApiScopeDetails > ( content ) ;
400+ }
401+ catch ( Exception ex )
402+ {
403+ // An exception has occurred, add some additional information to the message
404+ Exception exception = new Exception ( $ "Error getting api scope { apiScopeName } .", ex ) ;
405+
406+ throw exception ;
407+ }
408+
409+ return response ;
410+ }
411+
412+ /// <summary>
413+ /// Gets the API scopes.
414+ /// </summary>
415+ /// <param name="cancellationToken">The cancellation token.</param>
416+ /// <returns></returns>
417+ public async Task < List < ApiScopeDetails > > GetApiScopes ( CancellationToken cancellationToken )
418+ {
419+ List < ApiScopeDetails > response = null ;
420+ String requestUri = this . BuildRequestUrl ( "/api/apiscopes" ) ;
421+
422+ try
423+ {
424+ // Add the access token to the client headers
425+ //this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
426+
427+ // Make the Http Call here
428+ HttpResponseMessage httpResponse = await this . HttpClient . GetAsync ( requestUri , cancellationToken ) ;
429+
430+ // Process the response
431+ String content = await this . HandleResponse ( httpResponse , cancellationToken ) ;
432+
433+ // call was successful so now deserialise the body to the response object
434+ response = JsonConvert . DeserializeObject < List < ApiScopeDetails > > ( content ) ;
435+ }
436+ catch ( Exception ex )
437+ {
438+ // An exception has occurred, add some additional information to the message
439+ Exception exception = new Exception ( "Error getting api scopes." , ex ) ;
440+
441+ throw exception ;
442+ }
443+
444+ return response ;
445+ }
446+
334447 /// <summary>
335448 /// Gets the client.
336449 /// </summary>
0 commit comments