module TD.Query.EditStory
  (EditStory(..)
  , defaultEditStory
  ) 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.InputStoryContent as InputStoryContent
import qualified TD.Data.InputStoryAreas as InputStoryAreas
import qualified TD.Data.FormattedText as FormattedText

-- | Changes content and caption of a story. Can be called only if story.can_be_edited == true. Returns 'TD.Data.Ok.Ok'
data EditStory
  = EditStory
    { EditStory -> Maybe Int
story_sender_chat_id :: Maybe Int                                 -- ^ Identifier of the chat that posted the story
    , EditStory -> Maybe Int
story_id             :: Maybe Int                                 -- ^ Identifier of the story to edit
    , EditStory -> Maybe InputStoryContent
content              :: Maybe InputStoryContent.InputStoryContent -- ^ New content of the story; pass null to keep the current content
    , EditStory -> Maybe InputStoryAreas
areas                :: Maybe InputStoryAreas.InputStoryAreas     -- ^ New clickable rectangle areas to be shown on the story media; pass null to keep the current areas. Areas can't be edited if story content isn't changed
    , EditStory -> Maybe FormattedText
caption              :: Maybe FormattedText.FormattedText         -- ^ New story caption; pass null to keep the current caption
    }
  deriving (EditStory -> EditStory -> Bool
(EditStory -> EditStory -> Bool)
-> (EditStory -> EditStory -> Bool) -> Eq EditStory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EditStory -> EditStory -> Bool
== :: EditStory -> EditStory -> Bool
$c/= :: EditStory -> EditStory -> Bool
/= :: EditStory -> EditStory -> Bool
Eq, Int -> EditStory -> ShowS
[EditStory] -> ShowS
EditStory -> String
(Int -> EditStory -> ShowS)
-> (EditStory -> String)
-> ([EditStory] -> ShowS)
-> Show EditStory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EditStory -> ShowS
showsPrec :: Int -> EditStory -> ShowS
$cshow :: EditStory -> String
show :: EditStory -> String
$cshowList :: [EditStory] -> ShowS
showList :: [EditStory] -> ShowS
Show)

instance I.ShortShow EditStory where
  shortShow :: EditStory -> String
shortShow
    EditStory
      { story_sender_chat_id :: EditStory -> Maybe Int
story_sender_chat_id = Maybe Int
story_sender_chat_id_
      , story_id :: EditStory -> Maybe Int
story_id             = Maybe Int
story_id_
      , content :: EditStory -> Maybe InputStoryContent
content              = Maybe InputStoryContent
content_
      , areas :: EditStory -> Maybe InputStoryAreas
areas                = Maybe InputStoryAreas
areas_
      , caption :: EditStory -> Maybe FormattedText
caption              = Maybe FormattedText
caption_
      }
        = String
"EditStory"
          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
"content"              String -> Maybe InputStoryContent -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputStoryContent
content_
          , String
"areas"                String -> Maybe InputStoryAreas -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputStoryAreas
areas_
          , String
"caption"              String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
caption_
          ]

instance AT.ToJSON EditStory where
  toJSON :: EditStory -> Value
toJSON
    EditStory
      { story_sender_chat_id :: EditStory -> Maybe Int
story_sender_chat_id = Maybe Int
story_sender_chat_id_
      , story_id :: EditStory -> Maybe Int
story_id             = Maybe Int
story_id_
      , content :: EditStory -> Maybe InputStoryContent
content              = Maybe InputStoryContent
content_
      , areas :: EditStory -> Maybe InputStoryAreas
areas                = Maybe InputStoryAreas
areas_
      , caption :: EditStory -> Maybe FormattedText
caption              = Maybe FormattedText
caption_
      }
        = [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
"editStory"
          , 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
"content"              Key -> Maybe InputStoryContent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputStoryContent
content_
          , Key
"areas"                Key -> Maybe InputStoryAreas -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputStoryAreas
areas_
          , Key
"caption"              Key -> Maybe FormattedText -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe FormattedText
caption_
          ]

defaultEditStory :: EditStory
defaultEditStory :: EditStory
defaultEditStory =
  EditStory
    { 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
    , content :: Maybe InputStoryContent
content              = Maybe InputStoryContent
forall a. Maybe a
Nothing
    , areas :: Maybe InputStoryAreas
areas                = Maybe InputStoryAreas
forall a. Maybe a
Nothing
    , caption :: Maybe FormattedText
caption              = Maybe FormattedText
forall a. Maybe a
Nothing
    }