module TD.Query.GetNetworkStatistics
  (GetNetworkStatistics(..)
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Returns network data usage statistics. Can be called before authorization. Returns 'TD.Data.NetworkStatistics.NetworkStatistics'
data GetNetworkStatistics
  = GetNetworkStatistics
    { GetNetworkStatistics -> Maybe Bool
only_current :: Maybe Bool -- ^ Pass true to get statistics only for the current library launch
    }
  deriving (GetNetworkStatistics -> GetNetworkStatistics -> Bool
(GetNetworkStatistics -> GetNetworkStatistics -> Bool)
-> (GetNetworkStatistics -> GetNetworkStatistics -> Bool)
-> Eq GetNetworkStatistics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetNetworkStatistics -> GetNetworkStatistics -> Bool
== :: GetNetworkStatistics -> GetNetworkStatistics -> Bool
$c/= :: GetNetworkStatistics -> GetNetworkStatistics -> Bool
/= :: GetNetworkStatistics -> GetNetworkStatistics -> Bool
Eq, Int -> GetNetworkStatistics -> ShowS
[GetNetworkStatistics] -> ShowS
GetNetworkStatistics -> String
(Int -> GetNetworkStatistics -> ShowS)
-> (GetNetworkStatistics -> String)
-> ([GetNetworkStatistics] -> ShowS)
-> Show GetNetworkStatistics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetNetworkStatistics -> ShowS
showsPrec :: Int -> GetNetworkStatistics -> ShowS
$cshow :: GetNetworkStatistics -> String
show :: GetNetworkStatistics -> String
$cshowList :: [GetNetworkStatistics] -> ShowS
showList :: [GetNetworkStatistics] -> ShowS
Show)

instance I.ShortShow GetNetworkStatistics where
  shortShow :: GetNetworkStatistics -> String
shortShow
    GetNetworkStatistics
      { only_current :: GetNetworkStatistics -> Maybe Bool
only_current = Maybe Bool
only_current_
      }
        = String
"GetNetworkStatistics"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"only_current" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
only_current_
          ]

instance AT.ToJSON GetNetworkStatistics where
  toJSON :: GetNetworkStatistics -> Value
toJSON
    GetNetworkStatistics
      { only_current :: GetNetworkStatistics -> Maybe Bool
only_current = Maybe Bool
only_current_
      }
        = [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
"getNetworkStatistics"
          , Key
"only_current" 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_current_
          ]