module TD.Query.SetMenuButton
  (SetMenuButton(..)
  , defaultSetMenuButton
  ) 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.BotMenuButton as BotMenuButton

-- | Sets menu button for the given user or for all users; for bots only. Returns 'TD.Data.Ok.Ok'
data SetMenuButton
  = SetMenuButton
    { SetMenuButton -> Maybe Int
user_id     :: Maybe Int                         -- ^ Identifier of the user or 0 to set menu button for all users
    , SetMenuButton -> Maybe BotMenuButton
menu_button :: Maybe BotMenuButton.BotMenuButton -- ^ New menu button
    }
  deriving (SetMenuButton -> SetMenuButton -> Bool
(SetMenuButton -> SetMenuButton -> Bool)
-> (SetMenuButton -> SetMenuButton -> Bool) -> Eq SetMenuButton
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetMenuButton -> SetMenuButton -> Bool
== :: SetMenuButton -> SetMenuButton -> Bool
$c/= :: SetMenuButton -> SetMenuButton -> Bool
/= :: SetMenuButton -> SetMenuButton -> Bool
Eq, Int -> SetMenuButton -> ShowS
[SetMenuButton] -> ShowS
SetMenuButton -> String
(Int -> SetMenuButton -> ShowS)
-> (SetMenuButton -> String)
-> ([SetMenuButton] -> ShowS)
-> Show SetMenuButton
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetMenuButton -> ShowS
showsPrec :: Int -> SetMenuButton -> ShowS
$cshow :: SetMenuButton -> String
show :: SetMenuButton -> String
$cshowList :: [SetMenuButton] -> ShowS
showList :: [SetMenuButton] -> ShowS
Show)

instance I.ShortShow SetMenuButton where
  shortShow :: SetMenuButton -> String
shortShow
    SetMenuButton
      { user_id :: SetMenuButton -> Maybe Int
user_id     = Maybe Int
user_id_
      , menu_button :: SetMenuButton -> Maybe BotMenuButton
menu_button = Maybe BotMenuButton
menu_button_
      }
        = String
"SetMenuButton"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"user_id"     String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"menu_button" String -> Maybe BotMenuButton -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BotMenuButton
menu_button_
          ]

instance AT.ToJSON SetMenuButton where
  toJSON :: SetMenuButton -> Value
toJSON
    SetMenuButton
      { user_id :: SetMenuButton -> Maybe Int
user_id     = Maybe Int
user_id_
      , menu_button :: SetMenuButton -> Maybe BotMenuButton
menu_button = Maybe BotMenuButton
menu_button_
      }
        = [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
"setMenuButton"
          , Key
"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
user_id_
          , Key
"menu_button" Key -> Maybe BotMenuButton -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe BotMenuButton
menu_button_
          ]

defaultSetMenuButton :: SetMenuButton
defaultSetMenuButton :: SetMenuButton
defaultSetMenuButton =
  SetMenuButton
    { user_id :: Maybe Int
user_id     = Maybe Int
forall a. Maybe a
Nothing
    , menu_button :: Maybe BotMenuButton
menu_button = Maybe BotMenuButton
forall a. Maybe a
Nothing
    }