module TD.Query.GetGiftUpgradePreview
  (GetGiftUpgradePreview(..)
  ) where

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

-- | Returns examples of possible upgraded gifts for a regular gift. Returns 'TD.Data.GiftUpgradePreview.GiftUpgradePreview'
data GetGiftUpgradePreview
  = GetGiftUpgradePreview
    { GetGiftUpgradePreview -> Maybe Int
gift_id :: Maybe Int -- ^ Identifier of the gift
    }
  deriving (GetGiftUpgradePreview -> GetGiftUpgradePreview -> Bool
(GetGiftUpgradePreview -> GetGiftUpgradePreview -> Bool)
-> (GetGiftUpgradePreview -> GetGiftUpgradePreview -> Bool)
-> Eq GetGiftUpgradePreview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetGiftUpgradePreview -> GetGiftUpgradePreview -> Bool
== :: GetGiftUpgradePreview -> GetGiftUpgradePreview -> Bool
$c/= :: GetGiftUpgradePreview -> GetGiftUpgradePreview -> Bool
/= :: GetGiftUpgradePreview -> GetGiftUpgradePreview -> Bool
Eq, Int -> GetGiftUpgradePreview -> ShowS
[GetGiftUpgradePreview] -> ShowS
GetGiftUpgradePreview -> String
(Int -> GetGiftUpgradePreview -> ShowS)
-> (GetGiftUpgradePreview -> String)
-> ([GetGiftUpgradePreview] -> ShowS)
-> Show GetGiftUpgradePreview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetGiftUpgradePreview -> ShowS
showsPrec :: Int -> GetGiftUpgradePreview -> ShowS
$cshow :: GetGiftUpgradePreview -> String
show :: GetGiftUpgradePreview -> String
$cshowList :: [GetGiftUpgradePreview] -> ShowS
showList :: [GetGiftUpgradePreview] -> ShowS
Show)

instance I.ShortShow GetGiftUpgradePreview where
  shortShow :: GetGiftUpgradePreview -> String
shortShow
    GetGiftUpgradePreview
      { gift_id :: GetGiftUpgradePreview -> Maybe Int
gift_id = Maybe Int
gift_id_
      }
        = String
"GetGiftUpgradePreview"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"gift_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
gift_id_
          ]

instance AT.ToJSON GetGiftUpgradePreview where
  toJSON :: GetGiftUpgradePreview -> Value
toJSON
    GetGiftUpgradePreview
      { gift_id :: GetGiftUpgradePreview -> Maybe Int
gift_id = Maybe Int
gift_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
"getGiftUpgradePreview"
          , Key
"gift_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
gift_id_
          ]