module TD.Query.TransferGift
  (TransferGift(..)
  , defaultTransferGift
  ) where

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

-- | Sends a gift upgraded by the current user to another user. Returns 'TD.Data.Ok.Ok'
data TransferGift
  = TransferGift
    { TransferGift -> Maybe Int
sender_user_id   :: Maybe Int -- ^ Identifier of the user that sent the gift
    , TransferGift -> Maybe Int
message_id       :: Maybe Int -- ^ Identifier of the message with the upgraded gift in the chat with the user
    , TransferGift -> Maybe Int
receiver_user_id :: Maybe Int -- ^ Identifier of the user that will receive the gift
    , TransferGift -> Maybe Int
star_count       :: Maybe Int -- ^ The amount of Telegram Stars required for the transfer
    }
  deriving (TransferGift -> TransferGift -> Bool
(TransferGift -> TransferGift -> Bool)
-> (TransferGift -> TransferGift -> Bool) -> Eq TransferGift
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TransferGift -> TransferGift -> Bool
== :: TransferGift -> TransferGift -> Bool
$c/= :: TransferGift -> TransferGift -> Bool
/= :: TransferGift -> TransferGift -> Bool
Eq, Int -> TransferGift -> ShowS
[TransferGift] -> ShowS
TransferGift -> String
(Int -> TransferGift -> ShowS)
-> (TransferGift -> String)
-> ([TransferGift] -> ShowS)
-> Show TransferGift
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TransferGift -> ShowS
showsPrec :: Int -> TransferGift -> ShowS
$cshow :: TransferGift -> String
show :: TransferGift -> String
$cshowList :: [TransferGift] -> ShowS
showList :: [TransferGift] -> ShowS
Show)

instance I.ShortShow TransferGift where
  shortShow :: TransferGift -> String
shortShow
    TransferGift
      { sender_user_id :: TransferGift -> Maybe Int
sender_user_id   = Maybe Int
sender_user_id_
      , message_id :: TransferGift -> Maybe Int
message_id       = Maybe Int
message_id_
      , receiver_user_id :: TransferGift -> Maybe Int
receiver_user_id = Maybe Int
receiver_user_id_
      , star_count :: TransferGift -> Maybe Int
star_count       = Maybe Int
star_count_
      }
        = String
"TransferGift"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"sender_user_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
sender_user_id_
          , String
"message_id"       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
message_id_
          , String
"receiver_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
receiver_user_id_
          , String
"star_count"       String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
          ]

instance AT.ToJSON TransferGift where
  toJSON :: TransferGift -> Value
toJSON
    TransferGift
      { sender_user_id :: TransferGift -> Maybe Int
sender_user_id   = Maybe Int
sender_user_id_
      , message_id :: TransferGift -> Maybe Int
message_id       = Maybe Int
message_id_
      , receiver_user_id :: TransferGift -> Maybe Int
receiver_user_id = Maybe Int
receiver_user_id_
      , star_count :: TransferGift -> Maybe Int
star_count       = Maybe Int
star_count_
      }
        = [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
"transferGift"
          , Key
"sender_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
sender_user_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
"receiver_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
receiver_user_id_
          , Key
"star_count"       Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
star_count_
          ]

defaultTransferGift :: TransferGift
defaultTransferGift :: TransferGift
defaultTransferGift =
  TransferGift
    { sender_user_id :: Maybe Int
sender_user_id   = Maybe Int
forall a. Maybe a
Nothing
    , message_id :: Maybe Int
message_id       = Maybe Int
forall a. Maybe a
Nothing
    , receiver_user_id :: Maybe Int
receiver_user_id = Maybe Int
forall a. Maybe a
Nothing
    , star_count :: Maybe Int
star_count       = Maybe Int
forall a. Maybe a
Nothing
    }