[
    {
        "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 : Error, rails : 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": "Decoder railsError -> Result Error success -> Result (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": "Decoder railsError -> Error -> 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 -> Body -> Decoder val -> 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 -> Decoder val -> 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 -> Body -> Decoder val -> 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 -> Body -> Decoder val -> 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 -> Body -> Decoder val -> 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. 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": "{ method : String, headers : List Header, url : String, body : Body, expect : Expect a, timeout : Maybe Time, withCredentials : Bool } -> Request a"
            }
        ],
        "binops": []
    },
    {
        "name": "Rails.Decode",
        "comment": " Types\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 ( field, 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 String field -> Decoder (ErrorList field)"
            }
        ],
        "binops": []
    }
]