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

-- | Returns the secret phrase of the user's TON wallet as a space separated list of words. Works only if tonWalletState.can_export_phrase is true. Returns 'TD.Data.Text.Text'
data GetTonWalletSecretPhrase
  = GetTonWalletSecretPhrase
    { GetTonWalletSecretPhrase -> Maybe Text
password :: Maybe T.Text -- ^ Password of the current user; pass an empty string unless receive an error with a message "PASSWORD_MISSING" for a passwordless request
    }
  deriving (GetTonWalletSecretPhrase -> GetTonWalletSecretPhrase -> Bool
(GetTonWalletSecretPhrase -> GetTonWalletSecretPhrase -> Bool)
-> (GetTonWalletSecretPhrase -> GetTonWalletSecretPhrase -> Bool)
-> Eq GetTonWalletSecretPhrase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetTonWalletSecretPhrase -> GetTonWalletSecretPhrase -> Bool
== :: GetTonWalletSecretPhrase -> GetTonWalletSecretPhrase -> Bool
$c/= :: GetTonWalletSecretPhrase -> GetTonWalletSecretPhrase -> Bool
/= :: GetTonWalletSecretPhrase -> GetTonWalletSecretPhrase -> Bool
Eq, Int -> GetTonWalletSecretPhrase -> ShowS
[GetTonWalletSecretPhrase] -> ShowS
GetTonWalletSecretPhrase -> String
(Int -> GetTonWalletSecretPhrase -> ShowS)
-> (GetTonWalletSecretPhrase -> String)
-> ([GetTonWalletSecretPhrase] -> ShowS)
-> Show GetTonWalletSecretPhrase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetTonWalletSecretPhrase -> ShowS
showsPrec :: Int -> GetTonWalletSecretPhrase -> ShowS
$cshow :: GetTonWalletSecretPhrase -> String
show :: GetTonWalletSecretPhrase -> String
$cshowList :: [GetTonWalletSecretPhrase] -> ShowS
showList :: [GetTonWalletSecretPhrase] -> ShowS
Show)

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

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