module TD.Query.ReorderSupergroupActiveUsernames
  (ReorderSupergroupActiveUsernames(..)
  , defaultReorderSupergroupActiveUsernames
  ) 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

-- | Changes order of active usernames of a supergroup or channel, requires owner privileges in the supergroup or channel. Returns 'TD.Data.Ok.Ok'
data ReorderSupergroupActiveUsernames
  = ReorderSupergroupActiveUsernames
    { ReorderSupergroupActiveUsernames -> Maybe Int
supergroup_id :: Maybe Int      -- ^ Identifier of the supergroup or channel
    , ReorderSupergroupActiveUsernames -> Maybe [Text]
usernames     :: Maybe [T.Text] -- ^ The new order of active usernames. All currently active usernames must be specified
    }
  deriving (ReorderSupergroupActiveUsernames
-> ReorderSupergroupActiveUsernames -> Bool
(ReorderSupergroupActiveUsernames
 -> ReorderSupergroupActiveUsernames -> Bool)
-> (ReorderSupergroupActiveUsernames
    -> ReorderSupergroupActiveUsernames -> Bool)
-> Eq ReorderSupergroupActiveUsernames
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReorderSupergroupActiveUsernames
-> ReorderSupergroupActiveUsernames -> Bool
== :: ReorderSupergroupActiveUsernames
-> ReorderSupergroupActiveUsernames -> Bool
$c/= :: ReorderSupergroupActiveUsernames
-> ReorderSupergroupActiveUsernames -> Bool
/= :: ReorderSupergroupActiveUsernames
-> ReorderSupergroupActiveUsernames -> Bool
Eq, Int -> ReorderSupergroupActiveUsernames -> ShowS
[ReorderSupergroupActiveUsernames] -> ShowS
ReorderSupergroupActiveUsernames -> String
(Int -> ReorderSupergroupActiveUsernames -> ShowS)
-> (ReorderSupergroupActiveUsernames -> String)
-> ([ReorderSupergroupActiveUsernames] -> ShowS)
-> Show ReorderSupergroupActiveUsernames
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReorderSupergroupActiveUsernames -> ShowS
showsPrec :: Int -> ReorderSupergroupActiveUsernames -> ShowS
$cshow :: ReorderSupergroupActiveUsernames -> String
show :: ReorderSupergroupActiveUsernames -> String
$cshowList :: [ReorderSupergroupActiveUsernames] -> ShowS
showList :: [ReorderSupergroupActiveUsernames] -> ShowS
Show)

instance I.ShortShow ReorderSupergroupActiveUsernames where
  shortShow :: ReorderSupergroupActiveUsernames -> String
shortShow
    ReorderSupergroupActiveUsernames
      { supergroup_id :: ReorderSupergroupActiveUsernames -> Maybe Int
supergroup_id = Maybe Int
supergroup_id_
      , usernames :: ReorderSupergroupActiveUsernames -> Maybe [Text]
usernames     = Maybe [Text]
usernames_
      }
        = String
"ReorderSupergroupActiveUsernames"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"supergroup_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
supergroup_id_
          , String
"usernames"     String -> Maybe [Text] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Text]
usernames_
          ]

instance AT.ToJSON ReorderSupergroupActiveUsernames where
  toJSON :: ReorderSupergroupActiveUsernames -> Value
toJSON
    ReorderSupergroupActiveUsernames
      { supergroup_id :: ReorderSupergroupActiveUsernames -> Maybe Int
supergroup_id = Maybe Int
supergroup_id_
      , usernames :: ReorderSupergroupActiveUsernames -> Maybe [Text]
usernames     = Maybe [Text]
usernames_
      }
        = [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
"reorderSupergroupActiveUsernames"
          , Key
"supergroup_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
supergroup_id_
          , Key
"usernames"     Key -> Maybe [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Text]
usernames_
          ]

defaultReorderSupergroupActiveUsernames :: ReorderSupergroupActiveUsernames
defaultReorderSupergroupActiveUsernames :: ReorderSupergroupActiveUsernames
defaultReorderSupergroupActiveUsernames =
  ReorderSupergroupActiveUsernames
    { supergroup_id :: Maybe Int
supergroup_id = Maybe Int
forall a. Maybe a
Nothing
    , usernames :: Maybe [Text]
usernames     = Maybe [Text]
forall a. Maybe a
Nothing
    }