module TD.Query.GetReceivedGifts
  (GetReceivedGifts(..)
  , defaultGetReceivedGifts
  ) 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
import qualified TD.Data.MessageSender as MessageSender

-- | Returns gifts received by the given user or chat. Returns 'TD.Data.ReceivedGifts.ReceivedGifts'
data GetReceivedGifts
  = GetReceivedGifts
    { GetReceivedGifts -> Maybe Text
business_connection_id :: Maybe T.Text                      -- ^ Unique identifier of business connection on behalf of which to send the request; for bots only
    , GetReceivedGifts -> Maybe MessageSender
owner_id               :: Maybe MessageSender.MessageSender -- ^ Identifier of the gift receiver
    , GetReceivedGifts -> Maybe Bool
exclude_unsaved        :: Maybe Bool                        -- ^ Pass true to exclude gifts that aren't saved to the chat's profile page. Always true for gifts received by other users and channel chats without can_post_messages administrator right
    , GetReceivedGifts -> Maybe Bool
exclude_saved          :: Maybe Bool                        -- ^ Pass true to exclude gifts that are saved to the chat's profile page. Always false for gifts received by other users and channel chats without can_post_messages administrator right
    , GetReceivedGifts -> Maybe Bool
exclude_unlimited      :: Maybe Bool                        -- ^ Pass true to exclude gifts that can be purchased unlimited number of times
    , GetReceivedGifts -> Maybe Bool
exclude_limited        :: Maybe Bool                        -- ^ Pass true to exclude gifts that can be purchased limited number of times
    , GetReceivedGifts -> Maybe Bool
exclude_upgraded       :: Maybe Bool                        -- ^ Pass true to exclude upgraded gifts
    , GetReceivedGifts -> Maybe Bool
sort_by_price          :: Maybe Bool                        -- ^ Pass true to sort results by gift price instead of send date
    , GetReceivedGifts -> 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
    , GetReceivedGifts -> 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 (GetReceivedGifts -> GetReceivedGifts -> Bool
(GetReceivedGifts -> GetReceivedGifts -> Bool)
-> (GetReceivedGifts -> GetReceivedGifts -> Bool)
-> Eq GetReceivedGifts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetReceivedGifts -> GetReceivedGifts -> Bool
== :: GetReceivedGifts -> GetReceivedGifts -> Bool
$c/= :: GetReceivedGifts -> GetReceivedGifts -> Bool
/= :: GetReceivedGifts -> GetReceivedGifts -> Bool
Eq, Int -> GetReceivedGifts -> ShowS
[GetReceivedGifts] -> ShowS
GetReceivedGifts -> String
(Int -> GetReceivedGifts -> ShowS)
-> (GetReceivedGifts -> String)
-> ([GetReceivedGifts] -> ShowS)
-> Show GetReceivedGifts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetReceivedGifts -> ShowS
showsPrec :: Int -> GetReceivedGifts -> ShowS
$cshow :: GetReceivedGifts -> String
show :: GetReceivedGifts -> String
$cshowList :: [GetReceivedGifts] -> ShowS
showList :: [GetReceivedGifts] -> ShowS
Show)

instance I.ShortShow GetReceivedGifts where
  shortShow :: GetReceivedGifts -> String
shortShow
    GetReceivedGifts
      { business_connection_id :: GetReceivedGifts -> Maybe Text
business_connection_id = Maybe Text
business_connection_id_
      , owner_id :: GetReceivedGifts -> Maybe MessageSender
owner_id               = Maybe MessageSender
owner_id_
      , exclude_unsaved :: GetReceivedGifts -> Maybe Bool
exclude_unsaved        = Maybe Bool
exclude_unsaved_
      , exclude_saved :: GetReceivedGifts -> Maybe Bool
exclude_saved          = Maybe Bool
exclude_saved_
      , exclude_unlimited :: GetReceivedGifts -> Maybe Bool
exclude_unlimited      = Maybe Bool
exclude_unlimited_
      , exclude_limited :: GetReceivedGifts -> Maybe Bool
exclude_limited        = Maybe Bool
exclude_limited_
      , exclude_upgraded :: GetReceivedGifts -> Maybe Bool
exclude_upgraded       = Maybe Bool
exclude_upgraded_
      , sort_by_price :: GetReceivedGifts -> Maybe Bool
sort_by_price          = Maybe Bool
sort_by_price_
      , offset :: GetReceivedGifts -> Maybe Text
offset                 = Maybe Text
offset_
      , limit :: GetReceivedGifts -> Maybe Int
limit                  = Maybe Int
limit_
      }
        = String
"GetReceivedGifts"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"business_connection_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
business_connection_id_
          , String
"owner_id"               String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
owner_id_
          , String
"exclude_unsaved"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_unsaved_
          , String
"exclude_saved"          String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_saved_
          , String
"exclude_unlimited"      String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_unlimited_
          , String
"exclude_limited"        String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_limited_
          , String
"exclude_upgraded"       String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
exclude_upgraded_
          , String
"sort_by_price"          String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
sort_by_price_
          , 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 GetReceivedGifts where
  toJSON :: GetReceivedGifts -> Value
toJSON
    GetReceivedGifts
      { business_connection_id :: GetReceivedGifts -> Maybe Text
business_connection_id = Maybe Text
business_connection_id_
      , owner_id :: GetReceivedGifts -> Maybe MessageSender
owner_id               = Maybe MessageSender
owner_id_
      , exclude_unsaved :: GetReceivedGifts -> Maybe Bool
exclude_unsaved        = Maybe Bool
exclude_unsaved_
      , exclude_saved :: GetReceivedGifts -> Maybe Bool
exclude_saved          = Maybe Bool
exclude_saved_
      , exclude_unlimited :: GetReceivedGifts -> Maybe Bool
exclude_unlimited      = Maybe Bool
exclude_unlimited_
      , exclude_limited :: GetReceivedGifts -> Maybe Bool
exclude_limited        = Maybe Bool
exclude_limited_
      , exclude_upgraded :: GetReceivedGifts -> Maybe Bool
exclude_upgraded       = Maybe Bool
exclude_upgraded_
      , sort_by_price :: GetReceivedGifts -> Maybe Bool
sort_by_price          = Maybe Bool
sort_by_price_
      , offset :: GetReceivedGifts -> Maybe Text
offset                 = Maybe Text
offset_
      , limit :: GetReceivedGifts -> 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
"getReceivedGifts"
          , Key
"business_connection_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
business_connection_id_
          , Key
"owner_id"               Key -> Maybe MessageSender -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe MessageSender
owner_id_
          , Key
"exclude_unsaved"        Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_unsaved_
          , Key
"exclude_saved"          Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_saved_
          , Key
"exclude_unlimited"      Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_unlimited_
          , Key
"exclude_limited"        Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_limited_
          , Key
"exclude_upgraded"       Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
exclude_upgraded_
          , Key
"sort_by_price"          Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
sort_by_price_
          , 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_
          ]

defaultGetReceivedGifts :: GetReceivedGifts
defaultGetReceivedGifts :: GetReceivedGifts
defaultGetReceivedGifts =
  GetReceivedGifts
    { business_connection_id :: Maybe Text
business_connection_id = Maybe Text
forall a. Maybe a
Nothing
    , owner_id :: Maybe MessageSender
owner_id               = Maybe MessageSender
forall a. Maybe a
Nothing
    , exclude_unsaved :: Maybe Bool
exclude_unsaved        = Maybe Bool
forall a. Maybe a
Nothing
    , exclude_saved :: Maybe Bool
exclude_saved          = Maybe Bool
forall a. Maybe a
Nothing
    , exclude_unlimited :: Maybe Bool
exclude_unlimited      = Maybe Bool
forall a. Maybe a
Nothing
    , exclude_limited :: Maybe Bool
exclude_limited        = Maybe Bool
forall a. Maybe a
Nothing
    , exclude_upgraded :: Maybe Bool
exclude_upgraded       = Maybe Bool
forall a. Maybe a
Nothing
    , sort_by_price :: Maybe Bool
sort_by_price          = Maybe Bool
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
    }