Table of Contents

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

original ApiResponse

Properties

EqualityContract

protected virtual Type EqualityContract { get; }

Property Value

Type

IsSuccess

Gets a value indicating whether the request was successful.

public bool IsSuccess { get; }

Property Value

bool

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

string

Methods

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Equals(ApiResponse?)

public virtual bool Equals(ApiResponse? other)

Parameters

other ApiResponse

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

protected virtual bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

Returns

bool

ToString()

public override string ToString()

Returns

string

Operators

operator ==(ApiResponse?, ApiResponse?)

public static bool operator ==(ApiResponse? left, ApiResponse? right)

Parameters

left ApiResponse
right ApiResponse

Returns

bool

operator !=(ApiResponse?, ApiResponse?)

public static bool operator !=(ApiResponse? left, ApiResponse? right)

Parameters

left ApiResponse
right ApiResponse

Returns

bool