aoc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://adventofcode.com"

Variables

This section is empty.

Functions

func CalendarURL

func CalendarURL(year int) string

func DayURL

func DayURL(year, day int) string

func InputURL

func InputURL(year, day int) string

func IsDayUnlocked

func IsDayUnlocked(year int, day int) (bool, error)

isDayUnlocked checks if a challenge is unlocked based on the given year and day.

func SubmitURL

func SubmitURL(year, day int) string

Types

type Client

type Client struct {
	http.Client
}

func NewClient

func NewClient(token string, options ...Option) *Client

NewClient initializes a new client with a base URL and session token in a jar

func (*Client) GetDescription

func (c *Client) GetDescription(year, day int) (HTMLContent, error)

getDescription fetches the and parses the html content

func (*Client) GetExamples

func (c *Client) GetExamples(year, day int) ([]string, error)

func (*Client) GetInput

func (c *Client) GetInput(year, day int) (string, error)

func (*Client) Request

func (c *Client) Request(req *http.Request) (*http.Response, error)

func (*Client) RequestData

func (c *Client) RequestData(req *http.Request) ([]byte, error)

func (*Client) SubmitAnswer

func (c *Client) SubmitAnswer(level Level, year, day int, answer string) (SubmissionOutcome, error)

type DebugTransport

type DebugTransport struct {
	Transport http.RoundTripper
}

func NewDebugTransport

func NewDebugTransport() *DebugTransport

func (*DebugTransport) RoundTrip

func (d *DebugTransport) RoundTrip(req *http.Request) (*http.Response, error)

type HTMLContent

type HTMLContent string

func (HTMLContent) ToMarkdown

func (c HTMLContent) ToMarkdown(year int) (Markdown, error)

convert html to markdown

type Level

type Level int
const (
	LevelOne Level = 1
	LevelTwo
)

func ParseLevel

func ParseLevel(s string) Level

type Markdown

type Markdown = string

type Option

type Option func(c *Client)

func WithRedirectPolicy

func WithRedirectPolicy(f func(req *http.Request, via []*http.Request) error) Option

WithRedirectPolicy sets a custom redirecct policy for the client

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the timeout duration for the client

func WithTransport

func WithTransport(transport http.RoundTripper) Option

WithTransport sets a custom transport for the client

type RequestError

type RequestError struct {
	StatusCode int
	URL        string
	Err        error
}

func (RequestError) Error

func (e RequestError) Error() string

type SubmissionOutcome

type SubmissionOutcome int
const (
	SubmissionCorrect SubmissionOutcome = iota
	SubmissionIncorrect
	SubmissionWait
	SubmissionWrongLevel
	SubmissionError
)

func (SubmissionOutcome) String

func (so SubmissionOutcome) String() string

type UnknownResponseError

type UnknownResponseError struct {
	StatusCode int
	Response   string
}

func (UnknownResponseError) Error

func (e UnknownResponseError) Error() string

Jump to

Keyboard shortcuts

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