module TD.Query.SetGiftCollectionName
  (SetGiftCollectionName(..)
  , defaultSetGiftCollectionName
  ) 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.MessageSender as MessageSender
import qualified Data.Text as T

-- | Changes name of a gift collection. If the collection is owned by a channel chat, then requires can_post_messages administrator right in the channel chat. Returns the changed collection. Returns 'TD.Data.GiftCollection.GiftCollection'
data SetGiftCollectionName
  = SetGiftCollectionName
    { SetGiftCollectionName -> Maybe MessageSender
owner_id      :: Maybe MessageSender.MessageSender -- ^ Identifier of the user or the channel chat that owns the collection
    , SetGiftCollectionName -> Maybe Int
collection_id :: Maybe Int                         -- ^ Identifier of the gift collection
    , SetGiftCollectionName -> Maybe Text
name          :: Maybe T.Text                      -- ^ New name of the collection; 1-12 characters
    }
  deriving (SetGiftCollectionName -> SetGiftCollectionName -> Bool
(SetGiftCollectionName -> SetGiftCollectionName -> Bool)
-> (SetGiftCollectionName -> SetGiftCollectionName -> Bool)
-> Eq SetGiftCollectionName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetGiftCollectionName -> SetGiftCollectionName -> Bool
== :: SetGiftCollectionName -> SetGiftCollectionName -> Bool
$c/= :: SetGiftCollectionName -> SetGiftCollectionName -> Bool
/= :: SetGiftCollectionName -> SetGiftCollectionName -> Bool
Eq, Int -> SetGiftCollectionName -> ShowS
[SetGiftCollectionName] -> ShowS
SetGiftCollectionName -> String
(Int -> SetGiftCollectionName -> ShowS)
-> (SetGiftCollectionName -> String)
-> ([SetGiftCollectionName] -> ShowS)
-> Show SetGiftCollectionName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetGiftCollectionName -> ShowS
showsPrec :: Int -> SetGiftCollectionName -> ShowS
$cshow :: SetGiftCollectionName -> String
show :: SetGiftCollectionName -> String
$cshowList :: [SetGiftCollectionName] -> ShowS
showList :: [SetGiftCollectionName] -> ShowS
Show)

instance I.ShortShow SetGiftCollectionName where
  shortShow :: SetGiftCollectionName -> String
shortShow
    SetGiftCollectionName
      { owner_id :: SetGiftCollectionName -> Maybe MessageSender
owner_id      = Maybe MessageSender
owner_id_
      , collection_id :: SetGiftCollectionName -> Maybe Int
collection_id = Maybe Int
collection_id_
      , name :: SetGiftCollectionName -> Maybe Text
name          = Maybe Text
name_
      }
        = String
"SetGiftCollectionName"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"owner_id"      String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
owner_id_
          , String
"collection_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
collection_id_
          , String
"name"          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          ]

instance AT.ToJSON SetGiftCollectionName where
  toJSON :: SetGiftCollectionName -> Value
toJSON
    SetGiftCollectionName
      { owner_id :: SetGiftCollectionName -> Maybe MessageSender
owner_id      = Maybe MessageSender
owner_id_
      , collection_id :: SetGiftCollectionName -> Maybe Int
collection_id = Maybe Int
collection_id_
      , name :: SetGiftCollectionName -> Maybe Text
name          = Maybe Text
name_
      }
        = [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
"setGiftCollectionName"
          , Key
"owner_id"      Key -> Maybe MessageSender -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MessageSender
owner_id_
          , Key
"collection_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
collection_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_
          ]

defaultSetGiftCollectionName :: SetGiftCollectionName
defaultSetGiftCollectionName :: SetGiftCollectionName
defaultSetGiftCollectionName =
  SetGiftCollectionName
    { owner_id :: Maybe MessageSender
owner_id      = Maybe MessageSender
forall a. Maybe a
Nothing
    , collection_id :: Maybe Int
collection_id = Maybe Int
forall a. Maybe a
Nothing
    , name :: Maybe Text
name          = Maybe Text
forall a. Maybe a
Nothing
    }