module TD.Query.SetStoryPrivacySettings
  (SetStoryPrivacySettings(..)
  , defaultSetStoryPrivacySettings
  ) 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.StoryPrivacySettings as StoryPrivacySettings

-- | Changes privacy settings of a story. The method can be called only for stories posted on behalf of the current user and if story.can_be_edited == true. Returns 'TD.Data.Ok.Ok'
data SetStoryPrivacySettings
  = SetStoryPrivacySettings
    { SetStoryPrivacySettings -> Maybe Int
story_id         :: Maybe Int                                       -- ^ Identifier of the story
    , SetStoryPrivacySettings -> Maybe StoryPrivacySettings
privacy_settings :: Maybe StoryPrivacySettings.StoryPrivacySettings -- ^ The new privacy settigs for the story
    }
  deriving (SetStoryPrivacySettings -> SetStoryPrivacySettings -> Bool
(SetStoryPrivacySettings -> SetStoryPrivacySettings -> Bool)
-> (SetStoryPrivacySettings -> SetStoryPrivacySettings -> Bool)
-> Eq SetStoryPrivacySettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetStoryPrivacySettings -> SetStoryPrivacySettings -> Bool
== :: SetStoryPrivacySettings -> SetStoryPrivacySettings -> Bool
$c/= :: SetStoryPrivacySettings -> SetStoryPrivacySettings -> Bool
/= :: SetStoryPrivacySettings -> SetStoryPrivacySettings -> Bool
Eq, Int -> SetStoryPrivacySettings -> ShowS
[SetStoryPrivacySettings] -> ShowS
SetStoryPrivacySettings -> String
(Int -> SetStoryPrivacySettings -> ShowS)
-> (SetStoryPrivacySettings -> String)
-> ([SetStoryPrivacySettings] -> ShowS)
-> Show SetStoryPrivacySettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetStoryPrivacySettings -> ShowS
showsPrec :: Int -> SetStoryPrivacySettings -> ShowS
$cshow :: SetStoryPrivacySettings -> String
show :: SetStoryPrivacySettings -> String
$cshowList :: [SetStoryPrivacySettings] -> ShowS
showList :: [SetStoryPrivacySettings] -> ShowS
Show)

instance I.ShortShow SetStoryPrivacySettings where
  shortShow :: SetStoryPrivacySettings -> String
shortShow
    SetStoryPrivacySettings
      { story_id :: SetStoryPrivacySettings -> Maybe Int
story_id         = Maybe Int
story_id_
      , privacy_settings :: SetStoryPrivacySettings -> Maybe StoryPrivacySettings
privacy_settings = Maybe StoryPrivacySettings
privacy_settings_
      }
        = String
"SetStoryPrivacySettings"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"story_id"         String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
story_id_
          , String
"privacy_settings" String -> Maybe StoryPrivacySettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StoryPrivacySettings
privacy_settings_
          ]

instance AT.ToJSON SetStoryPrivacySettings where
  toJSON :: SetStoryPrivacySettings -> Value
toJSON
    SetStoryPrivacySettings
      { story_id :: SetStoryPrivacySettings -> Maybe Int
story_id         = Maybe Int
story_id_
      , privacy_settings :: SetStoryPrivacySettings -> Maybe StoryPrivacySettings
privacy_settings = Maybe StoryPrivacySettings
privacy_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
"setStoryPrivacySettings"
          , Key
"story_id"         Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
story_id_
          , Key
"privacy_settings" Key -> Maybe StoryPrivacySettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe StoryPrivacySettings
privacy_settings_
          ]

defaultSetStoryPrivacySettings :: SetStoryPrivacySettings
defaultSetStoryPrivacySettings :: SetStoryPrivacySettings
defaultSetStoryPrivacySettings =
  SetStoryPrivacySettings
    { story_id :: Maybe Int
story_id         = Maybe Int
forall a. Maybe a
Nothing
    , privacy_settings :: Maybe StoryPrivacySettings
privacy_settings = Maybe StoryPrivacySettings
forall a. Maybe a
Nothing
    }