module TD.Query.GetConnectedAffiliateProgram
  (GetConnectedAffiliateProgram(..)
  , defaultGetConnectedAffiliateProgram
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.AffiliateType as AffiliateType

-- | Returns an affiliate program that were connected to the given affiliate by identifier of the bot that created the program. Returns 'TD.Data.ConnectedAffiliateProgram.ConnectedAffiliateProgram'
data GetConnectedAffiliateProgram
  = GetConnectedAffiliateProgram
    { GetConnectedAffiliateProgram -> Maybe AffiliateType
affiliate   :: Maybe AffiliateType.AffiliateType -- ^ The affiliate to which the affiliate program will be connected
    , GetConnectedAffiliateProgram -> Maybe Int
bot_user_id :: Maybe Int                         -- ^ Identifier of the bot that created the program
    }
  deriving (GetConnectedAffiliateProgram
-> GetConnectedAffiliateProgram -> Bool
(GetConnectedAffiliateProgram
 -> GetConnectedAffiliateProgram -> Bool)
-> (GetConnectedAffiliateProgram
    -> GetConnectedAffiliateProgram -> Bool)
-> Eq GetConnectedAffiliateProgram
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetConnectedAffiliateProgram
-> GetConnectedAffiliateProgram -> Bool
== :: GetConnectedAffiliateProgram
-> GetConnectedAffiliateProgram -> Bool
$c/= :: GetConnectedAffiliateProgram
-> GetConnectedAffiliateProgram -> Bool
/= :: GetConnectedAffiliateProgram
-> GetConnectedAffiliateProgram -> Bool
Eq, Int -> GetConnectedAffiliateProgram -> ShowS
[GetConnectedAffiliateProgram] -> ShowS
GetConnectedAffiliateProgram -> String
(Int -> GetConnectedAffiliateProgram -> ShowS)
-> (GetConnectedAffiliateProgram -> String)
-> ([GetConnectedAffiliateProgram] -> ShowS)
-> Show GetConnectedAffiliateProgram
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetConnectedAffiliateProgram -> ShowS
showsPrec :: Int -> GetConnectedAffiliateProgram -> ShowS
$cshow :: GetConnectedAffiliateProgram -> String
show :: GetConnectedAffiliateProgram -> String
$cshowList :: [GetConnectedAffiliateProgram] -> ShowS
showList :: [GetConnectedAffiliateProgram] -> ShowS
Show)

instance I.ShortShow GetConnectedAffiliateProgram where
  shortShow :: GetConnectedAffiliateProgram -> String
shortShow
    GetConnectedAffiliateProgram
      { affiliate :: GetConnectedAffiliateProgram -> Maybe AffiliateType
affiliate   = Maybe AffiliateType
affiliate_
      , bot_user_id :: GetConnectedAffiliateProgram -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      }
        = String
"GetConnectedAffiliateProgram"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"affiliate"   String -> Maybe AffiliateType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe AffiliateType
affiliate_
          , String
"bot_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_user_id_
          ]

instance AT.ToJSON GetConnectedAffiliateProgram where
  toJSON :: GetConnectedAffiliateProgram -> Value
toJSON
    GetConnectedAffiliateProgram
      { affiliate :: GetConnectedAffiliateProgram -> Maybe AffiliateType
affiliate   = Maybe AffiliateType
affiliate_
      , bot_user_id :: GetConnectedAffiliateProgram -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      }
        = [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
"getConnectedAffiliateProgram"
          , Key
"affiliate"   Key -> Maybe AffiliateType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe AffiliateType
affiliate_
          , Key
"bot_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
bot_user_id_
          ]

defaultGetConnectedAffiliateProgram :: GetConnectedAffiliateProgram
defaultGetConnectedAffiliateProgram :: GetConnectedAffiliateProgram
defaultGetConnectedAffiliateProgram =
  GetConnectedAffiliateProgram
    { affiliate :: Maybe AffiliateType
affiliate   = Maybe AffiliateType
forall a. Maybe a
Nothing
    , bot_user_id :: Maybe Int
bot_user_id = Maybe Int
forall a. Maybe a
Nothing
    }