diff options
author | Joris | 2016-04-04 01:27:36 +0200 |
---|---|---|
committer | Joris | 2016-04-04 01:27:36 +0200 |
commit | 8cd63a64abafe21378c35c2489d49f24c9ece3c9 (patch) | |
tree | 541145481d1492f3e388002d931cb3f8fec0acb2 /src/client/elm/Server.elm | |
parent | 01e4ce0fa7c369996ec4ef3a033d16d6fa0eb715 (diff) |
Add income list CRUD in user page
Diffstat (limited to 'src/client/elm/Server.elm')
-rw-r--r-- | src/client/elm/Server.elm | 22 |
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" |