Safe Haskell | None |
---|---|
Language | Haskell2010 |
- class Parameters a where
- data APIRequest apiName responseType
- type APIQuery = [APIQueryItem]
- type APIQueryItem = (ByteString, PV)
- data PV
- = PVInteger { }
- | PVBool { }
- | PVString {
- unPVString :: Text
- | PVIntegerArray {
- unPVIntegerArray :: [Integer]
- | PVStringArray {
- unPVStringArray :: [Text]
- | PVDay { }
- makeSimpleQuery :: APIQuery -> SimpleQuery
- paramValueBS :: PV -> ByteString
Documentation
class Parameters a where Source #
Parameters (APIRequest apiName responseType) Source # | |
data APIRequest apiName responseType Source #
API request. You should use specific builder functions instead of building this directly.
For example, if there were a SampleApi
type and a builder function which named sampleApiRequest
.
In addition,
is a instance of both of APIRequest
SampleApi [SampleId]HasCountParam
and HasMaxIdParam
.
dataSampleApi
typeSampleId
=Integer
instanceHasCountParam
(APIRequest
SampleApi
[SampleId
]) instanceHasMaxIdParam
(APIRequest
SampleApi
[SampleId
])sampleApiRequest
::APIRequest
SampleApi
[SampleId
]sampleApiRequest
=APIRequestGet
"https://api.twitter.com/sample/api.json"def
We can obtain request params from
:APIRequest
SampleApi [SampleId]
>>>
sampleApiRequest ^. params
[]
And update request parameters.
>>>
(sampleApiRequest & count ?~ 100 & maxId ?~ 1234567890) ^. params
[("max_id",PVInteger {unPVInteger = 1234567890}),("count",PVInteger {unPVInteger = 100})]>>>
(sampleApiRequest & count ?~ 100 & maxId ?~ 1234567890 & count .~ Nothing) ^. params
[("max_id",PVInteger {unPVInteger = 1234567890})]
type APIQuery = [APIQueryItem] Source #
type APIQueryItem = (ByteString, PV) Source #
paramValueBS :: PV -> ByteString Source #