/// <summary>Confirm user account using code provided in mail</summary> /// <param name="model">Model containing id and code</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>Success</returns> /// <exception cref="ImperaPlusException">A server side error occurred.</exception> public async Task ConfirmEmailAsync(ConfirmationModel model, CancellationToken cancellationToken) { var url_ = string.Format("{0}/{1}", BaseUrl, "api/Account/ConfirmEmail"); var client_ = await CreateHttpClientAsync(cancellationToken).ConfigureAwait(false); var request_ = new HttpRequestMessage(); PrepareRequest(client_, ref url_); var content_ = new StringContent(JsonConvert.SerializeObject(model)); content_.Headers.ContentType.MediaType = "application/json"; request_.Content = content_; request_.Method = new HttpMethod("POST"); request_.RequestUri = new Uri(url_, UriKind.RelativeOrAbsolute); var response_ = await client_.SendAsync(request_, HttpCompletionOption.ResponseContentRead, cancellationToken).ConfigureAwait(false); ProcessResponse(client_, response_); var responseData_ = await response_.Content.ReadAsByteArrayAsync().ConfigureAwait(false); var status_ = ((int)response_.StatusCode).ToString(); if (status_ == "400") { var result_ = default(ErrorResponse); try { if (responseData_.Length > 0) result_ = JsonConvert.DeserializeObject<ErrorResponse>(Encoding.UTF8.GetString(responseData_, 0, responseData_.Length)); } catch (Exception exception) { throw new ImperaPlusException("Could not deserialize the response body.", status_, responseData_, exception); } throw new ImperaPlusException<ErrorResponse>("Client Error", status_, responseData_, result_, null); } else if (status_ == "200") { return; } else { } throw new ImperaPlusException("The HTTP status code of the response was not expected (" + (int)response_.StatusCode + ").", status_, responseData_, null); }
/// <summary>Confirm user account using code provided in mail</summary> /// <param name="model">Model containing id and code</param> /// <returns>Success</returns> /// <exception cref="ImperaPlusException">A server side error occurred.</exception> public Task ConfirmEmailAsync(ConfirmationModel model) { return ConfirmEmailAsync(model, CancellationToken.None); }