aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Server.elm
diff options
context:
space:
mode:
authorJoris2017-03-26 21:10:42 +0200
committerJoris2017-03-26 21:10:42 +0200
commit1e47a7754ca38bd1a6c74765d8378caf68ce4619 (patch)
treed0d9238479dc2529a1b558bbbcde346e7e8c2935 /src/client/elm/Server.elm
parentc0ac16a713c4e53cf6af8e72a6d5f6b8ac5d6456 (diff)
downloadbudget-1e47a7754ca38bd1a6c74765d8378caf68ce4619.tar.gz
budget-1e47a7754ca38bd1a6c74765d8378caf68ce4619.tar.bz2
budget-1e47a7754ca38bd1a6c74765d8378caf68ce4619.zip
Separate client and server watch
Diffstat (limited to 'src/client/elm/Server.elm')
-rw-r--r--src/client/elm/Server.elm114
1 files changed, 0 insertions, 114 deletions
diff --git a/src/client/elm/Server.elm b/src/client/elm/Server.elm
deleted file mode 100644
index 7f25876..0000000
--- a/src/client/elm/Server.elm
+++ /dev/null
@@ -1,114 +0,0 @@
-module Server exposing
- ( signIn
- , createPayment
- , editPayment
- , deletePayment
- , createIncome
- , editIncome
- , deleteIncome
- , createCategory
- , editCategory
- , deleteCategory
- , signOut
- )
-
-import Task as Task exposing (Task)
-import Http exposing (Error)
-import Date
-import Json.Decode as Decode
-import Json.Encode as Encode
-import Date exposing (Date)
-
-import Date.Extra.Format as DateFormat
-
-import Utils.Http as HttpUtils
-
-import Model.Payment exposing (..)
-import Model.Income exposing (incomeIdDecoder, IncomeId)
-import Model.Category exposing (categoryIdDecoder, CategoryId)
-import Model.User exposing (Users, usersDecoder, UserId, userIdDecoder)
-import Model.Init exposing (Init)
-
-signIn : String -> (Result Error String -> msg) -> Cmd msg
-signIn email = HttpUtils.request "POST" ("/signIn?email=" ++ email) Http.expectString
-
-createPayment : String -> Int -> Date -> CategoryId -> Frequency -> (Result Error PaymentId -> msg) -> Cmd msg
-createPayment name cost date categoryId frequency handleResult =
- let json =
- Encode.object
- [ ("name", Encode.string name)
- , ("cost", Encode.int cost)
- , ("date", Encode.string (DateFormat.isoDateString date))
- , ("category", Encode.int categoryId)
- , ("frequency", Encode.string (toString frequency))
- ]
- expect = Http.expectJson (Decode.field "id" paymentIdDecoder)
- in HttpUtils.jsonRequest "POST" "/payment" expect handleResult json
-
-editPayment : PaymentId -> String -> Int -> Date -> CategoryId -> Frequency -> (Result Error String -> msg) -> Cmd msg
-editPayment paymentId name cost date categoryId frequency handleResult =
- let json =
- Encode.object
- [ ("id", Encode.int paymentId)
- , ("name", Encode.string name)
- , ("cost", Encode.int cost)
- , ("date", Encode.string (DateFormat.isoDateString date))
- , ("category", Encode.int categoryId)
- , ("frequency", Encode.string (toString frequency))
- ]
- in HttpUtils.jsonRequest "PUT" "/payment" Http.expectString handleResult json
-
-deletePayment : PaymentId -> (Result Error String -> msg) -> Cmd msg
-deletePayment paymentId =
- HttpUtils.request "DELETE" ("/payment?id=" ++ (toString paymentId)) Http.expectString
-
-createIncome : Int -> Date -> (Result Error IncomeId -> msg) -> Cmd msg
-createIncome amount date handleResult =
- let json =
- Encode.object
- [ ("amount", Encode.int amount)
- , ("date", Encode.string (DateFormat.isoDateString date))
- ]
- expect = Http.expectJson (Decode.field "id" incomeIdDecoder)
- in HttpUtils.jsonRequest "POST" "/income" expect handleResult json
-
-editIncome : IncomeId -> Int -> Date -> (Result Error String -> msg) -> Cmd msg
-editIncome incomeId amount date handleResult =
- let json =
- Encode.object
- [ ("id", Encode.int incomeId)
- , ("amount", Encode.int amount)
- , ("date", Encode.string (DateFormat.isoDateString date))
- ]
- in HttpUtils.jsonRequest "PUT" "/income" Http.expectString handleResult json
-
-deleteIncome : IncomeId -> (Result Error String -> msg) -> Cmd msg
-deleteIncome incomeId =
- HttpUtils.request "DELETE" ("/income?id=" ++ (toString incomeId)) Http.expectString
-
-createCategory : String -> String -> (Result Error CategoryId -> msg) -> Cmd msg
-createCategory name color handleResult =
- let json =
- Encode.object
- [ ("name", Encode.string name)
- , ("color", Encode.string color)
- ]
- expect = Http.expectJson (Decode.field "id" categoryIdDecoder)
- in HttpUtils.jsonRequest "POST" "/category" expect handleResult json
-
-editCategory : CategoryId -> String -> String -> (Result Error String -> msg) -> Cmd msg
-editCategory categoryId name color handleResult =
- let json =
- Encode.object
- [ ("id", Encode.int categoryId)
- , ("name", Encode.string name)
- , ("color", Encode.string color)
- ]
- in HttpUtils.jsonRequest "PUT" "/category" Http.expectString handleResult json
-
-deleteCategory : CategoryId -> (Result Error String -> msg) -> Cmd msg
-deleteCategory categoryId =
- HttpUtils.request "DELETE" ("/category?id=" ++ (toString categoryId)) Http.expectString
-
-signOut : (Result Error String -> msg) -> Cmd msg
-signOut = HttpUtils.request "POST" "/signOut" Http.expectString