View Source Ibanity.Request (ibanity v1.1.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.

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.

Sets the token used in some Ponto Connect requests.

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

See application/2.

Link to this function

application(request, name)

View Source

Sets the request's application name

Link to this function

attribute(attribute, value)

View Source

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

Link to this function

attribute(request, attribute, value)

View Source

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

Link to this function

attributes(request, attributes)

View Source

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

Link to this function

customer_access_token(token)

View Source

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

Link to this function

customer_access_token(request, access)

View Source

Sets the customer access token to the request

Link to this function

get_header(request, header)

View Source

Fetches a header from the request

Fetches an id from the request

Link to this function

has_customer_access_token?(request)

View Source
Link to this function

has_header?(request, header)

View Source

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.

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

Link to this function

header(request, header, value)

View Source

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

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"],
  ...
}

Creates a new request and adds headers to it.

Same as headers(%Request{}, headers)

Link to this function

headers(request, headers)

View Source

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

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).

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

Link to this function

id(request, name, value)

View Source

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

Link to this function

idempotency_key(request, key)

View Source

Sets the idempotency key to the request

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

Link to this function

page_number(request, value)

View Source

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(request, value)

View Source

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)

View Source

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)

View Source

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.

Link to this function

resource_type(request, type)

View Source

Sets the resource type to the request.

Link to this function

token(request \\ %__MODULE__{}, token, application \\ :default)

View Source

Sets the token used in some Ponto Connect requests.

Since the token is bound to an application, the application is set to token.application.