module TD.Query.TestCallBytes
  (TestCallBytes(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.ByteString as BS

-- | Returns the received bytes; for testing only. This is an offline method. Can be called before authorization. Returns 'TD.Data.TestBytes.TestBytes'
data TestCallBytes
  = TestCallBytes
    { TestCallBytes -> Maybe ByteString
x :: Maybe BS.ByteString -- ^ Bytes to return
    }
  deriving (TestCallBytes -> TestCallBytes -> Bool
(TestCallBytes -> TestCallBytes -> Bool)
-> (TestCallBytes -> TestCallBytes -> Bool) -> Eq TestCallBytes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TestCallBytes -> TestCallBytes -> Bool
== :: TestCallBytes -> TestCallBytes -> Bool
$c/= :: TestCallBytes -> TestCallBytes -> Bool
/= :: TestCallBytes -> TestCallBytes -> Bool
Eq, Int -> TestCallBytes -> ShowS
[TestCallBytes] -> ShowS
TestCallBytes -> String
(Int -> TestCallBytes -> ShowS)
-> (TestCallBytes -> String)
-> ([TestCallBytes] -> ShowS)
-> Show TestCallBytes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TestCallBytes -> ShowS
showsPrec :: Int -> TestCallBytes -> ShowS
$cshow :: TestCallBytes -> String
show :: TestCallBytes -> String
$cshowList :: [TestCallBytes] -> ShowS
showList :: [TestCallBytes] -> ShowS
Show)

instance I.ShortShow TestCallBytes where
  shortShow :: TestCallBytes -> String
shortShow
    TestCallBytes
      { x :: TestCallBytes -> Maybe ByteString
x = Maybe ByteString
x_
      }
        = String
"TestCallBytes"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"x" String -> Maybe ByteString -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ByteString
x_
          ]

instance AT.ToJSON TestCallBytes where
  toJSON :: TestCallBytes -> Value
toJSON
    TestCallBytes
      { x :: TestCallBytes -> Maybe ByteString
x = Maybe ByteString
x_
      }
        = [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
"testCallBytes"
          , Key
"x"     Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (ByteString -> Value) -> Maybe ByteString -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Value
I.writeBytes  Maybe ByteString
x_
          ]