{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module StripeAPI.Types.Error 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.ApiErrors
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data Error = Error
{
Error -> ApiErrors
errorError :: ApiErrors
}
deriving
( Int -> Error -> ShowS
[Error] -> ShowS
Error -> String
(Int -> Error -> ShowS)
-> (Error -> String) -> ([Error] -> ShowS) -> Show Error
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Error] -> ShowS
$cshowList :: [Error] -> ShowS
show :: Error -> String
$cshow :: Error -> String
showsPrec :: Int -> Error -> ShowS
$cshowsPrec :: Int -> Error -> ShowS
GHC.Show.Show,
Error -> Error -> Bool
(Error -> Error -> Bool) -> (Error -> Error -> Bool) -> Eq Error
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Error -> Error -> Bool
$c/= :: Error -> Error -> Bool
== :: Error -> Error -> Bool
$c== :: Error -> Error -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON Error where
toJSON :: Error -> Value
toJSON Error
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object (Text
"error" Text -> ApiErrors -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Error -> ApiErrors
errorError Error
obj Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: [Pair]
forall a. Monoid a => a
GHC.Base.mempty)
toEncoding :: Error -> Encoding
toEncoding Error
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs (Text
"error" Text -> ApiErrors -> Series
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Data.Aeson.Types.ToJSON..= Error -> ApiErrors
errorError Error
obj)
instance Data.Aeson.Types.FromJSON.FromJSON Error where
parseJSON :: Value -> Parser Error
parseJSON = String -> (Object -> Parser Error) -> Value -> Parser Error
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Error" (\Object
obj -> (ApiErrors -> Error) -> Parser (ApiErrors -> Error)
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure ApiErrors -> Error
Error Parser (ApiErrors -> Error) -> Parser ApiErrors -> Parser Error
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Text -> Parser ApiErrors
forall a. FromJSON a => Object -> Text -> Parser a
Data.Aeson.Types.FromJSON..: Text
"error"))
mkError ::
ApiErrors ->
Error
mkError :: ApiErrors -> Error
mkError ApiErrors
errorError = Error :: ApiErrors -> Error
Error {errorError :: ApiErrors
errorError = ApiErrors
errorError}