@@ -21,6 +21,7 @@ import Control.Lens hiding ((.=))
21
21
import Data.Aeson (FromJSON (.. ), ToJSON (.. ), object , withObject , (.:) , (.=) )
22
22
import Data.Monoid ((<>) )
23
23
import Data.Text (Text )
24
+ import qualified Data.Char as Char
24
25
-- import Data.Text (Text)
25
26
import Data.Typeable (Typeable )
26
27
import GHC.Generics (Generic )
@@ -60,30 +61,33 @@ instance ToSchema WithdrawlRequest where
60
61
--------------------------------------------------------------------------------
61
62
-- | The result of processing a 'WithdrawlRequest'
62
63
data WithdrawlResult =
63
- WithdrawlError ClientError -- ^ Error with http client error
64
+ WithdrawlError Text -- ^ Error with http client error
64
65
| WithdrawlSuccess Transaction -- ^ Success with transaction details
65
66
deriving (Show , Typeable , Generic )
66
67
67
68
instance ToJSON WithdrawlResult where
68
69
toJSON (WithdrawlSuccess txn) =
69
70
object [" success" .= txn]
70
71
toJSON (WithdrawlError err) =
71
- object [" error" .= show err]
72
+ object [" error" .= err]
72
73
73
74
wdDesc :: Text
74
75
wdDesc = " An object with either a success field containing the transaction or "
75
76
<> " an error field containing the ClientError from the wallet as a string"
76
77
77
78
instance ToSchema WithdrawlResult where
78
- declareNamedSchema _ = do
79
- txnSchema <- declareSchemaRef (Proxy :: Proxy Transaction )
80
- errSchema <- declareSchemaRef (Proxy :: Proxy String )
81
- return $ NamedSchema (Just " WithdrawlResult" ) $ mempty
82
- & type_ .~ SwaggerObject
83
- & properties .~ (mempty
84
- & at " success" ?~ txnSchema
85
- & at " error" ?~ errSchema)
86
- & description .~ (Just $ wdDesc)
79
+ declareNamedSchema = genericDeclareNamedSchema defaultSchemaOptions
80
+ { constructorTagModifier = map Char. toLower . drop (length (" Withdrawl" :: String )) }
81
+ & mapped. mapped. schema. description ?~ wdDesc
82
+ -- declareNamedSchema _ = do
83
+ -- txnSchema <- declareSchemaRef (Proxy :: Proxy Transaction)
84
+ -- errSchema <- declareSchemaRef (Proxy :: Proxy Char)
85
+ -- return $ NamedSchema (Just "WithdrawlResult") $ mempty
86
+ -- & type_ .~ SwaggerObject
87
+ -- & properties .~ (mempty
88
+ -- & at "success" ?~ txnSchema
89
+ -- & at "error" ?~ errSchema)
90
+ -- & description .~ (Just $ wdDesc)
87
91
88
92
--------------------------------------------------------------------------------
89
93
-- | A request to deposit ADA back into the wallet __not currently used__
0 commit comments