{-# 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 TaxCode
module StripeAPI.Types.TaxCode 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.tax_code@ in the specification.
--
-- [Tax codes](https:\/\/stripe.com\/docs\/tax\/tax-codes) classify goods and services for tax purposes.
data TaxCode = TaxCode
  { -- | description: A detailed description of which types of products the tax code represents.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    TaxCode -> Text
taxCodeDescription :: Data.Text.Internal.Text,
    -- | id: Unique identifier for the object.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    TaxCode -> Text
taxCodeId :: Data.Text.Internal.Text,
    -- | name: A short name for the tax code.
    --
    -- Constraints:
    --
    -- * Maximum length of 5000
    TaxCode -> Text
taxCodeName :: Data.Text.Internal.Text
  }
  deriving
    ( Int -> TaxCode -> ShowS
[TaxCode] -> ShowS
TaxCode -> String
(Int -> TaxCode -> ShowS)
-> (TaxCode -> String) -> ([TaxCode] -> ShowS) -> Show TaxCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TaxCode] -> ShowS
$cshowList :: [TaxCode] -> ShowS
show :: TaxCode -> String
$cshow :: TaxCode -> String
showsPrec :: Int -> TaxCode -> ShowS
$cshowsPrec :: Int -> TaxCode -> ShowS
GHC.Show.Show,
      TaxCode -> TaxCode -> Bool
(TaxCode -> TaxCode -> Bool)
-> (TaxCode -> TaxCode -> Bool) -> Eq TaxCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TaxCode -> TaxCode -> Bool
$c/= :: TaxCode -> TaxCode -> Bool
== :: TaxCode -> TaxCode -> Bool
$c== :: TaxCode -> TaxCode -> Bool
GHC.Classes.Eq
    )

instance Data.Aeson.Types.ToJSON.ToJSON TaxCode where
  toJSON :: TaxCode -> Value
toJSON TaxCode
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxCode -> Text
taxCodeDescription TaxCode
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..= TaxCode -> Text
taxCodeId TaxCode
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxCode -> Text
taxCodeName TaxCode
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
"tax_code" Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
  toEncoding :: TaxCode -> Encoding
toEncoding TaxCode
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ((Text
"description" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxCode -> Text
taxCodeDescription TaxCode
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..= TaxCode -> Text
taxCodeId TaxCode
obj) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
GHC.Base.<> ((Text
"name" Text -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= TaxCode -> Text
taxCodeName TaxCode
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
"tax_code"))))

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

-- | Create a new 'TaxCode' with all required fields.
mkTaxCode ::
  -- | 'taxCodeDescription'
  Data.Text.Internal.Text ->
  -- | 'taxCodeId'
  Data.Text.Internal.Text ->
  -- | 'taxCodeName'
  Data.Text.Internal.Text ->
  TaxCode
mkTaxCode :: Text -> Text -> Text -> TaxCode
mkTaxCode Text
taxCodeDescription Text
taxCodeId Text
taxCodeName =
  TaxCode :: Text -> Text -> Text -> TaxCode
TaxCode
    { taxCodeDescription :: Text
taxCodeDescription = Text
taxCodeDescription,
      taxCodeId :: Text
taxCodeId = Text
taxCodeId,
      taxCodeName :: Text
taxCodeName = Text
taxCodeName
    }