module Network.IPFS.Info.Types (Info (..)) where

import Network.IPFS.Prelude
import Network.IPFS.Peer.Types

data Info = Info
  { Info -> Text
id              :: Text
  , Info -> Text
publicKey       :: Text
  , Info -> [Peer]
addresses       :: [Peer]
  , Info -> Text
agentVersion    :: Text
  , Info -> Text
protocolVersion :: Text
  } deriving (Int -> Info -> ShowS
[Info] -> ShowS
Info -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Info] -> ShowS
$cshowList :: [Info] -> ShowS
show :: Info -> String
$cshow :: Info -> String
showsPrec :: Int -> Info -> ShowS
$cshowsPrec :: Int -> Info -> ShowS
Show, Info -> Info -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Info -> Info -> Bool
$c/= :: Info -> Info -> Bool
== :: Info -> Info -> Bool
$c== :: Info -> Info -> Bool
Eq)

instance FromJSON Info where
  parseJSON :: Value -> Parser Info
parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"IPFS.Info" \Object
obj -> do
    Text
id              <- Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"ID"
    Text
publicKey       <- Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"PublicKey"
    [Peer]
addresses       <- Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"Addresses"
    Text
agentVersion    <- Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"AgentVersion"
    Text
protocolVersion <- Object
obj forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"ProtocolVersion"

    return Info {[Peer]
Text
protocolVersion :: Text
agentVersion :: Text
addresses :: [Peer]
publicKey :: Text
id :: Text
$sel:protocolVersion:Info :: Text
$sel:agentVersion:Info :: Text
$sel:addresses:Info :: [Peer]
$sel:publicKey:Info :: Text
$sel:id:Info :: Text
..}