ParseClient.Requests
Handles the requests for ParseClient.
Uses HTTPoison.
Summary
delete(url, headers \\ [], options \\ []) | |
get(url, headers \\ [], options \\ []) | |
head(url, headers \\ [], options \\ []) | |
options(url, headers \\ [], options \\ []) | |
parse_filters(filters, options) | Parse options in the query |
patch(url, body, headers \\ [], options \\ []) | |
post(url, body, headers \\ [], options \\ []) | |
process_request_body(body) | Encodes the body and raises an error if it cannot be encoded |
process_response_body(body) | Checks that the body can be decoded and handles any errors. Converts binary response keys to atoms |
process_url(endpoint) | Creates the URL for an endpoint (query) |
put(url, body, headers \\ [], options \\ []) | |
request(method, url, body \\ "", headers \\ [], options \\ []) | Sends an HTTP request. Args:
|
start() | Start httpoison and dependencies |
transformer(target) |
Functions
Specs:
- delete(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- get(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- head(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- options(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- patch(binary, binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.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}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Specs:
- request(atom, binary, binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.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 Returns HTTPoison.Response if successful. Raises HTTPoison.HTTPError if failed.