module TD.Query.GetGiftsForCrafting
  (GetGiftsForCrafting(..)
  , defaultGetGiftsForCrafting
  ) 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 upgraded gifts of the current user who can be used to craft another gifts. Returns 'TD.Data.GiftsForCrafting.GiftsForCrafting'
data GetGiftsForCrafting
  = GetGiftsForCrafting
    { GetGiftsForCrafting -> Maybe Int
regular_gift_id :: Maybe Int    -- ^ Identifier of the regular gift that will be used for crafting
    , GetGiftsForCrafting -> 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
    , GetGiftsForCrafting -> 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 (GetGiftsForCrafting -> GetGiftsForCrafting -> Bool
(GetGiftsForCrafting -> GetGiftsForCrafting -> Bool)
-> (GetGiftsForCrafting -> GetGiftsForCrafting -> Bool)
-> Eq GetGiftsForCrafting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetGiftsForCrafting -> GetGiftsForCrafting -> Bool
== :: GetGiftsForCrafting -> GetGiftsForCrafting -> Bool
$c/= :: GetGiftsForCrafting -> GetGiftsForCrafting -> Bool
/= :: GetGiftsForCrafting -> GetGiftsForCrafting -> Bool
Eq, Int -> GetGiftsForCrafting -> ShowS
[GetGiftsForCrafting] -> ShowS
GetGiftsForCrafting -> String
(Int -> GetGiftsForCrafting -> ShowS)
-> (GetGiftsForCrafting -> String)
-> ([GetGiftsForCrafting] -> ShowS)
-> Show GetGiftsForCrafting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetGiftsForCrafting -> ShowS
showsPrec :: Int -> GetGiftsForCrafting -> ShowS
$cshow :: GetGiftsForCrafting -> String
show :: GetGiftsForCrafting -> String
$cshowList :: [GetGiftsForCrafting] -> ShowS
showList :: [GetGiftsForCrafting] -> ShowS
Show)

instance I.ShortShow GetGiftsForCrafting where
  shortShow :: GetGiftsForCrafting -> String
shortShow
    GetGiftsForCrafting
      { regular_gift_id :: GetGiftsForCrafting -> Maybe Int
regular_gift_id = Maybe Int
regular_gift_id_
      , offset :: GetGiftsForCrafting -> Maybe Text
offset          = Maybe Text
offset_
      , limit :: GetGiftsForCrafting -> Maybe Int
limit           = Maybe Int
limit_
      }
        = String
"GetGiftsForCrafting"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"regular_gift_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
regular_gift_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 GetGiftsForCrafting where
  toJSON :: GetGiftsForCrafting -> Value
toJSON
    GetGiftsForCrafting
      { regular_gift_id :: GetGiftsForCrafting -> Maybe Int
regular_gift_id = Maybe Int
regular_gift_id_
      , offset :: GetGiftsForCrafting -> Maybe Text
offset          = Maybe Text
offset_
      , limit :: GetGiftsForCrafting -> 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
"getGiftsForCrafting"
          , Key
"regular_gift_id" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= (Int -> Value) -> Maybe Int -> Maybe Value
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Value
I.writeInt64  Maybe Int
regular_gift_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_
          ]

defaultGetGiftsForCrafting :: GetGiftsForCrafting
defaultGetGiftsForCrafting :: GetGiftsForCrafting
defaultGetGiftsForCrafting =
  GetGiftsForCrafting
    { regular_gift_id :: Maybe Int
regular_gift_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
    }