module TD.Query.ReorderActiveUsernames
  (ReorderActiveUsernames(..)
  ) 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 the current user. Returns 'TD.Data.Ok.Ok'
data ReorderActiveUsernames
  = ReorderActiveUsernames
    { ReorderActiveUsernames -> Maybe [Text]
usernames :: Maybe [T.Text] -- ^ The new order of active usernames. All currently active usernames must be specified
    }
  deriving (ReorderActiveUsernames -> ReorderActiveUsernames -> Bool
(ReorderActiveUsernames -> ReorderActiveUsernames -> Bool)
-> (ReorderActiveUsernames -> ReorderActiveUsernames -> Bool)
-> Eq ReorderActiveUsernames
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReorderActiveUsernames -> ReorderActiveUsernames -> Bool
== :: ReorderActiveUsernames -> ReorderActiveUsernames -> Bool
$c/= :: ReorderActiveUsernames -> ReorderActiveUsernames -> Bool
/= :: ReorderActiveUsernames -> ReorderActiveUsernames -> Bool
Eq, Int -> ReorderActiveUsernames -> ShowS
[ReorderActiveUsernames] -> ShowS
ReorderActiveUsernames -> String
(Int -> ReorderActiveUsernames -> ShowS)
-> (ReorderActiveUsernames -> String)
-> ([ReorderActiveUsernames] -> ShowS)
-> Show ReorderActiveUsernames
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReorderActiveUsernames -> ShowS
showsPrec :: Int -> ReorderActiveUsernames -> ShowS
$cshow :: ReorderActiveUsernames -> String
show :: ReorderActiveUsernames -> String
$cshowList :: [ReorderActiveUsernames] -> ShowS
showList :: [ReorderActiveUsernames] -> ShowS
Show)

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

instance AT.ToJSON ReorderActiveUsernames where
  toJSON :: ReorderActiveUsernames -> Value
toJSON
    ReorderActiveUsernames
      { usernames :: ReorderActiveUsernames -> 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
"reorderActiveUsernames"
          , 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_
          ]