Current section

Files

Jump to
mollie_api lib mollie_api api mandates_api.ex
Raw

lib/mollie_api/api/mandates_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.MandatesAPI do
@moduledoc """
API calls for all endpoints tagged `MandatesAPI`.
"""
alias MollieAPI.Connection
import MollieAPI.RequestBuilder
@doc """
Create mandate
Create a mandate for a specific customer. Mandates allow you to charge a customer's card, PayPal account or bank account recurrently. It is only possible to create mandates for IBANs and PayPal billing agreements with this endpoint. To create mandates for cards, your customers need to perform a 'first payment' with their card.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `customer_id` (String.t): Provide the ID of the related customer.
- `opts` (keyword): Optional parameters
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
- `:body` (MandateRequest):
### Returns
- `{:ok, MollieAPI.Model.MandateResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec create_mandate(Tesla.Env.client, String.t, keyword()) :: {:ok, MollieAPI.Model.MandateResponse.t} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def create_mandate(connection, customer_id, opts \\ []) do
optional_params = %{
:"idempotency-key" => :headers,
:body => :body
}
request =
%{}
|> method(:post)
|> url("/customers/#{customer_id}/mandates")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{201, MollieAPI.Model.MandateResponse},
{404, MollieAPI.Model.ErrorResponse}
])
end
@doc """
Get mandate
Retrieve a single mandate by its ID. Depending on the type of mandate, the object will contain the customer's bank account details, card details, or PayPal account details.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `customer_id` (String.t): Provide the ID of the related customer.
- `mandate_id` (String.t): Provide the ID of the related mandate.
- `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, MollieAPI.Model.MandateResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec get_mandate(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, MollieAPI.Model.MandateResponse.t} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def get_mandate(connection, customer_id, mandate_id, opts \\ []) do
optional_params = %{
:testmode => :query,
:"idempotency-key" => :headers
}
request =
%{}
|> method(:get)
|> url("/customers/#{customer_id}/mandates/#{mandate_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, MollieAPI.Model.MandateResponse},
{404, MollieAPI.Model.ErrorResponse}
])
end
@doc """
List mandates
Retrieve a list of all mandates. The results are paginated.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `customer_id` (String.t): Provide the ID of the related customer.
- `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.
- `:scopes` ([MollieAPI.Model.MandateScopes.t]): Returns only mandates that include the specified scopes.
- `: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.ListMandates200Response.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec list_mandates(Tesla.Env.client, String.t, keyword()) :: {:ok, MollieAPI.Model.ListMandates200Response.t} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def list_mandates(connection, customer_id, opts \\ []) do
optional_params = %{
:from => :query,
:limit => :query,
:sort => :query,
:scopes => :query,
:testmode => :query,
:"idempotency-key" => :headers
}
request =
%{}
|> method(:get)
|> url("/customers/#{customer_id}/mandates")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, MollieAPI.Model.ListMandates200Response},
{400, MollieAPI.Model.ErrorResponse},
{404, MollieAPI.Model.ErrorResponse}
])
end
@doc """
Revoke mandate
Revoke a customer's mandate. You will no longer be able to charge the customer's bank account or card with this mandate, and all connected subscriptions will be canceled.
### Parameters
- `connection` (MollieAPI.Connection): Connection to server
- `customer_id` (String.t): Provide the ID of the related customer.
- `mandate_id` (String.t): Provide the ID of the related mandate.
- `opts` (keyword): Optional parameters
- `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string.
- `:body` (DeletePaymentLinkRequest):
### Returns
- `{:ok, nil}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec revoke_mandate(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t}
def revoke_mandate(connection, customer_id, mandate_id, opts \\ []) do
optional_params = %{
:"idempotency-key" => :headers,
:body => :body
}
request =
%{}
|> method(:delete)
|> url("/customers/#{customer_id}/mandates/#{mandate_id}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{204, false},
{404, MollieAPI.Model.ErrorResponse}
])
end
end