{-# 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 Terminal_Location
module StripeAPI.Types.Terminal_Location 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 {-# SOURCE #-} StripeAPI.Types.Address
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe

-- | Defines the object schema located at @components.schemas.terminal.location@ in the specification.
--
-- A Location represents a grouping of readers.
--
-- Related guide: [Fleet Management](https:\/\/stripe.com\/docs\/terminal\/creating-locations).
data Terminal'location = Terminal'location
  { -- | address:
    Terminal'location -> Address
terminal'locationAddress :: Address,
    -- | display_name: The display name of the location.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Terminal'location -> Text
terminal'locationDisplayName :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    Terminal'location -> Text
terminal'locationId :: Data.Text.Internal.Text,
    -- | livemode: Has the value \`true\` if the object exists in live mode or the value \`false\` if the object exists in test mode.
    Terminal'location -> Bool
terminal'locationLivemode :: GHC.Types.Bool,
    -- | metadata: Set of [key-value pairs](https:\/\/stripe.com\/docs\/api\/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
    Terminal'location -> Object
terminal'locationMetadata :: Data.Aeson.Types.Internal.Object
  }
  deriving
    ( Int -> Terminal'location -> ShowS
[Terminal'location] -> ShowS
Terminal'location -> String
(Int -> Terminal'location -> ShowS)
-> (Terminal'location -> String)
-> ([Terminal'location] -> ShowS)
-> Show Terminal'location
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Terminal'location] -> ShowS
$cshowList :: [Terminal'location] -> ShowS
show :: Terminal'location -> String
$cshow :: Terminal'location -> String
showsPrec :: Int -> Terminal'location -> ShowS
$cshowsPrec :: Int -> Terminal'location -> ShowS
GHC.Show.Show,
      Terminal'location -> Terminal'location -> Bool
(Terminal'location -> Terminal'location -> Bool)
-> (Terminal'location -> Terminal'location -> Bool)
-> Eq Terminal'location
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Terminal'location -> Terminal'location -> Bool
$c/= :: Terminal'location -> Terminal'location -> Bool
== :: Terminal'location -> Terminal'location -> Bool
$c== :: Terminal'location -> Terminal'location -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON Terminal'location where
  toJSON :: Terminal'location -> Value
toJSON Terminal'location
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"address" Text -> Address -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Address
terminal'locationAddress Terminal'location
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"display_name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Text
terminal'locationDisplayName Terminal'location
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Text
terminal'locationId Terminal'location
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"livemode" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Bool
terminal'locationLivemode Terminal'location
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"metadata" Text -> Object -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Object
terminal'locationMetadata Terminal'location
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
"terminal.location" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: Terminal'location -> Encoding
toEncoding Terminal'location
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"address" Text -> Address -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Address
terminal'locationAddress Terminal'location
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"display_name" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Text
terminal'locationDisplayName Terminal'location
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"id" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Text
terminal'locationId Terminal'location
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"livemode" Text -> Bool -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Bool
terminal'locationLivemode Terminal'location
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"metadata" Text -> Object -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Terminal'location -> Object
terminal'locationMetadata Terminal'location
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
"terminal.location"))))))

instance Data.Aeson.Types.FromJSON.FromJSON Terminal'location where
  parseJSON :: Value -> Parser Terminal'location
parseJSON = String
-> (Object -> Parser Terminal'location)
-> Value
-> Parser Terminal'location
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Terminal'location" (\Object
obj -> (((((Address -> Text -> Text -> Bool -> Object -> Terminal'location)
-> Parser
     (Address -> Text -> Text -> Bool -> Object -> Terminal'location)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Address -> Text -> Text -> Bool -> Object -> Terminal'location
Terminal'location Parser
  (Address -> Text -> Text -> Bool -> Object -> Terminal'location)
-> Parser Address
-> Parser (Text -> Text -> Bool -> Object -> Terminal'location)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Address
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"address")) Parser (Text -> Text -> Bool -> Object -> Terminal'location)
-> Parser Text
-> Parser (Text -> Bool -> Object -> Terminal'location)
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
"display_name")) Parser (Text -> Bool -> Object -> Terminal'location)
-> Parser Text -> Parser (Bool -> Object -> Terminal'location)
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
"id")) Parser (Bool -> Object -> Terminal'location)
-> Parser Bool -> Parser (Object -> Terminal'location)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"livemode")) Parser (Object -> Terminal'location)
-> Parser Object -> Parser Terminal'location
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser Object
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"metadata"))

-- | Create a new 'Terminal'location' with all required fields.
mkTerminal'location ::
  -- | 'terminal'locationAddress'
  Address ->
  -- | 'terminal'locationDisplayName'
  Data.Text.Internal.Text ->
  -- | 'terminal'locationId'
  Data.Text.Internal.Text ->
  -- | 'terminal'locationLivemode'
  GHC.Types.Bool ->
  -- | 'terminal'locationMetadata'
  Data.Aeson.Types.Internal.Object ->
  Terminal'location
mkTerminal'location :: Address -> Text -> Text -> Bool -> Object -> Terminal'location
mkTerminal'location Address
terminal'locationAddress Text
terminal'locationDisplayName Text
terminal'locationId Bool
terminal'locationLivemode Object
terminal'locationMetadata =
  Terminal'location :: Address -> Text -> Text -> Bool -> Object -> Terminal'location
Terminal'location
    { terminal'locationAddress :: Address
terminal'locationAddress = Address
terminal'locationAddress,
      terminal'locationDisplayName :: Text
terminal'locationDisplayName = Text
terminal'locationDisplayName,
      terminal'locationId :: Text
terminal'locationId = Text
terminal'locationId,
      terminal'locationLivemode :: Bool
terminal'locationLivemode = Bool
terminal'locationLivemode,
      terminal'locationMetadata :: Object
terminal'locationMetadata = Object
terminal'locationMetadata
    }