{-# 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 BitcoinTransaction
module StripeAPI.Types.BitcoinTransaction 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.bitcoin_transaction@ in the specification.
data BitcoinTransaction = BitcoinTransaction
  { -- | amount: The amount of \`currency\` that the transaction was converted to in real-time.
    BitcoinTransaction -> Int
bitcoinTransactionAmount :: GHC.Types.Int,
    -- | bitcoin_amount: The amount of bitcoin contained in the transaction.
    BitcoinTransaction -> Int
bitcoinTransactionBitcoinAmount :: GHC.Types.Int,
    -- | created: Time at which the object was created. Measured in seconds since the Unix epoch.
    BitcoinTransaction -> Int
bitcoinTransactionCreated :: GHC.Types.Int,
    -- | currency: Three-letter [ISO code for the currency](https:\/\/stripe.com\/docs\/currencies) to which this transaction was converted.
    BitcoinTransaction -> Text
bitcoinTransactionCurrency :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    BitcoinTransaction -> Text
bitcoinTransactionId :: Data.Text.Internal.Text,
    -- | receiver: The receiver to which this transaction was sent.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    BitcoinTransaction -> Text
bitcoinTransactionReceiver :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> BitcoinTransaction -> ShowS
[BitcoinTransaction] -> ShowS
BitcoinTransaction -> String
(Int -> BitcoinTransaction -> ShowS)
-> (BitcoinTransaction -> String)
-> ([BitcoinTransaction] -> ShowS)
-> Show BitcoinTransaction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BitcoinTransaction] -> ShowS
$cshowList :: [BitcoinTransaction] -> ShowS
show :: BitcoinTransaction -> String
$cshow :: BitcoinTransaction -> String
showsPrec :: Int -> BitcoinTransaction -> ShowS
$cshowsPrec :: Int -> BitcoinTransaction -> ShowS
GHC.Show.Show,
      BitcoinTransaction -> BitcoinTransaction -> Bool
(BitcoinTransaction -> BitcoinTransaction -> Bool)
-> (BitcoinTransaction -> BitcoinTransaction -> Bool)
-> Eq BitcoinTransaction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BitcoinTransaction -> BitcoinTransaction -> Bool
$c/= :: BitcoinTransaction -> BitcoinTransaction -> Bool
== :: BitcoinTransaction -> BitcoinTransaction -> Bool
$c== :: BitcoinTransaction -> BitcoinTransaction -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON BitcoinTransaction where
  toJSON :: BitcoinTransaction -> Value
toJSON BitcoinTransaction
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Int
bitcoinTransactionAmount BitcoinTransaction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"bitcoin_amount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Int
bitcoinTransactionBitcoinAmount BitcoinTransaction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"created" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Int
bitcoinTransactionCreated BitcoinTransaction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"currency" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Text
bitcoinTransactionCurrency BitcoinTransaction
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..= BitcoinTransaction -> Text
bitcoinTransactionId BitcoinTransaction
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"receiver" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Text
bitcoinTransactionReceiver BitcoinTransaction
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
"bitcoin_transaction" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: BitcoinTransaction -> Encoding
toEncoding BitcoinTransaction
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Int
bitcoinTransactionAmount BitcoinTransaction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"bitcoin_amount" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Int
bitcoinTransactionBitcoinAmount BitcoinTransaction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"created" Text -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Int
bitcoinTransactionCreated BitcoinTransaction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"currency" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Text
bitcoinTransactionCurrency BitcoinTransaction
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..= BitcoinTransaction -> Text
bitcoinTransactionId BitcoinTransaction
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"receiver" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= BitcoinTransaction -> Text
bitcoinTransactionReceiver BitcoinTransaction
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
"bitcoin_transaction")))))))

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

-- | Create a new 'BitcoinTransaction' with all required fields.
mkBitcoinTransaction ::
  -- | 'bitcoinTransactionAmount'
  GHC.Types.Int ->
  -- | 'bitcoinTransactionBitcoinAmount'
  GHC.Types.Int ->
  -- | 'bitcoinTransactionCreated'
  GHC.Types.Int ->
  -- | 'bitcoinTransactionCurrency'
  Data.Text.Internal.Text ->
  -- | 'bitcoinTransactionId'
  Data.Text.Internal.Text ->
  -- | 'bitcoinTransactionReceiver'
  Data.Text.Internal.Text ->
  BitcoinTransaction
mkBitcoinTransaction :: Int -> Int -> Int -> Text -> Text -> Text -> BitcoinTransaction
mkBitcoinTransaction Int
bitcoinTransactionAmount Int
bitcoinTransactionBitcoinAmount Int
bitcoinTransactionCreated Text
bitcoinTransactionCurrency Text
bitcoinTransactionId Text
bitcoinTransactionReceiver =
  BitcoinTransaction :: Int -> Int -> Int -> Text -> Text -> Text -> BitcoinTransaction
BitcoinTransaction
    { bitcoinTransactionAmount :: Int
bitcoinTransactionAmount = Int
bitcoinTransactionAmount,
      bitcoinTransactionBitcoinAmount :: Int
bitcoinTransactionBitcoinAmount = Int
bitcoinTransactionBitcoinAmount,
      bitcoinTransactionCreated :: Int
bitcoinTransactionCreated = Int
bitcoinTransactionCreated,
      bitcoinTransactionCurrency :: Text
bitcoinTransactionCurrency = Text
bitcoinTransactionCurrency,
      bitcoinTransactionId :: Text
bitcoinTransactionId = Text
bitcoinTransactionId,
      bitcoinTransactionReceiver :: Text
bitcoinTransactionReceiver = Text
bitcoinTransactionReceiver
    }