Copyright | (c) Justin Le 2019 |
---|---|
License | BSD3 |
Maintainer | justin@jle.im |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- 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))))))))
- adventAPI :: Proxy AdventAPI
- adventAPIClient :: Integer -> ClientM NextDayTime :<|> ((Day -> ClientM (Map Part Text) :<|> (ClientM Text :<|> (SubmitInfo -> ClientM (Text :<|> SubmitRes)))) :<|> (ClientM GlobalLeaderboard :<|> ((Day -> ClientM DailyLeaderboard) :<|> (PublicCode -> ClientM Leaderboard))))
- adventAPIPuzzleClient :: Integer -> Day -> ClientM (Map Part Text) :<|> (ClientM Text :<|> (SubmitInfo -> ClientM (Text :<|> SubmitRes)))
- data HTMLTags (tag :: Symbol)
- class FromTags tag a where
- type Articles = HTMLTags "article"
- type Divs = HTMLTags "div"
- type Scripts = HTMLTags "script"
- data RawText
- processHTML :: String -> Text -> [Text]
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.
adventAPIClient :: Integer -> ClientM NextDayTime :<|> ((Day -> ClientM (Map Part Text) :<|> (ClientM Text :<|> (SubmitInfo -> ClientM (Text :<|> SubmitRes)))) :<|> (ClientM GlobalLeaderboard :<|> ((Day -> ClientM DailyLeaderboard) :<|> (PublicCode -> ClientM Leaderboard)))) Source #
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
Accept (HTMLTags cls :: Type) Source # | |
Defined in Advent.API | |
(FromTags tag a, KnownSymbol tag) => MimeUnrender (HTMLTags tag :: Type) a Source # | |
Defined in Advent.API mimeUnrender :: Proxy (HTMLTags tag) -> ByteString -> Either String a # mimeUnrenderWithType :: Proxy (HTMLTags tag) -> MediaType -> ByteString -> Either String a # |
class FromTags tag a where Source #
Class for interpreting a list of Text
in tags to some desired
output.
Since: 0.2.3.0
Instances
FromTags "article" SubmitRes Source # | |
FromTags "div" DailyLeaderboard Source # | |
Defined in Advent.API | |
FromTags "div" GlobalLeaderboard Source # | |
Defined in Advent.API | |
FromTags "script" NextDayTime Source # | |
Defined in Advent.API | |
FromTags (cls :: k) Text Source # | |
FromTags (cls :: k) [Text] Source # | |
(Ord a, Enum a, Bounded a) => FromTags (cls :: k) (Map a Text) Source # | |
(FromTags cls a, FromTags cls b) => FromTags (cls :: k) (a :<|> b) Source # | |
Raw "text/plain" MIME type
Instances
Accept RawText Source # | |
Defined in Advent.API | |
MimeUnrender RawText Text Source # | |
Defined in Advent.API mimeUnrender :: Proxy RawText -> ByteString -> Either String Text # mimeUnrenderWithType :: Proxy RawText -> MediaType -> ByteString -> Either String Text # |