module TD.Query.CreateStoryAlbum
  (CreateStoryAlbum(..)
  , defaultCreateStoryAlbum
  ) where

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

-- | Creates an album of stories; requires can_edit_stories administrator right for supergroup and channel chats. Returns 'TD.Data.StoryAlbum.StoryAlbum'
data CreateStoryAlbum
  = CreateStoryAlbum
    { CreateStoryAlbum -> Maybe Int
story_poster_chat_id :: Maybe Int    -- ^ Identifier of the chat that posted the stories
    , CreateStoryAlbum -> Maybe Text
name                 :: Maybe T.Text -- ^ Name of the album; 1-12 characters
    , CreateStoryAlbum -> Maybe [Int]
story_ids            :: Maybe [Int]  -- ^ Identifiers of stories to add to the album; 0-getOption("story_album_story_count_max") identifiers
    }
  deriving (CreateStoryAlbum -> CreateStoryAlbum -> Bool
(CreateStoryAlbum -> CreateStoryAlbum -> Bool)
-> (CreateStoryAlbum -> CreateStoryAlbum -> Bool)
-> Eq CreateStoryAlbum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateStoryAlbum -> CreateStoryAlbum -> Bool
== :: CreateStoryAlbum -> CreateStoryAlbum -> Bool
$c/= :: CreateStoryAlbum -> CreateStoryAlbum -> Bool
/= :: CreateStoryAlbum -> CreateStoryAlbum -> Bool
Eq, Int -> CreateStoryAlbum -> ShowS
[CreateStoryAlbum] -> ShowS
CreateStoryAlbum -> String
(Int -> CreateStoryAlbum -> ShowS)
-> (CreateStoryAlbum -> String)
-> ([CreateStoryAlbum] -> ShowS)
-> Show CreateStoryAlbum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateStoryAlbum -> ShowS
showsPrec :: Int -> CreateStoryAlbum -> ShowS
$cshow :: CreateStoryAlbum -> String
show :: CreateStoryAlbum -> String
$cshowList :: [CreateStoryAlbum] -> ShowS
showList :: [CreateStoryAlbum] -> ShowS
Show)

instance I.ShortShow CreateStoryAlbum where
  shortShow :: CreateStoryAlbum -> String
shortShow
    CreateStoryAlbum
      { story_poster_chat_id :: CreateStoryAlbum -> Maybe Int
story_poster_chat_id = Maybe Int
story_poster_chat_id_
      , name :: CreateStoryAlbum -> Maybe Text
name                 = Maybe Text
name_
      , story_ids :: CreateStoryAlbum -> Maybe [Int]
story_ids            = Maybe [Int]
story_ids_
      }
        = String
"CreateStoryAlbum"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"story_poster_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_poster_chat_id_
          , String
"name"                 String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , String
"story_ids"            String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
story_ids_
          ]

instance AT.ToJSON CreateStoryAlbum where
  toJSON :: CreateStoryAlbum -> Value
toJSON
    CreateStoryAlbum
      { story_poster_chat_id :: CreateStoryAlbum -> Maybe Int
story_poster_chat_id = Maybe Int
story_poster_chat_id_
      , name :: CreateStoryAlbum -> Maybe Text
name                 = Maybe Text
name_
      , story_ids :: CreateStoryAlbum -> Maybe [Int]
story_ids            = Maybe [Int]
story_ids_
      }
        = [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
"createStoryAlbum"
          , Key
"story_poster_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_poster_chat_id_
          , Key
"name"                 Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
          , Key
"story_ids"            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_ids_
          ]

defaultCreateStoryAlbum :: CreateStoryAlbum
defaultCreateStoryAlbum :: CreateStoryAlbum
defaultCreateStoryAlbum =
  CreateStoryAlbum
    { story_poster_chat_id :: Maybe Int
story_poster_chat_id = Maybe Int
forall a. Maybe a
Nothing
    , name :: Maybe Text
name                 = Maybe Text
forall a. Maybe a
Nothing
    , story_ids :: Maybe [Int]
story_ids            = Maybe [Int]
forall a. Maybe a
Nothing
    }