module TD.Query.CheckAuthenticationPremiumPurchase
  (CheckAuthenticationPremiumPurchase(..)
  , defaultCheckAuthenticationPremiumPurchase
  ) 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

-- | Checks whether an in-store purchase of Telegram Premium is possible before authorization. Works only when the current authorization state is authorizationStateWaitPremiumPurchase. Returns 'TD.Data.Ok.Ok'
data CheckAuthenticationPremiumPurchase
  = CheckAuthenticationPremiumPurchase
    { CheckAuthenticationPremiumPurchase -> Maybe Text
currency :: Maybe T.Text -- ^ ISO 4217 currency code of the payment currency
    , CheckAuthenticationPremiumPurchase -> Maybe Int
amount   :: Maybe Int    -- ^ Paid amount, in the smallest units of the currency
    }
  deriving (CheckAuthenticationPremiumPurchase
-> CheckAuthenticationPremiumPurchase -> Bool
(CheckAuthenticationPremiumPurchase
 -> CheckAuthenticationPremiumPurchase -> Bool)
-> (CheckAuthenticationPremiumPurchase
    -> CheckAuthenticationPremiumPurchase -> Bool)
-> Eq CheckAuthenticationPremiumPurchase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckAuthenticationPremiumPurchase
-> CheckAuthenticationPremiumPurchase -> Bool
== :: CheckAuthenticationPremiumPurchase
-> CheckAuthenticationPremiumPurchase -> Bool
$c/= :: CheckAuthenticationPremiumPurchase
-> CheckAuthenticationPremiumPurchase -> Bool
/= :: CheckAuthenticationPremiumPurchase
-> CheckAuthenticationPremiumPurchase -> Bool
Eq, Int -> CheckAuthenticationPremiumPurchase -> ShowS
[CheckAuthenticationPremiumPurchase] -> ShowS
CheckAuthenticationPremiumPurchase -> String
(Int -> CheckAuthenticationPremiumPurchase -> ShowS)
-> (CheckAuthenticationPremiumPurchase -> String)
-> ([CheckAuthenticationPremiumPurchase] -> ShowS)
-> Show CheckAuthenticationPremiumPurchase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckAuthenticationPremiumPurchase -> ShowS
showsPrec :: Int -> CheckAuthenticationPremiumPurchase -> ShowS
$cshow :: CheckAuthenticationPremiumPurchase -> String
show :: CheckAuthenticationPremiumPurchase -> String
$cshowList :: [CheckAuthenticationPremiumPurchase] -> ShowS
showList :: [CheckAuthenticationPremiumPurchase] -> ShowS
Show)

instance I.ShortShow CheckAuthenticationPremiumPurchase where
  shortShow :: CheckAuthenticationPremiumPurchase -> String
shortShow
    CheckAuthenticationPremiumPurchase
      { currency :: CheckAuthenticationPremiumPurchase -> Maybe Text
currency = Maybe Text
currency_
      , amount :: CheckAuthenticationPremiumPurchase -> Maybe Int
amount   = Maybe Int
amount_
      }
        = String
"CheckAuthenticationPremiumPurchase"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"currency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
currency_
          , String
"amount"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
          ]

instance AT.ToJSON CheckAuthenticationPremiumPurchase where
  toJSON :: CheckAuthenticationPremiumPurchase -> Value
toJSON
    CheckAuthenticationPremiumPurchase
      { currency :: CheckAuthenticationPremiumPurchase -> Maybe Text
currency = Maybe Text
currency_
      , amount :: CheckAuthenticationPremiumPurchase -> Maybe Int
amount   = Maybe Int
amount_
      }
        = [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
"checkAuthenticationPremiumPurchase"
          , Key
"currency" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
currency_
          , Key
"amount"   Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
amount_
          ]

defaultCheckAuthenticationPremiumPurchase :: CheckAuthenticationPremiumPurchase
defaultCheckAuthenticationPremiumPurchase :: CheckAuthenticationPremiumPurchase
defaultCheckAuthenticationPremiumPurchase =
  CheckAuthenticationPremiumPurchase
    { currency :: Maybe Text
currency = Maybe Text
forall a. Maybe a
Nothing
    , amount :: Maybe Int
amount   = Maybe Int
forall a. Maybe a
Nothing
    }