module TD.Query.GetPaymentForm
  (GetPaymentForm(..)
  , defaultGetPaymentForm
  ) where

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

-- | Returns an invoice payment form. This method must be called when the user presses inline button of the type inlineKeyboardButtonTypeBuy, or wants to buy access to media in a messagePaidMedia message. Returns 'TD.Data.PaymentForm.PaymentForm'
data GetPaymentForm
  = GetPaymentForm
    { GetPaymentForm -> Maybe InputInvoice
input_invoice :: Maybe InputInvoice.InputInvoice       -- ^ The invoice
    , GetPaymentForm -> Maybe ThemeParameters
theme         :: Maybe ThemeParameters.ThemeParameters -- ^ Preferred payment form theme; pass null to use the default theme
    }
  deriving (GetPaymentForm -> GetPaymentForm -> Bool
(GetPaymentForm -> GetPaymentForm -> Bool)
-> (GetPaymentForm -> GetPaymentForm -> Bool) -> Eq GetPaymentForm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetPaymentForm -> GetPaymentForm -> Bool
== :: GetPaymentForm -> GetPaymentForm -> Bool
$c/= :: GetPaymentForm -> GetPaymentForm -> Bool
/= :: GetPaymentForm -> GetPaymentForm -> Bool
Eq, Int -> GetPaymentForm -> ShowS
[GetPaymentForm] -> ShowS
GetPaymentForm -> String
(Int -> GetPaymentForm -> ShowS)
-> (GetPaymentForm -> String)
-> ([GetPaymentForm] -> ShowS)
-> Show GetPaymentForm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetPaymentForm -> ShowS
showsPrec :: Int -> GetPaymentForm -> ShowS
$cshow :: GetPaymentForm -> String
show :: GetPaymentForm -> String
$cshowList :: [GetPaymentForm] -> ShowS
showList :: [GetPaymentForm] -> ShowS
Show)

instance I.ShortShow GetPaymentForm where
  shortShow :: GetPaymentForm -> String
shortShow
    GetPaymentForm
      { input_invoice :: GetPaymentForm -> Maybe InputInvoice
input_invoice = Maybe InputInvoice
input_invoice_
      , theme :: GetPaymentForm -> Maybe ThemeParameters
theme         = Maybe ThemeParameters
theme_
      }
        = String
"GetPaymentForm"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"input_invoice" String -> Maybe InputInvoice -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputInvoice
input_invoice_
          , String
"theme"         String -> Maybe ThemeParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ThemeParameters
theme_
          ]

instance AT.ToJSON GetPaymentForm where
  toJSON :: GetPaymentForm -> Value
toJSON
    GetPaymentForm
      { input_invoice :: GetPaymentForm -> Maybe InputInvoice
input_invoice = Maybe InputInvoice
input_invoice_
      , theme :: GetPaymentForm -> Maybe ThemeParameters
theme         = Maybe ThemeParameters
theme_
      }
        = [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
"getPaymentForm"
          , Key
"input_invoice" Key -> Maybe InputInvoice -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputInvoice
input_invoice_
          , Key
"theme"         Key -> Maybe ThemeParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe ThemeParameters
theme_
          ]

defaultGetPaymentForm :: GetPaymentForm
defaultGetPaymentForm :: GetPaymentForm
defaultGetPaymentForm =
  GetPaymentForm
    { input_invoice :: Maybe InputInvoice
input_invoice = Maybe InputInvoice
forall a. Maybe a
Nothing
    , theme :: Maybe ThemeParameters
theme         = Maybe ThemeParameters
forall a. Maybe a
Nothing
    }