module TD.Data.PollMedia
(PollMedia(..)) 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.Animation as Animation
import qualified TD.Data.Audio as Audio
import qualified TD.Data.Document as Document
import qualified Data.Text as T
import qualified TD.Data.LinkPreview as LinkPreview
import qualified TD.Data.Location as Location
import qualified TD.Data.Photo as Photo
import qualified TD.Data.Video as Video
import qualified TD.Data.Sticker as Sticker
import qualified TD.Data.Venue as Venue
import qualified TD.Data.AlternativeVideo as AlternativeVideo
import qualified TD.Data.VideoStoryboard as VideoStoryboard
data PollMedia
= PollMediaAnimation
{ PollMedia -> Maybe Animation
animation :: Maybe Animation.Animation
}
| PollMediaAudio
{ PollMedia -> Maybe Audio
audio :: Maybe Audio.Audio
}
| PollMediaDocument
{ PollMedia -> Maybe Document
document :: Maybe Document.Document
}
| PollMediaLink
{ PollMedia -> Maybe Text
url :: Maybe T.Text
, PollMedia -> Maybe LinkPreview
link_preview :: Maybe LinkPreview.LinkPreview
}
| PollMediaLocation
{ PollMedia -> Maybe Location
location :: Maybe Location.Location
}
| PollMediaPhoto
{ PollMedia -> Maybe Photo
photo :: Maybe Photo.Photo
, PollMedia -> Maybe Video
video :: Maybe Video.Video
}
| PollMediaSticker
{ PollMedia -> Maybe Sticker
sticker :: Maybe Sticker.Sticker
}
| PollMediaVenue
{ PollMedia -> Maybe Venue
venue :: Maybe Venue.Venue
}
| PollMediaVideo
{ video :: Maybe Video.Video
, PollMedia -> Maybe [AlternativeVideo]
alternative_videos :: Maybe [AlternativeVideo.AlternativeVideo]
, PollMedia -> Maybe [VideoStoryboard]
storyboards :: Maybe [VideoStoryboard.VideoStoryboard]
, PollMedia -> Maybe Photo
cover :: Maybe Photo.Photo
, PollMedia -> Maybe Int
start_timestamp :: Maybe Int
}
deriving (PollMedia -> PollMedia -> Bool
(PollMedia -> PollMedia -> Bool)
-> (PollMedia -> PollMedia -> Bool) -> Eq PollMedia
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PollMedia -> PollMedia -> Bool
== :: PollMedia -> PollMedia -> Bool
$c/= :: PollMedia -> PollMedia -> Bool
/= :: PollMedia -> PollMedia -> Bool
Eq, Int -> PollMedia -> ShowS
[PollMedia] -> ShowS
PollMedia -> String
(Int -> PollMedia -> ShowS)
-> (PollMedia -> String)
-> ([PollMedia] -> ShowS)
-> Show PollMedia
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PollMedia -> ShowS
showsPrec :: Int -> PollMedia -> ShowS
$cshow :: PollMedia -> String
show :: PollMedia -> String
$cshowList :: [PollMedia] -> ShowS
showList :: [PollMedia] -> ShowS
Show)
instance I.ShortShow PollMedia where
shortShow :: PollMedia -> String
shortShow PollMediaAnimation
{ animation :: PollMedia -> Maybe Animation
animation = Maybe Animation
animation_
}
= String
"PollMediaAnimation"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"animation" String -> Maybe Animation -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Animation
animation_
]
shortShow PollMediaAudio
{ audio :: PollMedia -> Maybe Audio
audio = Maybe Audio
audio_
}
= String
"PollMediaAudio"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"audio" String -> Maybe Audio -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Audio
audio_
]
shortShow PollMediaDocument
{ document :: PollMedia -> Maybe Document
document = Maybe Document
document_
}
= String
"PollMediaDocument"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"document" String -> Maybe Document -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Document
document_
]
shortShow PollMediaLink
{ url :: PollMedia -> Maybe Text
url = Maybe Text
url_
, link_preview :: PollMedia -> Maybe LinkPreview
link_preview = Maybe LinkPreview
link_preview_
}
= String
"PollMediaLink"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
url_
, String
"link_preview" String -> Maybe LinkPreview -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe LinkPreview
link_preview_
]
shortShow PollMediaLocation
{ location :: PollMedia -> Maybe Location
location = Maybe Location
location_
}
= String
"PollMediaLocation"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"location" String -> Maybe Location -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Location
location_
]
shortShow PollMediaPhoto
{ photo :: PollMedia -> Maybe Photo
photo = Maybe Photo
photo_
, video :: PollMedia -> Maybe Video
video = Maybe Video
video_
}
= String
"PollMediaPhoto"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"photo" String -> Maybe Photo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Photo
photo_
, String
"video" String -> Maybe Video -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Video
video_
]
shortShow PollMediaSticker
{ sticker :: PollMedia -> Maybe Sticker
sticker = Maybe Sticker
sticker_
}
= String
"PollMediaSticker"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"sticker" String -> Maybe Sticker -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Sticker
sticker_
]
shortShow PollMediaVenue
{ venue :: PollMedia -> Maybe Venue
venue = Maybe Venue
venue_
}
= String
"PollMediaVenue"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"venue" String -> Maybe Venue -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Venue
venue_
]
shortShow PollMediaVideo
{ video :: PollMedia -> Maybe Video
video = Maybe Video
video_
, alternative_videos :: PollMedia -> Maybe [AlternativeVideo]
alternative_videos = Maybe [AlternativeVideo]
alternative_videos_
, storyboards :: PollMedia -> Maybe [VideoStoryboard]
storyboards = Maybe [VideoStoryboard]
storyboards_
, cover :: PollMedia -> Maybe Photo
cover = Maybe Photo
cover_
, start_timestamp :: PollMedia -> Maybe Int
start_timestamp = Maybe Int
start_timestamp_
}
= String
"PollMediaVideo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"video" String -> Maybe Video -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Video
video_
, String
"alternative_videos" String -> Maybe [AlternativeVideo] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [AlternativeVideo]
alternative_videos_
, String
"storyboards" String -> Maybe [VideoStoryboard] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [VideoStoryboard]
storyboards_
, String
"cover" String -> Maybe Photo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Photo
cover_
, String
"start_timestamp" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
start_timestamp_
]
instance AT.FromJSON PollMedia where
parseJSON :: Value -> Parser PollMedia
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
"pollMediaAnimation" -> Value -> Parser PollMedia
parsePollMediaAnimation Value
v
String
"pollMediaAudio" -> Value -> Parser PollMedia
parsePollMediaAudio Value
v
String
"pollMediaDocument" -> Value -> Parser PollMedia
parsePollMediaDocument Value
v
String
"pollMediaLink" -> Value -> Parser PollMedia
parsePollMediaLink Value
v
String
"pollMediaLocation" -> Value -> Parser PollMedia
parsePollMediaLocation Value
v
String
"pollMediaPhoto" -> Value -> Parser PollMedia
parsePollMediaPhoto Value
v
String
"pollMediaSticker" -> Value -> Parser PollMedia
parsePollMediaSticker Value
v
String
"pollMediaVenue" -> Value -> Parser PollMedia
parsePollMediaVenue Value
v
String
"pollMediaVideo" -> Value -> Parser PollMedia
parsePollMediaVideo Value
v
String
_ -> Parser PollMedia
forall a. Monoid a => a
mempty
where
parsePollMediaAnimation :: A.Value -> AT.Parser PollMedia
parsePollMediaAnimation :: Value -> Parser PollMedia
parsePollMediaAnimation = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaAnimation" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Animation
animation_ <- Object
o Object -> Key -> Parser (Maybe Animation)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"animation"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaAnimation
{ animation :: Maybe Animation
animation = Maybe Animation
animation_
}
parsePollMediaAudio :: A.Value -> AT.Parser PollMedia
parsePollMediaAudio :: Value -> Parser PollMedia
parsePollMediaAudio = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaAudio" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Audio
audio_ <- Object
o Object -> Key -> Parser (Maybe Audio)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"audio"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaAudio
{ audio :: Maybe Audio
audio = Maybe Audio
audio_
}
parsePollMediaDocument :: A.Value -> AT.Parser PollMedia
parsePollMediaDocument :: Value -> Parser PollMedia
parsePollMediaDocument = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaDocument" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Document
document_ <- Object
o Object -> Key -> Parser (Maybe Document)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"document"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaDocument
{ document :: Maybe Document
document = Maybe Document
document_
}
parsePollMediaLink :: A.Value -> AT.Parser PollMedia
parsePollMediaLink :: Value -> Parser PollMedia
parsePollMediaLink = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaLink" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"url"
Maybe LinkPreview
link_preview_ <- Object
o Object -> Key -> Parser (Maybe LinkPreview)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"link_preview"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaLink
{ url :: Maybe Text
url = Maybe Text
url_
, link_preview :: Maybe LinkPreview
link_preview = Maybe LinkPreview
link_preview_
}
parsePollMediaLocation :: A.Value -> AT.Parser PollMedia
parsePollMediaLocation :: Value -> Parser PollMedia
parsePollMediaLocation = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaLocation" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Location
location_ <- Object
o Object -> Key -> Parser (Maybe Location)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"location"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaLocation
{ location :: Maybe Location
location = Maybe Location
location_
}
parsePollMediaPhoto :: A.Value -> AT.Parser PollMedia
parsePollMediaPhoto :: Value -> Parser PollMedia
parsePollMediaPhoto = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaPhoto" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Photo
photo_ <- Object
o Object -> Key -> Parser (Maybe Photo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"photo"
Maybe Video
video_ <- Object
o Object -> Key -> Parser (Maybe Video)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"video"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaPhoto
{ photo :: Maybe Photo
photo = Maybe Photo
photo_
, video :: Maybe Video
video = Maybe Video
video_
}
parsePollMediaSticker :: A.Value -> AT.Parser PollMedia
parsePollMediaSticker :: Value -> Parser PollMedia
parsePollMediaSticker = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaSticker" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Sticker
sticker_ <- Object
o Object -> Key -> Parser (Maybe Sticker)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sticker"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaSticker
{ sticker :: Maybe Sticker
sticker = Maybe Sticker
sticker_
}
parsePollMediaVenue :: A.Value -> AT.Parser PollMedia
parsePollMediaVenue :: Value -> Parser PollMedia
parsePollMediaVenue = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaVenue" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Venue
venue_ <- Object
o Object -> Key -> Parser (Maybe Venue)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"venue"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaVenue
{ venue :: Maybe Venue
venue = Maybe Venue
venue_
}
parsePollMediaVideo :: A.Value -> AT.Parser PollMedia
parsePollMediaVideo :: Value -> Parser PollMedia
parsePollMediaVideo = String -> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollMediaVideo" ((Object -> Parser PollMedia) -> Value -> Parser PollMedia)
-> (Object -> Parser PollMedia) -> Value -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Video
video_ <- Object
o Object -> Key -> Parser (Maybe Video)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"video"
Maybe [AlternativeVideo]
alternative_videos_ <- Object
o Object -> Key -> Parser (Maybe [AlternativeVideo])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"alternative_videos"
Maybe [VideoStoryboard]
storyboards_ <- Object
o Object -> Key -> Parser (Maybe [VideoStoryboard])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"storyboards"
Maybe Photo
cover_ <- Object
o Object -> Key -> Parser (Maybe Photo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"cover"
Maybe Int
start_timestamp_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"start_timestamp"
PollMedia -> Parser PollMedia
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollMedia -> Parser PollMedia) -> PollMedia -> Parser PollMedia
forall a b. (a -> b) -> a -> b
$ PollMediaVideo
{ video :: Maybe Video
video = Maybe Video
video_
, alternative_videos :: Maybe [AlternativeVideo]
alternative_videos = Maybe [AlternativeVideo]
alternative_videos_
, storyboards :: Maybe [VideoStoryboard]
storyboards = Maybe [VideoStoryboard]
storyboards_
, cover :: Maybe Photo
cover = Maybe Photo
cover_
, start_timestamp :: Maybe Int
start_timestamp = Maybe Int
start_timestamp_
}
parseJSON Value
_ = Parser PollMedia
forall a. Monoid a => a
mempty