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
Sets the customer access token to the request
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
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
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
after_id(id)
after_id(request, id)
Sets the pagination cursor to the given id. See https://documentation.ibanity.com/api#pagination
application(name)
Creates a new request and sets the application name
See application/2
.
application(request, name)
Sets the request's application name
attribute(attribute, value)
Creates a new request and adds the attribute and its value to it
attribute(request, attribute, value)
Adds an attribute to a request. Overrides existing attribute with the same name
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
attributes(request, attributes)
Adds the attributes and their corresponding value to the request, all at once. Override existing attributes with the same name
before_id(id)
before_id(request, id)
Sets the pagination cursor to the given id. See https://documentation.ibanity.com/api#pagination
customer_access_token(token)
Creates a new request and sets the customer access token to it
customer_access_token(request, access)
Sets the customer access token to the request
get_header(request, header)
Fetches a header from the request
get_id(request, id)
Fetches an id from the request
has_customer_access_token?(request)
has_header?(request, header)
Checks if the request contains a specific header.
has_id?(request, id)
Checks if the request contains a specific id.
header(header, value)
Creates a new request and adds a header to it.
Same as header(%Request{}, header, value)
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"],
...
}
headers(headers)
Creates a new request and adds headers to it.
Same as headers(%Request{}, headers)
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"
],
...
}
id(value)
Creates a new request and sets the :id
URI identifier.
It is equivalent to id(:id, value)
.
id(request, value)
Creates a new request and adds an URI identifier to it.
id(request, name, value)
Sets the URI identifier to its corresponding value. Overrides existing value if identifier's already present
idempotency_key(key)
Creates a new Ibanity.Request
and sets the idempotency key to it
idempotency_key(request, key)
Sets the idempotency key to the request
ids(ids)
Creates a new request and add multiple URI identifiers at once.
ids(request, ids)
Sets URI template identifiers to their corresponding values. Overrides existing values if identifiers are already present
limit(max)
limit(request, max)
Sets the maximum number of items to fetch at once. See https://documentation.ibanity.com/api#pagination
meta(request, meta)
page_number(value)
page_number(request, value)
Sets the page of results to fetch using page-based pagination. See https://documentation.ibanity.com/api#page-based-pagination
page_size(value)
page_size(request, value)
Sets the maximum number of results to fetch per page. See https://documentation.ibanity.com/api#page-based-pagination
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
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
resource_type(type)
Creates a new request and sets the resource type to it.
resource_type(request, type)
Sets the resource type to the request.