{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Operations.PostBillingPortalSessions 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
postBillingPortalSessions ::
forall m.
StripeAPI.Common.MonadHTTP m =>
PostBillingPortalSessionsRequestBody ->
StripeAPI.Common.StripeT m (Network.HTTP.Client.Types.Response PostBillingPortalSessionsResponse)
postBillingPortalSessions :: PostBillingPortalSessionsRequestBody
-> StripeT m (Response PostBillingPortalSessionsResponse)
postBillingPortalSessions PostBillingPortalSessionsRequestBody
body =
(Response ByteString -> Response PostBillingPortalSessionsResponse)
-> StripeT m (Response ByteString)
-> StripeT m (Response PostBillingPortalSessionsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( \Response ByteString
response_0 ->
(ByteString -> PostBillingPortalSessionsResponse)
-> Response ByteString
-> Response PostBillingPortalSessionsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
GHC.Base.fmap
( (String -> PostBillingPortalSessionsResponse)
-> (PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse)
-> Either String PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
Data.Either.either String -> PostBillingPortalSessionsResponse
PostBillingPortalSessionsResponseError PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse
forall a. a -> a
GHC.Base.id
(Either String PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse)
-> (ByteString -> Either String PostBillingPortalSessionsResponse)
-> ByteString
-> PostBillingPortalSessionsResponse
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) ->
BillingPortal'session -> PostBillingPortalSessionsResponse
PostBillingPortalSessionsResponse200
(BillingPortal'session -> PostBillingPortalSessionsResponse)
-> Either String BillingPortal'session
-> Either String PostBillingPortalSessionsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Data.Functor.<$> ( ByteString -> Either String BillingPortal'session
forall a. FromJSON a => ByteString -> Either String a
Data.Aeson.eitherDecodeStrict ByteString
body ::
Data.Either.Either
GHC.Base.String
BillingPortal'session
)
| 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 -> PostBillingPortalSessionsResponse
PostBillingPortalSessionsResponseDefault
(Error -> PostBillingPortalSessionsResponse)
-> Either String Error
-> Either String PostBillingPortalSessionsResponse
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 PostBillingPortalSessionsResponse
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 PostBillingPortalSessionsRequestBody
-> RequestBodyEncoding
-> StripeT m (Response ByteString)
forall (m :: * -> *) body.
(MonadHTTP m, ToJSON body) =>
Text
-> Text
-> [QueryParameter]
-> Maybe body
-> RequestBodyEncoding
-> StripeT 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/billing_portal/sessions") [QueryParameter]
forall a. Monoid a => a
GHC.Base.mempty (PostBillingPortalSessionsRequestBody
-> Maybe PostBillingPortalSessionsRequestBody
forall a. a -> Maybe a
GHC.Maybe.Just PostBillingPortalSessionsRequestBody
body) RequestBodyEncoding
StripeAPI.Common.RequestBodyEncodingFormData)
data PostBillingPortalSessionsRequestBody = PostBillingPortalSessionsRequestBody
{
PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyConfiguration :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
PostBillingPortalSessionsRequestBody -> Text
postBillingPortalSessionsRequestBodyCustomer :: Data.Text.Internal.Text,
PostBillingPortalSessionsRequestBody -> Maybe [Text]
postBillingPortalSessionsRequestBodyExpand :: (GHC.Maybe.Maybe ([Data.Text.Internal.Text])),
PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyOnBehalfOf :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyReturnUrl :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> PostBillingPortalSessionsRequestBody -> ShowS
[PostBillingPortalSessionsRequestBody] -> ShowS
PostBillingPortalSessionsRequestBody -> String
(Int -> PostBillingPortalSessionsRequestBody -> ShowS)
-> (PostBillingPortalSessionsRequestBody -> String)
-> ([PostBillingPortalSessionsRequestBody] -> ShowS)
-> Show PostBillingPortalSessionsRequestBody
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostBillingPortalSessionsRequestBody] -> ShowS
$cshowList :: [PostBillingPortalSessionsRequestBody] -> ShowS
show :: PostBillingPortalSessionsRequestBody -> String
$cshow :: PostBillingPortalSessionsRequestBody -> String
showsPrec :: Int -> PostBillingPortalSessionsRequestBody -> ShowS
$cshowsPrec :: Int -> PostBillingPortalSessionsRequestBody -> ShowS
GHC.Show.Show,
PostBillingPortalSessionsRequestBody
-> PostBillingPortalSessionsRequestBody -> Bool
(PostBillingPortalSessionsRequestBody
-> PostBillingPortalSessionsRequestBody -> Bool)
-> (PostBillingPortalSessionsRequestBody
-> PostBillingPortalSessionsRequestBody -> Bool)
-> Eq PostBillingPortalSessionsRequestBody
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostBillingPortalSessionsRequestBody
-> PostBillingPortalSessionsRequestBody -> Bool
$c/= :: PostBillingPortalSessionsRequestBody
-> PostBillingPortalSessionsRequestBody -> Bool
== :: PostBillingPortalSessionsRequestBody
-> PostBillingPortalSessionsRequestBody -> Bool
$c== :: PostBillingPortalSessionsRequestBody
-> PostBillingPortalSessionsRequestBody -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON PostBillingPortalSessionsRequestBody where
toJSON :: PostBillingPortalSessionsRequestBody -> Value
toJSON PostBillingPortalSessionsRequestBody
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"configuration" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyConfiguration PostBillingPortalSessionsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"customer" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostBillingPortalSessionsRequestBody -> Text
postBillingPortalSessionsRequestBodyCustomer PostBillingPortalSessionsRequestBody
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..= PostBillingPortalSessionsRequestBody -> Maybe [Text]
postBillingPortalSessionsRequestBodyExpand PostBillingPortalSessionsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"on_behalf_of" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyOnBehalfOf PostBillingPortalSessionsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"return_url" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyReturnUrl PostBillingPortalSessionsRequestBody
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: PostBillingPortalSessionsRequestBody -> Encoding
toEncoding PostBillingPortalSessionsRequestBody
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"configuration" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyConfiguration PostBillingPortalSessionsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"customer" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostBillingPortalSessionsRequestBody -> Text
postBillingPortalSessionsRequestBodyCustomer PostBillingPortalSessionsRequestBody
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..= PostBillingPortalSessionsRequestBody -> Maybe [Text]
postBillingPortalSessionsRequestBodyExpand PostBillingPortalSessionsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"on_behalf_of" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyOnBehalfOf PostBillingPortalSessionsRequestBody
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"return_url" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PostBillingPortalSessionsRequestBody -> Maybe Text
postBillingPortalSessionsRequestBodyReturnUrl PostBillingPortalSessionsRequestBody
obj)))))
instance Data.Aeson.Types.FromJSON.FromJSON PostBillingPortalSessionsRequestBody where
parseJSON :: Value -> Parser PostBillingPortalSessionsRequestBody
parseJSON = String
-> (Object -> Parser PostBillingPortalSessionsRequestBody)
-> Value
-> Parser PostBillingPortalSessionsRequestBody
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PostBillingPortalSessionsRequestBody" (\Object
obj -> (((((Maybe Text
-> Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody)
-> Parser
(Maybe Text
-> Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text
-> Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody
PostBillingPortalSessionsRequestBody Parser
(Maybe Text
-> Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody)
-> Parser (Maybe Text)
-> Parser
(Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody)
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
"configuration")) Parser
(Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody)
-> Parser Text
-> Parser
(Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody)
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
"customer")) Parser
(Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody)
-> Parser (Maybe [Text])
-> Parser
(Maybe Text -> Maybe Text -> PostBillingPortalSessionsRequestBody)
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
(Maybe Text -> Maybe Text -> PostBillingPortalSessionsRequestBody)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PostBillingPortalSessionsRequestBody)
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
"on_behalf_of")) Parser (Maybe Text -> PostBillingPortalSessionsRequestBody)
-> Parser (Maybe Text)
-> Parser PostBillingPortalSessionsRequestBody
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
"return_url"))
mkPostBillingPortalSessionsRequestBody ::
Data.Text.Internal.Text ->
PostBillingPortalSessionsRequestBody
mkPostBillingPortalSessionsRequestBody :: Text -> PostBillingPortalSessionsRequestBody
mkPostBillingPortalSessionsRequestBody Text
postBillingPortalSessionsRequestBodyCustomer =
PostBillingPortalSessionsRequestBody :: Maybe Text
-> Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> PostBillingPortalSessionsRequestBody
PostBillingPortalSessionsRequestBody
{ postBillingPortalSessionsRequestBodyConfiguration :: Maybe Text
postBillingPortalSessionsRequestBodyConfiguration = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
postBillingPortalSessionsRequestBodyCustomer :: Text
postBillingPortalSessionsRequestBodyCustomer = Text
postBillingPortalSessionsRequestBodyCustomer,
postBillingPortalSessionsRequestBodyExpand :: Maybe [Text]
postBillingPortalSessionsRequestBodyExpand = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing,
postBillingPortalSessionsRequestBodyOnBehalfOf :: Maybe Text
postBillingPortalSessionsRequestBodyOnBehalfOf = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
postBillingPortalSessionsRequestBodyReturnUrl :: Maybe Text
postBillingPortalSessionsRequestBodyReturnUrl = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}
data PostBillingPortalSessionsResponse
=
PostBillingPortalSessionsResponseError GHC.Base.String
|
PostBillingPortalSessionsResponse200 BillingPortal'session
|
PostBillingPortalSessionsResponseDefault Error
deriving (Int -> PostBillingPortalSessionsResponse -> ShowS
[PostBillingPortalSessionsResponse] -> ShowS
PostBillingPortalSessionsResponse -> String
(Int -> PostBillingPortalSessionsResponse -> ShowS)
-> (PostBillingPortalSessionsResponse -> String)
-> ([PostBillingPortalSessionsResponse] -> ShowS)
-> Show PostBillingPortalSessionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostBillingPortalSessionsResponse] -> ShowS
$cshowList :: [PostBillingPortalSessionsResponse] -> ShowS
show :: PostBillingPortalSessionsResponse -> String
$cshow :: PostBillingPortalSessionsResponse -> String
showsPrec :: Int -> PostBillingPortalSessionsResponse -> ShowS
$cshowsPrec :: Int -> PostBillingPortalSessionsResponse -> ShowS
GHC.Show.Show, PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse -> Bool
(PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse -> Bool)
-> (PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse -> Bool)
-> Eq PostBillingPortalSessionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse -> Bool
$c/= :: PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse -> Bool
== :: PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse -> Bool
$c== :: PostBillingPortalSessionsResponse
-> PostBillingPortalSessionsResponse -> Bool
GHC.Classes.Eq)