module TD.Data.ConnectedAffiliateProgram
(ConnectedAffiliateProgram(..)) 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.AffiliateProgramParameters as AffiliateProgramParameters
data ConnectedAffiliateProgram
= ConnectedAffiliateProgram
{ ConnectedAffiliateProgram -> Maybe Text
url :: Maybe T.Text
, ConnectedAffiliateProgram -> Maybe Int
bot_user_id :: Maybe Int
, ConnectedAffiliateProgram -> Maybe AffiliateProgramParameters
parameters :: Maybe AffiliateProgramParameters.AffiliateProgramParameters
, ConnectedAffiliateProgram -> Maybe Int
connection_date :: Maybe Int
, ConnectedAffiliateProgram -> Maybe Bool
is_disconnected :: Maybe Bool
, ConnectedAffiliateProgram -> Maybe Int
user_count :: Maybe Int
, ConnectedAffiliateProgram -> Maybe Int
revenue_star_count :: Maybe Int
}
deriving (ConnectedAffiliateProgram -> ConnectedAffiliateProgram -> Bool
(ConnectedAffiliateProgram -> ConnectedAffiliateProgram -> Bool)
-> (ConnectedAffiliateProgram -> ConnectedAffiliateProgram -> Bool)
-> Eq ConnectedAffiliateProgram
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConnectedAffiliateProgram -> ConnectedAffiliateProgram -> Bool
== :: ConnectedAffiliateProgram -> ConnectedAffiliateProgram -> Bool
$c/= :: ConnectedAffiliateProgram -> ConnectedAffiliateProgram -> Bool
/= :: ConnectedAffiliateProgram -> ConnectedAffiliateProgram -> Bool
Eq, Int -> ConnectedAffiliateProgram -> ShowS
[ConnectedAffiliateProgram] -> ShowS
ConnectedAffiliateProgram -> String
(Int -> ConnectedAffiliateProgram -> ShowS)
-> (ConnectedAffiliateProgram -> String)
-> ([ConnectedAffiliateProgram] -> ShowS)
-> Show ConnectedAffiliateProgram
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConnectedAffiliateProgram -> ShowS
showsPrec :: Int -> ConnectedAffiliateProgram -> ShowS
$cshow :: ConnectedAffiliateProgram -> String
show :: ConnectedAffiliateProgram -> String
$cshowList :: [ConnectedAffiliateProgram] -> ShowS
showList :: [ConnectedAffiliateProgram] -> ShowS
Show)
instance I.ShortShow ConnectedAffiliateProgram where
shortShow :: ConnectedAffiliateProgram -> String
shortShow ConnectedAffiliateProgram
{ url :: ConnectedAffiliateProgram -> Maybe Text
url = Maybe Text
url_
, bot_user_id :: ConnectedAffiliateProgram -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
, parameters :: ConnectedAffiliateProgram -> Maybe AffiliateProgramParameters
parameters = Maybe AffiliateProgramParameters
parameters_
, connection_date :: ConnectedAffiliateProgram -> Maybe Int
connection_date = Maybe Int
connection_date_
, is_disconnected :: ConnectedAffiliateProgram -> Maybe Bool
is_disconnected = Maybe Bool
is_disconnected_
, user_count :: ConnectedAffiliateProgram -> Maybe Int
user_count = Maybe Int
user_count_
, revenue_star_count :: ConnectedAffiliateProgram -> Maybe Int
revenue_star_count = Maybe Int
revenue_star_count_
}
= String
"ConnectedAffiliateProgram"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
url_
, String
"bot_user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_user_id_
, String
"parameters" String -> Maybe AffiliateProgramParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe AffiliateProgramParameters
parameters_
, String
"connection_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
connection_date_
, String
"is_disconnected" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_disconnected_
, String
"user_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_count_
, String
"revenue_star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
revenue_star_count_
]
instance AT.FromJSON ConnectedAffiliateProgram where
parseJSON :: Value -> Parser ConnectedAffiliateProgram
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"connectedAffiliateProgram" -> Value -> Parser ConnectedAffiliateProgram
parseConnectedAffiliateProgram Value
v
String
_ -> Parser ConnectedAffiliateProgram
forall a. Monoid a => a
mempty
where
parseConnectedAffiliateProgram :: A.Value -> AT.Parser ConnectedAffiliateProgram
parseConnectedAffiliateProgram :: Value -> Parser ConnectedAffiliateProgram
parseConnectedAffiliateProgram = String
-> (Object -> Parser ConnectedAffiliateProgram)
-> Value
-> Parser ConnectedAffiliateProgram
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ConnectedAffiliateProgram" ((Object -> Parser ConnectedAffiliateProgram)
-> Value -> Parser ConnectedAffiliateProgram)
-> (Object -> Parser ConnectedAffiliateProgram)
-> Value
-> Parser ConnectedAffiliateProgram
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"url"
Maybe Int
bot_user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"bot_user_id"
Maybe AffiliateProgramParameters
parameters_ <- Object
o Object -> Key -> Parser (Maybe AffiliateProgramParameters)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"parameters"
Maybe Int
connection_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"connection_date"
Maybe Bool
is_disconnected_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_disconnected"
Maybe Int
user_count_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_count"
Maybe Int
revenue_star_count_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"revenue_star_count"
ConnectedAffiliateProgram -> Parser ConnectedAffiliateProgram
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ConnectedAffiliateProgram -> Parser ConnectedAffiliateProgram)
-> ConnectedAffiliateProgram -> Parser ConnectedAffiliateProgram
forall a b. (a -> b) -> a -> b
$ ConnectedAffiliateProgram
{ url :: Maybe Text
url = Maybe Text
url_
, bot_user_id :: Maybe Int
bot_user_id = Maybe Int
bot_user_id_
, parameters :: Maybe AffiliateProgramParameters
parameters = Maybe AffiliateProgramParameters
parameters_
, connection_date :: Maybe Int
connection_date = Maybe Int
connection_date_
, is_disconnected :: Maybe Bool
is_disconnected = Maybe Bool
is_disconnected_
, user_count :: Maybe Int
user_count = Maybe Int
user_count_
, revenue_star_count :: Maybe Int
revenue_star_count = Maybe Int
revenue_star_count_
}
parseJSON Value
_ = Parser ConnectedAffiliateProgram
forall a. Monoid a => a
mempty