# 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.CapturesAPI do @moduledoc """ API calls for all endpoints tagged `CapturesAPI`. """ alias MollieAPI.Connection import MollieAPI.RequestBuilder @doc """ Create capture Capture an *authorized* payment. Some payment methods allow you to first collect a customer's authorization, and capture the amount at a later point. By default, Mollie captures payments automatically. If however you configured your payment with `captureMode: manual`, you can capture the payment using this endpoint after having collected the customer's authorization. ### 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` (EntityCapture): ### Returns - `{:ok, MollieAPI.Model.CaptureResponse.t}` on success - `{:error, Tesla.Env.t}` on failure """ @spec create_capture(Tesla.Env.client, String.t, keyword()) :: {:ok, MollieAPI.Model.CaptureResponse.t} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t} def create_capture(connection, payment_id, opts \\ []) do optional_params = %{ :"idempotency-key" => :headers, :body => :body } request = %{} |> method(:post) |> url("/v2/payments/#{payment_id}/captures") |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) connection |> Connection.request(request) |> evaluate_response([ {201, MollieAPI.Model.CaptureResponse}, {404, MollieAPI.Model.ErrorResponse}, {422, MollieAPI.Model.ErrorResponse}, {429, MollieAPI.Model.ErrorResponse} ]) end @doc """ Get capture Retrieve a single payment capture 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. - `capture_id` (String.t): Provide the ID of the related capture. - `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.CaptureResponse.t}` on success - `{:error, Tesla.Env.t}` on failure """ @spec get_capture(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, MollieAPI.Model.CaptureResponse.t} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t} def get_capture(connection, payment_id, capture_id, opts \\ []) do optional_params = %{ :embed => :query, :testmode => :query, :"idempotency-key" => :headers } request = %{} |> method(:get) |> url("/v2/payments/#{payment_id}/captures/#{capture_id}") |> add_optional_params(optional_params, opts) |> Enum.into([]) connection |> Connection.request(request) |> evaluate_response([ {200, MollieAPI.Model.CaptureResponse}, {404, MollieAPI.Model.ErrorResponse}, {429, MollieAPI.Model.ErrorResponse} ]) end @doc """ List captures Retrieve a list of all captures 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.ListCaptures200Response.t}` on success - `{:error, Tesla.Env.t}` on failure """ @spec list_captures(Tesla.Env.client, String.t, keyword()) :: {:ok, MollieAPI.Model.ErrorResponse.t} | {:ok, MollieAPI.Model.ListCaptures200Response.t} | {:error, Tesla.Env.t} def list_captures(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}/captures") |> add_optional_params(optional_params, opts) |> Enum.into([]) connection |> Connection.request(request) |> evaluate_response([ {200, MollieAPI.Model.ListCaptures200Response}, {400, MollieAPI.Model.ErrorResponse}, {404, MollieAPI.Model.ErrorResponse}, {429, MollieAPI.Model.ErrorResponse} ]) end end