module TD.Query.GetUserGifts
  (GetUserGifts(..)
  , defaultGetUserGifts
  ) 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 gifts saved to profile by the given user. Returns 'TD.Data.UserGifts.UserGifts'
data GetUserGifts
  = GetUserGifts
    { GetUserGifts -> Maybe Int
user_id :: Maybe Int    -- ^ Identifier of the user
    , GetUserGifts -> Maybe Text
offset  :: Maybe T.Text -- ^ Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
    , GetUserGifts -> Maybe Int
limit   :: Maybe Int    -- ^ The maximum number of gifts to be returned; must be positive and can't be greater than 100. For optimal performance, the number of returned objects is chosen by TDLib and can be smaller than the specified limit
    }
  deriving (GetUserGifts -> GetUserGifts -> Bool
(GetUserGifts -> GetUserGifts -> Bool)
-> (GetUserGifts -> GetUserGifts -> Bool) -> Eq GetUserGifts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetUserGifts -> GetUserGifts -> Bool
== :: GetUserGifts -> GetUserGifts -> Bool
$c/= :: GetUserGifts -> GetUserGifts -> Bool
/= :: GetUserGifts -> GetUserGifts -> Bool
Eq, Int -> GetUserGifts -> ShowS
[GetUserGifts] -> ShowS
GetUserGifts -> String
(Int -> GetUserGifts -> ShowS)
-> (GetUserGifts -> String)
-> ([GetUserGifts] -> ShowS)
-> Show GetUserGifts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetUserGifts -> ShowS
showsPrec :: Int -> GetUserGifts -> ShowS
$cshow :: GetUserGifts -> String
show :: GetUserGifts -> String
$cshowList :: [GetUserGifts] -> ShowS
showList :: [GetUserGifts] -> ShowS
Show)

instance I.ShortShow GetUserGifts where
  shortShow :: GetUserGifts -> String
shortShow
    GetUserGifts
      { user_id :: GetUserGifts -> Maybe Int
user_id = Maybe Int
user_id_
      , offset :: GetUserGifts -> Maybe Text
offset  = Maybe Text
offset_
      , limit :: GetUserGifts -> Maybe Int
limit   = Maybe Int
limit_
      }
        = String
"GetUserGifts"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
          , String
"offset"  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
offset_
          , String
"limit"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
limit_
          ]

instance AT.ToJSON GetUserGifts where
  toJSON :: GetUserGifts -> Value
toJSON
    GetUserGifts
      { user_id :: GetUserGifts -> Maybe Int
user_id = Maybe Int
user_id_
      , offset :: GetUserGifts -> Maybe Text
offset  = Maybe Text
offset_
      , limit :: GetUserGifts -> Maybe Int
limit   = Maybe Int
limit_
      }
        = [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
"getUserGifts"
          , Key
"user_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
user_id_
          , 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_
          , Key
"limit"   Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
limit_
          ]

defaultGetUserGifts :: GetUserGifts
defaultGetUserGifts :: GetUserGifts
defaultGetUserGifts =
  GetUserGifts
    { user_id :: Maybe Int
user_id = Maybe Int
forall a. Maybe a
Nothing
    , offset :: Maybe Text
offset  = Maybe Text
forall a. Maybe a
Nothing
    , limit :: Maybe Int
limit   = Maybe Int
forall a. Maybe a
Nothing
    }