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

-- | Applies a Telegram Premium gift code. Returns 'TD.Data.Ok.Ok'
data ApplyPremiumGiftCode
  = ApplyPremiumGiftCode
    { ApplyPremiumGiftCode -> Maybe Text
code :: Maybe T.Text -- ^ The code to apply
    }
  deriving (ApplyPremiumGiftCode -> ApplyPremiumGiftCode -> Bool
(ApplyPremiumGiftCode -> ApplyPremiumGiftCode -> Bool)
-> (ApplyPremiumGiftCode -> ApplyPremiumGiftCode -> Bool)
-> Eq ApplyPremiumGiftCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ApplyPremiumGiftCode -> ApplyPremiumGiftCode -> Bool
== :: ApplyPremiumGiftCode -> ApplyPremiumGiftCode -> Bool
$c/= :: ApplyPremiumGiftCode -> ApplyPremiumGiftCode -> Bool
/= :: ApplyPremiumGiftCode -> ApplyPremiumGiftCode -> Bool
Eq, Int -> ApplyPremiumGiftCode -> ShowS
[ApplyPremiumGiftCode] -> ShowS
ApplyPremiumGiftCode -> String
(Int -> ApplyPremiumGiftCode -> ShowS)
-> (ApplyPremiumGiftCode -> String)
-> ([ApplyPremiumGiftCode] -> ShowS)
-> Show ApplyPremiumGiftCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ApplyPremiumGiftCode -> ShowS
showsPrec :: Int -> ApplyPremiumGiftCode -> ShowS
$cshow :: ApplyPremiumGiftCode -> String
show :: ApplyPremiumGiftCode -> String
$cshowList :: [ApplyPremiumGiftCode] -> ShowS
showList :: [ApplyPremiumGiftCode] -> ShowS
Show)

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

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