Current section

Files

Jump to
mollie_api lib mollie_api api refunds_api.ex
Raw

lib/mollie_api/api/refunds_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.RefundsAPI do
@moduledoc """
API calls for all endpoints tagged `RefundsAPI`.
"""
alias MollieAPI.Connection
import MollieAPI.RequestBuilder
@doc """
Cancel payment refund
Refunds will be executed with a delay of two hours. Until that time, refunds may be canceled manually via the Mollie Dashboard, or by using this endpoint. A refund can only be canceled while its `status` field is either `queued` or `pending`. See the [Get refund endpoint](get-refund) for more information.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `payment_id` (String.t): Provide the ID of the related payment.
- `refund_id` (String.t): Provide the ID of the related refund.
- `opts` (keyword): Optional parameters
- `:testmode` (boolean()): Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter must not be sent. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec cancel_refund(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def cancel_refund(connection, payment_id, refund_id, opts \\ []) do
optional_params = %{
:testmode => :query,
:"idempotency-key" => :headers
}
request =
%{}
|> method(:delete)
|> url("/v2/payments/#{payment_id}/refunds/#{refund_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{404, MollieAPI.Model.ErrorResponse},
{429, MollieAPI.Model.ErrorResponse}
])
end
@doc """
Create payment refund
Creates a refund for a specific payment. The refunded amount is credited to your customer usually either via a bank transfer or by refunding the amount to your customer's credit card.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `payment_id` (String.t): Provide the ID of the related payment.
- `opts` (keyword): Optional parameters
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
- `:body` (RefundRequest):
### Returns
- `{:ok, MollieAPI.Model.EntityRefundResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_refund(Tesla.Env.client, String.t, keyword()) :: {:ok, MollieAPI.Model.EntityRefundResponse.t} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def create_refund(connection, payment_id, opts \\ []) do
optional_params = %{
:"idempotency-key" => :headers,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/v2/payments/#{payment_id}/refunds")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, MollieAPI.Model.EntityRefundResponse},
{404, MollieAPI.Model.ErrorResponse},
{409, MollieAPI.Model.ErrorResponse},
{422, MollieAPI.Model.ErrorResponse},
{429, MollieAPI.Model.ErrorResponse}
])
end
@doc """
Get payment refund
Retrieve a single payment refund by its ID and the ID of its parent payment.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `payment_id` (String.t): Provide the ID of the related payment.
- `refund_id` (String.t): Provide the ID of the related refund.
- `opts` (keyword): Optional parameters
- `:embed` (String.t): This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
- `:testmode` (boolean()): Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter must not be sent. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
### Returns
- `{:ok, MollieAPI.Model.EntityRefundResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_refund(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, MollieAPI.Model.EntityRefundResponse.t} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def get_refund(connection, payment_id, refund_id, opts \\ []) do
optional_params = %{
:embed => :query,
:testmode => :query,
:"idempotency-key" => :headers
}
request =
%{}
|> method(:get)
|> url("/v2/payments/#{payment_id}/refunds/#{refund_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, MollieAPI.Model.EntityRefundResponse},
{404, MollieAPI.Model.ErrorResponse},
{429, MollieAPI.Model.ErrorResponse}
])
end
@doc """
List all refunds
Retrieve a list of all of your refunds. The results are paginated.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `opts` (keyword): Optional parameters
- `: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.
- `:embed` (String.t): This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
- `:profileId` (String.t): The identifier referring to the [profile](get-profile) you wish to retrieve the resources for. Most API credentials are linked to a single profile. In these cases the `profileId` must not be sent. For organization-level credentials such as OAuth access tokens however, the `profileId` parameter is required.
- `:testmode` (boolean()): Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter must not be sent. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
### Returns
- `{:ok, MollieAPI.Model.ListRefunds200Response.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_all_refunds(Tesla.Env.client, keyword()) :: {:ok, MollieAPI.Model.ErrorResponse.t} | {:ok, MollieAPI.Model.ListRefunds200Response.t} | {:error, Tesla.Env.t}
def list_all_refunds(connection, opts \\ []) do
optional_params = %{
:from => :query,
:limit => :query,
:sort => :query,
:embed => :query,
:profileId => :query,
:testmode => :query,
:"idempotency-key" => :headers
}
request =
%{}
|> method(:get)
|> url("/v2/refunds")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, MollieAPI.Model.ListRefunds200Response},
{400, MollieAPI.Model.ErrorResponse},
{429, MollieAPI.Model.ErrorResponse}
])
end
@doc """
List payment refunds
Retrieve a list of all refunds created for a specific payment. The results are paginated.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `payment_id` (String.t): Provide the ID of the related payment.
- `opts` (keyword): Optional parameters
- `: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.
- `:embed` (String.t): This endpoint allows embedding related API items by appending the following values via the `embed` query string parameter.
- `:testmode` (boolean()): Most API credentials are specifically created for either live mode or test mode. In those cases the `testmode` query parameter must not be sent. For organization-level credentials such as OAuth access tokens, you can enable test mode by setting the `testmode` query parameter to `true`. Test entities cannot be retrieved when the endpoint is set to live mode, and vice versa.
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
### Returns
- `{:ok, MollieAPI.Model.ListRefunds200Response.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_refunds(Tesla.Env.client, String.t, keyword()) :: {:ok, MollieAPI.Model.ErrorResponse.t} | {:ok, MollieAPI.Model.ListRefunds200Response.t} | {:error, Tesla.Env.t}
def list_refunds(connection, payment_id, opts \\ []) do
optional_params = %{
:from => :query,
:limit => :query,
:embed => :query,
:testmode => :query,
:"idempotency-key" => :headers
}
request =
%{}
|> method(:get)
|> url("/v2/payments/#{payment_id}/refunds")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, MollieAPI.Model.ListRefunds200Response},
{400, MollieAPI.Model.ErrorResponse},
{404, MollieAPI.Model.ErrorResponse},
{429, MollieAPI.Model.ErrorResponse}
])
end
end