{-# LANGUAGE TemplateHaskell #-}
module Calamity.Types.Model.Voice.VoiceRegion (VoiceRegion (..)) where
import Calamity.Internal.Utils
import Calamity.Types.Snowflake
import Data.Aeson ((.:))
import Data.Aeson qualified as Aeson
import Data.Text (Text)
import Optics.TH
import TextShow.TH
data VoiceRegion = VoiceRegion
{ VoiceRegion -> Snowflake VoiceRegion
id :: Snowflake VoiceRegion
, VoiceRegion -> Text
name :: Text
, VoiceRegion -> Bool
vip :: Bool
, VoiceRegion -> Bool
optimal :: Bool
, VoiceRegion -> Bool
deprecated :: Bool
, VoiceRegion -> Bool
custom :: Bool
}
deriving (Int -> VoiceRegion -> ShowS
[VoiceRegion] -> ShowS
VoiceRegion -> String
(Int -> VoiceRegion -> ShowS)
-> (VoiceRegion -> String)
-> ([VoiceRegion] -> ShowS)
-> Show VoiceRegion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VoiceRegion -> ShowS
showsPrec :: Int -> VoiceRegion -> ShowS
$cshow :: VoiceRegion -> String
show :: VoiceRegion -> String
$cshowList :: [VoiceRegion] -> ShowS
showList :: [VoiceRegion] -> ShowS
Show, VoiceRegion -> VoiceRegion -> Bool
(VoiceRegion -> VoiceRegion -> Bool)
-> (VoiceRegion -> VoiceRegion -> Bool) -> Eq VoiceRegion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VoiceRegion -> VoiceRegion -> Bool
== :: VoiceRegion -> VoiceRegion -> Bool
$c/= :: VoiceRegion -> VoiceRegion -> Bool
/= :: VoiceRegion -> VoiceRegion -> Bool
Eq)
deriving ([VoiceRegion] -> Value
[VoiceRegion] -> Encoding
VoiceRegion -> Value
VoiceRegion -> Encoding
(VoiceRegion -> Value)
-> (VoiceRegion -> Encoding)
-> ([VoiceRegion] -> Value)
-> ([VoiceRegion] -> Encoding)
-> ToJSON VoiceRegion
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: VoiceRegion -> Value
toJSON :: VoiceRegion -> Value
$ctoEncoding :: VoiceRegion -> Encoding
toEncoding :: VoiceRegion -> Encoding
$ctoJSONList :: [VoiceRegion] -> Value
toJSONList :: [VoiceRegion] -> Value
$ctoEncodingList :: [VoiceRegion] -> Encoding
toEncodingList :: [VoiceRegion] -> Encoding
Aeson.ToJSON) via CalamityToJSON VoiceRegion
instance CalamityToJSON' VoiceRegion where
toPairs :: forall kv. KeyValue kv => VoiceRegion -> [Maybe kv]
toPairs VoiceRegion {Bool
Text
Snowflake VoiceRegion
$sel:id:VoiceRegion :: VoiceRegion -> Snowflake VoiceRegion
$sel:name:VoiceRegion :: VoiceRegion -> Text
$sel:vip:VoiceRegion :: VoiceRegion -> Bool
$sel:optimal:VoiceRegion :: VoiceRegion -> Bool
$sel:deprecated:VoiceRegion :: VoiceRegion -> Bool
$sel:custom:VoiceRegion :: VoiceRegion -> Bool
id :: Snowflake VoiceRegion
name :: Text
vip :: Bool
optimal :: Bool
deprecated :: Bool
custom :: Bool
..} =
[ Key
"id" Key -> Snowflake VoiceRegion -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Snowflake VoiceRegion
id
, Key
"name" Key -> Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Text
name
, Key
"vip" Key -> Bool -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Bool
vip
, Key
"optimal" Key -> Bool -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Bool
optimal
, Key
"deprecated" Key -> Bool -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Bool
deprecated
, Key
"custom" Key -> Bool -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Bool
custom
]
instance Aeson.FromJSON VoiceRegion where
parseJSON :: Value -> Parser VoiceRegion
parseJSON = String
-> (Object -> Parser VoiceRegion) -> Value -> Parser VoiceRegion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"VoiceRegion" ((Object -> Parser VoiceRegion) -> Value -> Parser VoiceRegion)
-> (Object -> Parser VoiceRegion) -> Value -> Parser VoiceRegion
forall a b. (a -> b) -> a -> b
$ \Object
v ->
Snowflake VoiceRegion
-> Text -> Bool -> Bool -> Bool -> Bool -> VoiceRegion
VoiceRegion
(Snowflake VoiceRegion
-> Text -> Bool -> Bool -> Bool -> Bool -> VoiceRegion)
-> Parser (Snowflake VoiceRegion)
-> Parser (Text -> Bool -> Bool -> Bool -> Bool -> VoiceRegion)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake VoiceRegion)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
Parser (Text -> Bool -> Bool -> Bool -> Bool -> VoiceRegion)
-> Parser Text
-> Parser (Bool -> Bool -> Bool -> Bool -> VoiceRegion)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"
Parser (Bool -> Bool -> Bool -> Bool -> VoiceRegion)
-> Parser Bool -> Parser (Bool -> Bool -> Bool -> VoiceRegion)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"vip"
Parser (Bool -> Bool -> Bool -> VoiceRegion)
-> Parser Bool -> Parser (Bool -> Bool -> VoiceRegion)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"optimal"
Parser (Bool -> Bool -> VoiceRegion)
-> Parser Bool -> Parser (Bool -> VoiceRegion)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"deprecated"
Parser (Bool -> VoiceRegion) -> Parser Bool -> Parser VoiceRegion
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"custom"
$(deriveTextShow ''VoiceRegion)
$(makeFieldLabelsNoPrefix ''VoiceRegion)