factual-api-0.5.0: A driver for the Factual API

Safe HaskellSafe-Infered

Network.Factual.API

Contents

Description

This module exports functions which are used to execute requests and handle the OAuth authentication process.

Synopsis

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 => Token -> query -> IO ResponseSource

This function takes a Token and 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 => Token -> 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 a Token, a Map of key Strings to Queries and returns a Map from the same keys to Response values.

get :: Token -> Path -> Params -> IO ResponseSource

This function can be used to perform raw read queries to any API endpoint. It takes a Token, 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 => Token -> write -> IO ResponseSource

This function is used to execute Writes. The function takes a Token and a Write value, and returns a Response value.

post :: Token -> Path -> Params -> Body -> IO ResponseSource

This function can be used to perform raw post queries to any API endpoint. It takes a Token, 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.

The hoauth Token type

data Token

The OAuth Token.

Constructors

TwoLegg

This token is used to perform 2 legged OAuth requests.

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.

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.

Instances