Safe Haskell | None |
---|
Network.Factual.API
Contents
Description
This module exports functions which are used to execute requests and handle the OAuth authentication process.
- generateToken :: Key -> Secret -> Token
- executeQuery :: Query query => Options -> query -> IO Response
- executeMultiQuery :: Query query => Options -> Map String query -> IO (Map String Response)
- get :: Options -> Path -> Params -> IO Response
- executeWrite :: Write write => Options -> write -> IO Response
- post :: Options -> Path -> Params -> Body -> IO Response
- debugQuery :: Query query => query -> IO ()
- debugWrite :: Write write => write -> IO ()
- data Options = Options {}
- type Long = Word32
- data Token
- = TwoLegg { }
- | ReqToken { }
- | AccessToken { }
- urlEncode :: String -> String
Authentication
generateToken :: Key -> Secret -> TokenSource
This function takes a Key and Secret, and generates a Token that is passed to the various methods used to make requests.
Read functions
executeQuery :: Query query => Options -> query -> IO ResponseSource
This function takes Options and a Query value and sends the query to the Factual API. The resultant IO action contains a Response value which wraps the resultant data.
executeMultiQuery :: Query query => Options -> Map String query -> IO (Map String Response)Source
This function can be used to make a Multi Query (multiple queries in a single request. It takes Options, a Map of key Strings to Queries and returns a Map from the same keys to Response values.
get :: Options -> Path -> Params -> IO ResponseSource
This function can be used to perform raw read queries to any API endpoint. It takes Options, a Path string and a Map of params (both keys and values are strings). The function returns a standard Response value.
Write functions
executeWrite :: Write write => Options -> write -> IO ResponseSource
This function is used to execute Writes. The function takes Options and a Write value, and returns a Response value.
post :: Options -> Path -> Params -> Body -> IO ResponseSource
This function can be used to perform raw post queries to any API endpoint. It takes Options, a Path string, a Map of params and a body Map. Both Maps have String keys and values. The function returns a standard Response value.
Debug functions
debugQuery :: Query query => query -> IO ()Source
This function can be used to debug Queries. It takes a Query value and prints out the URL path generated by that query.
debugWrite :: Write write => write -> IO ()Source
This function can be used to debug Writes. It takes a Write value and prints out the URL path, and post body generated by that write.
Options type
Options is used to store the Token and a potential timeout
The hoauth Token type
data Token
The OAuth Token.
Constructors
TwoLegg | This token is used to perform 2 legged OAuth requests. |
Fields | |
ReqToken | The service provider has granted you the request token but the user has not yet authorized your application. You need to exchange this token by a proper AccessToken, but this may only happen after user has granted you permission to do so. |
Fields | |
AccessToken | This is a proper 3 legged OAuth. The difference between this and ReqToken is that user has authorized your application and you can perform requests on behalf of that user. |
Fields |