libstackexchange-0.2.1.0: StackExchange API interface

Safe HaskellNone

Network.StackExchange.Request

Contents

Description

StackExchange API request manipulation routines

Synopsis

Type

type Request a n r = Dual (Endo (R a n r))Source

data R a n r Source

StackExchange API Request data type.

a is a phantom type showing whether authentication is enabled

n is a phantom type dissallowing combination of different API calls in one request

r is a type of parsed API call result

Constructors

R 

Fields

_host :: Text

API host link

_path :: Text

API call link

_method :: Text

API call method (GET/POST)

_query :: Map Text Text

API call query parameters

_parse :: Maybe (ByteString -> r)

API call result parsing function

Instances

Default (R a n r)

Default StackExchange API request, defines only host link

data Auth Source

Authentication

Constructors

RequireToken

Request requires auth_token

Ready

Request may be sent without auth_token

newtype SE a Source

SE response value wrapper

Constructors

SE 

Fields

unSE :: Value
 

Instances

Show (SE a) 
FromJSON (SE a) 

data Object Source

SE response type

Constructors

AccessToken

https://api.stackexchange.com/docs/types/access-token

AccountMerge

https://api.stackexchange.com/docs/types/account-merge

Answer

https://api.stackexchange.com/docs/types/answer

Badge

https://api.stackexchange.com/docs/types/badge

Comment

https://api.stackexchange.com/docs/types/comment

Error

https://api.stackexchange.com/docs/types/error

Event

https://api.stackexchange.com/docs/types/event

Filter

https://api.stackexchange.com/docs/types/filter

InboxItem

https://api.stackexchange.com/docs/types/inbox-item

Info

https://api.stackexchange.com/docs/types/info

NetworkUser

https://api.stackexchange.com/docs/types/network-user

Notification

https://api.stackexchange.com/docs/types/notification

Post

https://api.stackexchange.com/docs/types/post

Privilege

https://api.stackexchange.com/docs/types/privilege

Question

https://api.stackexchange.com/docs/types/question

QuestionTimeline

https://api.stackexchange.com/docs/types/question-timeline

Reputation

https://api.stackexchange.com/docs/types/reputation

ReputationHistory

https://api.stackexchange.com/docs/types/reputation-history

Revision

https://api.stackexchange.com/docs/types/revision

Site

https://api.stackexchange.com/docs/types/site

SuggestedEdit

https://api.stackexchange.com/docs/types/suggested-edit

Tag

https://api.stackexchange.com/docs/types/tag

TagScore

https://api.stackexchange.com/docs/types/tag-score

TagSynonym

https://api.stackexchange.com/docs/types/tag-synonym

TagWiki

https://api.stackexchange.com/docs/types/tag-wiki

TopTag

https://api.stackexchange.com/docs/types/top-tag

User

https://api.stackexchange.com/docs/types/user

UserTimeline

https://api.stackexchange.com/docs/types/user-timeline

WritePermission

https://api.stackexchange.com/docs/types/write-permission

Constructing requests

host :: Text -> Request a n rSource

Request defining only API call host

Primarily used in Auth, not intended for usage by library user

path :: Text -> Request a n rSource

Request defining only API call path

Primarily used in API call wrappers, not intended for usage by library user

method :: Text -> Request a n rSource

Request defining only call method

Primarily used in API call wrappers, not intended for usage by library user

parse :: (ByteString -> r) -> Request a n rSource

Request defining only API call result parsing function

Primarily used in API call wrappers, not intended for usage by library user

query :: [(Text, Text)] -> Request a n rSource

Request defining only API call query parameters

Rather low level interface. For more specific usage site, filter, etc calls may be more convenient

Takes a list of (key, value) parameters such as [("order", "asc"), ("sort", "rank")]

token :: Text -> Request RequireToken n r -> Request Ready n rSource

Convert token requiring Request into ready one

key :: Text -> Request a n rSource

Request defining only App key

site :: Text -> Request a n rSource

Request defining only API call site query parameter

filter :: Text -> Request a n rSource

Request defining only API call filter query parameter

state :: Text -> Request a n rSource

Request defining only API call state query parameter

data Scope Source

Scope defines permission granted for application by user

scope :: [Scope] -> Request a n rSource

Request defining only API call scope query parameter

client :: Int -> Request a n rSource

Request defining only Authentication API call application id

Primarily used in Authentication API call wrappers, not intended for usage by library user

redirectURI :: Text -> Request a n rSource

Request defining only Authentication API call redirect url

Primarily used in Authentication API call wrappers, not intended for usage by library user

secret :: Text -> Request a n rSource

Request defining only Authentication API call application secret

Primarily used in Authentication API call wrappers, not intended for usage by library user

code :: Text -> Request a n rSource

Request defining only Authentication API call code

Primarily used in Authentication API call wrappers, not intended for usage by library user

Internal wrapping/unwrapping

wrap :: (R a n r -> R a n r) -> Request a n rSource

Wrapping to interesting Monoid (R -> R) instance

unwrap :: Request a n r -> R a n r -> R a n rSource

Unwrapping from interesting Monoid (R -> R) instance

Rendering

render :: Request a n r -> StringSource

Render R as URI string for networking