Struct ApiResponse<T>
Represents a structured response from an API call, encapsulating a response code, an optional message, an optional value, and the endpoint reference.
public readonly struct ApiResponse<T> : IEquatable<ApiResponse<T>>, IEquatable<T>
Type Parameters
T
The type of the value contained in the response.
- Implements
-
IEquatable<T>
- Inherited Members
Constructors
- ApiResponse(ApiResponseCode, string, string)
Initializes a new instance of the ApiResponse<T> struct with a response code, message, and endpoint.
- ApiResponse(ApiResponseCode, T, string)
Initializes a new instance of the ApiResponse<T> struct with a response code, value, and endpoint.
Properties
- Endpoint
Gets the endpoint that was called for this response.
- IsSuccess
Indicates whether the response represents a successful API call.
- Message
Gets the optional message describing the result of the API call.
- ResponseCode
Gets the response code indicating the status of the API call.
- Value
Gets the value returned from the API, if applicable.
Methods
- EnsureSuccess()
Ensures that the API call was successful, throwing an exception if it was not.
- Equals(ApiResponse<T>)
Indicates whether the current object is equal to another object of the same type.
- Equals(object?)
Indicates whether this instance and a specified object are equal.
- Equals(T?)
Indicates whether the current object is equal to another object of the same type.
- GetHashCode()
Returns the hash code for this instance.
Operators
- implicit operator T(ApiResponse<T>)
Implicitly converts the ApiResponse<T> to its value if the response was successful.