aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Server.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Server.elm')
-rw-r--r--src/client/elm/Server.elm22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/client/elm/Server.elm b/src/client/elm/Server.elm
index be052bb..36adb33 100644
--- a/src/client/elm/Server.elm
+++ b/src/client/elm/Server.elm
@@ -2,7 +2,8 @@ module Server
( signIn
, addPayment
, deletePayment
- , setIncome
+ , addIncome
+ , deleteIncome
, signOut
) where
@@ -10,7 +11,7 @@ import Signal
import Task as Task exposing (Task)
import Http
import Json.Decode as Json exposing ((:=))
-import Date
+import Date exposing (Date)
import Utils.Http exposing (..)
@@ -29,16 +30,21 @@ addPayment name cost frequency =
post ("/api/payment/add?name=" ++ name ++ "&cost=" ++ cost ++ "&frequency=" ++ (toString frequency))
|> flip Task.andThen (decodeHttpValue <| "id" := paymentIdDecoder)
-deletePayment : Payment -> Frequency -> Task Http.Error ()
-deletePayment payment frequency =
- post ("/api/payment/delete?id=" ++ (toString payment.id))
+deletePayment : PaymentId -> Task Http.Error ()
+deletePayment paymentId =
+ delete ("/api/payment/delete?id=" ++ (toString paymentId))
|> Task.map (always ())
-setIncome : Int -> Task Http.Error IncomeId
-setIncome amount =
- post ("/api/income?amount=" ++ (toString amount))
+addIncome : Date -> Int -> Task Http.Error IncomeId
+addIncome creation amount =
+ post ("/api/income?creation=" ++ (toString << Date.toTime <| creation) ++ "&amount=" ++ (toString amount))
|> flip Task.andThen (decodeHttpValue <| "id" := incomeIdDecoder)
+deleteIncome : IncomeId -> Task Http.Error ()
+deleteIncome incomeId =
+ delete ("/api/income/delete?id=" ++ (toString incomeId))
+ |> Task.map (always ())
+
signOut : Task Http.Error ()
signOut =
post "/api/signOut"