module TD.Query.GetConnectedAffiliatePrograms
  (GetConnectedAffiliatePrograms(..)
  , defaultGetConnectedAffiliatePrograms
  ) 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
import qualified Data.Text as T

-- | Returns affiliate programs that were connected to the given affiliate. Returns 'TD.Data.ConnectedAffiliatePrograms.ConnectedAffiliatePrograms'
data GetConnectedAffiliatePrograms
  = GetConnectedAffiliatePrograms
    { GetConnectedAffiliatePrograms -> Maybe AffiliateType
affiliate :: Maybe AffiliateType.AffiliateType -- ^ The affiliate to which the affiliate program were connected
    , GetConnectedAffiliatePrograms -> Maybe Text
offset    :: Maybe T.Text                      -- ^ Offset of the first affiliate program to return as received from the previous request; use empty string to get the first chunk of results
    , GetConnectedAffiliatePrograms -> Maybe Int
limit     :: Maybe Int                         -- ^ The maximum number of affiliate programs to return
    }
  deriving (GetConnectedAffiliatePrograms
-> GetConnectedAffiliatePrograms -> Bool
(GetConnectedAffiliatePrograms
 -> GetConnectedAffiliatePrograms -> Bool)
-> (GetConnectedAffiliatePrograms
    -> GetConnectedAffiliatePrograms -> Bool)
-> Eq GetConnectedAffiliatePrograms
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetConnectedAffiliatePrograms
-> GetConnectedAffiliatePrograms -> Bool
== :: GetConnectedAffiliatePrograms
-> GetConnectedAffiliatePrograms -> Bool
$c/= :: GetConnectedAffiliatePrograms
-> GetConnectedAffiliatePrograms -> Bool
/= :: GetConnectedAffiliatePrograms
-> GetConnectedAffiliatePrograms -> Bool
Eq, Int -> GetConnectedAffiliatePrograms -> ShowS
[GetConnectedAffiliatePrograms] -> ShowS
GetConnectedAffiliatePrograms -> String
(Int -> GetConnectedAffiliatePrograms -> ShowS)
-> (GetConnectedAffiliatePrograms -> String)
-> ([GetConnectedAffiliatePrograms] -> ShowS)
-> Show GetConnectedAffiliatePrograms
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetConnectedAffiliatePrograms -> ShowS
showsPrec :: Int -> GetConnectedAffiliatePrograms -> ShowS
$cshow :: GetConnectedAffiliatePrograms -> String
show :: GetConnectedAffiliatePrograms -> String
$cshowList :: [GetConnectedAffiliatePrograms] -> ShowS
showList :: [GetConnectedAffiliatePrograms] -> ShowS
Show)

instance I.ShortShow GetConnectedAffiliatePrograms where
  shortShow :: GetConnectedAffiliatePrograms -> String
shortShow
    GetConnectedAffiliatePrograms
      { affiliate :: GetConnectedAffiliatePrograms -> Maybe AffiliateType
affiliate = Maybe AffiliateType
affiliate_
      , offset :: GetConnectedAffiliatePrograms -> Maybe Text
offset    = Maybe Text
offset_
      , limit :: GetConnectedAffiliatePrograms -> Maybe Int
limit     = Maybe Int
limit_
      }
        = String
"GetConnectedAffiliatePrograms"
          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
"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 GetConnectedAffiliatePrograms where
  toJSON :: GetConnectedAffiliatePrograms -> Value
toJSON
    GetConnectedAffiliatePrograms
      { affiliate :: GetConnectedAffiliatePrograms -> Maybe AffiliateType
affiliate = Maybe AffiliateType
affiliate_
      , offset :: GetConnectedAffiliatePrograms -> Maybe Text
offset    = Maybe Text
offset_
      , limit :: GetConnectedAffiliatePrograms -> 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
"getConnectedAffiliatePrograms"
          , 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
"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_
          ]

defaultGetConnectedAffiliatePrograms :: GetConnectedAffiliatePrograms
defaultGetConnectedAffiliatePrograms :: GetConnectedAffiliatePrograms
defaultGetConnectedAffiliatePrograms =
  GetConnectedAffiliatePrograms
    { affiliate :: Maybe AffiliateType
affiliate = Maybe AffiliateType
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
    }