module TD.Query.SetBusinessMessageIsPinned
  (SetBusinessMessageIsPinned(..)
  , defaultSetBusinessMessageIsPinned
  ) 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

-- | Pins or unpins a message sent on behalf of a business account; for bots only. Returns 'TD.Data.Ok.Ok'
data SetBusinessMessageIsPinned
  = SetBusinessMessageIsPinned
    { SetBusinessMessageIsPinned -> Maybe Text
business_connection_id :: Maybe T.Text -- ^ Unique identifier of business connection on behalf of which the message was sent
    , SetBusinessMessageIsPinned -> Maybe Int
chat_id                :: Maybe Int    -- ^ The chat the message belongs to
    , SetBusinessMessageIsPinned -> Maybe Int
message_id             :: Maybe Int    -- ^ Identifier of the message
    , SetBusinessMessageIsPinned -> Maybe Bool
is_pinned              :: Maybe Bool   -- ^ Pass true to pin the message, pass false to unpin it
    }
  deriving (SetBusinessMessageIsPinned -> SetBusinessMessageIsPinned -> Bool
(SetBusinessMessageIsPinned -> SetBusinessMessageIsPinned -> Bool)
-> (SetBusinessMessageIsPinned
    -> SetBusinessMessageIsPinned -> Bool)
-> Eq SetBusinessMessageIsPinned
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetBusinessMessageIsPinned -> SetBusinessMessageIsPinned -> Bool
== :: SetBusinessMessageIsPinned -> SetBusinessMessageIsPinned -> Bool
$c/= :: SetBusinessMessageIsPinned -> SetBusinessMessageIsPinned -> Bool
/= :: SetBusinessMessageIsPinned -> SetBusinessMessageIsPinned -> Bool
Eq, Int -> SetBusinessMessageIsPinned -> ShowS
[SetBusinessMessageIsPinned] -> ShowS
SetBusinessMessageIsPinned -> String
(Int -> SetBusinessMessageIsPinned -> ShowS)
-> (SetBusinessMessageIsPinned -> String)
-> ([SetBusinessMessageIsPinned] -> ShowS)
-> Show SetBusinessMessageIsPinned
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetBusinessMessageIsPinned -> ShowS
showsPrec :: Int -> SetBusinessMessageIsPinned -> ShowS
$cshow :: SetBusinessMessageIsPinned -> String
show :: SetBusinessMessageIsPinned -> String
$cshowList :: [SetBusinessMessageIsPinned] -> ShowS
showList :: [SetBusinessMessageIsPinned] -> ShowS
Show)

instance I.ShortShow SetBusinessMessageIsPinned where
  shortShow :: SetBusinessMessageIsPinned -> String
shortShow
    SetBusinessMessageIsPinned
      { business_connection_id :: SetBusinessMessageIsPinned -> Maybe Text
business_connection_id = Maybe Text
business_connection_id_
      , chat_id :: SetBusinessMessageIsPinned -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , message_id :: SetBusinessMessageIsPinned -> Maybe Int
message_id             = Maybe Int
message_id_
      , is_pinned :: SetBusinessMessageIsPinned -> Maybe Bool
is_pinned              = Maybe Bool
is_pinned_
      }
        = String
"SetBusinessMessageIsPinned"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"business_connection_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
business_connection_id_
          , String
"chat_id"                String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
chat_id_
          , String
"message_id"             String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_id_
          , String
"is_pinned"              String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_pinned_
          ]

instance AT.ToJSON SetBusinessMessageIsPinned where
  toJSON :: SetBusinessMessageIsPinned -> Value
toJSON
    SetBusinessMessageIsPinned
      { business_connection_id :: SetBusinessMessageIsPinned -> Maybe Text
business_connection_id = Maybe Text
business_connection_id_
      , chat_id :: SetBusinessMessageIsPinned -> Maybe Int
chat_id                = Maybe Int
chat_id_
      , message_id :: SetBusinessMessageIsPinned -> Maybe Int
message_id             = Maybe Int
message_id_
      , is_pinned :: SetBusinessMessageIsPinned -> Maybe Bool
is_pinned              = Maybe Bool
is_pinned_
      }
        = [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
"setBusinessMessageIsPinned"
          , Key
"business_connection_id" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
business_connection_id_
          , Key
"chat_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
chat_id_
          , Key
"message_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
message_id_
          , Key
"is_pinned"              Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_pinned_
          ]

defaultSetBusinessMessageIsPinned :: SetBusinessMessageIsPinned
defaultSetBusinessMessageIsPinned :: SetBusinessMessageIsPinned
defaultSetBusinessMessageIsPinned =
  SetBusinessMessageIsPinned
    { business_connection_id :: Maybe Text
business_connection_id = Maybe Text
forall a. Maybe a
Nothing
    , chat_id :: Maybe Int
chat_id                = Maybe Int
forall a. Maybe a
Nothing
    , message_id :: Maybe Int
message_id             = Maybe Int
forall a. Maybe a
Nothing
    , is_pinned :: Maybe Bool
is_pinned              = Maybe Bool
forall a. Maybe a
Nothing
    }