View Source Ibanity.PontoConnect.Usage (ibanity v1.1.0)

Payment Activation Request API wrapper

NOTE: This resource needs a client token!

See Ibanity.PontoConnect.Token.create/1 to find out how to request a client token.

Summary

Functions

Link to this function

find(request_or_token, ids)

View Source

Find organization's Usage for a given month

Takes a Ibanity.PontoConnect.Token, or a Ibanity.Request with set :token as first argument.

Takes a map with the following keys as second argument:

  • :organization_id: a valid organization ID as string
  • :month: month of a year in the format "[year]-[month]" e.g. "2024-09"

Examples

Attributes

iex> attributes = %{
...>   organization_id: "16e79b57-6113-4292-9bfe-87580ff2b317",
...>   month: "2024-09"
...> }

With client token

iex> Ibanity.PontoConnect.Usage.find(client_token, attributes)
{:ok, %Ibanity.PontoConnect.Usage{account_count: 7}}

With request

iex> client_token
...> |> Ibanity.Request.token()
...> |> Ibanity.Request.application(:my_application)
...> |> Ibanity.PontoConnect.Usage.find(attributes)
{:ok, %Ibanity.PontoConnect.Sandbox.Usage{id: "953934eb-229a-4fd2-8675-07794078cc7d"}}

Error

iex> Ibanity.PontoConnect.Usage.find(client_token, %{organization_id: "does-not-exist", month: "2024-09"})
{:error,
  [
    %{
      "code" => "resourceNotFound",
      "detail" => "The requested resource was not found.",
      "meta" => %{
        "requestId" => "00077F00000184847F0000011F4066E44223327005A",
        "resource" => "Usage"
      }
    }
  ]}