-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Simmerl
committed
Mar 9, 2017
1 parent
06ca95a
commit ad100e3
Showing
13 changed files
with
351 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,41 @@ | ||
module Rule.Api exposing (getRule, listRules) | ||
module Rule.Api exposing (deleteRule, getRule, listRules) | ||
|
||
import Http | ||
import RemoteData exposing (WebData, sendRequest) | ||
import Rule.Model exposing (Rule, decode, decodeList) | ||
|
||
|
||
deleteRule : String -> String -> Cmd (WebData Bool) | ||
deleteRule appId ruleId = | ||
Http.request | ||
{ body = Http.emptyBody | ||
, expect = Http.expectStringResponse readDelete | ||
, headers = [] | ||
, method = "DELETE" | ||
, timeout = Nothing | ||
, url = ruleUrl appId ruleId | ||
, withCredentials = False | ||
} | ||
|> sendRequest | ||
|
||
getRule : String -> String -> Cmd (WebData Rule) | ||
getRule appId ruleId = | ||
Http.get ("/api/apps/" ++ appId ++ "/rules/" ++ ruleId) decode | ||
Http.get (ruleUrl appId ruleId) decode | ||
|> sendRequest | ||
|
||
|
||
listRules : String -> Cmd (WebData (List Rule)) | ||
listRules appId = | ||
Http.get ("/api/apps/" ++ appId ++ "/rules") decodeList | ||
|> sendRequest | ||
|
||
readDelete : Http.Response String -> Result String Bool | ||
readDelete response = | ||
if response.status.code == 204 then | ||
Ok True | ||
else | ||
Err response.status.message | ||
|
||
ruleUrl : String -> String -> String | ||
ruleUrl appId ruleId = | ||
"/api/apps/" ++ appId ++ "/rules/" ++ ruleId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.