Current section

Files

Jump to
mollie_api lib mollie_api api invoices_api.ex
Raw

lib/mollie_api/api/invoices_api.ex

# NOTE: This file is auto generated by OpenAPI Generator 7.17.0 (https://openapi-generator.tech).
# Do not edit this file manually.
defmodule MollieAPI.Api.InvoicesAPI do
@moduledoc """
API calls for all endpoints tagged `InvoicesAPI`.
"""
alias MollieAPI.Connection
import MollieAPI.RequestBuilder
@doc """
Get invoice
Retrieve a single invoice by its ID. If you want to retrieve the details of an invoice by its invoice number, call the [List invoices](list-invoices) endpoint with the `reference` parameter.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `invoice_id` (String.t): Provide the ID of the related invoice.
- `opts` (keyword): Optional parameters
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
### Returns
- `{:ok, MollieAPI.Model.EntityInvoice.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_invoice(Tesla.Env.client, String.t, keyword()) :: {:ok, MollieAPI.Model.ErrorResponse.t} | {:ok, MollieAPI.Model.EntityInvoice.t} | {:error, Tesla.Env.t}
def get_invoice(connection, invoice_id, opts \\ []) do
optional_params = %{
:"idempotency-key" => :headers
}
request =
%{}
|> method(:get)
|> url("/invoices/#{invoice_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, MollieAPI.Model.EntityInvoice},
{404, MollieAPI.Model.ErrorResponse}
])
end
@doc """
List invoices
Retrieve a list of all your invoices, optionally filtered by year or by invoice reference. The results are paginated.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `:reference` (String.t): Filter for an invoice with a specific invoice reference, for example `2024.10000`.
- `:year` (String.t): Filter for invoices of a specific year, for example `2024`.
- `:from` (String.t): Provide an ID to start the result set from the item with the given ID and onwards. This allows you to paginate the result set.
- `:limit` (integer()): The maximum number of items to return. Defaults to 50 items.
- `:sort` (Sorting): Used for setting the direction of the result set. Defaults to descending order, meaning the results are ordered from newest to oldest.
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
### Returns
- `{:ok, MollieAPI.Model.ListInvoices200Response.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_invoices(Tesla.Env.client, keyword()) :: {:ok, MollieAPI.Model.ErrorResponse.t} | {:ok, MollieAPI.Model.ListInvoices200Response.t} | {:error, Tesla.Env.t}
def list_invoices(connection, opts \\ []) do
optional_params = %{
:reference => :query,
:year => :query,
:from => :query,
:limit => :query,
:sort => :query,
:"idempotency-key" => :headers
}
request =
%{}
|> method(:get)
|> url("/invoices")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, MollieAPI.Model.ListInvoices200Response},
{400, MollieAPI.Model.ErrorResponse},
{404, MollieAPI.Model.ErrorResponse}
])
end
end