advent-of-code-api-0.2.8.5: Advent of Code REST API bindings and servant API
Copyright(c) Justin Le 2019
LicenseBSD3
Maintainerjustin@jle.im
Stabilityexperimental
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Advent.API

Description

Raw Servant API for Advent of Code. Can be useful for building mock servers, generating documentation and other servanty things, or low-level raw requests.

If you use this to make requests directly, please use responsibly: do not make automated requests more than once per day and throttle all manual requestes. See notes in Advent.

Since: 0.2.0.0

Synopsis

Servant API

type AdventAPI = Capture "year" Integer :> (Get '[Scripts] NextDayTime :<|> (("day" :> (Capture "day" Day :> (Get '[Articles] (Map Part Text) :<|> (("input" :> Get '[RawText] Text) :<|> ("answer" :> (ReqBody '[FormUrlEncoded] SubmitInfo :> Post '[Articles] (Text :<|> SubmitRes))))))) :<|> ("leaderboard" :> (Get '[Divs] GlobalLeaderboard :<|> (("day" :> (Capture "day" Day :> Get '[Divs] DailyLeaderboard)) :<|> ("private" :> ("view" :> (Capture "code" PublicCode :> Get '[JSON] Leaderboard)))))))) Source #

REST API of Advent of Code.

Note that most of these requests assume a "session=" cookie.

adventAPI :: Proxy AdventAPI Source #

Proxy used for servant functions.

adventAPIPuzzleClient :: Integer -> Day -> ClientM (Map Part Text) :<|> (ClientM Text :<|> (SubmitInfo -> ClientM (Text :<|> SubmitRes))) Source #

A subset of adventAPIClient for only puzzle-related API routes, not leaderboard ones.

Types

data HTMLTags (tag :: Symbol) Source #

Interpret repsonse as a list of HTML Text found in the given type of tag

Since: 0.2.3.0

Instances

Instances details
Accept (HTMLTags cls :: Type) Source # 
Instance details

Defined in Advent.API

(FromTags tag a, KnownSymbol tag) => MimeUnrender (HTMLTags tag :: Type) a Source # 
Instance details

Defined in Advent.API

class FromTags tag a where Source #

Class for interpreting a list of Text in tags to some desired output.

Since: 0.2.3.0

Methods

fromTags :: p tag -> [Text] -> Maybe a Source #

Instances

Instances details
FromTags "article" SubmitRes Source # 
Instance details

Defined in Advent.API

Methods

fromTags :: p "article" -> [Text] -> Maybe SubmitRes Source #

FromTags "div" DailyLeaderboard Source # 
Instance details

Defined in Advent.API

Methods

fromTags :: p "div" -> [Text] -> Maybe DailyLeaderboard Source #

FromTags "div" GlobalLeaderboard Source # 
Instance details

Defined in Advent.API

Methods

fromTags :: p "div" -> [Text] -> Maybe GlobalLeaderboard Source #

FromTags "script" NextDayTime Source # 
Instance details

Defined in Advent.API

Methods

fromTags :: p "script" -> [Text] -> Maybe NextDayTime Source #

FromTags (cls :: k) Text Source # 
Instance details

Defined in Advent.API

Methods

fromTags :: p cls -> [Text] -> Maybe Text Source #

FromTags (cls :: k) [Text] Source # 
Instance details

Defined in Advent.API

Methods

fromTags :: p cls -> [Text] -> Maybe [Text] Source #

(Ord a, Enum a, Bounded a) => FromTags (cls :: k) (Map a Text) Source # 
Instance details

Defined in Advent.API

Methods

fromTags :: p cls -> [Text] -> Maybe (Map a Text) Source #

(FromTags cls a, FromTags cls b) => FromTags (cls :: k) (a :<|> b) Source # 
Instance details

Defined in Advent.API

Methods

fromTags :: p cls -> [Text] -> Maybe (a :<|> b) Source #

type Articles = HTMLTags "article" Source #

Interpret a response as a list of HTML Text found in article tags.

type Divs = HTMLTags "div" Source #

Interpret a response as a list of HTML Text found in div tags.

Since: 0.2.3.0

type Scripts = HTMLTags "script" Source #

Interpret a response as a list of HTML Text found in script tags.

data RawText Source #

Raw "text/plain" MIME type

Internal

processHTML Source #

Arguments

:: String

tag type

-> Text

html

-> [Text] 

Process an HTML webpage into a list of all contents in the given tag type