module TD.Query.SendStory
  (SendStory(..)
  , defaultSendStory
  ) 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
import qualified TD.Data.StoryPrivacySettings as StoryPrivacySettings
import qualified TD.Data.StoryFullId as StoryFullId

-- | Sends a new story to a chat; requires can_post_stories right for supergroup and channel chats. Returns a temporary story. Returns 'TD.Data.Story.Story'
data SendStory
  = SendStory
    { SendStory -> Maybe Int
chat_id                :: Maybe Int                                       -- ^ Identifier of the chat that will post the story. Pass Saved Messages chat identifier when posting a story on behalf of the current user
    , SendStory -> Maybe InputStoryContent
content                :: Maybe InputStoryContent.InputStoryContent       -- ^ Content of the story
    , SendStory -> Maybe InputStoryAreas
areas                  :: Maybe InputStoryAreas.InputStoryAreas           -- ^ Clickable rectangle areas to be shown on the story media; pass null if none
    , SendStory -> Maybe FormattedText
caption                :: Maybe FormattedText.FormattedText               -- ^ Story caption; pass null to use an empty caption; 0-getOption("story_caption_length_max") characters; can have entities only if getOption("can_use_text_entities_in_story_caption")
    , SendStory -> Maybe StoryPrivacySettings
privacy_settings       :: Maybe StoryPrivacySettings.StoryPrivacySettings -- ^ The privacy settings for the story; ignored for stories sent to supergroup and channel chats
    , SendStory -> Maybe Int
active_period          :: Maybe Int                                       -- ^ Period after which the story is moved to archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 for Telegram Premium users, and 86400 otherwise
    , SendStory -> Maybe StoryFullId
from_story_full_id     :: Maybe StoryFullId.StoryFullId                   -- ^ Full identifier of the original story, which content was used to create the story; pass null if the story isn't repost of another story
    , SendStory -> Maybe Bool
is_posted_to_chat_page :: Maybe Bool                                      -- ^ Pass true to keep the story accessible after expiration
    , SendStory -> Maybe Bool
protect_content        :: Maybe Bool                                      -- ^ Pass true if the content of the story must be protected from forwarding and screenshotting
    }
  deriving (SendStory -> SendStory -> Bool
(SendStory -> SendStory -> Bool)
-> (SendStory -> SendStory -> Bool) -> Eq SendStory
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SendStory -> SendStory -> Bool
== :: SendStory -> SendStory -> Bool
$c/= :: SendStory -> SendStory -> Bool
/= :: SendStory -> SendStory -> Bool
Eq, Int -> SendStory -> ShowS
[SendStory] -> ShowS
SendStory -> String
(Int -> SendStory -> ShowS)
-> (SendStory -> String)
-> ([SendStory] -> ShowS)
-> Show SendStory
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SendStory -> ShowS
showsPrec :: Int -> SendStory -> ShowS
$cshow :: SendStory -> String
show :: SendStory -> String
$cshowList :: [SendStory] -> ShowS
showList :: [SendStory] -> ShowS
Show)

instance I.ShortShow SendStory where
  shortShow :: SendStory -> String
shortShow
    SendStory
      { chat_id :: SendStory -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , content :: SendStory -> Maybe InputStoryContent
content                = Maybe InputStoryContent
content_
      , areas :: SendStory -> Maybe InputStoryAreas
areas                  = Maybe InputStoryAreas
areas_
      , caption :: SendStory -> Maybe FormattedText
caption                = Maybe FormattedText
caption_
      , privacy_settings :: SendStory -> Maybe StoryPrivacySettings
privacy_settings       = Maybe StoryPrivacySettings
privacy_settings_
      , active_period :: SendStory -> Maybe Int
active_period          = Maybe Int
active_period_
      , from_story_full_id :: SendStory -> Maybe StoryFullId
from_story_full_id     = Maybe StoryFullId
from_story_full_id_
      , is_posted_to_chat_page :: SendStory -> Maybe Bool
is_posted_to_chat_page = Maybe Bool
is_posted_to_chat_page_
      , protect_content :: SendStory -> Maybe Bool
protect_content        = Maybe Bool
protect_content_
      }
        = String
"SendStory"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"chat_id"                String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_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_
          , String
"privacy_settings"       String -> Maybe StoryPrivacySettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StoryPrivacySettings
privacy_settings_
          , String
"active_period"          String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
active_period_
          , String
"from_story_full_id"     String -> Maybe StoryFullId -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StoryFullId
from_story_full_id_
          , String
"is_posted_to_chat_page" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_posted_to_chat_page_
          , String
"protect_content"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
protect_content_
          ]

instance AT.ToJSON SendStory where
  toJSON :: SendStory -> Value
toJSON
    SendStory
      { chat_id :: SendStory -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , content :: SendStory -> Maybe InputStoryContent
content                = Maybe InputStoryContent
content_
      , areas :: SendStory -> Maybe InputStoryAreas
areas                  = Maybe InputStoryAreas
areas_
      , caption :: SendStory -> Maybe FormattedText
caption                = Maybe FormattedText
caption_
      , privacy_settings :: SendStory -> Maybe StoryPrivacySettings
privacy_settings       = Maybe StoryPrivacySettings
privacy_settings_
      , active_period :: SendStory -> Maybe Int
active_period          = Maybe Int
active_period_
      , from_story_full_id :: SendStory -> Maybe StoryFullId
from_story_full_id     = Maybe StoryFullId
from_story_full_id_
      , is_posted_to_chat_page :: SendStory -> Maybe Bool
is_posted_to_chat_page = Maybe Bool
is_posted_to_chat_page_
      , protect_content :: SendStory -> Maybe Bool
protect_content        = Maybe Bool
protect_content_
      }
        = [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
"sendStory"
          , Key
"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
chat_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_
          , Key
"privacy_settings"       Key -> Maybe StoryPrivacySettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe StoryPrivacySettings
privacy_settings_
          , Key
"active_period"          Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
active_period_
          , Key
"from_story_full_id"     Key -> Maybe StoryFullId -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe StoryFullId
from_story_full_id_
          , Key
"is_posted_to_chat_page" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_posted_to_chat_page_
          , Key
"protect_content"        Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
protect_content_
          ]

defaultSendStory :: SendStory
defaultSendStory :: SendStory
defaultSendStory =
  SendStory
    { chat_id :: Maybe Int
chat_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
    , privacy_settings :: Maybe StoryPrivacySettings
privacy_settings       = Maybe StoryPrivacySettings
forall a. Maybe a
Nothing
    , active_period :: Maybe Int
active_period          = Maybe Int
forall a. Maybe a
Nothing
    , from_story_full_id :: Maybe StoryFullId
from_story_full_id     = Maybe StoryFullId
forall a. Maybe a
Nothing
    , is_posted_to_chat_page :: Maybe Bool
is_posted_to_chat_page = Maybe Bool
forall a. Maybe a
Nothing
    , protect_content :: Maybe Bool
protect_content        = Maybe Bool
forall a. Maybe a
Nothing
    }