module TD.Query.ReorderGiftCollections
  (ReorderGiftCollections(..)
  , defaultReorderGiftCollections
  ) 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

-- | Changes order of gift collections. If the collections are owned by a channel chat, then requires can_post_messages administrator right in the channel chat. Returns 'TD.Data.Ok.Ok'
data ReorderGiftCollections
  = ReorderGiftCollections
    { ReorderGiftCollections -> Maybe MessageSender
owner_id       :: Maybe MessageSender.MessageSender -- ^ Identifier of the user or the channel chat that owns the collection
    , ReorderGiftCollections -> Maybe [Int]
collection_ids :: Maybe [Int]                       -- ^ New order of gift collections
    }
  deriving (ReorderGiftCollections -> ReorderGiftCollections -> Bool
(ReorderGiftCollections -> ReorderGiftCollections -> Bool)
-> (ReorderGiftCollections -> ReorderGiftCollections -> Bool)
-> Eq ReorderGiftCollections
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReorderGiftCollections -> ReorderGiftCollections -> Bool
== :: ReorderGiftCollections -> ReorderGiftCollections -> Bool
$c/= :: ReorderGiftCollections -> ReorderGiftCollections -> Bool
/= :: ReorderGiftCollections -> ReorderGiftCollections -> Bool
Eq, Int -> ReorderGiftCollections -> ShowS
[ReorderGiftCollections] -> ShowS
ReorderGiftCollections -> String
(Int -> ReorderGiftCollections -> ShowS)
-> (ReorderGiftCollections -> String)
-> ([ReorderGiftCollections] -> ShowS)
-> Show ReorderGiftCollections
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReorderGiftCollections -> ShowS
showsPrec :: Int -> ReorderGiftCollections -> ShowS
$cshow :: ReorderGiftCollections -> String
show :: ReorderGiftCollections -> String
$cshowList :: [ReorderGiftCollections] -> ShowS
showList :: [ReorderGiftCollections] -> ShowS
Show)

instance I.ShortShow ReorderGiftCollections where
  shortShow :: ReorderGiftCollections -> String
shortShow
    ReorderGiftCollections
      { owner_id :: ReorderGiftCollections -> Maybe MessageSender
owner_id       = Maybe MessageSender
owner_id_
      , collection_ids :: ReorderGiftCollections -> Maybe [Int]
collection_ids = Maybe [Int]
collection_ids_
      }
        = String
"ReorderGiftCollections"
          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_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
collection_ids_
          ]

instance AT.ToJSON ReorderGiftCollections where
  toJSON :: ReorderGiftCollections -> Value
toJSON
    ReorderGiftCollections
      { owner_id :: ReorderGiftCollections -> Maybe MessageSender
owner_id       = Maybe MessageSender
owner_id_
      , collection_ids :: ReorderGiftCollections -> Maybe [Int]
collection_ids = Maybe [Int]
collection_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
"reorderGiftCollections"
          , 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_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]
collection_ids_
          ]

defaultReorderGiftCollections :: ReorderGiftCollections
defaultReorderGiftCollections :: ReorderGiftCollections
defaultReorderGiftCollections =
  ReorderGiftCollections
    { owner_id :: Maybe MessageSender
owner_id       = Maybe MessageSender
forall a. Maybe a
Nothing
    , collection_ids :: Maybe [Int]
collection_ids = Maybe [Int]
forall a. Maybe a
Nothing
    }