{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Operations.Post3dSecure where
import qualified Control.Monad.Fail
import qualified Control.Monad.Trans.Reader
import qualified Data.Aeson
import qualified Data.Aeson as Data.Aeson.Encoding.Internal
import qualified Data.Aeson as Data.Aeson.Types
import qualified Data.Aeson as Data.Aeson.Types.FromJSON
import qualified Data.Aeson as Data.Aeson.Types.Internal
import qualified Data.Aeson as Data.Aeson.Types.ToJSON
import qualified Data.ByteString.Char8
import qualified Data.ByteString.Char8 as Data.ByteString.Internal
import qualified Data.Either
import qualified Data.Functor
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text.Internal
import qualified Data.Time.Calendar as Data.Time.Calendar.Days
import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime
import qualified Data.Vector
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified Network.HTTP.Client
import qualified Network.HTTP.Client as Network.HTTP.Client.Request
import qualified Network.HTTP.Client as Network.HTTP.Client.Types
import qualified Network.HTTP.Simple
import qualified Network.HTTP.Types
import qualified Network.HTTP.Types as Network.HTTP.Types.Status
import qualified Network.HTTP.Types as Network.HTTP.Types.URI
import qualified StripeAPI.Common
import StripeAPI.Types
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
post3dSecure ::
forall m.
StripeAPI.Common.MonadHTTP m =>
Post3dSecureRequestBody ->
StripeAPI.Common.ClientT m (Network.HTTP.Client.Types.Response Post3dSecureResponse)
post3dSecure :: Post3dSecureRequestBody
-> ClientT m (Response Post3dSecureResponse)
post3dSecure Post3dSecureRequestBody
body =
(Response ByteString -> Response Post3dSecureResponse)
-> ClientT m (Response ByteString)
-> ClientT m (Response Post3dSecureResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( \Response ByteString
response_0 ->
(ByteString -> Post3dSecureResponse)
-> Response ByteString -> Response Post3dSecureResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( (String -> Post3dSecureResponse)
-> (Post3dSecureResponse -> Post3dSecureResponse)
-> Either String Post3dSecureResponse
-> Post3dSecureResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> Post3dSecureResponse
Post3dSecureResponseError Post3dSecureResponse -> Post3dSecureResponse
forall a. a -> a
GHC.Base.id
(Either String Post3dSecureResponse -> Post3dSecureResponse)
-> (ByteString -> Either String Post3dSecureResponse)
-> ByteString
-> Post3dSecureResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. ( \Response ByteString
response ByteString
body ->
if
| (\Status
status_1 -> Status -> Int
Network.HTTP.Types.Status.statusCode Status
status_1 Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Int
200) (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
ThreeDSecure -> Post3dSecureResponse
Post3dSecureResponse200
(ThreeDSecure -> Post3dSecureResponse)
-> Either String ThreeDSecure -> Either String Post3dSecureResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String ThreeDSecure
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
Data.Either.Either
GHC.Base.String
ThreeDSecure
)
| Bool -> Status -> Bool
forall a b. a -> b -> a
GHC.Base.const Bool
GHC.Types.True (Response ByteString -> Status
forall body. Response body -> Status
Network.HTTP.Client.Types.responseStatus Response ByteString
response) ->
Error -> Post3dSecureResponse
Post3dSecureResponseDefault
(Error -> Post3dSecureResponse)
-> Either String Error -> Either String Post3dSecureResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String Error
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
Data.Either.Either
GHC.Base.String
Error
)
| Bool
GHC.Base.otherwise -> String -> Either String Post3dSecureResponse
forall a b. a -> Either a b
Data.Either.Left String
"Missing default response type"
)
Response ByteString
response_0
)
Response ByteString
response_0
)
(Text
-> Text
-> [QueryParameter]
-> Maybe Post3dSecureRequestBody
-> RequestBodyEncoding
-> ClientT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> ClientT m (Response ByteString)
StripeAPI.Common.doBodyCallWithConfigurationM (Text -> Text
Data.Text.toUpper (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
GHC.Base.$ String -> Text
Data.Text.pack String
"POST") (String -> Text
Data.Text.pack String
"/v1/3d_secure") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (Post3dSecureRequestBody -> Maybe Post3dSecureRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just Post3dSecureRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)
data Post3dSecureRequestBody = Post3dSecureRequestBody
{
Post3dSecureRequestBody -> Int
post3dSecureRequestBodyAmount :: GHC.Types.Int,
Post3dSecureRequestBody -> Maybe Text
post3dSecureRequestBodyCard :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Post3dSecureRequestBody -> Text
post3dSecureRequestBodyCurrency :: Data.Text.Internal.Text,
Post3dSecureRequestBody -> Maybe Text
post3dSecureRequestBodyCustomer :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
Post3dSecureRequestBody -> Maybe [Text]
post3dSecureRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
Post3dSecureRequestBody -> Text
post3dSecureRequestBodyReturnUrl :: Data.Text.Internal.Text
}
deriving
( Int -> Post3dSecureRequestBody -> ShowS
[Post3dSecureRequestBody] -> ShowS
Post3dSecureRequestBody -> String
(Int -> Post3dSecureRequestBody -> ShowS)
-> (Post3dSecureRequestBody -> String)
-> ([Post3dSecureRequestBody] -> ShowS)
-> Show Post3dSecureRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Post3dSecureRequestBody] -> ShowS
$cshowList :: [Post3dSecureRequestBody] -> ShowS
show :: Post3dSecureRequestBody -> String
$cshow :: Post3dSecureRequestBody -> String
showsPrec :: Int -> Post3dSecureRequestBody -> ShowS
$cshowsPrec :: Int -> Post3dSecureRequestBody -> ShowS
GHC.Show.Show,
Post3dSecureRequestBody -> Post3dSecureRequestBody -> Bool
(Post3dSecureRequestBody -> Post3dSecureRequestBody -> Bool)
-> (Post3dSecureRequestBody -> Post3dSecureRequestBody -> Bool)
-> Eq Post3dSecureRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Post3dSecureRequestBody -> Post3dSecureRequestBody -> Bool
$c/= :: Post3dSecureRequestBody -> Post3dSecureRequestBody -> Bool
== :: Post3dSecureRequestBody -> Post3dSecureRequestBody -> Bool
$c== :: Post3dSecureRequestBody -> Post3dSecureRequestBody -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON Post3dSecureRequestBody where
toJSON :: Post3dSecureRequestBody -> Value
toJSON Post3dSecureRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Int
post3dSecureRequestBodyAmount Post3dSecureRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"card" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Maybe Text
post3dSecureRequestBodyCard Post3dSecureRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"currency" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Text
post3dSecureRequestBodyCurrency Post3dSecureRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"customer" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Maybe Text
post3dSecureRequestBodyCustomer Post3dSecureRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expand" Text -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Maybe [Text]
post3dSecureRequestBodyExpand Post3dSecureRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"return_url" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Text
post3dSecureRequestBodyReturnUrl Post3dSecureRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: Post3dSecureRequestBody -> Encoding
toEncoding Post3dSecureRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Int
post3dSecureRequestBodyAmount Post3dSecureRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"card" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Maybe Text
post3dSecureRequestBodyCard Post3dSecureRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"currency" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Text
post3dSecureRequestBodyCurrency Post3dSecureRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"customer" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Maybe Text
post3dSecureRequestBodyCustomer Post3dSecureRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expand" Text -> Maybe [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Maybe [Text]
post3dSecureRequestBodyExpand Post3dSecureRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"return_url" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Post3dSecureRequestBody -> Text
post3dSecureRequestBodyReturnUrl Post3dSecureRequestBody
obj))))))
instance Data.Aeson.Types.FromJSON.FromJSON Post3dSecureRequestBody where
parseJSON :: Value -> Parser Post3dSecureRequestBody
parseJSON = String
-> (Object -> Parser Post3dSecureRequestBody)
-> Value
-> Parser Post3dSecureRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Post3dSecureRequestBody" (\Object
obj -> ((((((Int
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Text
-> Post3dSecureRequestBody)
-> Parser
(Int
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Text
-> Post3dSecureRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Int
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Text
-> Post3dSecureRequestBody
Post3dSecureRequestBody Parser
(Int
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Text
-> Post3dSecureRequestBody)
-> Parser Int
-> Parser
(Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Text
-> Post3dSecureRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"amount")) Parser
(Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Text
-> Post3dSecureRequestBody)
-> Parser (Maybe Text)
-> Parser
(Text
-> Maybe Text -> Maybe [Text] -> Text -> Post3dSecureRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"card")) Parser
(Text
-> Maybe Text -> Maybe [Text] -> Text -> Post3dSecureRequestBody)
-> Parser Text
-> Parser
(Maybe Text -> Maybe [Text] -> Text -> Post3dSecureRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"currency")) Parser
(Maybe Text -> Maybe [Text] -> Text -> Post3dSecureRequestBody)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> Text -> Post3dSecureRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"customer")) Parser (Maybe [Text] -> Text -> Post3dSecureRequestBody)
-> Parser (Maybe [Text])
-> Parser (Text -> Post3dSecureRequestBody)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"expand")) Parser (Text -> Post3dSecureRequestBody)
-> Parser Text -> Parser Post3dSecureRequestBody
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"return_url"))
mkPost3dSecureRequestBody ::
GHC.Types.Int ->
Data.Text.Internal.Text ->
Data.Text.Internal.Text ->
Post3dSecureRequestBody
mkPost3dSecureRequestBody :: Int -> Text -> Text -> Post3dSecureRequestBody
mkPost3dSecureRequestBody Int
post3dSecureRequestBodyAmount Text
post3dSecureRequestBodyCurrency Text
post3dSecureRequestBodyReturnUrl =
Post3dSecureRequestBody :: Int
-> Maybe Text
-> Text
-> Maybe Text
-> Maybe [Text]
-> Text
-> Post3dSecureRequestBody
Post3dSecureRequestBody
{ post3dSecureRequestBodyAmount :: Int
post3dSecureRequestBodyAmount = Int
post3dSecureRequestBodyAmount,
post3dSecureRequestBodyCard :: Maybe Text
post3dSecureRequestBodyCard = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
post3dSecureRequestBodyCurrency :: Text
post3dSecureRequestBodyCurrency = Text
post3dSecureRequestBodyCurrency,
post3dSecureRequestBodyCustomer :: Maybe Text
post3dSecureRequestBodyCustomer = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
post3dSecureRequestBodyExpand :: Maybe [Text]
post3dSecureRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
post3dSecureRequestBodyReturnUrl :: Text
post3dSecureRequestBodyReturnUrl = Text
post3dSecureRequestBodyReturnUrl
}
data Post3dSecureResponse
=
Post3dSecureResponseError GHC.Base.String
|
Post3dSecureResponse200 ThreeDSecure
|
Post3dSecureResponseDefault Error
deriving (Int -> Post3dSecureResponse -> ShowS
[Post3dSecureResponse] -> ShowS
Post3dSecureResponse -> String
(Int -> Post3dSecureResponse -> ShowS)
-> (Post3dSecureResponse -> String)
-> ([Post3dSecureResponse] -> ShowS)
-> Show Post3dSecureResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Post3dSecureResponse] -> ShowS
$cshowList :: [Post3dSecureResponse] -> ShowS
show :: Post3dSecureResponse -> String
$cshow :: Post3dSecureResponse -> String
showsPrec :: Int -> Post3dSecureResponse -> ShowS
$cshowsPrec :: Int -> Post3dSecureResponse -> ShowS
GHC.Show.Show, Post3dSecureResponse -> Post3dSecureResponse -> Bool
(Post3dSecureResponse -> Post3dSecureResponse -> Bool)
-> (Post3dSecureResponse -> Post3dSecureResponse -> Bool)
-> Eq Post3dSecureResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Post3dSecureResponse -> Post3dSecureResponse -> Bool
$c/= :: Post3dSecureResponse -> Post3dSecureResponse -> Bool
== :: Post3dSecureResponse -> Post3dSecureResponse -> Bool
$c== :: Post3dSecureResponse -> Post3dSecureResponse -> Bool
GHC.Classes.Eq)