Safe Haskell | Safe-Infered |
---|
Network.Factual.API
Description
This module exports functions which are used to execute queries and handle the OAuth authentication process.
- generateToken :: Key -> Secret -> Token
- makeRequest :: Query query => Token -> query -> IO Response
- makeRawRequest :: Token -> String -> IO Response
- makeMultiRequest :: Query query => Token -> Map String query -> IO (Map String Response)
- sendWrite :: Write write => Token -> write -> IO Response
- data Token
- = TwoLegg { }
- | ReqToken { }
- | AccessToken { }
Authentication
generateToken :: Key -> Secret -> TokenSource
This function takes a set of credentials and returns an OAuth token that can be used to make requests.
Read functions
makeRequest :: Query query => Token -> query -> IO ResponseSource
This function takes an OAuth token and a query (which is member of the Query typeclass) and returns an IO action which will fetch a response from the Factual API.
makeRawRequest :: Token -> String -> IO ResponseSource
This function can be used to make raw read requests for any path. You pass in your Token and the path of your request (e.g. "/t/places?q=starbucks")
makeMultiRequest :: Query query => Token -> Map String query -> IO (Map String Response)Source
This function can be used to make multi queries. You pass in a Map of Strings to queries and a single query is made to the API. The result is a Map of the same keys to regular response values.
Write functions
sendWrite :: Write write => Token -> write -> IO ResponseSource
This function takes an OAuth token and a Write and retunrs and IO action which sends the Write to API and returns a Response.
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 |