{-# 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 PersonRelationship
module StripeAPI.Types.PersonRelationship 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.person_relationship@ in the specification.
data PersonRelationship = PersonRelationship
  { -- | director: Whether the person is a director of the account\'s legal entity. Currently only required for accounts in the EU. Directors are typically members of the governing board of the company, or responsible for ensuring the company meets its regulatory obligations.
    PersonRelationship -> Maybe Bool
personRelationshipDirector :: (GHC.Maybe.Maybe GHC.Types.Bool),
    -- | executive: Whether the person has significant responsibility to control, manage, or direct the organization.
    PersonRelationship -> Maybe Bool
personRelationshipExecutive :: (GHC.Maybe.Maybe GHC.Types.Bool),
    -- | owner: Whether the person is an owner of the account’s legal entity.
    PersonRelationship -> Maybe Bool
personRelationshipOwner :: (GHC.Maybe.Maybe GHC.Types.Bool),
    -- | percent_ownership: The percent owned by the person of the account\'s legal entity.
    PersonRelationship -> Maybe Double
personRelationshipPercentOwnership :: (GHC.Maybe.Maybe GHC.Types.Double),
    -- | representative: Whether the person is authorized as the primary representative of the account. This is the person nominated by the business to provide information about themselves, and general information about the account. There can only be one representative at any given time. At the time the account is created, this person should be set to the person responsible for opening the account.
    PersonRelationship -> Maybe Bool
personRelationshipRepresentative :: (GHC.Maybe.Maybe GHC.Types.Bool),
    -- | title: The person\'s title (e.g., CEO, Support Engineer).
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    PersonRelationship -> Maybe Text
personRelationshipTitle :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
  }
  deriving
    ( Int -> PersonRelationship -> ShowS
[PersonRelationship] -> ShowS
PersonRelationship -> String
(Int -> PersonRelationship -> ShowS)
-> (PersonRelationship -> String)
-> ([PersonRelationship] -> ShowS)
-> Show PersonRelationship
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PersonRelationship] -> ShowS
$cshowList :: [PersonRelationship] -> ShowS
show :: PersonRelationship -> String
$cshow :: PersonRelationship -> String
showsPrec :: Int -> PersonRelationship -> ShowS
$cshowsPrec :: Int -> PersonRelationship -> ShowS
GHC.Show.Show,
      PersonRelationship -> PersonRelationship -> Bool
(PersonRelationship -> PersonRelationship -> Bool)
-> (PersonRelationship -> PersonRelationship -> Bool)
-> Eq PersonRelationship
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PersonRelationship -> PersonRelationship -> Bool
$c/= :: PersonRelationship -> PersonRelationship -> Bool
== :: PersonRelationship -> PersonRelationship -> Bool
$c== :: PersonRelationship -> PersonRelationship -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON PersonRelationship where
  toJSON :: PersonRelationship -> Value
toJSON PersonRelationship
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"director" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Bool
personRelationshipDirector PersonRelationship
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"executive" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Bool
personRelationshipExecutive PersonRelationship
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"owner" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Bool
personRelationshipOwner PersonRelationship
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"percent_ownership" Text -> Maybe Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Double
personRelationshipPercentOwnership PersonRelationship
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"representative" Text -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Bool
personRelationshipRepresentative PersonRelationship
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"title" Text -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Text
personRelationshipTitle PersonRelationship
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: PersonRelationship -> Encoding
toEncoding PersonRelationship
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"director" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Bool
personRelationshipDirector PersonRelationship
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"executive" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Bool
personRelationshipExecutive PersonRelationship
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"owner" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Bool
personRelationshipOwner PersonRelationship
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"percent_ownership" Text -> Maybe Double -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Double
personRelationshipPercentOwnership PersonRelationship
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"representative" Text -> Maybe Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Bool
personRelationshipRepresentative PersonRelationship
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> (Text
"title" Text -> Maybe Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= PersonRelationship -> Maybe Text
personRelationshipTitle PersonRelationship
obj))))))

instance Data.Aeson.Types.FromJSON.FromJSON PersonRelationship where
  parseJSON :: Value -> Parser PersonRelationship
parseJSON = String
-> (Object -> Parser PersonRelationship)
-> Value
-> Parser PersonRelationship
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"PersonRelationship" (\Object
obj -> ((((((Maybe Bool
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Double
 -> Maybe Bool
 -> Maybe Text
 -> PersonRelationship)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Double
      -> Maybe Bool
      -> Maybe Text
      -> PersonRelationship)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Double
-> Maybe Bool
-> Maybe Text
-> PersonRelationship
PersonRelationship Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Double
   -> Maybe Bool
   -> Maybe Text
   -> PersonRelationship)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Bool
      -> Maybe Double
      -> Maybe Bool
      -> Maybe Text
      -> PersonRelationship)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"director")) Parser
  (Maybe Bool
   -> Maybe Bool
   -> Maybe Double
   -> Maybe Bool
   -> Maybe Text
   -> PersonRelationship)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Bool
      -> Maybe Double -> Maybe Bool -> Maybe Text -> PersonRelationship)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"executive")) Parser
  (Maybe Bool
   -> Maybe Double -> Maybe Bool -> Maybe Text -> PersonRelationship)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Double -> Maybe Bool -> Maybe Text -> PersonRelationship)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"owner")) Parser
  (Maybe Double -> Maybe Bool -> Maybe Text -> PersonRelationship)
-> Parser (Maybe Double)
-> Parser (Maybe Bool -> Maybe Text -> PersonRelationship)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"percent_ownership")) Parser (Maybe Bool -> Maybe Text -> PersonRelationship)
-> Parser (Maybe Bool) -> Parser (Maybe Text -> PersonRelationship)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Text
"representative")) Parser (Maybe Text -> PersonRelationship)
-> Parser (Maybe Text) -> Parser PersonRelationship
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
"title"))

-- | Create a new 'PersonRelationship' with all required fields.
mkPersonRelationship :: PersonRelationship
mkPersonRelationship :: PersonRelationship
mkPersonRelationship =
  PersonRelationship :: Maybe Bool
-> Maybe Bool
-> Maybe Bool
-> Maybe Double
-> Maybe Bool
-> Maybe Text
-> PersonRelationship
PersonRelationship
    { personRelationshipDirector :: Maybe Bool
personRelationshipDirector = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      personRelationshipExecutive :: Maybe Bool
personRelationshipExecutive = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      personRelationshipOwner :: Maybe Bool
personRelationshipOwner = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      personRelationshipPercentOwnership :: Maybe Double
personRelationshipPercentOwnership = Maybe Double
forall a. Maybe a
GHC.Maybe.Nothing,
      personRelationshipRepresentative :: Maybe Bool
personRelationshipRepresentative = Maybe Bool
forall a. Maybe a
GHC.Maybe.Nothing,
      personRelationshipTitle :: Maybe Text
personRelationshipTitle = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
    }