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

-- | Reuses an active subscription and joins the subscribed chat again. Returns 'TD.Data.Ok.Ok'
data ReuseStarSubscription
  = ReuseStarSubscription
    { ReuseStarSubscription -> Maybe Text
subscription_id :: Maybe T.Text -- ^ Identifier of the subscription
    }
  deriving (ReuseStarSubscription -> ReuseStarSubscription -> Bool
(ReuseStarSubscription -> ReuseStarSubscription -> Bool)
-> (ReuseStarSubscription -> ReuseStarSubscription -> Bool)
-> Eq ReuseStarSubscription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReuseStarSubscription -> ReuseStarSubscription -> Bool
== :: ReuseStarSubscription -> ReuseStarSubscription -> Bool
$c/= :: ReuseStarSubscription -> ReuseStarSubscription -> Bool
/= :: ReuseStarSubscription -> ReuseStarSubscription -> Bool
Eq, Int -> ReuseStarSubscription -> ShowS
[ReuseStarSubscription] -> ShowS
ReuseStarSubscription -> String
(Int -> ReuseStarSubscription -> ShowS)
-> (ReuseStarSubscription -> String)
-> ([ReuseStarSubscription] -> ShowS)
-> Show ReuseStarSubscription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReuseStarSubscription -> ShowS
showsPrec :: Int -> ReuseStarSubscription -> ShowS
$cshow :: ReuseStarSubscription -> String
show :: ReuseStarSubscription -> String
$cshowList :: [ReuseStarSubscription] -> ShowS
showList :: [ReuseStarSubscription] -> ShowS
Show)

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

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