module TD.Query.CreateInvoiceLink
  (CreateInvoiceLink(..)
  ) 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.InputMessageContent as InputMessageContent

-- | Creates a link for the given invoice; for bots only. Returns 'TD.Data.HttpUrl.HttpUrl'
data CreateInvoiceLink
  = CreateInvoiceLink
    { CreateInvoiceLink -> Maybe InputMessageContent
invoice :: Maybe InputMessageContent.InputMessageContent -- ^ Information about the invoice of the type inputMessageInvoice
    }
  deriving (CreateInvoiceLink -> CreateInvoiceLink -> Bool
(CreateInvoiceLink -> CreateInvoiceLink -> Bool)
-> (CreateInvoiceLink -> CreateInvoiceLink -> Bool)
-> Eq CreateInvoiceLink
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateInvoiceLink -> CreateInvoiceLink -> Bool
== :: CreateInvoiceLink -> CreateInvoiceLink -> Bool
$c/= :: CreateInvoiceLink -> CreateInvoiceLink -> Bool
/= :: CreateInvoiceLink -> CreateInvoiceLink -> Bool
Eq, Int -> CreateInvoiceLink -> ShowS
[CreateInvoiceLink] -> ShowS
CreateInvoiceLink -> String
(Int -> CreateInvoiceLink -> ShowS)
-> (CreateInvoiceLink -> String)
-> ([CreateInvoiceLink] -> ShowS)
-> Show CreateInvoiceLink
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateInvoiceLink -> ShowS
showsPrec :: Int -> CreateInvoiceLink -> ShowS
$cshow :: CreateInvoiceLink -> String
show :: CreateInvoiceLink -> String
$cshowList :: [CreateInvoiceLink] -> ShowS
showList :: [CreateInvoiceLink] -> ShowS
Show)

instance I.ShortShow CreateInvoiceLink where
  shortShow :: CreateInvoiceLink -> String
shortShow
    CreateInvoiceLink
      { invoice :: CreateInvoiceLink -> Maybe InputMessageContent
invoice = Maybe InputMessageContent
invoice_
      }
        = String
"CreateInvoiceLink"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"invoice" String -> Maybe InputMessageContent -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe InputMessageContent
invoice_
          ]

instance AT.ToJSON CreateInvoiceLink where
  toJSON :: CreateInvoiceLink -> Value
toJSON
    CreateInvoiceLink
      { invoice :: CreateInvoiceLink -> Maybe InputMessageContent
invoice = Maybe InputMessageContent
invoice_
      }
        = [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
"createInvoiceLink"
          , Key
"invoice" Key -> Maybe InputMessageContent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe InputMessageContent
invoice_
          ]