{-# LANGUAGE DeriveGeneric , DuplicateRecordFields , OverloadedStrings #-} module Lightning.Manifest where import Lightning.Generic import GHC.Generics import Data.Aeson import Data.Text (Text) type Manifest = Value type Dynamic = Bool type Subscription = Text genManifest :: Dynamic -> [Option] -> [RpcMethod] -> [Hook] -> [Notification] -> [Subscription] -> Manifest genManifest d ox rx hx nx sx = object [ "dynamic" .= d , "options" .= ox , "rpcmethods" .= rx , "hooks" .= hx , "notifications" .= nx , "subscriptions" .= sx ] data Option = Option { name :: Text , _type :: Text , _default :: Text , description :: Text , deprecated :: Bool } deriving Generic instance ToJSON Option where toJSON = genericToJSON defaultOptions{fieldLabelModifier = dropWhile (=='_')} data RpcMethod = RpcMethod { name :: Text , usage :: Text , description :: Text , long_description :: Maybe Text , deprecated :: Bool } deriving Generic instance ToJSON RpcMethod where toJSON = genericToJSON defaultOptions{omitNothingFields = True} data Hook = Hook { name :: Text , before :: Maybe Value } deriving Generic instance ToJSON Hook where toJSON = genericToJSON defaultOptions{omitNothingFields = True} data Notification = Notification { __method :: Text } deriving Generic instance ToJSON Notification where toJSON = genericToJSON defaultOptions{fieldLabelModifier = dropWhile (=='_')} data Features = Features { __init :: Text , node :: Text , channel :: Text , invoice :: Text } deriving (Generic, Show) instance ToJSON Features instance FromJSON Features where parseJSON = defaultParse