module TD.Query.GetStarSubscriptions
  (GetStarSubscriptions(..)
  , defaultGetStarSubscriptions
  ) 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

-- | Returns the list of Telegram Star subscriptions for the current user. Returns 'TD.Data.StarSubscriptions.StarSubscriptions'
data GetStarSubscriptions
  = GetStarSubscriptions
    { GetStarSubscriptions -> Maybe Bool
only_expiring :: Maybe Bool   -- ^ Pass true to receive only expiring subscriptions for which there are no enough Telegram Stars to extend
    , GetStarSubscriptions -> Maybe Text
offset        :: Maybe T.Text -- ^ Offset of the first subscription to return as received from the previous request; use empty string to get the first chunk of results
    }
  deriving (GetStarSubscriptions -> GetStarSubscriptions -> Bool
(GetStarSubscriptions -> GetStarSubscriptions -> Bool)
-> (GetStarSubscriptions -> GetStarSubscriptions -> Bool)
-> Eq GetStarSubscriptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetStarSubscriptions -> GetStarSubscriptions -> Bool
== :: GetStarSubscriptions -> GetStarSubscriptions -> Bool
$c/= :: GetStarSubscriptions -> GetStarSubscriptions -> Bool
/= :: GetStarSubscriptions -> GetStarSubscriptions -> Bool
Eq, Int -> GetStarSubscriptions -> ShowS
[GetStarSubscriptions] -> ShowS
GetStarSubscriptions -> String
(Int -> GetStarSubscriptions -> ShowS)
-> (GetStarSubscriptions -> String)
-> ([GetStarSubscriptions] -> ShowS)
-> Show GetStarSubscriptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetStarSubscriptions -> ShowS
showsPrec :: Int -> GetStarSubscriptions -> ShowS
$cshow :: GetStarSubscriptions -> String
show :: GetStarSubscriptions -> String
$cshowList :: [GetStarSubscriptions] -> ShowS
showList :: [GetStarSubscriptions] -> ShowS
Show)

instance I.ShortShow GetStarSubscriptions where
  shortShow :: GetStarSubscriptions -> String
shortShow
    GetStarSubscriptions
      { only_expiring :: GetStarSubscriptions -> Maybe Bool
only_expiring = Maybe Bool
only_expiring_
      , offset :: GetStarSubscriptions -> Maybe Text
offset        = Maybe Text
offset_
      }
        = String
"GetStarSubscriptions"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"only_expiring" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_expiring_
          , String
"offset"        String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
offset_
          ]

instance AT.ToJSON GetStarSubscriptions where
  toJSON :: GetStarSubscriptions -> Value
toJSON
    GetStarSubscriptions
      { only_expiring :: GetStarSubscriptions -> Maybe Bool
only_expiring = Maybe Bool
only_expiring_
      , offset :: GetStarSubscriptions -> Maybe Text
offset        = Maybe Text
offset_
      }
        = [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
"getStarSubscriptions"
          , Key
"only_expiring" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
only_expiring_
          , Key
"offset"        Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
offset_
          ]

defaultGetStarSubscriptions :: GetStarSubscriptions
defaultGetStarSubscriptions :: GetStarSubscriptions
defaultGetStarSubscriptions =
  GetStarSubscriptions
    { only_expiring :: Maybe Bool
only_expiring = Maybe Bool
forall a. Maybe a
Nothing
    , offset :: Maybe Text
offset        = Maybe Text
forall a. Maybe a
Nothing
    }