diff --git a/src/Lib.hs b/src/Lib.hs index 2858cc9cee86e39989951396f6f2f836848bfa4d..3bb7a13b5e6f1f32e2bad739978e4b034757b5e9 100755 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -10,7 +10,7 @@ import GHC.Generics import Data.Aeson import Aws.Lambda import qualified Data.ByteString.Lazy.Char8 as ByteString -import qualified InterestRateReturn +import qualified NetPresentValue -- Input data Event = Event @@ -30,11 +30,11 @@ header = object ["Access-Control-Allow-Origin" .= ("*" :: String)] handler :: Event -> Context () -> IO (Either String Response) handler Event{..} context = do case decode (ByteString.pack body) of - Just inputInterestRateReturn -> + Just inputNetPresentValue -> pure $ Right Response { statusCode = 200 , headers = header - , body = InterestRateReturn.calculateInterestRateReturn inputInterestRateReturn + , body = NetPresentValue.calculateNetPresentValue inputNetPresentValue } Nothing -> pure $ Right Response diff --git a/src/InterestRateReturn.hs b/src/NetPresentValue.hs similarity index 52% rename from src/InterestRateReturn.hs rename to src/NetPresentValue.hs index a38718514466f28ed6d350060290d03080de84c7..f3bb4d5a245598bc3aa6dce85de7333058f45581 100644 --- a/src/InterestRateReturn.hs +++ b/src/NetPresentValue.hs @@ -4,19 +4,19 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} -module InterestRateReturn where +module NetPresentValue where import GHC.Generics import Aws.Lambda import Data.Aeson -data InputInterestRateReturn = InputInterestRateReturn +data InputNetPresentValue = InputNetPresentValue { income_1 :: Int , outcome_1 :: Int } deriving (Generic, FromJSON, ToJSON) -calculateInterestRateReturn :: InputInterestRateReturn -> Int -calculateInterestRateReturn inputInterestRateReturn = p + q +calculateNetPresentValue :: InputNetPresentValue -> Int +calculateNetPresentValue inputNetPresentValue = p + q where - p = income_1 inputInterestRateReturn - q = outcome_1 inputInterestRateReturn \ No newline at end of file + p = income_1 inputNetPresentValue + q = outcome_1 inputNetPresentValue \ No newline at end of file