module TD.Data.InputSticker
( InputSticker(..)
, defaultInputSticker
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.InputFile as InputFile
import qualified TD.Data.StickerFormat as StickerFormat
import qualified Data.Text as T
import qualified TD.Data.MaskPosition as MaskPosition
data InputSticker
= InputSticker
{ InputSticker -> Maybe InputFile
sticker :: Maybe InputFile.InputFile
, InputSticker -> Maybe StickerFormat
format :: Maybe StickerFormat.StickerFormat
, InputSticker -> Maybe Text
emojis :: Maybe T.Text
, InputSticker -> Maybe MaskPosition
mask_position :: Maybe MaskPosition.MaskPosition
, InputSticker -> Maybe [Text]
keywords :: Maybe [T.Text]
}
deriving (InputSticker -> InputSticker -> Bool
(InputSticker -> InputSticker -> Bool)
-> (InputSticker -> InputSticker -> Bool) -> Eq InputSticker
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InputSticker -> InputSticker -> Bool
== :: InputSticker -> InputSticker -> Bool
$c/= :: InputSticker -> InputSticker -> Bool
/= :: InputSticker -> InputSticker -> Bool
Eq, Int -> InputSticker -> ShowS
[InputSticker] -> ShowS
InputSticker -> String
(Int -> InputSticker -> ShowS)
-> (InputSticker -> String)
-> ([InputSticker] -> ShowS)
-> Show InputSticker
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InputSticker -> ShowS
showsPrec :: Int -> InputSticker -> ShowS
$cshow :: InputSticker -> String
show :: InputSticker -> String
$cshowList :: [InputSticker] -> ShowS
showList :: [InputSticker] -> ShowS
Show)
instance I.ShortShow InputSticker where
shortShow :: InputSticker -> String
shortShow InputSticker
{ sticker :: InputSticker -> Maybe InputFile
sticker = Maybe InputFile
sticker_
, format :: InputSticker -> Maybe StickerFormat
format = Maybe StickerFormat
format_
, emojis :: InputSticker -> Maybe Text
emojis = Maybe Text
emojis_
, mask_position :: InputSticker -> Maybe MaskPosition
mask_position = Maybe MaskPosition
mask_position_
, keywords :: InputSticker -> Maybe [Text]
keywords = Maybe [Text]
keywords_
}
= String
"InputSticker"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"sticker" String -> Maybe InputFile -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputFile
sticker_
, String
"format" String -> Maybe StickerFormat -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StickerFormat
format_
, String
"emojis" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
emojis_
, String
"mask_position" String -> Maybe MaskPosition -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MaskPosition
mask_position_
, String
"keywords" String -> Maybe [Text] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Text]
keywords_
]
instance AT.FromJSON InputSticker where
parseJSON :: Value -> Parser InputSticker
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"inputSticker" -> Value -> Parser InputSticker
parseInputSticker Value
v
String
_ -> Parser InputSticker
forall a. Monoid a => a
mempty
where
parseInputSticker :: A.Value -> AT.Parser InputSticker
parseInputSticker :: Value -> Parser InputSticker
parseInputSticker = String
-> (Object -> Parser InputSticker) -> Value -> Parser InputSticker
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"InputSticker" ((Object -> Parser InputSticker) -> Value -> Parser InputSticker)
-> (Object -> Parser InputSticker) -> Value -> Parser InputSticker
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe InputFile
sticker_ <- Object
o Object -> Key -> Parser (Maybe InputFile)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sticker"
Maybe StickerFormat
format_ <- Object
o Object -> Key -> Parser (Maybe StickerFormat)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"format"
Maybe Text
emojis_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"emojis"
Maybe MaskPosition
mask_position_ <- Object
o Object -> Key -> Parser (Maybe MaskPosition)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"mask_position"
Maybe [Text]
keywords_ <- Object
o Object -> Key -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"keywords"
InputSticker -> Parser InputSticker
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InputSticker -> Parser InputSticker)
-> InputSticker -> Parser InputSticker
forall a b. (a -> b) -> a -> b
$ InputSticker
{ sticker :: Maybe InputFile
sticker = Maybe InputFile
sticker_
, format :: Maybe StickerFormat
format = Maybe StickerFormat
format_
, emojis :: Maybe Text
emojis = Maybe Text
emojis_
, mask_position :: Maybe MaskPosition
mask_position = Maybe MaskPosition
mask_position_
, keywords :: Maybe [Text]
keywords = Maybe [Text]
keywords_
}
parseJSON Value
_ = Parser InputSticker
forall a. Monoid a => a
mempty
instance AT.ToJSON InputSticker where
toJSON :: InputSticker -> Value
toJSON InputSticker
{ sticker :: InputSticker -> Maybe InputFile
sticker = Maybe InputFile
sticker_
, format :: InputSticker -> Maybe StickerFormat
format = Maybe StickerFormat
format_
, emojis :: InputSticker -> Maybe Text
emojis = Maybe Text
emojis_
, mask_position :: InputSticker -> Maybe MaskPosition
mask_position = Maybe MaskPosition
mask_position_
, keywords :: InputSticker -> Maybe [Text]
keywords = Maybe [Text]
keywords_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"inputSticker"
, Key
"sticker" Key -> Maybe InputFile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputFile
sticker_
, Key
"format" Key -> Maybe StickerFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe StickerFormat
format_
, Key
"emojis" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
emojis_
, Key
"mask_position" Key -> Maybe MaskPosition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MaskPosition
mask_position_
, Key
"keywords" Key -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Text]
keywords_
]
defaultInputSticker :: InputSticker
defaultInputSticker :: InputSticker
defaultInputSticker =
InputSticker
{ sticker :: Maybe InputFile
sticker = Maybe InputFile
forall a. Maybe a
Nothing
, format :: Maybe StickerFormat
format = Maybe StickerFormat
forall a. Maybe a
Nothing
, emojis :: Maybe Text
emojis = Maybe Text
forall a. Maybe a
Nothing
, mask_position :: Maybe MaskPosition
mask_position = Maybe MaskPosition
forall a. Maybe a
Nothing
, keywords :: Maybe [Text]
keywords = Maybe [Text]
forall a. Maybe a
Nothing
}