VKHS-1.9.1: Provides access to Vkontakte social network via public API

Safe HaskellNone
LanguageHaskell98

Web.VKHS.API.Base

Synopsis

Documentation

data APIState Source #

Constructors

APIState 

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)

Instances

type API m x a = m (R m x) a Source #

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`

apiJ Source #

Arguments

:: MonadAPI m x s 
=> String

API method name

-> [(String, Text)]

API method arguments

-> API m x JSON 

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

api Source #

Arguments

:: (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

apiRf Source #

Arguments

:: (FromJSON b, MonadAPI m x s) 
=> MethodName

API method name

-> MethodArgs

API method arguments

-> (b -> Either String a) 
-> API m x a 

Invoke the request, in case of failure, escalate the probelm to the supervisor. The superwiser has a chance to change the arguments

apiR Source #

Arguments

:: (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 supervisor. The superwiser has a chance to change the arguments

apiHM Source #

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 supervisor. The superwiser has a chance to change the arguments

apiH Source #

Arguments

:: (FromJSON a, MonadAPI m x s) 
=> MethodName

API method name

-> MethodArgs

API method arguments

-> (ErrorRecord -> Maybe a) 
-> API m x a