Safe Haskell | None |
---|---|
Language | Haskell98 |
- data APIState = APIState {}
- defaultState :: APIState
- class ToGenericOptions s => ToAPIState s where
- modifyAccessToken :: (MonadIO m, MonadState s m, ToAPIState s) => AccessToken -> m ()
- class (MonadIO (m (R m x)), MonadClient (m (R m x)) s, ToAPIState s, MonadVK (m (R m x)) (R m x)) => MonadAPI m x s | m -> s
- type API m x a = m (R m x) a
- decodeJSON :: MonadAPI m x s => ByteString -> API m x JSON
- apiJ :: MonadAPI m x s => String -> [(String, Text)] -> API m x JSON
- api :: (FromJSON a, MonadAPI m x s) => String -> [(String, Text)] -> API m x a
- apiR :: (FromJSON a, MonadAPI m x s) => MethodName -> MethodArgs -> API m x a
- apiHM :: forall m x a s. (FromJSON a, MonadAPI m x s) => MethodName -> MethodArgs -> (ErrorRecord -> API m x (Maybe a)) -> API m x a
- apiH :: forall m x a s. (FromJSON a, MonadAPI m x s) => MethodName -> MethodArgs -> (ErrorRecord -> Maybe a) -> API m x a
- apiE :: (FromJSON a, MonadAPI m x s) => String -> [(String, Text)] -> API m x (Either (Response ErrorRecord) a)
- apiD :: (FromJSON a, MonadAPI m x s) => a -> String -> [(String, Text)] -> API m x a
- api_S :: (FromJSON a, MonadAPI m x s) => String -> [(String, String)] -> API m x a
- jsonEncode :: JSON -> ByteString
- jsonEncodePretty :: JSON -> ByteString
Documentation
class ToGenericOptions s => ToAPIState s where Source #
toAPIState :: s -> APIState Source #
modifyAPIState :: (APIState -> APIState) -> s -> s Source #
modifyAccessToken :: (MonadIO m, MonadState s m, ToAPIState s) => AccessToken -> m () Source #
Modifies VK access token in the internal state as well as in the external storage, if enabled.
See also readInitialAccessToken
class (MonadIO (m (R m x)), MonadClient (m (R m x)) s, ToAPIState s, MonadVK (m (R m x)) (R m x)) => MonadAPI m x s | m -> s Source #
Class of monads able to run VK API calls. m
- the monad itself, x
-
type of early error, s
- type of state (see alse ToAPIState
)
decodeJSON :: MonadAPI m x s => ByteString -> API m x JSON Source #
Utility function to parse JSON object
- FIXME Don't raise exception, simply return `Left err`
Invoke the request. Returns answer as JSON object .
See the official documentation: https://vk.com/dev/methods https://vk.com/dev/json_schema
- FIXME We currentyl use Text.unpack to encode text into strings. Use encodeUtf8 FIXME instead.
- FIXME Split into request builder and request executer
:: (FromJSON a, MonadAPI m x s) | |
=> String | API method name |
-> [(String, Text)] | API method arguments |
-> API m x a |
Invoke the request, return answer as a Haskell datatype. On error fall out
to the supervizer (e.g. VKHS.defaultSuperviser
) without possibility to
continue
:: (FromJSON a, MonadAPI m x s) | |
=> MethodName | API method name |
-> MethodArgs | API method arguments |
-> API m x a |
Invoke the request, in case of failure, escalate the probelm to the superwiser. The superwiser has a chance to change the arguments
:: (FromJSON a, MonadAPI m x s) | |
=> MethodName | API method name |
-> MethodArgs | API method arguments |
-> (ErrorRecord -> API m x (Maybe a)) | |
-> API m x a |
Invoke the request, in case of failure, escalate the probelm to the superwiser. The superwiser has a chance to change the arguments
:: (FromJSON a, MonadAPI m x s) | |
=> MethodName | API method name |
-> MethodArgs | API method arguments |
-> (ErrorRecord -> Maybe a) | |
-> API m x a |
:: (FromJSON a, MonadAPI m x s) | |
=> String | API method name |
-> [(String, Text)] | API method arguments |
-> API m x (Either (Response ErrorRecord) a) |
Invoke the request, return answer as a Haskell datatype or ErrorRecord
object
:: (FromJSON a, MonadAPI m x s) | |
=> a | |
-> String | API method name |
-> [(String, Text)] | API method arguments |
-> API m x a |
Invoke the request, returns answer or the default value in case of error
api_S :: (FromJSON a, MonadAPI m x s) => String -> [(String, String)] -> API m x a Source #
String version of api
Deprecated
jsonEncode :: JSON -> ByteString Source #
jsonEncodePretty :: JSON -> ByteString Source #