Skip to content

ApiResponse\<T>

ApiResponse<T> is the generic response-envelope DTO used to represent a single API call's results: it carries the server/version identity of the responding service, the resolved HttpStatusCode, and a typed array of result items. It has no constructor logic beyond the implicit default and no methods — it is a pure data holder consumed by SAIF.Web.API.Clients's JsonHttpClient to deserialize and return API responses to callers.

Purpose

  • Provide a uniform, generic shape for API responses so that any consumer of a SAIF Web API can deserialize results of any type T through one envelope type, rather than a bespoke response class per endpoint.
  • Carry the responding server's identity (Server, Version) and the resolved HttpStatusCode alongside the typed Results array, so callers have both the payload and its transport-level status available together.

Context

  • Namespace: SAIF.API.Responses
  • Assembly/package: SAIF.Web.API.Core (bundled into the SAIF.Web.API.Clients NuGet package)

Public members

Member Signature Purpose
Server string Server { get; set; } Identifies the server that produced the response.
Version string Version { get; set; } Identifies the API/service version that produced the response.
StatusCode HttpStatusCode StatusCode { get; set; } Carries the resolved HTTP status code associated with this response.
Results T[] Results { get; set; } Holds the typed array of result items returned by the API call.

Behavioral notes

  • This type has no constructor logic beyond the implicit parameterless default, and no methods — every member is a plain settable property populated by the caller (e.g., during deserialization).
  • JsonHttpClient.GetApiResponse<T> (in SAIF.Web.API.Clients) is an observed caller: it constructs new ApiResponse<T>() and explicitly populates Results, Server, StatusCode, and Version from the deserialized JSON response before returning the instance to its own callers (GetResponse<T>, PostJson<T>, PutJson<T>, PatchJson<T>, DeleteJson<T>).

Constraints and usage notes

  • Results is a plain array (T[]), not a collection interface — callers should not assume list-mutation semantics.

Sources

  • src/SAIF.Web.API.Core/ApiResponse.cs
  • src/SAIF.Web.API.Clients/JsonHttpClient.cs