ParseClient.Requests
Handles the requests for ParseClient.
Uses HTTPoison.
Summary
Functions
Specs:
- delete(binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Specs:
- delete!(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- get(binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Specs:
- get!(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- head(binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Specs:
- head!(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- options(binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Specs:
- options!(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- patch(binary, binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Specs:
- patch!(binary, binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- post(binary, binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Specs:
- post!(binary, binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Encodes the body and raises an error if it cannot be encoded.
Example
iex> body = %{"job" => "Lumberjack", "clothes" => "stockings"}
...> ParseClient.Requests.process_request_body(body)
~S({"clothes":"stockings","job":"Lumberjack"})
Checks that the body can be decoded and handles any errors. Converts binary response keys to atoms.
Example
iex> body = ~S({"score":42,"objectId":"sOxpug2373","playerName":"Tommy"})
...> ParseClient.Requests.process_response_body(body)
%{score: 42, objectId: "sOxpug2373", playerName: "Tommy"}
Creates the URL for an endpoint (query).
Example
iex> endpoint = "classes/GameScore"
...> ParseClient.Requests.process_url(endpoint)
"https://api.parse.com/1/classes/GameScore"
Specs:
- put(binary, binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Specs:
- put!(binary, binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- request(atom, binary, binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Sends an HTTP request. Args:
- method - HTTP method, atom (:get, :head, :post, :put, :delete, etc.)
- url - URL, binary string or char list
- body - request body, binary string or char list
- headers - HTTP headers, orddict (eg. [{:Accept, "application/json"}])
- options - orddict of options Options:
- timeout - timeout in ms, integer
- stream_to - process id to stream the response
Returns {:ok, Response} or {:ok, AsyncResponse} if successful. {:error, Error} otherwise.