Class ApiResponse
- Namespace
- Tudormobile.Airthings
- Assembly
- Tudormobile.Airthings.dll
Base class for all Airthings API responses.
public record ApiResponse : IEquatable<ApiResponse>
- Inheritance
-
ApiResponse
- Implements
- Derived
- Inherited Members
Remarks
Mapping of the Airthings API response.
Constructors
ApiResponse()
public ApiResponse()
ApiResponse(ApiResponse)
protected ApiResponse(ApiResponse original)
Parameters
originalApiResponse
Properties
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
IsSuccess
Gets a value indicating whether the request was successful.
public bool IsSuccess { get; }
Property Value
Remarks
Returns true when Message is null. None of the current Airthings API endpoints return a message on success, so this property is implemented to catch the error replies, which all return a simple message. Exceptions will aslo use the message property to return the error details, so this is a catch-all for any failed request.
If the API adds successful messages in the future, this logic will need to be updated along with the API response object builders to check for specific errors instead, and explicitly set the success status. For now, this is sufficient to catch all errors, and the API does not return any messages on success.
Message
Gets or sets an error message returned by the API, or null if the request succeeded.
public string? Message { get; set; }
Property Value
Methods
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
Equals(ApiResponse?)
public virtual bool Equals(ApiResponse? other)
Parameters
otherApiResponse
Returns
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
public override string ToString()
Returns
Operators
operator ==(ApiResponse?, ApiResponse?)
public static bool operator ==(ApiResponse? left, ApiResponse? right)
Parameters
leftApiResponserightApiResponse
Returns
operator !=(ApiResponse?, ApiResponse?)
public static bool operator !=(ApiResponse? left, ApiResponse? right)
Parameters
leftApiResponserightApiResponse