module TD.Query.CreateGiftCollection
  (CreateGiftCollection(..)
  , defaultCreateGiftCollection
  ) 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

-- | Creates a collection from gifts on the current user's or a channel's profile page; requires can_post_messages administrator right in the channel chat. An owner can have up to getOption("gift_collection_count_max") gift collections. The new collection will be added to the end of the gift collection list of the owner. Returns the created collection. Returns 'TD.Data.GiftCollection.GiftCollection'
data CreateGiftCollection
  = CreateGiftCollection
    { CreateGiftCollection -> Maybe MessageSender
owner_id          :: Maybe MessageSender.MessageSender -- ^ Identifier of the user or the channel chat that received the gifts
    , CreateGiftCollection -> Maybe Text
name              :: Maybe T.Text                      -- ^ Name of the collection; 1-12 characters
    , CreateGiftCollection -> Maybe [Text]
received_gift_ids :: Maybe [T.Text]                    -- ^ Identifier of the gifts to add to the collection; 0-getOption("gift_collection_gift_count_max") identifiers
    }
  deriving (CreateGiftCollection -> CreateGiftCollection -> Bool
(CreateGiftCollection -> CreateGiftCollection -> Bool)
-> (CreateGiftCollection -> CreateGiftCollection -> Bool)
-> Eq CreateGiftCollection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateGiftCollection -> CreateGiftCollection -> Bool
== :: CreateGiftCollection -> CreateGiftCollection -> Bool
$c/= :: CreateGiftCollection -> CreateGiftCollection -> Bool
/= :: CreateGiftCollection -> CreateGiftCollection -> Bool
Eq, Int -> CreateGiftCollection -> ShowS
[CreateGiftCollection] -> ShowS
CreateGiftCollection -> String
(Int -> CreateGiftCollection -> ShowS)
-> (CreateGiftCollection -> String)
-> ([CreateGiftCollection] -> ShowS)
-> Show CreateGiftCollection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateGiftCollection -> ShowS
showsPrec :: Int -> CreateGiftCollection -> ShowS
$cshow :: CreateGiftCollection -> String
show :: CreateGiftCollection -> String
$cshowList :: [CreateGiftCollection] -> ShowS
showList :: [CreateGiftCollection] -> ShowS
Show)

instance I.ShortShow CreateGiftCollection where
  shortShow :: CreateGiftCollection -> String
shortShow
    CreateGiftCollection
      { owner_id :: CreateGiftCollection -> Maybe MessageSender
owner_id          = Maybe MessageSender
owner_id_
      , name :: CreateGiftCollection -> Maybe Text
name              = Maybe Text
name_
      , received_gift_ids :: CreateGiftCollection -> Maybe [Text]
received_gift_ids = Maybe [Text]
received_gift_ids_
      }
        = String
"CreateGiftCollection"
          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
"name"              String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , String
"received_gift_ids" String -> Maybe [Text] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Text]
received_gift_ids_
          ]

instance AT.ToJSON CreateGiftCollection where
  toJSON :: CreateGiftCollection -> Value
toJSON
    CreateGiftCollection
      { owner_id :: CreateGiftCollection -> Maybe MessageSender
owner_id          = Maybe MessageSender
owner_id_
      , name :: CreateGiftCollection -> Maybe Text
name              = Maybe Text
name_
      , received_gift_ids :: CreateGiftCollection -> Maybe [Text]
received_gift_ids = Maybe [Text]
received_gift_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
"createGiftCollection"
          , 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
"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
"received_gift_ids" Key -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Text]
received_gift_ids_
          ]

defaultCreateGiftCollection :: CreateGiftCollection
defaultCreateGiftCollection :: CreateGiftCollection
defaultCreateGiftCollection =
  CreateGiftCollection
    { owner_id :: Maybe MessageSender
owner_id          = Maybe MessageSender
forall a. Maybe a
Nothing
    , name :: Maybe Text
name              = Maybe Text
forall a. Maybe a
Nothing
    , received_gift_ids :: Maybe [Text]
received_gift_ids = Maybe [Text]
forall a. Maybe a
Nothing
    }