Ibanity.Request (ibanity v0.12.0)

Abstraction layer that eases the construction of an HTTP request.

Most of the functions come in two flavors. Those with a Ibanity.Request as first argument modify return a modified version of it, and those without one first create a base Ibanity.Request and modify it afterwards. The only purpose of this mechanism is to ease the construction of a request.

Note that all functions of this module return a Ibanity.Request. None of them can directly fail, and they can therefore be used with the pipe operator.

Link to this section Summary

Functions

Sets the pagination cursor to the given id. See https://documentation.ibanity.com/api#pagination

Creates a new request and sets the application name

Sets the request's application name

Creates a new request and adds the attribute and its value to it

Adds an attribute to a request. Overrides existing attribute with the same name

Creates a new request and adds the attributes and their corresponding value to it, all at once. Override existing attributes with the same name

Adds the attributes and their corresponding value to the request, all at once. Override existing attributes with the same name

Sets the pagination cursor to the given id. See https://documentation.ibanity.com/api#pagination

Creates a new request and sets the customer access token to it

Fetches a header from the request

Fetches an id from the request

Checks if the request contains a specific header.

Checks if the request contains a specific id.

Creates a new request and adds a header to it.

Adds a header to a request. Override existing header with the same name if it is present.

Creates a new request and adds headers to it.

Adds multiple headers to a request, all at once. Override existing headers with the same name if they are present.

Creates a new request and sets the :id URI identifier. It is equivalent to id(:id, value).

Creates a new request and adds an URI identifier to it.

Sets the URI identifier to its corresponding value. Overrides existing value if identifier's already present

Creates a new Ibanity.Request and sets the idempotency key to it

Creates a new request and add multiple URI identifiers at once.

Sets URI template identifiers to their corresponding values. Overrides existing values if identifiers are already present

Sets the maximum number of items to fetch at once. See https://documentation.ibanity.com/api#pagination

Sets the page of results to fetch using page-based pagination. See https://documentation.ibanity.com/api#page-based-pagination

Sets the maximum number of results to fetch per page. See https://documentation.ibanity.com/api#page-based-pagination

Creates a new request and adds the query params and their corresponding values to it, all at once. Overrides existing query params with the same name

Adds the query params and their corresponding values to the request, all at once. Overrides existing query params with the same name

Creates a new request and sets the resource type to it.

Sets the resource type to the request.

Link to this section Functions

Link to this function

after_id(request, id)

Sets the pagination cursor to the given id. See https://documentation.ibanity.com/api#pagination

Link to this function

application(name)

Creates a new request and sets the application name

See application/2.

Link to this function

application(request, name)

Sets the request's application name

Link to this function

attribute(attribute, value)

Creates a new request and adds the attribute and its value to it

Link to this function

attribute(request, attribute, value)

Adds an attribute to a request. Overrides existing attribute with the same name

Link to this function

attributes(attributes)

Creates a new request and adds the attributes and their corresponding value to it, all at once. Override existing attributes with the same name

Link to this function

attributes(request, attributes)

Adds the attributes and their corresponding value to the request, all at once. Override existing attributes with the same name

Link to this function

before_id(request, id)

Sets the pagination cursor to the given id. See https://documentation.ibanity.com/api#pagination

Link to this function

customer_access_token(token)

Creates a new request and sets the customer access token to it

Link to this function

customer_access_token(request, access)

Sets the customer access token to the request

Link to this function

get_header(request, header)

Fetches a header from the request

Link to this function

get_id(request, id)

Fetches an id from the request

Link to this function

has_customer_access_token?(request)

Link to this function

has_header?(request, header)

Checks if the request contains a specific header.

Link to this function

has_id?(request, id)

Checks if the request contains a specific id.

Link to this function

header(header, value)

Creates a new request and adds a header to it.

Same as header(%Request{}, header, value)

Link to this function

header(request, header, value)

Adds a header to a request. Override existing header with the same name if it is present.

examples

Examples

iex> header(%Request{}, :"X-Http-Dummy", "1708ef66-d37d-4ce0-85d8-6c062863418a")
%Ibanity.Request{
  headers: [
    Accept: "application/json",
    "Content-Type": "application/json",
    "X-Http-Dummy": "1708ef66-d37d-4ce0-85d8-6c062863418a"
  ],
  ...
}

iex> %Request{headers: ["X-Http-Dummy": "1708ef66-d37d-4ce0-85d8-6c062863418a"]}
...> |> header(:"X-Http-Dummy", "396c66d5-daf6-48ff-ba4a-58b9be319ec5")
%Ibanity.Request{
  headers: ["X-Http-Dummy": "396c66d5-daf6-48ff-ba4a-58b9be319ec5"],
  ...
}
Link to this function

headers(headers)

Creates a new request and adds headers to it.

Same as headers(%Request{}, headers)

Link to this function

headers(request, headers)

Adds multiple headers to a request, all at once. Override existing headers with the same name if they are present.

examples

Examples

iex> headers(%Request{}, ["X-Dummy1": "1708ef66", "X-Dummy2": "28207dbe"])
%Ibanity.Request{
  headers: [
    Accept: "application/json",
    "Content-Type": "application/json",
    "X-Dummy1": "1708ef66",
    "X-Dummy2": "28207dbe"
  ],
  ...
}

iex> %Request{headers: ["X-Dummy1": "1708ef66", "X-Dummy2": "28207dbe"]}
...> |> headers(["X-Dummy1": "1708ef66", "X-Dummy3": "5127d068"])
%Ibanity.Request{
  headers: [
    "X-Dummy2": "28207dbe",
    "X-Dummy1": "1708ef66",
    "X-Dummy3": "5127d068"
  ],
  ...
}

Creates a new request and sets the :id URI identifier. It is equivalent to id(:id, value).

Link to this function

id(request, value)

Creates a new request and adds an URI identifier to it.

Link to this function

id(request, name, value)

Sets the URI identifier to its corresponding value. Overrides existing value if identifier's already present

Link to this function

idempotency_key(key)

Creates a new Ibanity.Request and sets the idempotency key to it

Link to this function

idempotency_key(request, key)

Sets the idempotency key to the request

Creates a new request and add multiple URI identifiers at once.

Link to this function

ids(request, ids)

Sets URI template identifiers to their corresponding values. Overrides existing values if identifiers are already present

Link to this function

limit(request, max)

Sets the maximum number of items to fetch at once. See https://documentation.ibanity.com/api#pagination

Link to this function

meta(request, meta)

Link to this function

page_number(value)

Link to this function

page_number(request, value)

Sets the page of results to fetch using page-based pagination. See https://documentation.ibanity.com/api#page-based-pagination

Link to this function

page_size(value)

Link to this function

page_size(request, value)

Sets the maximum number of results to fetch per page. See https://documentation.ibanity.com/api#page-based-pagination

Link to this function

query_params(query_params)

Creates a new request and adds the query params and their corresponding values to it, all at once. Overrides existing query params with the same name

Link to this function

query_params(request, query_params)

Adds the query params and their corresponding values to the request, all at once. Overrides existing query params with the same name

Link to this function

resource_type(type)

Creates a new request and sets the resource type to it.

Link to this function

resource_type(request, type)

Sets the resource type to the request.