module TD.Query.GetCollectibleItemInfo
  (GetCollectibleItemInfo(..)
  ) 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.CollectibleItemType as CollectibleItemType

-- | Returns information about a given collectible item that was purchased at https://fragment.com. Returns 'TD.Data.CollectibleItemInfo.CollectibleItemInfo'
data GetCollectibleItemInfo
  = GetCollectibleItemInfo
    { GetCollectibleItemInfo -> Maybe CollectibleItemType
_type :: Maybe CollectibleItemType.CollectibleItemType -- ^ Type of the collectible item. The item must be used by a user and must be visible to the current user
    }
  deriving (GetCollectibleItemInfo -> GetCollectibleItemInfo -> Bool
(GetCollectibleItemInfo -> GetCollectibleItemInfo -> Bool)
-> (GetCollectibleItemInfo -> GetCollectibleItemInfo -> Bool)
-> Eq GetCollectibleItemInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetCollectibleItemInfo -> GetCollectibleItemInfo -> Bool
== :: GetCollectibleItemInfo -> GetCollectibleItemInfo -> Bool
$c/= :: GetCollectibleItemInfo -> GetCollectibleItemInfo -> Bool
/= :: GetCollectibleItemInfo -> GetCollectibleItemInfo -> Bool
Eq, Int -> GetCollectibleItemInfo -> ShowS
[GetCollectibleItemInfo] -> ShowS
GetCollectibleItemInfo -> String
(Int -> GetCollectibleItemInfo -> ShowS)
-> (GetCollectibleItemInfo -> String)
-> ([GetCollectibleItemInfo] -> ShowS)
-> Show GetCollectibleItemInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetCollectibleItemInfo -> ShowS
showsPrec :: Int -> GetCollectibleItemInfo -> ShowS
$cshow :: GetCollectibleItemInfo -> String
show :: GetCollectibleItemInfo -> String
$cshowList :: [GetCollectibleItemInfo] -> ShowS
showList :: [GetCollectibleItemInfo] -> ShowS
Show)

instance I.ShortShow GetCollectibleItemInfo where
  shortShow :: GetCollectibleItemInfo -> String
shortShow
    GetCollectibleItemInfo
      { _type :: GetCollectibleItemInfo -> Maybe CollectibleItemType
_type = Maybe CollectibleItemType
_type_
      }
        = String
"GetCollectibleItemInfo"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"_type" String -> Maybe CollectibleItemType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe CollectibleItemType
_type_
          ]

instance AT.ToJSON GetCollectibleItemInfo where
  toJSON :: GetCollectibleItemInfo -> Value
toJSON
    GetCollectibleItemInfo
      { _type :: GetCollectibleItemInfo -> Maybe CollectibleItemType
_type = Maybe CollectibleItemType
_type_
      }
        = [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
"getCollectibleItemInfo"
          , Key
"type"  Key -> Maybe CollectibleItemType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe CollectibleItemType
_type_
          ]