module TD.Query.ConnectAffiliateProgram
  (ConnectAffiliateProgram(..)
  , defaultConnectAffiliateProgram
  ) 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

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

instance I.ShortShow ConnectAffiliateProgram where
  shortShow :: ConnectAffiliateProgram -> String
shortShow
    ConnectAffiliateProgram
      { affiliate :: ConnectAffiliateProgram -> Maybe AffiliateType
affiliate   = Maybe AffiliateType
affiliate_
      , bot_user_id :: ConnectAffiliateProgram -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      }
        = String
"ConnectAffiliateProgram"
          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 ConnectAffiliateProgram where
  toJSON :: ConnectAffiliateProgram -> Value
toJSON
    ConnectAffiliateProgram
      { affiliate :: ConnectAffiliateProgram -> Maybe AffiliateType
affiliate   = Maybe AffiliateType
affiliate_
      , bot_user_id :: ConnectAffiliateProgram -> 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
"connectAffiliateProgram"
          , 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_
          ]

defaultConnectAffiliateProgram :: ConnectAffiliateProgram
defaultConnectAffiliateProgram :: ConnectAffiliateProgram
defaultConnectAffiliateProgram =
  ConnectAffiliateProgram
    { 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
    }