module TD.Query.GetMenuButton
  (GetMenuButton(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

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

instance I.ShortShow GetMenuButton where
  shortShow :: GetMenuButton -> String
shortShow
    GetMenuButton
      { user_id :: GetMenuButton -> Maybe Int
user_id = Maybe Int
user_id_
      }
        = String
"GetMenuButton"
          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_
          ]

instance AT.ToJSON GetMenuButton where
  toJSON :: GetMenuButton -> Value
toJSON
    GetMenuButton
      { user_id :: GetMenuButton -> Maybe Int
user_id = Maybe Int
user_id_
      }
        = [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
"getMenuButton"
          , 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_
          ]