module TD.Query.ReorderGiftCollectionGifts
  (ReorderGiftCollectionGifts(..)
  , defaultReorderGiftCollectionGifts
  ) 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 order of gifts in a 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 ReorderGiftCollectionGifts
  = ReorderGiftCollectionGifts
    { ReorderGiftCollectionGifts -> Maybe MessageSender
owner_id          :: Maybe MessageSender.MessageSender -- ^ Identifier of the user or the channel chat that owns the collection
    , ReorderGiftCollectionGifts -> Maybe Int
collection_id     :: Maybe Int                         -- ^ Identifier of the gift collection
    , ReorderGiftCollectionGifts -> Maybe [Text]
received_gift_ids :: Maybe [T.Text]                    -- ^ Identifier of the gifts to move to the beginning of the collection. All other gifts are placed in the current order after the specified gifts
    }
  deriving (ReorderGiftCollectionGifts -> ReorderGiftCollectionGifts -> Bool
(ReorderGiftCollectionGifts -> ReorderGiftCollectionGifts -> Bool)
-> (ReorderGiftCollectionGifts
    -> ReorderGiftCollectionGifts -> Bool)
-> Eq ReorderGiftCollectionGifts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReorderGiftCollectionGifts -> ReorderGiftCollectionGifts -> Bool
== :: ReorderGiftCollectionGifts -> ReorderGiftCollectionGifts -> Bool
$c/= :: ReorderGiftCollectionGifts -> ReorderGiftCollectionGifts -> Bool
/= :: ReorderGiftCollectionGifts -> ReorderGiftCollectionGifts -> Bool
Eq, Int -> ReorderGiftCollectionGifts -> ShowS
[ReorderGiftCollectionGifts] -> ShowS
ReorderGiftCollectionGifts -> String
(Int -> ReorderGiftCollectionGifts -> ShowS)
-> (ReorderGiftCollectionGifts -> String)
-> ([ReorderGiftCollectionGifts] -> ShowS)
-> Show ReorderGiftCollectionGifts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReorderGiftCollectionGifts -> ShowS
showsPrec :: Int -> ReorderGiftCollectionGifts -> ShowS
$cshow :: ReorderGiftCollectionGifts -> String
show :: ReorderGiftCollectionGifts -> String
$cshowList :: [ReorderGiftCollectionGifts] -> ShowS
showList :: [ReorderGiftCollectionGifts] -> ShowS
Show)

instance I.ShortShow ReorderGiftCollectionGifts where
  shortShow :: ReorderGiftCollectionGifts -> String
shortShow
    ReorderGiftCollectionGifts
      { owner_id :: ReorderGiftCollectionGifts -> Maybe MessageSender
owner_id          = Maybe MessageSender
owner_id_
      , collection_id :: ReorderGiftCollectionGifts -> Maybe Int
collection_id     = Maybe Int
collection_id_
      , received_gift_ids :: ReorderGiftCollectionGifts -> Maybe [Text]
received_gift_ids = Maybe [Text]
received_gift_ids_
      }
        = String
"ReorderGiftCollectionGifts"
          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
"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 ReorderGiftCollectionGifts where
  toJSON :: ReorderGiftCollectionGifts -> Value
toJSON
    ReorderGiftCollectionGifts
      { owner_id :: ReorderGiftCollectionGifts -> Maybe MessageSender
owner_id          = Maybe MessageSender
owner_id_
      , collection_id :: ReorderGiftCollectionGifts -> Maybe Int
collection_id     = Maybe Int
collection_id_
      , received_gift_ids :: ReorderGiftCollectionGifts -> 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
"reorderGiftCollectionGifts"
          , 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
"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_
          ]

defaultReorderGiftCollectionGifts :: ReorderGiftCollectionGifts
defaultReorderGiftCollectionGifts :: ReorderGiftCollectionGifts
defaultReorderGiftCollectionGifts =
  ReorderGiftCollectionGifts
    { 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
    , received_gift_ids :: Maybe [Text]
received_gift_ids = Maybe [Text]
forall a. Maybe a
Nothing
    }