apod

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const APIPath = "/planetary/apod"

Variables

This section is empty.

Functions

This section is empty.

Types

type Opts

type Opts func(*Request)

func WithAPIKey

func WithAPIKey(apiKey string) Opts

WithAPIKey returns function for setting Request.APIKey.

func WithCount

func WithCount(count int) Opts

WithCount returns function for setting Request.Count.

func WithDate

func WithDate(date nasaapi.Date) Opts

WithDate returns function for setting Request.Date.

func WithEndDate

func WithEndDate(endDate nasaapi.Date) Opts

WithEndDate returns function for setting Request.EndDate.

func WithStartDate

func WithStartDate(startDate nasaapi.Date) Opts

WithStartDate returns function for setting Request.StartDate.

func WithThumbs

func WithThumbs(thumbs bool) Opts

WithThumbs returns function for setting Request.Thumbs.

type Request added in v0.2.0

type Request struct {
	Date      nasaapi.Date `json:"date,omitempty"`       // The date of the APOD image to retrieve
	StartDate nasaapi.Date `json:"start_date,omitempty"` // The start of a date range, when requesting date for a range of dates. Cannot be used with date.
	EndDate   nasaapi.Date `json:"end_date,omitempty"`   // The end of the date range, when used with start_date.
	Count     int          `json:"count,omitempty"`      // If this is specified then count randomly chosen images will be returned. Cannot be used with date or start_date and end_date.
	Thumbs    bool         `json:"thumbs,omitempty"`     // Return the URL of video thumbnail. If an APOD is not a video, this parameter is ignored.
	APIKey    string       `json:"api_key"`              // api.nasa.gov key for expanded usage
}

Request is for context of APOD API.

func New

func New(opts ...Opts) *Request

New returns new Request instance for APOD API.

func (*Request) Encode added in v0.2.0

func (apod *Request) Encode() (string, error)

Encode returns JSON string.

func (*Request) Get added in v0.2.0

func (apod *Request) Get(ctx context.Context) ([]*Response, error)

Get method gets APOD data from NASA API, and returns []*Response instance.

func (*Request) GetRawData added in v0.2.0

func (apod *Request) GetRawData(ctx context.Context) (io.ReadCloser, error)

GetRawData method gets APOD data from NASA API, and returns raw response string.

func (*Request) String added in v0.2.0

func (apod *Request) String() string

Stringger method.

type Response

type Response struct {
	Copyright      string       `json:"copyright,omitempty"`
	Date           nasaapi.Date `json:"date,omitempty"`
	Explanation    string       `json:"explanation,omitempty"`
	HdUrl          string       `json:"hdurl,omitempty"`
	MediaType      string       `json:"media_type,omitempty"`
	ServiceVersion string       `json:"service_version,omitempty"`
	Title          string       `json:"title,omitempty"`
	Url            string       `json:"url,omitempty"`
	ThumbnailUrl   string       `json:"thumbnail_url,omitempty"`
}

Response is response data from NASA APOD API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL