module TD.Query.GetCountryFlagEmoji
  (GetCountryFlagEmoji(..)
  ) 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 an emoji for the given country. Returns an empty string on failure. Can be called synchronously. Returns 'TD.Data.Text.Text'
data GetCountryFlagEmoji
  = GetCountryFlagEmoji
    { GetCountryFlagEmoji -> Maybe Text
country_code :: Maybe T.Text -- ^ A two-letter ISO 3166-1 alpha-2 country code as received from getCountries
    }
  deriving (GetCountryFlagEmoji -> GetCountryFlagEmoji -> Bool
(GetCountryFlagEmoji -> GetCountryFlagEmoji -> Bool)
-> (GetCountryFlagEmoji -> GetCountryFlagEmoji -> Bool)
-> Eq GetCountryFlagEmoji
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetCountryFlagEmoji -> GetCountryFlagEmoji -> Bool
== :: GetCountryFlagEmoji -> GetCountryFlagEmoji -> Bool
$c/= :: GetCountryFlagEmoji -> GetCountryFlagEmoji -> Bool
/= :: GetCountryFlagEmoji -> GetCountryFlagEmoji -> Bool
Eq, Int -> GetCountryFlagEmoji -> ShowS
[GetCountryFlagEmoji] -> ShowS
GetCountryFlagEmoji -> String
(Int -> GetCountryFlagEmoji -> ShowS)
-> (GetCountryFlagEmoji -> String)
-> ([GetCountryFlagEmoji] -> ShowS)
-> Show GetCountryFlagEmoji
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetCountryFlagEmoji -> ShowS
showsPrec :: Int -> GetCountryFlagEmoji -> ShowS
$cshow :: GetCountryFlagEmoji -> String
show :: GetCountryFlagEmoji -> String
$cshowList :: [GetCountryFlagEmoji] -> ShowS
showList :: [GetCountryFlagEmoji] -> ShowS
Show)

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

instance AT.ToJSON GetCountryFlagEmoji where
  toJSON :: GetCountryFlagEmoji -> Value
toJSON
    GetCountryFlagEmoji
      { country_code :: GetCountryFlagEmoji -> Maybe Text
country_code = Maybe Text
country_code_
      }
        = [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
"getCountryFlagEmoji"
          , Key
"country_code" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
country_code_
          ]