Show / Hide Table of Contents

Class ApodResponse

Contains information about the response from a request to the API.

Inheritance
Object
ApodResponse
Namespace: Apod
Assembly: Apod.dll
Syntax
public class ApodResponse : object
Remarks

Make sure that the StatusCode is OK before trying to access any content.

Examples
using var client = new ApodClient();
var response = await client.FetchApodAsync();

if (response.StatusCode != ApodStatusCode.OK)
{
    Console.WriteLine(response.Error.ErrorMessage);
    return;
}

Console.WriteLine(response.Content.Title);
Console.WriteLine(response.Content.Explanation);

Constructors

| Improve this Doc View Source

ApodResponse(ApodStatusCode, ApodContent[], ApodError)

The default constructor for an ApodResponse.

Declaration
public ApodResponse(ApodStatusCode statusCode, ApodContent[] allContent = null, ApodError error = null)
Parameters
Type Name Description
ApodStatusCode statusCode

The StatusCode value.

ApodContent[] allContent

The AllContent value.

ApodError error

The Error value.

Remarks

Unless you are overriding internal behaviour, you should not need to call this constructor.

Fields

| Improve this Doc View Source

AllContent

All the ApodContent of the response from the API request.

Declaration
public readonly ApodContent[] AllContent
Field Value
Type Description
ApodContent[]

All the ApodContent of the response from the API request.

Remarks

If the StatusCode is OK you can safely assume that this array is initialized.

Examples
var date = new DateTime(2000, 01, 01);
var response = await client.FetchApodAsync(date);
Console.WriteLine(response1.AllContent?.Length);

Output: 1


var response = await client.FetchApodAsync(5);
Console.WriteLine(response.AllContent?.Length);

Output: 5


| Improve this Doc View Source

Content

The ApodContent of the response from the API request.

Declaration
public readonly ApodContent Content
Field Value
Type Description
ApodContent

The ApodContent of the response from the API request.

Remarks

If the response contains more than one ApodContent, use AllContent to access all of them. If you still use this field, it will contain the most recent Astronomy Picture of the Day.

| Improve this Doc View Source

Error

Information about the error with the request, if any.

Declaration
public readonly ApodError Error
Field Value
Type Description
ApodError

Information about the error with the request.

Remarks

This will be null if the StatusCode is OK.

| Improve this Doc View Source

StatusCode

The status code of the request. Always make sure this is equal to OK before trying to access any content.

Declaration
public readonly ApodStatusCode StatusCode
Field Value
Type Description
ApodStatusCode

The status code of the request.

See Also

ApodContent
ApodStatusCode
ApodError
  • Improve this Doc
  • View Source
Back to top Generated by DocFX