aboutsummaryrefslogtreecommitdiff
path: root/src/client/Server.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Server.elm')
-rw-r--r--src/client/Server.elm115
1 files changed, 0 insertions, 115 deletions
diff --git a/src/client/Server.elm b/src/client/Server.elm
deleted file mode 100644
index c44b777..0000000
--- a/src/client/Server.elm
+++ /dev/null
@@ -1,115 +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.Frequency exposing (Frequency)
-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