ex_jira v0.0.5 ExJira.Request View Source

Provides the base request function and helper functions for GET and POST. All request functions return either {:ok, data} or {:error, reason}

Link to this section Summary

Functions

Sends a GET request to the specified resource_path with the specified query_params, returning the subitem with the key specified by the resource parameter. Sends multiple requests if more resources are available

Sends a GET request to the specified resource_path with the specified query_params. Expects a single return item

Sends a POST request to the specified resource_path with the specified query_params (as a string in the form "key1=val1&key2=val2") and the specified payload

Sends a request using the specified method to the specified resource_path with the specified query_params (as a string in the form "key1=val1&key2=val2") and the specified payload

Link to this section Types

Link to this type

request_response() View Source
request_response() :: {:ok, any()} | {:error, any()}

Link to this section Functions

Link to this function

get_all(resource_path, resource, query_params) View Source
get_all(String.t(), String.t(), String.t()) :: request_response()

Sends a GET request to the specified resource_path with the specified query_params, returning the subitem with the key specified by the resource parameter. Sends multiple requests if more resources are available.

Note: REST endpoints that return all entries every time as a top level list and never page (e.g. Project) should use get_one/2 instead.

Examples

iex> Request.get_all("/some/items", "items", "a=b&c=d")
{:ok, [%{"id" => "1002"},%{"id" => "1003"}]}

iex> Request.get_all("/some/failure", "items", "a=b&c=d")
{:error, "aliens"}
Link to this function

get_one(resource_path, query_params) View Source
get_one(String.t(), String.t()) :: request_response()

Sends a GET request to the specified resource_path with the specified query_params. Expects a single return item.

iex> Request.get_one("/one/widget", "c=d&e=f")
{:ok, %{"id" => "1006"}}
Link to this function

post(resource_path, query_params, payload) View Source

Sends a POST request to the specified resource_path with the specified query_params (as a string in the form "key1=val1&key2=val2") and the specified payload.

Link to this function

request(method, resource_path, query_params, payload) View Source

Sends a request using the specified method to the specified resource_path with the specified query_params (as a string in the form "key1=val1&key2=val2") and the specified payload.

Examples

iex> ExJira.Request.request("GET", "/some/item", "a=b&c=d", "")
{:ok, %{"id" => "1001"}}

iex> ExJira.Request.request("GET", "/httpotion/failure", "a=b&c=d", "")
{:error, "some error"}