/// <summary>Adds a new user to the system.</summary> /// <param name="user">The details of the user to add to the system.</param> /// <param name="authorization">The JWT token to use for authorization (must include Bearer prefix)</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>OK</returns> /// <exception cref="SwaggerException">A server side error occurred.</exception> public async Task <Dictionary <string, object> > UserAddAsync(UserAddRequest user, string authorization, CancellationToken cancellationToken) { var url_ = string.Format("{0}/{1}?", BaseUrl, "users"); var client_ = new HttpClient(); PrepareRequest(client_, ref url_); client_.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", authorization); var content_ = new StringContent(JsonConvert.SerializeObject(user)); content_.Headers.ContentType.MediaType = "application/json"; var response_ = await client_.PostAsync(url_, content_, cancellationToken).ConfigureAwait(false); ProcessResponse(client_, response_); var responseData_ = await response_.Content.ReadAsByteArrayAsync().ConfigureAwait(false); var status_ = ((int)response_.StatusCode).ToString(); if (status_ == "200") { var result_ = default(Dictionary <string, object>); try { if (responseData_.Length > 0) { result_ = JsonConvert.DeserializeObject <Dictionary <string, object> >(Encoding.UTF8.GetString(responseData_)); } return(result_); } catch (Exception exception) { throw new SwaggerException("Could not deserialize the response body.", status_, responseData_, exception); } } else if (status_ == "201") { return(default(Dictionary <string, object>)); } else if (status_ == "400") { return(default(Dictionary <string, object>)); } else if (status_ == "401") { return(default(Dictionary <string, object>)); } else { } throw new SwaggerException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", status_, responseData_, null); }
/// <summary>Adds a new user to the system.</summary> /// <param name="user">The details of the user to add to the system.</param> /// <param name="authorization">The JWT token to use for authorization (must include Bearer prefix)</param> /// <returns>OK</returns> /// <exception cref="SwaggerException">A server side error occurred.</exception> public Task <Dictionary <string, object> > UserAddAsync(UserAddRequest user, string authorization) { return(UserAddAsync(user, authorization, CancellationToken.None)); }