stripeapi-2.0.0.1: Stripe-Library
Safe HaskellNone
LanguageHaskell2010

StripeAPI.Common

Description

This module serves the purpose of defining common functionality which remains the same across all OpenAPI specifications.

Synopsis

Documentation

doCallWithConfiguration Source #

Arguments

:: MonadHTTP m 
=> Configuration

Configuration options like base URL and security scheme

-> Text

HTTP method (GET, POST, etc.)

-> Text

Path to append to the base URL (path parameters should already be replaced)

-> [QueryParameter]

Query parameters

-> m (Response ByteString)

The raw response from the server

This is the main functionality of this module

It makes a concrete Call to a Server without a body

doCallWithConfigurationM :: MonadHTTP m => Text -> Text -> [QueryParameter] -> ClientT m (Response ByteString) Source #

Same as doCallWithConfiguration but run in a ReaderT environment which contains the configuration. This is useful if multiple calls have to be executed with the same configuration.

doBodyCallWithConfiguration Source #

Arguments

:: (MonadHTTP m, ToJSON body) 
=> Configuration

Configuration options like base URL and security scheme

-> Text

HTTP method (GET, POST, etc.)

-> Text

Path to append to the base URL (path parameters should already be replaced)

-> [QueryParameter]

Query parameters

-> Maybe body

Request body

-> RequestBodyEncoding

JSON or form data deepobjects

-> m (Response ByteString)

The raw response from the server

This is the main functionality of this module

It makes a concrete Call to a Server with a body

doBodyCallWithConfigurationM :: (MonadHTTP m, ToJSON body) => Text -> Text -> [QueryParameter] -> Maybe body -> RequestBodyEncoding -> ClientT m (Response ByteString) Source #

Same as doBodyCallWithConfiguration but run in a ReaderT environment which contains the configuration. This is useful if multiple calls have to be executed with the same configuration.

runWithConfiguration :: Configuration -> ClientT m a -> m a Source #

Run a ClientT monad transformer in another monad with a specified configuration

stringifyModel :: StringifyModel a => a -> String Source #

Stringifies a showable value

>>> stringifyModel "Test"
"Test"
>>> stringifyModel 123
"123"

anonymousSecurityScheme :: SecurityScheme Source #

Anonymous security scheme which does not alter the request in any way

data Configuration Source #

An operation can and must be configured with data, which may be common for many operations.

This configuration consists of information about the server URL and the used security scheme.

In OpenAPI these information can be defined

  • Root level
  • Path level
  • Operation level

To get started, the defaultConfiguration can be used and changed accordingly.

Note that it is possible that bearerAuthenticationSecurityScheme is not available because it is not a security scheme in the OpenAPI specification.

defaultConfiguration
  { configSecurityScheme = bearerAuthenticationSecurityScheme "token" }

Instances

Instances details
Monad m => MonadReader Configuration (ClientT m) Source # 
Instance details

Defined in StripeAPI.Common

type SecurityScheme = Request -> Request Source #

This type specifies a security scheme which can modify a request according to the scheme (e. g. add an Authorization header)

class Monad m => MonadHTTP m where Source #

Abstracts the usage of httpBS away, so that it can be used for testing

Instances

Instances details
MonadHTTP IO Source #

This instance is the default instance used for production code

Instance details

Defined in StripeAPI.Common

MonadHTTP m => MonadHTTP (ClientT m) Source # 
Instance details

Defined in StripeAPI.Common

MonadHTTP m => MonadHTTP (ReaderT r m) Source # 
Instance details

Defined in StripeAPI.Common

class Show a => StringifyModel a Source #

This type class makes the code generation for URL parameters easier as it allows to stringify a value

The Show class is not sufficient as strings should not be stringified with quotes.

Minimal complete definition

stringifyModel

Instances

Instances details
Show a => StringifyModel a Source # 
Instance details

Defined in StripeAPI.Common

Methods

stringifyModel :: a -> String Source #

StringifyModel String Source # 
Instance details

Defined in StripeAPI.Common

StringifyModel Text Source # 
Instance details

Defined in StripeAPI.Common

data RequestBodyEncoding Source #

Defines how a request body is encoded

Constructors

RequestBodyEncodingJSON

Encode the body as JSON

RequestBodyEncodingFormData

Encode the body as form data

data QueryParameter Source #

Defines a query parameter with the information necessary for serialization

Instances

Instances details
Eq QueryParameter Source # 
Instance details

Defined in StripeAPI.Common

Show QueryParameter Source # 
Instance details

Defined in StripeAPI.Common

newtype ClientT m a Source #

The monad in which the operations can be run. Contains the Configuration to run the requests with.

Run it with runWithConfiguration

Constructors

ClientT (ReaderT Configuration m a) 

Instances

Instances details
MonadTrans ClientT Source # 
Instance details

Defined in StripeAPI.Common

Methods

lift :: Monad m => m a -> ClientT m a #

Monad m => MonadReader Configuration (ClientT m) Source # 
Instance details

Defined in StripeAPI.Common

Monad m => Monad (ClientT m) Source # 
Instance details

Defined in StripeAPI.Common

Methods

(>>=) :: ClientT m a -> (a -> ClientT m b) -> ClientT m b #

(>>) :: ClientT m a -> ClientT m b -> ClientT m b #

return :: a -> ClientT m a #

Functor m => Functor (ClientT m) Source # 
Instance details

Defined in StripeAPI.Common

Methods

fmap :: (a -> b) -> ClientT m a -> ClientT m b #

(<$) :: a -> ClientT m b -> ClientT m a #

Applicative m => Applicative (ClientT m) Source # 
Instance details

Defined in StripeAPI.Common

Methods

pure :: a -> ClientT m a #

(<*>) :: ClientT m (a -> b) -> ClientT m a -> ClientT m b #

liftA2 :: (a -> b -> c) -> ClientT m a -> ClientT m b -> ClientT m c #

(*>) :: ClientT m a -> ClientT m b -> ClientT m b #

(<*) :: ClientT m a -> ClientT m b -> ClientT m a #

MonadIO m => MonadIO (ClientT m) Source # 
Instance details

Defined in StripeAPI.Common

Methods

liftIO :: IO a -> ClientT m a #

MonadHTTP m => MonadHTTP (ClientT m) Source # 
Instance details

Defined in StripeAPI.Common

type ClientM a = ClientT IO a Source #

Utility type which uses IO as underlying monad