module TD.Data.ImportedContacts
(ImportedContacts(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ImportedContacts
= ImportedContacts
{ ImportedContacts -> Maybe [Int]
user_ids :: Maybe [Int]
, ImportedContacts -> Maybe [Int]
importer_count :: Maybe [Int]
}
deriving (ImportedContacts -> ImportedContacts -> Bool
(ImportedContacts -> ImportedContacts -> Bool)
-> (ImportedContacts -> ImportedContacts -> Bool)
-> Eq ImportedContacts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ImportedContacts -> ImportedContacts -> Bool
== :: ImportedContacts -> ImportedContacts -> Bool
$c/= :: ImportedContacts -> ImportedContacts -> Bool
/= :: ImportedContacts -> ImportedContacts -> Bool
Eq, Int -> ImportedContacts -> ShowS
[ImportedContacts] -> ShowS
ImportedContacts -> String
(Int -> ImportedContacts -> ShowS)
-> (ImportedContacts -> String)
-> ([ImportedContacts] -> ShowS)
-> Show ImportedContacts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ImportedContacts -> ShowS
showsPrec :: Int -> ImportedContacts -> ShowS
$cshow :: ImportedContacts -> String
show :: ImportedContacts -> String
$cshowList :: [ImportedContacts] -> ShowS
showList :: [ImportedContacts] -> ShowS
Show)
instance I.ShortShow ImportedContacts where
shortShow :: ImportedContacts -> String
shortShow ImportedContacts
{ user_ids :: ImportedContacts -> Maybe [Int]
user_ids = Maybe [Int]
user_ids_
, importer_count :: ImportedContacts -> Maybe [Int]
importer_count = Maybe [Int]
importer_count_
}
= String
"ImportedContacts"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"user_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
user_ids_
, String
"importer_count" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
importer_count_
]
instance AT.FromJSON ImportedContacts where
parseJSON :: Value -> Parser ImportedContacts
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
"importedContacts" -> Value -> Parser ImportedContacts
parseImportedContacts Value
v
String
_ -> Parser ImportedContacts
forall a. Monoid a => a
mempty
where
parseImportedContacts :: A.Value -> AT.Parser ImportedContacts
parseImportedContacts :: Value -> Parser ImportedContacts
parseImportedContacts = String
-> (Object -> Parser ImportedContacts)
-> Value
-> Parser ImportedContacts
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ImportedContacts" ((Object -> Parser ImportedContacts)
-> Value -> Parser ImportedContacts)
-> (Object -> Parser ImportedContacts)
-> Value
-> Parser ImportedContacts
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [Int]
user_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_ids"
Maybe [Int]
importer_count_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"importer_count"
ImportedContacts -> Parser ImportedContacts
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ImportedContacts -> Parser ImportedContacts)
-> ImportedContacts -> Parser ImportedContacts
forall a b. (a -> b) -> a -> b
$ ImportedContacts
{ user_ids :: Maybe [Int]
user_ids = Maybe [Int]
user_ids_
, importer_count :: Maybe [Int]
importer_count = Maybe [Int]
importer_count_
}
parseJSON Value
_ = Parser ImportedContacts
forall a. Monoid a => a
mempty