aztro

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const AztroBaseURL = "https://aztro.sameerkumar.website"

Variables

This section is empty.

Functions

func WithDay

func WithDay(day Day) func(*AztroRequestParam)

WithDay is function to add Day into AztroRequestParam

Types

type AztroClient

type AztroClient struct {
	HTTPReq    *http.Request
	HTTPClient *http.Client
}

AztroClient is struct represent a client to query to Aztro API

func NewAztroClient

func NewAztroClient() (*AztroClient, error)

NewAztroClient is function to create AztroClient

func (*AztroClient) GetHoroscope

func (ac *AztroClient) GetHoroscope(param *AztroRequestParam) (Horoscope, *AztroErr)

GetHoroscope is function to get a horoscope based on requested param

type AztroErr

type AztroErr struct {
	Message        string `json:"message"`
	HTTPStatusCode int    `json:"status_code,omitempty"`
}

AztroErr is struct that represent error object from Aztro API

type AztroRequestParam

type AztroRequestParam struct {
	Sign Sign
	Day  Day
}

AztroRequestParam struct represent a request parameter to query from Aztro API

func NewAztroRequestParam

func NewAztroRequestParam(sign Sign, opts ...func(*AztroRequestParam)) *AztroRequestParam

NewAztroRequestParam is function to create a new AztroRequestParam, Default Day=Today

type Day

type Day int
const (
	Yesterday Day = iota
	Today
	Tomorrow
)

func (Day) String

func (d Day) String() string

String for Day struct is to convert it into string

type Horoscope

type Horoscope struct {
	DateRange     string `json:"date_range"`
	CurrentDate   string `json:"current_date"`
	Description   string `json:"description"`
	Compatibility string `json:"compatibility"`
	Mood          string `json:"mood"`
	Color         string `json:"color"`
	LuckyNumber   string `json:"lucky_number"`
	LuckyTime     string `json:"lucky_time"`
}

Horoscope is struct that represent a horoscope

type IAztroClient

type IAztroClient interface {
	GetHoroscope(param *AztroRequestParam) (Horoscope, *AztroErr)
}

IAztroClient is interface that represent a query to Aztro API

type Sign

type Sign int
const (
	Aries Sign = iota
	Taurus
	Gemini
	Cancer
	Leo
	Virgo
	Libra
	Scorpio
	Sagittarius
	Capricorn
	Aquarius
	Pisces
)

func (Sign) String

func (s Sign) String() string

String for sign struct is to convert it into string

Jump to

Keyboard shortcuts

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