/// <summary> /// Returns a new <see cref="HttpResponseMessage"/> with the <see cref="HttpResponseMessage.Content"/> set to <paramref name="scimResponse"/>. If /// <paramref name="scimResponse"/> contains an error, it will attempt to parse the <see cref="ScimError.Status"/> as an <see cref="HttpStatusCode"/> /// and assign it to the response message. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="scimResponse">The content contained in the HTTP response.</param> /// <param name="httpRequestMessage">The active <see cref="HttpRequestMessage"/>.</param> /// <param name="statusCode">The <see cref="HttpStatusCode"/> to set if <paramref name="scimResponse"/> has no errors.</param> /// <returns>HttpResponseMessage instance.</returns> public static HttpResponseMessage ToHttpResponseMessage <T>( this IScimResponse <T> scimResponse, HttpRequestMessage httpRequestMessage, HttpStatusCode statusCode = HttpStatusCode.OK) { return(scimResponse.ToHttpResponseMessage(httpRequestMessage, null, statusCode)); }
/// <summary> /// Invokes the specified <paramref name="responseBuilder" /> action if <paramref name="scimResponse" /> does not contain an error - returning the configured <see cref="HttpResponseMessage" />. /// If <paramref name="scimResponse" /> contains errors, the returned response with contain the error content and will attempt to parse the <see cref="ScimError.Status" /> as an /// <see cref="HttpStatusCode" /> and assign it to the response message. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="scimResponse">The <see cref="IScimResponse{T}" /> used to build the <see cref="HttpResponseMessage" />.</param> /// <param name="httpRequestMessage">The active <see cref="HttpRequestMessage" />.</param> /// <param name="responseBuilder">The response builder method to invoke when no errors exist.</param> /// <param name="setResponseContent">Determines whether to set the <see ref="scimResponse.Data" /> as the response content.</param> /// <returns>HttpResponseMessage instance.</returns> public static HttpResponseMessage ToHttpResponseMessage <T>( this IScimResponse <T> scimResponse, HttpRequestMessage httpRequestMessage, Action <T, HttpResponseMessage> responseBuilder, bool setResponseContent = true) { return(scimResponse.ToHttpResponseMessage(httpRequestMessage, responseBuilder, HttpStatusCode.OK, setResponseContent)); }