Class ApiResponseBase
Defines the shared members of a response which was returned by a RESTful HTTP API after making a request with this library.
Inheritance
Implements
Namespace: ReqRest
Assembly: ReqRest.dll
Syntax
public abstract class ApiResponseBase : HttpResponseMessageBuilder, IHttpResponseMessageBuilder, IHttpHeadersBuilder<HttpResponseHeaders>, IHttpHeadersBuilder, IHttpContentBuilder, IHttpProtocolVersionBuilder, IHttpResponseReasonPhraseBuilder, IHttpStatusCodeBuilder, IBuilder
Constructors
ApiResponseBase(Nullable<HttpResponseMessage>, Nullable<IEnumerable<ResponseTypeInfo>>)
Initializes a new ApiResponseBase instance with the specified values.
Declaration
public ApiResponseBase(HttpResponseMessage? httpResponseMessage, IEnumerable<ResponseTypeInfo>? possibleResponseTypes)
Parameters
Type | Name | Description |
---|---|---|
Nullable<HttpResponseMessage> | httpResponseMessage | The HttpResponseMessage which was the underlying result returned by an HttpClient after making the associated request. If null, a new instance is created instead. |
Nullable<IEnumerable<ResponseTypeInfo>> | possibleResponseTypes | A set of elements that declare which .NET types may have been returned by the HTTP API in this response. If null, an empty set is used instead. |
Properties
PossibleResponseTypes
Gets a set of elements that declare which .NET types may have been returned by the HTTP API in this response.
Declaration
protected IReadOnlyCollection<ResponseTypeInfo> PossibleResponseTypes { get; }
Methods
GetCurrentResponseTypeInfo()
Returns the ResponseTypeInfo from the PossibleResponseTypes set which is the most appropriate one for the response's current status code.
This is null if the PossibleResponseTypes property doesn't contain any information which matches the response's status code.
Declaration
protected ResponseTypeInfo GetCurrentResponseTypeInfo()
Returns
Type | Description |
---|---|
ResponseTypeInfo | The ResponseTypeInfo from the PossibleResponseTypes set which is the most specific match for the response's current HTTP status code. If there are multiple instances that match this status code with equal specificness, it returns the first one. |