module TD.Query.SetGiftSettings
  (SetGiftSettings(..)
  ) 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.GiftSettings as GiftSettings

-- | Changes settings for gift receiving for the current user. Returns 'TD.Data.Ok.Ok'
data SetGiftSettings
  = SetGiftSettings
    { SetGiftSettings -> Maybe GiftSettings
settings :: Maybe GiftSettings.GiftSettings -- ^ The new settings
    }
  deriving (SetGiftSettings -> SetGiftSettings -> Bool
(SetGiftSettings -> SetGiftSettings -> Bool)
-> (SetGiftSettings -> SetGiftSettings -> Bool)
-> Eq SetGiftSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetGiftSettings -> SetGiftSettings -> Bool
== :: SetGiftSettings -> SetGiftSettings -> Bool
$c/= :: SetGiftSettings -> SetGiftSettings -> Bool
/= :: SetGiftSettings -> SetGiftSettings -> Bool
Eq, Int -> SetGiftSettings -> ShowS
[SetGiftSettings] -> ShowS
SetGiftSettings -> String
(Int -> SetGiftSettings -> ShowS)
-> (SetGiftSettings -> String)
-> ([SetGiftSettings] -> ShowS)
-> Show SetGiftSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetGiftSettings -> ShowS
showsPrec :: Int -> SetGiftSettings -> ShowS
$cshow :: SetGiftSettings -> String
show :: SetGiftSettings -> String
$cshowList :: [SetGiftSettings] -> ShowS
showList :: [SetGiftSettings] -> ShowS
Show)

instance I.ShortShow SetGiftSettings where
  shortShow :: SetGiftSettings -> String
shortShow
    SetGiftSettings
      { settings :: SetGiftSettings -> Maybe GiftSettings
settings = Maybe GiftSettings
settings_
      }
        = String
"SetGiftSettings"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"settings" String -> Maybe GiftSettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe GiftSettings
settings_
          ]

instance AT.ToJSON SetGiftSettings where
  toJSON :: SetGiftSettings -> Value
toJSON
    SetGiftSettings
      { settings :: SetGiftSettings -> Maybe GiftSettings
settings = Maybe GiftSettings
settings_
      }
        = [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
"setGiftSettings"
          , Key
"settings" Key -> Maybe GiftSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe GiftSettings
settings_
          ]