FabienHenon / jsonapi-http / Http.Request

Http.Request allows you to create http requests with jsonapi objects.

The request functions will return a RemoteData with a jsonapi Document. The content-type used in the request headers is application/vnd.api+json according to the jsonapi specification.

Definitions


type alias Request meta data =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) (JsonApi.Document.Document meta data)) 
}

Defines a Request with a url, some headers, a body, and a jsonapi document decoder. metaand data are types used by the jsonapi document that represent the meta object you would like to decode, and the data object you would like to decode


type alias RequestCustomData data =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) data) 
}

Defines a Request with a url, some headers, a body, and a custom decoder. data is the type of the object you would like to decode.


type alias RequestNoContent =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value 
}

Defines a Request with a url, some headers, and a body. There is no content decoder. Useful for DELETE requests for instance.


type alias RequestFiles meta data msg =
{ url : Http.Url.Url
, headers : List Http.Header
, multipartNames : List String
, files : List File
, multipartEncoder : String -> File -> Http.Part
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) (JsonApi.Document.Document meta data))
, tracker : Maybe String
, msg : RemoteData Http.Error.RequestError (JsonApi.Document.Document meta data) -> msg 
}

Defines a Request with a url, some headers, a list of files, and a custom decoder. data is the type of the object you would like to decode.


type alias RequestAdv meta data =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) (JsonApi.Document.Document meta data))
, risky : Basics.Bool 
}

Defines a RequestAdv with a url, some headers, a body, and a jsonapi document decoder. metaand data are types used by the jsonapi document that represent the meta object you would like to decode, and the data object you would like to decode? Risky uses the withCredentials


type alias RequestEx meta data =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) (JsonApi.Document.Document meta data))
, extractHeaders : List String 
}

Defines a RequestEx with a url, some headers, a body, and a jsonapi document decoder. metaand data are types used by the jsonapi document that represent the meta object you would like to decode, and the data object you would like to decode. You can also extract some response headers to use them later


type alias RequestCustomDataEx data =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) data)
, extractHeaders : List String 
}

Defines a Request with a url, some headers, a body, and a custom decoder. data is the type of the object you would like to decode. You can also extract some response headers to use them later


type alias RequestNoContentEx =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, extractHeaders : List String 
}

Defines a Request with a url, some headers, and a body. There is no content decoder. Useful for DELETE requests for instance. You can also extract some response headers to use them later


type alias RequestFilesEx meta data msg =
{ url : Http.Url.Url
, headers : List Http.Header
, multipartNames : List String
, files : List File
, multipartEncoder : String -> File -> Http.Part
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) (JsonApi.Document.Document meta data))
, tracker : Maybe String
, extractHeaders : List String
, msg : RemoteData ( Http.Error.RequestError
, List ( String
, String ) ) ( JsonApi.Document.Document meta data
, List ( String
, String ) ) -> msg 
}

Defines a Request with a url, some headers, a list of files, and a custom decoder. data is the type of the object you would like to decode. You can also extract some response headers to use them later


type alias RequestAdvEx meta data =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) (JsonApi.Document.Document meta data))
, extractHeaders : List String
, risky : Basics.Bool 
}

Defines a RequestAdvEx with a url, some headers, a body, and a jsonapi document decoder. metaand data are types used by the jsonapi document that represent the meta object you would like to decode, and the data object you would like to decode. You can also extract some response headers to use them later Risky uses the withCredentials


type alias RequestFilesAdv meta data msg =
{ url : Http.Url.Url
, headers : List Http.Header
, multipartNames : List String
, files : List File
, multipartEncoder : String -> File -> Http.Part
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) (JsonApi.Document.Document meta data))
, tracker : Maybe String
, msg : RemoteData Http.Error.RequestError (JsonApi.Document.Document meta data) -> msg
, risky : Basics.Bool 
}

Defines an advance Request with a url, some headers, a list of files, and a custom decoder. data is the type of the object you would like to decode. Risky uses the withCredentials


type alias RequestFilesAdvEx meta data msg =
{ url : Http.Url.Url
, headers : List Http.Header
, multipartNames : List String
, files : List File
, multipartEncoder : String -> File -> Http.Part
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) (JsonApi.Document.Document meta data))
, tracker : Maybe String
, extractHeaders : List String
, msg : RemoteData ( Http.Error.RequestError
, List ( String
, String ) ) ( JsonApi.Document.Document meta data
, List ( String
, String ) ) -> msg
, risky : Basics.Bool 
}

Defines an advance Request with a url, some headers, a list of files, and a custom decoder. data is the type of the object you would like to decode. You can also extract some response headers to use them later Risky uses the withCredentials


