module TD.Query.GetBackgroundUrl
  (GetBackgroundUrl(..)
  , defaultGetBackgroundUrl
  ) 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.BackgroundType as BackgroundType

-- | Constructs a persistent HTTP URL for a background. Returns 'TD.Data.HttpUrl.HttpUrl'
data GetBackgroundUrl
  = GetBackgroundUrl
    { GetBackgroundUrl -> Maybe Text
name  :: Maybe T.Text                        -- ^ Background name
    , GetBackgroundUrl -> Maybe BackgroundType
_type :: Maybe BackgroundType.BackgroundType -- ^ Background type; backgroundTypeChatTheme isn't supported
    }
  deriving (GetBackgroundUrl -> GetBackgroundUrl -> Bool
(GetBackgroundUrl -> GetBackgroundUrl -> Bool)
-> (GetBackgroundUrl -> GetBackgroundUrl -> Bool)
-> Eq GetBackgroundUrl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetBackgroundUrl -> GetBackgroundUrl -> Bool
== :: GetBackgroundUrl -> GetBackgroundUrl -> Bool
$c/= :: GetBackgroundUrl -> GetBackgroundUrl -> Bool
/= :: GetBackgroundUrl -> GetBackgroundUrl -> Bool
Eq, Int -> GetBackgroundUrl -> ShowS
[GetBackgroundUrl] -> ShowS
GetBackgroundUrl -> String
(Int -> GetBackgroundUrl -> ShowS)
-> (GetBackgroundUrl -> String)
-> ([GetBackgroundUrl] -> ShowS)
-> Show GetBackgroundUrl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetBackgroundUrl -> ShowS
showsPrec :: Int -> GetBackgroundUrl -> ShowS
$cshow :: GetBackgroundUrl -> String
show :: GetBackgroundUrl -> String
$cshowList :: [GetBackgroundUrl] -> ShowS
showList :: [GetBackgroundUrl] -> ShowS
Show)

instance I.ShortShow GetBackgroundUrl where
  shortShow :: GetBackgroundUrl -> String
shortShow
    GetBackgroundUrl
      { name :: GetBackgroundUrl -> Maybe Text
name  = Maybe Text
name_
      , _type :: GetBackgroundUrl -> Maybe BackgroundType
_type = Maybe BackgroundType
_type_
      }
        = String
"GetBackgroundUrl"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"name"  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          , String
"_type" String -> Maybe BackgroundType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BackgroundType
_type_
          ]

instance AT.ToJSON GetBackgroundUrl where
  toJSON :: GetBackgroundUrl -> Value
toJSON
    GetBackgroundUrl
      { name :: GetBackgroundUrl -> Maybe Text
name  = Maybe Text
name_
      , _type :: GetBackgroundUrl -> Maybe BackgroundType
_type = Maybe BackgroundType
_type_
      }
        = [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
"getBackgroundUrl"
          , Key
"name"  Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
          , Key
"type"  Key -> Maybe BackgroundType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe BackgroundType
_type_
          ]

defaultGetBackgroundUrl :: GetBackgroundUrl
defaultGetBackgroundUrl :: GetBackgroundUrl
defaultGetBackgroundUrl =
  GetBackgroundUrl
    { name :: Maybe Text
name  = Maybe Text
forall a. Maybe a
Nothing
    , _type :: Maybe BackgroundType
_type = Maybe BackgroundType
forall a. Maybe a
Nothing
    }