aboutsummaryrefslogtreecommitdiff
path: root/src/client/ServerCommunication.elm
diff options
context:
space:
mode:
authorJoris2015-09-05 13:53:36 +0200
committerJoris2015-09-05 13:53:36 +0200
commit3b738e0d4cc65f314da7389d4542ec826ba0f454 (patch)
treeee99236117ad698974c5a6e40ab170f617cb06f3 /src/client/ServerCommunication.elm
parent139d4a103a6a48880e5f12a796033956f223563c (diff)
downloadbudget-3b738e0d4cc65f314da7389d4542ec826ba0f454.tar.gz
budget-3b738e0d4cc65f314da7389d4542ec826ba0f454.tar.bz2
budget-3b738e0d4cc65f314da7389d4542ec826ba0f454.zip
Using UserId instead of UserName to indentify users
Diffstat (limited to 'src/client/ServerCommunication.elm')
-rw-r--r--src/client/ServerCommunication.elm17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/client/ServerCommunication.elm b/src/client/ServerCommunication.elm
index 719a563..5ddcfb9 100644
--- a/src/client/ServerCommunication.elm
+++ b/src/client/ServerCommunication.elm
@@ -11,6 +11,7 @@ import Json.Decode exposing (..)
import Date
import Model.Message exposing (messageDecoder)
+import Model.User exposing (UserId)
import Model.Payment exposing (PaymentId, perPage, paymentsDecoder)
import Update as U
@@ -20,8 +21,8 @@ import Update.Payment as UP
type Communication =
NoCommunication
| SignIn String
- | AddPayment String String Int
- | DeletePayment PaymentId String Int Int
+ | AddPayment UserId String Int
+ | DeletePayment PaymentId UserId Int Int
| UpdatePage Int
| SignOut
@@ -43,10 +44,10 @@ getRequest communication =
Nothing
SignIn login ->
Just (simple "post" ("/signIn?login=" ++ login))
- AddPayment userName paymentName cost ->
+ AddPayment userId paymentName cost ->
Just (simple "post" ("/payment/add?name=" ++ paymentName ++ "&cost=" ++ (toString cost)))
DeletePayment paymentId _ _ _ ->
- Just (simple "post" ("payment/delete?id=" ++ paymentId))
+ Just (simple "post" ("payment/delete?id=" ++ (toString paymentId)))
UpdatePage page ->
Just (updatePageRequest page)
SignOut ->
@@ -73,7 +74,7 @@ serverResult communication response =
Task.succeed U.NoOp
SignIn login ->
Task.succeed (U.UpdateSignIn (ValidLogin login))
- AddPayment userName paymentName cost ->
+ AddPayment userId paymentName cost ->
Http.send Http.defaultSettings (updatePageRequest 1)
|> Task.map (\response ->
if response.status == 200
@@ -81,11 +82,11 @@ serverResult communication response =
decodeResponse
response
paymentsDecoder
- (\payments -> U.UpdatePayment (UP.AddPayment userName cost payments))
+ (\payments -> U.UpdatePayment (UP.AddPayment userId cost payments))
else
U.NoOp
)
- DeletePayment id userName cost currentPage ->
+ DeletePayment id userId cost currentPage ->
Http.send Http.defaultSettings (updatePageRequest currentPage)
|> Task.map (\response ->
if response.status == 200
@@ -93,7 +94,7 @@ serverResult communication response =
decodeResponse
response
paymentsDecoder
- (\payments -> U.UpdatePayment (UP.Remove userName cost payments))
+ (\payments -> U.UpdatePayment (UP.Remove userId cost payments))
else
U.NoOp
)