module TD.Query.ReorderBotActiveUsernames
  (ReorderBotActiveUsernames(..)
  , defaultReorderBotActiveUsernames
  ) 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 bot. Can be called only if userTypeBot.can_be_edited == true. Returns 'TD.Data.Ok.Ok'
data ReorderBotActiveUsernames
  = ReorderBotActiveUsernames
    { ReorderBotActiveUsernames -> Maybe Int
bot_user_id :: Maybe Int      -- ^ Identifier of the target bot
    , ReorderBotActiveUsernames -> Maybe [Text]
usernames   :: Maybe [T.Text] -- ^ The new order of active usernames. All currently active usernames must be specified
    }
  deriving (ReorderBotActiveUsernames -> ReorderBotActiveUsernames -> Bool
(ReorderBotActiveUsernames -> ReorderBotActiveUsernames -> Bool)
-> (ReorderBotActiveUsernames -> ReorderBotActiveUsernames -> Bool)
-> Eq ReorderBotActiveUsernames
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReorderBotActiveUsernames -> ReorderBotActiveUsernames -> Bool
== :: ReorderBotActiveUsernames -> ReorderBotActiveUsernames -> Bool
$c/= :: ReorderBotActiveUsernames -> ReorderBotActiveUsernames -> Bool
/= :: ReorderBotActiveUsernames -> ReorderBotActiveUsernames -> Bool
Eq, Int -> ReorderBotActiveUsernames -> ShowS
[ReorderBotActiveUsernames] -> ShowS
ReorderBotActiveUsernames -> String
(Int -> ReorderBotActiveUsernames -> ShowS)
-> (ReorderBotActiveUsernames -> String)
-> ([ReorderBotActiveUsernames] -> ShowS)
-> Show ReorderBotActiveUsernames
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReorderBotActiveUsernames -> ShowS
showsPrec :: Int -> ReorderBotActiveUsernames -> ShowS
$cshow :: ReorderBotActiveUsernames -> String
show :: ReorderBotActiveUsernames -> String
$cshowList :: [ReorderBotActiveUsernames] -> ShowS
showList :: [ReorderBotActiveUsernames] -> ShowS
Show)

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

instance AT.ToJSON ReorderBotActiveUsernames where
  toJSON :: ReorderBotActiveUsernames -> Value
toJSON
    ReorderBotActiveUsernames
      { bot_user_id :: ReorderBotActiveUsernames -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      , usernames :: ReorderBotActiveUsernames -> 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
"reorderBotActiveUsernames"
          , Key
"bot_user_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
bot_user_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_
          ]

defaultReorderBotActiveUsernames :: ReorderBotActiveUsernames
defaultReorderBotActiveUsernames :: ReorderBotActiveUsernames
defaultReorderBotActiveUsernames =
  ReorderBotActiveUsernames
    { bot_user_id :: Maybe Int
bot_user_id = Maybe Int
forall a. Maybe a
Nothing
    , usernames :: Maybe [Text]
usernames   = Maybe [Text]
forall a. Maybe a
Nothing
    }