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

-- | Accepts Telegram terms of services. Returns 'TD.Data.Ok.Ok'
data AcceptTermsOfService
  = AcceptTermsOfService
    { AcceptTermsOfService -> Maybe Text
terms_of_service_id :: Maybe T.Text -- ^ Terms of service identifier
    }
  deriving (AcceptTermsOfService -> AcceptTermsOfService -> Bool
(AcceptTermsOfService -> AcceptTermsOfService -> Bool)
-> (AcceptTermsOfService -> AcceptTermsOfService -> Bool)
-> Eq AcceptTermsOfService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AcceptTermsOfService -> AcceptTermsOfService -> Bool
== :: AcceptTermsOfService -> AcceptTermsOfService -> Bool
$c/= :: AcceptTermsOfService -> AcceptTermsOfService -> Bool
/= :: AcceptTermsOfService -> AcceptTermsOfService -> Bool
Eq, Int -> AcceptTermsOfService -> ShowS
[AcceptTermsOfService] -> ShowS
AcceptTermsOfService -> String
(Int -> AcceptTermsOfService -> ShowS)
-> (AcceptTermsOfService -> String)
-> ([AcceptTermsOfService] -> ShowS)
-> Show AcceptTermsOfService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AcceptTermsOfService -> ShowS
showsPrec :: Int -> AcceptTermsOfService -> ShowS
$cshow :: AcceptTermsOfService -> String
show :: AcceptTermsOfService -> String
$cshowList :: [AcceptTermsOfService] -> ShowS
showList :: [AcceptTermsOfService] -> ShowS
Show)

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

instance AT.ToJSON AcceptTermsOfService where
  toJSON :: AcceptTermsOfService -> Value
toJSON
    AcceptTermsOfService
      { terms_of_service_id :: AcceptTermsOfService -> Maybe Text
terms_of_service_id = Maybe Text
terms_of_service_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
"acceptTermsOfService"
          , Key
"terms_of_service_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
terms_of_service_id_
          ]