/********* ** Private methods *********/ /// <summary>Get the generic Nexus error from an HTTP response, if available.</summary> /// <param name="response">The HTTP response.</param> /// <returns>Returns the error if applicable, else <c>null</c>.</returns> private GenericError GetError(IResponse response) { try { return(response.As <GenericError>().Result); } catch { return(null); } }
public async Task <string> As(string content) { // arrange IResponse response = this.ConstructResponseForModel(content); // act Model <string> actual = await response .As <Model <string> >() .VerifyTaskResultAsync(); // assert Assert.That(actual, Is.Not.Null, "deserialized model"); return(actual.Value); }
/// <summary>Asynchronously retrieve the response body as a deserialized model.</summary> /// <typeparam name="T">The response model to deserialize into.</typeparam> /// <exception cref="ApiException">An error occurred processing the response.</exception> public async Task <T> As <T>() { IResponse response = await this.AsResponse().ConfigureAwait(false); return(await response.As <T>().ConfigureAwait(false)); }