[{"name":"Rails","comment":"\n\n\n## Requests\n\n@docs Error, get, post, put, patch, delete, decodeErrors, decodeRawErrors, request\n\n","unions":[],"aliases":[{"name":"Error","comment":" The kinds of errors a Rails server may return.\n","args":["error"],"type":"{ http : Http.Error, rails : Maybe.Maybe error }"}],"values":[{"name":"decodeErrors","comment":" Decode Rails-specific error information from a [`BadStatus`](http://package.elm-lang.org/packages/elm-lang/http/latest/Http#Error)\nresponse. (That is, a response whose status code is outside the 200 range.)\n\nThis is intended to be used with [`Http.send`](http://package.elm-lang.org/packages/elm-lang/http/1.0.0/Http#send)\nlike so:\n\n    import Dict\n    import Http\n    import Json.Decode exposing (at, list, string)\n    import Json.Encode as Encode\n    import Rails\n    import Rails.Decode\n\n    requestHats : HatStyle -> Cmd Msg\n    requestHats style =\n        let\n            body =\n                [ ( \"style\", encodeHatStyle style ) ]\n                    |> Encode.object\n                    |> Http.jsonBody\n\n            getErrors =\n                at [ \"errors\", \"style\" ] string\n                    |> Rails.decodeErrors\n        in\n        list string\n            |> Rails.post url body\n            |> Http.send (getErrors >> HandleResponse)\n\n","type":"Json.Decode.Decoder railsError -> Result.Result Http.Error success -> Result.Result (Rails.Error railsError) success"},{"name":"decodeRawErrors","comment":" Decode Rails-specific error information from a [`BadStatus`](http://package.elm-lang.org/packages/elm-lang/http/latest/Http#Error)\nresponse. (That is, a response whose status code is outside the 200 range.)\n\nSee also, `decodeErrors`.\n\n","type":"Json.Decode.Decoder railsError -> Http.Error -> Rails.Error railsError"},{"name":"delete","comment":" Send a DELETE request to the given URL. Specify how to decode the response.\n\n    import Http\n    import Json.Decode exposing (list, string, succeed)\n    import Rails\n\n    hats : Cmd msg\n    hats =\n        list hatDecoder\n            |> Rails.delete \"http://example.com/hat-categories/5\" Http.emptyBody\n            |> Http.send HandleResponse\n\n**NOTE:** Rails typically expects an `X-CSRF-Token` header for `DELETE`\nrequests, which this does not include. To have this header included\nautomatically, add [`csrf-xhr`](https://www.npmjs.com/package/csrf-xhr)\nto the page, before your `Elm` program gets initialized.\n\n","type":"String.String -> Http.Body -> Json.Decode.Decoder val -> Http.Request val"},{"name":"get","comment":" Send a GET request to the given URL. Specify how to decode the response.\n\n    import Http\n    import Json.Decode exposing (list, string, succeed)\n    import Rails\n\n    getHats : Cmd msg\n    getHats =\n        list hatDecoder\n            |> Rails.get \"http://example.com/hat-categories.json\"\n            |> Http.send HandleGetHatsResponse\n\n","type":"String.String -> Json.Decode.Decoder val -> Http.Request val"},{"name":"patch","comment":" Send a PATCH request to the given URL. Specify how to decode the response.\n\n    import Http\n    import Json.Decode exposing (list, string, succeed)\n    import Rails\n\n    hats : Cmd msg\n    hats =\n        list hatDecoder\n            |> Rails.patch \"http://example.com/hat-categories/5\" revisedHatData\n            |> Http.send HandleResponse\n\n**NOTE:** Rails typically expects an `X-CSRF-Token` header for `PATCH`\nrequests, which this does not include. To have this header included\nautomatically, add [`csrf-xhr`](https://www.npmjs.com/package/csrf-xhr)\nto the page, before your `Elm` program gets initialized.\n\n","type":"String.String -> Http.Body -> Json.Decode.Decoder val -> Http.Request val"},{"name":"post","comment":" Send a POST request to the given URL. Specify how to decode the response.\n\n    import Http\n    import Json.Decode exposing (list, string, succeed)\n    import Rails\n\n    hats : Cmd msg\n    hats =\n        list hatDecoder\n            |> Rails.post \"http://example.com/hat-categories/new\" Http.emptyBody\n            |> Http.send HandleResponse\n\n**NOTE:** Rails typically expects an `X-CSRF-Token` header for `POST`\nrequests, which this does not include. To have this header included\nautomatically, add [`csrf-xhr`](https://www.npmjs.com/package/csrf-xhr)\nto the page, before your `Elm` program gets initialized.\n\n","type":"String.String -> Http.Body -> Json.Decode.Decoder val -> Http.Request val"},{"name":"put","comment":" Send a PUT request to the given URL. Specify how to decode the response.\n\n    import Http\n    import Json.Decode exposing (list, string, succeed)\n    import Rails\n\n    hats : Cmd msg\n    hats =\n        list hatDecoder\n            |> Rails.put \"http://example.com/hat-categories/5\" revisedHatData\n            |> Http.send HandleResponse\n\n**NOTE:** Rails typically expects an `X-CSRF-Token` header for `PUT`\nrequests, which this does not include. To have this header included\nautomatically, add [`csrf-xhr`](https://www.npmjs.com/package/csrf-xhr)\nto the page, before your `Elm` program gets initialized.\n\n","type":"String.String -> Http.Body -> Json.Decode.Decoder val -> Http.Request val"},{"name":"request","comment":" Wraps `Http.request` while adding the following default headers:\n\n  - `Content-Type` - `\"application/json\"`\n  - `Accept` - `\"application/json, text/javascript, */*; q=0.01\"`\n  - `X-Requested-With` - `\"XMLHttpRequest\"`\n\nYou can specify additional headers in the `headers` field of the configuration record.\n\n    import Dict\n    import Http\n    import Json.Decode exposing (list, string)\n    import Json.Encode as Encode\n    import Rails\n    import Rails.Decode\n\n    hatRequest : HatStyle -> Request (Result (ErrorList Field) Hat)\n    hatRequest style =\n        let\n            body =\n                [ ( \"style\", encodeHatStyle style ) ]\n                    |> Encode.object\n                    |> Http.jsonBody\n        in\n        Rails.request\n            { method = \"POST\"\n            , headers = []\n            , url = url\n            , body = body\n            , expect = Http.expectJson (list string)\n            , timeout = Nothing\n            , withCredentials = False\n            }\n\n**NOTE:** Rails typically expects an `X-CSRF-Token` header for requests other\nthan `GET`, which this does not include. One way to have this header included\nautomatically is to add [`csrf-xhr`](https://www.npmjs.com/package/csrf-xhr)\nto the page, before your `Elm` program gets initialized.\n\n","type":"{ method : String.String, headers : List.List Http.Header, url : String.String, body : Http.Body, expect : Http.Expect a, timeout : Maybe.Maybe Basics.Float, withCredentials : Basics.Bool } -> Http.Request a"}],"binops":[]},{"name":"Rails.Decode","comment":" Types\n\n@docs ErrorList\n\n\n# Decoding\n\n@docs errors\n\n","unions":[],"aliases":[{"name":"ErrorList","comment":" ErrorList is a type alias for a list of `( fields, String )` pairs,\nwhere `field` is a type we can use to reference which fields had errors.\n\n    type Field\n        = Name\n        | Password\n\n    decode : ErrorList Field\n\n","args":["field"],"type":"List.List ( field, String.String )"}],"values":[{"name":"errors","comment":" Decodes errors passed from rails formatted like this:\n\n`{ errors: {errorName: [\"Error String\"] } }`.\n\nThis function takes a Dict that is a map of all the fields you need decoded.\nIt should look like this:\n\n    Dict.fromList\n        [ ( \"school\", School )\n        , ( \"school.name\", SchoolName )\n        , ( \"school.address\", SchoolAddress )\n        , ( \"school.city\", City )\n        , ( \"school.state\", State )\n        , ( \"school.zip\", Zip )\n        , ( \"school.country\", Country )\n        ]\n\n","type":"Dict.Dict String.String field -> Json.Decode.Decoder (Rails.Decode.ErrorList field)"}],"binops":[]}]