module TD.Query.GetPushReceiverId
  (GetPushReceiverId(..)
  ) 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

-- | Returns a globally unique push notification subscription identifier for identification of an account, which has received a push notification. Can be called synchronously. Returns 'TD.Data.PushReceiverId.PushReceiverId'
data GetPushReceiverId
  = GetPushReceiverId
    { GetPushReceiverId -> Maybe Text
payload :: Maybe T.Text -- ^ JSON-encoded push notification payload
    }
  deriving (GetPushReceiverId -> GetPushReceiverId -> Bool
(GetPushReceiverId -> GetPushReceiverId -> Bool)
-> (GetPushReceiverId -> GetPushReceiverId -> Bool)
-> Eq GetPushReceiverId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetPushReceiverId -> GetPushReceiverId -> Bool
== :: GetPushReceiverId -> GetPushReceiverId -> Bool
$c/= :: GetPushReceiverId -> GetPushReceiverId -> Bool
/= :: GetPushReceiverId -> GetPushReceiverId -> Bool
Eq, Int -> GetPushReceiverId -> ShowS
[GetPushReceiverId] -> ShowS
GetPushReceiverId -> String
(Int -> GetPushReceiverId -> ShowS)
-> (GetPushReceiverId -> String)
-> ([GetPushReceiverId] -> ShowS)
-> Show GetPushReceiverId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetPushReceiverId -> ShowS
showsPrec :: Int -> GetPushReceiverId -> ShowS
$cshow :: GetPushReceiverId -> String
show :: GetPushReceiverId -> String
$cshowList :: [GetPushReceiverId] -> ShowS
showList :: [GetPushReceiverId] -> ShowS
Show)

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

instance AT.ToJSON GetPushReceiverId where
  toJSON :: GetPushReceiverId -> Value
toJSON
    GetPushReceiverId
      { payload :: GetPushReceiverId -> Maybe Text
payload = Maybe Text
payload_
      }
        = [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
"getPushReceiverId"
          , Key
"payload" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
payload_
          ]