EngageSoftware/elm-dnn-http/2.0.0

NOTE: the latest version is 2.3.1

Engage.Http

Helpers for working with DNN Web API

Types

type alias Config =
{ baseUrl : String
, headers : List Header
}

Configuration type

  • baseUrl the base URL for the HTTP requests
  • headers: list of the headers for the HTTP requests
type Error
= BadUrl String
| Timeout
| NetworkError
| BadStatus Int String
| BadBody String

When a request fails, the Failure value will be one of these. Most of these are copied from Http.Error in the elm/http module.

When there is a BadStatus, both the status code and the body of the response are included. This allows getErrorMessage to retrieve any error message in the response, if they are available.

Http Verbs

get :
Config
-> (RemoteData Error success -> msg)
-> Decoder success
-> { methodName : String
, queryStringParams : List ( String, String )
}
-> Cmd msg

Http GET

Config
-> (RemoteData Error success -> msg)
-> Decoder success
-> { methodName : String
, value : Value
}
-> Cmd msg

Http POST

Config
-> (RemoteData Error success -> msg)
-> Decoder success
-> { methodName : String
, value : Value
}
-> Cmd msg

Http PATCH

put :
Config
-> (RemoteData Error success -> msg)
-> Decoder success
-> { methodName : String
, value : Value
}
-> Cmd msg

Http PUT

Config
-> (RemoteData Error success -> msg)
-> Decoder success
-> { methodName : String
, value : Value
}
-> Cmd msg

Http DELETE

Helper functions

getErrorMessage : { a | localization : Localization } -> Error -> String

Get the localized error message from the Error

Decode/Encoder

configDecoder : Decoder Config

Json decoder for Config

serverErrorDecoder : { a | localization : Localization } -> Decoder String

Json decoder for server error, localized.

multipleServerErrorDecoder : { a | localization : Localization } -> Decoder String

Json decoder for multiple server error messages, localized.

nullDecoder : Decoder ()

Null decoder. Useful for when the server doesn't return any value.