{-# 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 AccountLink
module StripeAPI.Types.AccountLink 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.account_link@ in the specification.
--
-- Account Links are the means by which a Connect platform grants a connected account permission to access
-- Stripe-hosted applications, such as Connect Onboarding.
--
-- Related guide: [Connect Onboarding](https:\/\/stripe.com\/docs\/connect\/connect-onboarding).
data AccountLink = AccountLink
  { -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    AccountLink -> Int
accountLinkCreated :: GHC.Types.Int,
    -- | expires_at: The timestamp at which this account link will expire.
    AccountLink -> Int
accountLinkExpiresAt :: GHC.Types.Int,
    -- | url: The URL for the account link.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    AccountLink -> Text
accountLinkUrl :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> AccountLink -> ShowS
[AccountLink] -> ShowS
AccountLink -> String
(Int -> AccountLink -> ShowS)
-> (AccountLink -> String)
-> ([AccountLink] -> ShowS)
-> Show AccountLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountLink] -> ShowS
$cshowList :: [AccountLink] -> ShowS
show :: AccountLink -> String
$cshow :: AccountLink -> String
showsPrec :: Int -> AccountLink -> ShowS
$cshowsPrec :: Int -> AccountLink -> ShowS
GHC.Show.Show,
      AccountLink -> AccountLink -> Bool
(AccountLink -> AccountLink -> Bool)
-> (AccountLink -> AccountLink -> Bool) -> Eq AccountLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountLink -> AccountLink -> Bool
$c/= :: AccountLink -> AccountLink -> Bool
== :: AccountLink -> AccountLink -> Bool
$c== :: AccountLink -> AccountLink -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON AccountLink where
  toJSON :: AccountLink -> Value
toJSON AccountLink
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountLink -> Int
accountLinkCreated AccountLink
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"expires_at" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountLink -> Int
accountLinkExpiresAt AccountLink
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"url" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountLink -> Text
accountLinkUrl AccountLink
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"object" Text -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"account_link" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: AccountLink -> Encoding
toEncoding AccountLink
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountLink -> Int
accountLinkCreated AccountLink
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"expires_at" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountLink -> Int
accountLinkExpiresAt AccountLink
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"url" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= AccountLink -> Text
accountLinkUrl AccountLink
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"object" Text -> Value -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Text -> Value
Data.Aeson.Types.Internal.String Text
"account_link"))))

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

-- | Create a new 'AccountLink' with all required fields.
mkAccountLink ::
  -- | 'accountLinkCreated'
  GHC.Types.Int ->
  -- | 'accountLinkExpiresAt'
  GHC.Types.Int ->
  -- | 'accountLinkUrl'
  Data.Text.Internal.Text ->
  AccountLink
mkAccountLink :: Int -> Int -> Text -> AccountLink
mkAccountLink Int
accountLinkCreated Int
accountLinkExpiresAt Text
accountLinkUrl =
  AccountLink :: Int -> Int -> Text -> AccountLink
AccountLink
    { accountLinkCreated :: Int
accountLinkCreated = Int
accountLinkCreated,
      accountLinkExpiresAt :: Int
accountLinkExpiresAt = Int
accountLinkExpiresAt,
      accountLinkUrl :: Text
accountLinkUrl = Text
accountLinkUrl
    }