type alias RequestCustomDataAdv data =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) data)
, risky : Basics.Bool 
}

Defines an advance Request with a url, some headers, a body, and a custom decoder. data is the type of the object you would like to decode. Risky uses the withCredentials


type alias RequestCustomDataAdvEx data =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, documentDecoder : Json.Decode.Decoder (Result (List JsonApi.Decode.Error) data)
, extractHeaders : List String
, risky : Basics.Bool 
}

Defines an advance Request with a url, some headers, a body, and a custom decoder. data is the type of the object you would like to decode. You can also extract some response headers to use them later Risky uses the withCredentials


type alias RequestNoContentAdv =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, risky : Basics.Bool 
}

Defines a Request with a url, some headers, and a body. There is no content decoder. Useful for DELETE requests for instance. Risky uses the withCredentials


type alias RequestNoContentAdvEx =
{ url : Http.Url.Url
, headers : List Http.Header
, body : Json.Encode.Value
, extractHeaders : List String
, risky : Basics.Bool 
}

Defines a Request with a url, some headers, and a body. There is no content decoder. Useful for DELETE requests for instance. You can also extract some response headers to use them later Risky uses the withCredentials


type AdvanceContent meta data
    = DocumentContent (JsonApi.Document.Document meta data)
    | NoContent

Type used to specify the content received from an advanced request like requestAdv or requestAdvEx Possible values are:

Requests

request : Request meta data -> Task Basics.Never (RemoteData Http.Error.RequestError (JsonApi.Document.Document meta data))

Create a request task that will decode a jsonapi object

requestCustomData : RequestCustomData data -> Task Basics.Never (RemoteData Http.Error.RequestError data)

Create a request task that will decode a custom object

requestNoContent : RequestNoContent -> Task Basics.Never (RemoteData Http.Error.RequestError ())

Create a request task that will expect nothing to decode

requestFiles : RequestFiles meta data msg -> Platform.Cmd.Cmd msg

Create a request files that will decode a jsonapi object

requestAdv : RequestAdv meta data -> Task Basics.Never (RemoteData Http.Error.RequestError (AdvanceContent meta data))

Create an advanced request task that will decode an advance content: a jsonapi document or no content

requestEx : RequestEx meta data -> Task Basics.Never (RemoteData ( Http.Error.RequestError, List ( String, String ) ) ( JsonApi.Document.Document meta data, List ( String, String ) ))

Create a request task that will decode a jsonapi object. It will also return in the msg the list of extracted headers.

requestCustomDataEx : RequestCustomDataEx data -> Task Basics.Never (RemoteData ( Http.Error.RequestError, List ( String, String ) ) ( data, List ( String, String ) ))

Create a request task that will decode a custom object. It will also return in the msg the list of extracted headers.

requestNoContentEx : RequestNoContentEx -> Task Basics.Never (RemoteData ( Http.Error.RequestError, List ( String, String ) ) (List ( String, String )))

Create a request task that will expect nothing to decode. It will also return in the msg the list of extracted headers.

requestFilesEx : RequestFilesEx meta data msg -> Platform.Cmd.Cmd msg

Create a request files that will decode a jsonapi object. It will also return in the msg the list of extracted headers.

requestAdvEx : RequestAdvEx meta data -> Task Basics.Never (RemoteData ( Http.Error.RequestError, List ( String, String ) ) ( AdvanceContent meta data, List ( String, String ) ))

Create a request task that will decode an advance content: a jsonapi document or no content. It will also return in the msg the list of extracted headers.

requestCustomDataAdv : RequestCustomDataAdv data -> Task Basics.Never (RemoteData Http.Error.RequestError data)

Create a request task that will decode a custom object

requestCustomDataAdvEx : RequestCustomDataAdvEx data -> Task Basics.Never (RemoteData ( Http.Error.RequestError, List ( String, String ) ) ( data, List ( String, String ) ))

Create a request task that will decode a custom object. It will also return in the msg the list of extracted headers.

requestFilesAdv : RequestFilesAdv meta data msg -> Platform.Cmd.Cmd msg

Create a request files that will decode a jsonapi object

requestFilesAdvEx : RequestFilesAdvEx meta data msg -> Platform.Cmd.Cmd msg

Create a request files that will decode a jsonapi object. It will also return in the msg the list of extracted headers.

requestNoContentAdv : RequestNoContentAdv -> Task Basics.Never (RemoteData Http.Error.RequestError ())

Create a request task that will expect nothing to decode

requestNoContentAdvEx : RequestNoContentAdvEx -> Task Basics.Never (RemoteData ( Http.Error.RequestError, List ( String, String ) ) (List ( String, String )))

Create a request task that will expect nothing to decode. It will also return in the msg the list of extracted headers.