stripe-wreq-1.0.1.15: Use the Stripe API via Wreq
Safe HaskellSafe-Inferred
LanguageHaskell2010

Stripe.Wreq

Description

Typical use of this module:

  1. Run get, post, or delete to get a WreqResponse.
  2. Use wreqResponse to convert the Wreq response to a Response.
  3. Use responseValue to obtain the response payload as an Aeson Value (or an Error if the request was not successful).
Synopsis

Request

GET

data Get Source #

Constructors

Get 

Fields

POST

data Post Source #

Constructors

Post 

Fields

DELETE

data Delete Source #

Constructors

Delete 

Fields

Response

data Response Source #

Constructors

Response 

Fields

wreqResponse :: WreqResponse -> Response Source #

Convert a WreqResponse into a Response by parsing the JSON response body (the Stripe API always returns JSON) and getting the HTTP status code.

responseValue :: Response -> Either Error Value Source #

Interpret a response, returning Right with the parsed JSON payload if everything is okay, or Left with an error if the response contains any indication that something went wrong.

responseValueError :: Value -> Error Source #

If the response object looks like this:

{
  "error": {
      "type": "card_error",
      "message": "..."
    }
  }
}

then we use the value of the message field as a UserMessage. Otherwise it is a LogMessage.

"message: A human-readable message providing more details about the error. For card errors, these messages can be shown to your users. [...] Card errors are the most common type of error you should expect to handle. They result when the user enters a card that can't be charged for some reason." - Stripe

Error

data Error Source #

Constructors

Error 

Instances

Instances details
Monoid Error Source # 
Instance details

Defined in Stripe.Wreq

Methods

mempty :: Error #

mappend :: Error -> Error -> Error #

mconcat :: [Error] -> Error #

Semigroup Error Source # 
Instance details

Defined in Stripe.Wreq

Methods

(<>) :: Error -> Error -> Error #

sconcat :: NonEmpty Error -> Error #

stimes :: Integral b => b -> Error -> Error #

Exception Error Source # 
Instance details

Defined in Stripe.Wreq

Show Error Source # 
Instance details

Defined in Stripe.Wreq

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

Eq Error Source # 
Instance details

Defined in Stripe.Wreq

Methods

(==) :: Error -> Error -> Bool #

(/=) :: Error -> Error -> Bool #

newtype UserMessage Source #

An error message suitable for being shown to a user.

Constructors

UserMessage Text 

Instances

Instances details
Show UserMessage Source # 
Instance details

Defined in Stripe.Wreq

Eq UserMessage Source # 
Instance details

Defined in Stripe.Wreq

newtype LogMessage Source #

An error message that should go into an error log, not shown to a user.

Constructors

LogMessage Text 

Instances

Instances details
Show LogMessage Source # 
Instance details

Defined in Stripe.Wreq

Eq LogMessage Source # 
Instance details

Defined in Stripe.Wreq

userError Source #

Arguments

:: Text

An error message intended to be shown to a user.

-> Error 

logError Source #

Arguments

:: Text

An error message intended to go into a log file, not to be shown to a user.

-> Error 

Status code

newtype StatusCode Source #

An HTTP status code returned by Stripe.

"Stripe uses conventional HTTP response codes to indicate the success or failure of an API request." - Stripe

Constructors

StatusCode Int 

Instances

Instances details
Eq StatusCode Source # 
Instance details

Defined in Stripe.Wreq

Predicates

Some basic functions for interpreting status codes.

isSuccess :: StatusCode -> Bool Source #

"Codes in the 2xx range indicate success." - Stripe

isError :: StatusCode -> Bool Source #

isError x is equivalent to isClientError x || isServerError x.

isClientError :: StatusCode -> Bool Source #

"Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.)." - Stripe

isServerError :: StatusCode -> Bool Source #

"Codes in the 5xx range indicate an error with Stripe's servers." - Stripe

Client error codes

Constants for each of the error codes enumerated in the Stripe API documentation, for your convenience.

badRequest400 :: StatusCode Source #

400 - Bad Request

"The request was unacceptable, often due to missing a required parameter." - Stripe

unauthorized401 :: StatusCode Source #

401 - Unauthorized

"No valid API key provided." - Stripe

requestFailed402 :: StatusCode Source #

402 - Request Failed

"The parameters were valid but the request failed." - Stripe

notFound404 :: StatusCode Source #

404 - Not Found

"The requested resource doesn't exist." - Stripe

conflict409 :: StatusCode Source #

409 - Conflict

"The request conflicts with another request (perhaps due to using the same idempotent key)." - Stripe

tooManyRequests429 :: StatusCode Source #

429 - Too Many Requests

"Too many requests hit the API too quickly. We recommend an exponential backoff of your requests." - Stripe

Re-exports from Wreq

data FormParam where #

A key/value pair for an application/x-www-form-urlencoded POST request body.

Constructors

(:=) :: forall v. FormValue v => ByteString -> v -> FormParam infixr 3 

Instances

Instances details
Show FormParam 
Instance details

Defined in Network.Wreq.Internal.Types

data Session #

A session that spans multiple requests. This is responsible for cookie management and TCP connection reuse.

Instances

Instances details
Show Session 
Instance details

Defined in Network.Wreq.Internal.Types

newAPISession :: IO Session #

Create a session.

This uses the default session manager settings, but does not manage cookies. It is intended for use with REST-like HTTP-based APIs, which typically do not use cookies.

Since: wreq-0.5.2.0