ParseClient.Requests

Handles the requests for ParseClient.

Uses HTTPoison.

Source

Summary

delete!(url, headers \\ [], options \\ [])
delete(url, headers \\ [], options \\ [])
get!(url, headers \\ [], options \\ [])
get(url, headers \\ [], options \\ [])
head!(url, headers \\ [], options \\ [])
head(url, headers \\ [], options \\ [])
options!(url, headers \\ [], options \\ [])
options(url, headers \\ [], options \\ [])
parse_filters(filters, options)

Parse options in the query

patch!(url, body, headers \\ [], options \\ [])
patch(url, body, headers \\ [], options \\ [])
post!(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 \\ [])
put(url, body, headers \\ [], options \\ [])
request!(method, url, body \\ "", headers \\ [], options \\ [])
request(method, url, body \\ "", headers \\ [], options \\ [])

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
start()

Start httpoison and dependencies

transformer(target)

Types

headers :: %{} | [{binary, binary}]

Functions

delete(url, headers \\ [], options \\ [])

Specs:

  • delete(binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Source
delete!(url, headers \\ [], options \\ [])

Specs:

  • delete!(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Source
get(url, headers \\ [], options \\ [])

Specs:

  • get(binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Source
get!(url, headers \\ [], options \\ [])

Specs:

  • get!(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Source
head(url, headers \\ [], options \\ [])

Specs:

  • head(binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Source
head!(url, headers \\ [], options \\ [])

Specs:

  • head!(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Source
options(url, headers \\ [], options \\ [])

Specs:

  • options(binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Source
options!(url, headers \\ [], options \\ [])

Specs:

  • options!(binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Source
parse_filters(filters, options)

Parse options in the query.

Source
patch(url, body, headers \\ [], options \\ [])

Specs:

  • patch(binary, binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Source
patch!(url, body, headers \\ [], options \\ [])

Specs:

  • patch!(binary, binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Source
post(url, body, headers \\ [], options \\ [])

Specs:

  • post(binary, binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Source
post!(url, body, headers \\ [], options \\ [])

Specs:

  • post!(binary, binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Source
process_request_body(body)

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"})
Source
process_response_body(body)

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"}
Source
process_url(endpoint)

Creates the URL for an endpoint (query).

Example

iex> endpoint = "classes/GameScore"
...> ParseClient.Requests.process_url(endpoint)
"https://api.parse.com/1/classes/GameScore"
Source
put(url, body, headers \\ [], options \\ [])

Specs:

  • put(binary, binary, headers, [{atom, any}]) :: {:ok, HTTPoison.Response.t | HTTPoison.AsyncResponse.t} | {:error, HTTPoison.Error.t}
Source
put!(url, body, headers \\ [], options \\ [])

Specs:

  • put!(binary, binary, headers, [{atom, any}]) :: HTTPoison.Response.t | HTTPoison.AsyncResponse.t
Source
request(method, url, body \\ "", headers \\ [], options \\ [])

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.

Source
request!(method, url, body \\ "", headers \\ [], options \\ [])
Source
start()

Start httpoison and dependencies.

Source
transformer(target)

Specs:

  • transformer(pid) :: :ok
Source