Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Leanpub a = Leanpub (Context -> IO a)
- data Context = Context {}
- runLeanpub :: Config -> Leanpub a -> IO a
- data Config
- configSession :: Session -> Config
- configKey :: ApiSecretKey -> Config
- configKeyFile :: FilePath -> Config
- getBookSummary :: BookSlug -> Leanpub Value
- getBookSalesSummary :: BookSlug -> Leanpub Value
- createFreeBookCoupon :: BookSlug -> CouponCode -> CouponMaxUses -> Maybe CouponNote -> Leanpub Value
- createManyFreeBookCoupons :: (CouponCode -> IO ()) -> Natural -> BookSlug -> CouponMaxUses -> Maybe CouponNote -> Leanpub ()
- wreqGet :: Path -> Extension -> [QueryParam] -> Leanpub WreqResponse
- wreqPost :: Path -> Extension -> [FormParam] -> Leanpub WreqResponse
- wreqGetAeson :: Path -> [QueryParam] -> Leanpub Value
- wreqPostAeson :: Path -> [FormParam] -> Leanpub Value
- wreqPostAeson_ :: Path -> [FormParam] -> Leanpub ()
- type WreqResponse = Response ByteString
- type Path = [Text]
- type Extension = Text
- type QueryParam = (Text, Text)
- data FormParam where
- (:=) :: forall v. FormValue v => ByteString -> v -> FormParam
- data Session
- newAPISession :: IO Session
The Leanpub monad
There are two ways to run a Leanpub
action:
- Create a
Context
and then apply the newtypedContext -> IO a
function directly. - Create a
Config
and then apply therunLeanpub
function. This approach is likely more convenient, because it can do some things automatically like creating theSession
and reading your API key from a file.
Configuration
Construct a Config
by using <>
to combine any of the following:
- Either
configKey
orconfigKeyFile
(not both) - Optionally,
configSession
Then use the config as the first argument to the runLeanpub
function.
configSession :: Session -> Config Source #
configKey :: ApiSecretKey -> Config Source #
configKeyFile :: FilePath -> Config Source #
Leanpub actions
:: BookSlug | What book does the coupon give away? |
-> CouponCode | The secret that the user needs to have to redeem the coupon |
-> CouponMaxUses | How many times can each coupon be used? |
-> Maybe CouponNote | An optional note to remind you what the coupon is for, why it was issued, etc. |
-> Leanpub Value |
createManyFreeBookCoupons Source #
:: (CouponCode -> IO ()) | Action to perform after creating each coupon,
e.g. perhaps |
-> Natural | How many coupons? |
-> BookSlug | What book does the coupon give away? |
-> CouponMaxUses | How many times can each coupon be used? |
-> Maybe CouponNote | An optional note to remind you what the coupon is for, why it was issued, etc. |
-> Leanpub () |
Wreq
wreqGet :: Path -> Extension -> [QueryParam] -> Leanpub WreqResponse Source #
wreqGetAeson :: Path -> [QueryParam] -> Leanpub Value Source #
type WreqResponse = Response ByteString Source #
type QueryParam = (Text, Text) Source #
A key/value pair for an application/x-www-form-urlencoded
POST request body.
(:=) :: forall v. FormValue v => ByteString -> v -> FormParam infixr 3 |
A session that spans multiple requests. This is responsible for cookie management and TCP connection reuse.
newAPISession :: IO Session #
Create a session.
This uses the default session manager settings, but does not manage cookies. It is intended for use with REST-like HTTP-based APIs, which typically do not use cookies.
Since: wreq-0.5.2.0