module TD.Query.EditStoryCover
  (EditStoryCover(..)
  , defaultEditStoryCover
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Changes cover of a video story. Can be called only if story.can_be_edited == true and the story isn't being edited now. Returns 'TD.Data.Ok.Ok'
data EditStoryCover
  = EditStoryCover
    { EditStoryCover -> Maybe Int
story_sender_chat_id  :: Maybe Int    -- ^ Identifier of the chat that posted the story
    , EditStoryCover -> Maybe Int
story_id              :: Maybe Int    -- ^ Identifier of the story to edit
    , EditStoryCover -> Maybe Double
cover_frame_timestamp :: Maybe Double -- ^ New timestamp of the frame, which will be used as video thumbnail
    }
  deriving (EditStoryCover -> EditStoryCover -> Bool
(EditStoryCover -> EditStoryCover -> Bool)
-> (EditStoryCover -> EditStoryCover -> Bool) -> Eq EditStoryCover
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditStoryCover -> EditStoryCover -> Bool
== :: EditStoryCover -> EditStoryCover -> Bool
$c/= :: EditStoryCover -> EditStoryCover -> Bool
/= :: EditStoryCover -> EditStoryCover -> Bool
Eq, Int -> EditStoryCover -> ShowS
[EditStoryCover] -> ShowS
EditStoryCover -> String
(Int -> EditStoryCover -> ShowS)
-> (EditStoryCover -> String)
-> ([EditStoryCover] -> ShowS)
-> Show EditStoryCover
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditStoryCover -> ShowS
showsPrec :: Int -> EditStoryCover -> ShowS
$cshow :: EditStoryCover -> String
show :: EditStoryCover -> String
$cshowList :: [EditStoryCover] -> ShowS
showList :: [EditStoryCover] -> ShowS
Show)

instance I.ShortShow EditStoryCover where
  shortShow :: EditStoryCover -> String
shortShow
    EditStoryCover
      { story_sender_chat_id :: EditStoryCover -> Maybe Int
story_sender_chat_id  = Maybe Int
story_sender_chat_id_
      , story_id :: EditStoryCover -> Maybe Int
story_id              = Maybe Int
story_id_
      , cover_frame_timestamp :: EditStoryCover -> Maybe Double
cover_frame_timestamp = Maybe Double
cover_frame_timestamp_
      }
        = String
"EditStoryCover"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"story_sender_chat_id"  String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_sender_chat_id_
          , String
"story_id"              String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_id_
          , String
"cover_frame_timestamp" String -> Maybe Double -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Double
cover_frame_timestamp_
          ]

instance AT.ToJSON EditStoryCover where
  toJSON :: EditStoryCover -> Value
toJSON
    EditStoryCover
      { story_sender_chat_id :: EditStoryCover -> Maybe Int
story_sender_chat_id  = Maybe Int
story_sender_chat_id_
      , story_id :: EditStoryCover -> Maybe Int
story_id              = Maybe Int
story_id_
      , cover_frame_timestamp :: EditStoryCover -> Maybe Double
cover_frame_timestamp = Maybe Double
cover_frame_timestamp_
      }
        = [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
"editStoryCover"
          , Key
"story_sender_chat_id"  Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
story_sender_chat_id_
          , Key
"story_id"              Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
story_id_
          , Key
"cover_frame_timestamp" Key -> Maybe Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Double
cover_frame_timestamp_
          ]

defaultEditStoryCover :: EditStoryCover
defaultEditStoryCover :: EditStoryCover
defaultEditStoryCover =
  EditStoryCover
    { story_sender_chat_id :: Maybe Int
story_sender_chat_id  = Maybe Int
forall a. Maybe a
Nothing
    , story_id :: Maybe Int
story_id              = Maybe Int
forall a. Maybe a
Nothing
    , cover_frame_timestamp :: Maybe Double
cover_frame_timestamp = Maybe Double
forall a. Maybe a
Nothing
    }