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

Safe HaskellNone

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 => 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

data Options Source

Options is used to store the Token and a potential timeout

Constructors

Options 

Fields

token :: Token
 
timeout :: Maybe Long
 

type Long = Word32

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