{-# LANGUAGE MultiWayIf #-}
-- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator.
{-# LANGUAGE OverloadedStrings #-}

-- | Contains the types generated from the schema SetupIntentNextActionRedirectToUrl
module StripeAPI.Types.SetupIntentNextActionRedirectToUrl where

import qualified Control.Monad.Fail
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.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 GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified StripeAPI.Common
import StripeAPI.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.setup_intent_next_action_redirect_to_url@ in the specification.
data SetupIntentNextActionRedirectToUrl = SetupIntentNextActionRedirectToUrl
  { -- | return_url: If the customer does not exit their browser while authenticating, they will be redirected to this specified URL after completion.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    SetupIntentNextActionRedirectToUrl -> Maybe Text
setupIntentNextActionRedirectToUrlReturnUrl :: (GHC.Maybe.Maybe Data.Text.Internal.Text),
    -- | url: The URL you must redirect your customer to in order to authenticate.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    SetupIntentNextActionRedirectToUrl -> Maybe Text
setupIntentNextActionRedirectToUrlUrl :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> SetupIntentNextActionRedirectToUrl -> ShowS
[SetupIntentNextActionRedirectToUrl] -> ShowS
SetupIntentNextActionRedirectToUrl -> String
(Int -> SetupIntentNextActionRedirectToUrl -> ShowS)
-> (SetupIntentNextActionRedirectToUrl -> String)
-> ([SetupIntentNextActionRedirectToUrl] -> ShowS)
-> Show SetupIntentNextActionRedirectToUrl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetupIntentNextActionRedirectToUrl] -> ShowS
$cshowList :: [SetupIntentNextActionRedirectToUrl] -> ShowS
show :: SetupIntentNextActionRedirectToUrl -> String
$cshow :: SetupIntentNextActionRedirectToUrl -> String
showsPrec :: Int -> SetupIntentNextActionRedirectToUrl -> ShowS
$cshowsPrec :: Int -> SetupIntentNextActionRedirectToUrl -> ShowS
GHC.Show.Show,
      SetupIntentNextActionRedirectToUrl
-> SetupIntentNextActionRedirectToUrl -> Bool
(SetupIntentNextActionRedirectToUrl
 -> SetupIntentNextActionRedirectToUrl -> Bool)
-> (SetupIntentNextActionRedirectToUrl
    -> SetupIntentNextActionRedirectToUrl -> Bool)
-> Eq SetupIntentNextActionRedirectToUrl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetupIntentNextActionRedirectToUrl
-> SetupIntentNextActionRedirectToUrl -> Bool
$c/= :: SetupIntentNextActionRedirectToUrl
-> SetupIntentNextActionRedirectToUrl -> Bool
== :: SetupIntentNextActionRedirectToUrl
-> SetupIntentNextActionRedirectToUrl -> Bool
$c== :: SetupIntentNextActionRedirectToUrl
-> SetupIntentNextActionRedirectToUrl -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON SetupIntentNextActionRedirectToUrl where
  toJSON :: SetupIntentNextActionRedirectToUrl -> Value
toJSON SetupIntentNextActionRedirectToUrl
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"return_url" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SetupIntentNextActionRedirectToUrl -> Maybe Text
setupIntentNextActionRedirectToUrlReturnUrl SetupIntentNextActionRedirectToUrl
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"url" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SetupIntentNextActionRedirectToUrl -> Maybe Text
setupIntentNextActionRedirectToUrlUrl SetupIntentNextActionRedirectToUrl
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: SetupIntentNextActionRedirectToUrl -> Encoding
toEncoding SetupIntentNextActionRedirectToUrl
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"return_url" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SetupIntentNextActionRedirectToUrl -> Maybe Text
setupIntentNextActionRedirectToUrlReturnUrl SetupIntentNextActionRedirectToUrl
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"url" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= SetupIntentNextActionRedirectToUrl -> Maybe Text
setupIntentNextActionRedirectToUrlUrl SetupIntentNextActionRedirectToUrl
obj))

instance Data.Aeson.Types.FromJSON.FromJSON SetupIntentNextActionRedirectToUrl where
  parseJSON :: Value -> Parser SetupIntentNextActionRedirectToUrl
parseJSON = String
-> (Object -> Parser SetupIntentNextActionRedirectToUrl)
-> Value
-> Parser SetupIntentNextActionRedirectToUrl
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"SetupIntentNextActionRedirectToUrl" (\Object
obj -> ((Maybe Text -> Maybe Text -> SetupIntentNextActionRedirectToUrl)
-> Parser
     (Maybe Text -> Maybe Text -> SetupIntentNextActionRedirectToUrl)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Text -> Maybe Text -> SetupIntentNextActionRedirectToUrl
SetupIntentNextActionRedirectToUrl Parser
  (Maybe Text -> Maybe Text -> SetupIntentNextActionRedirectToUrl)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SetupIntentNextActionRedirectToUrl)
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")) Parser (Maybe Text -> SetupIntentNextActionRedirectToUrl)
-> Parser (Maybe Text) -> Parser SetupIntentNextActionRedirectToUrl
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
"url"))

-- | Create a new 'SetupIntentNextActionRedirectToUrl' with all required fields.
mkSetupIntentNextActionRedirectToUrl :: SetupIntentNextActionRedirectToUrl
mkSetupIntentNextActionRedirectToUrl :: SetupIntentNextActionRedirectToUrl
mkSetupIntentNextActionRedirectToUrl =
  SetupIntentNextActionRedirectToUrl :: Maybe Text -> Maybe Text -> SetupIntentNextActionRedirectToUrl
SetupIntentNextActionRedirectToUrl
    { setupIntentNextActionRedirectToUrlReturnUrl :: Maybe Text
setupIntentNextActionRedirectToUrlReturnUrl = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing,
      setupIntentNextActionRedirectToUrlUrl :: Maybe Text
setupIntentNextActionRedirectToUrlUrl = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }