# 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.OAuthAPI do @moduledoc """ API calls for all endpoints tagged `OAuthAPI`. """ alias MollieAPI.Connection import MollieAPI.RequestBuilder @doc """ Generate tokens Exchange the authorization code you received from the [Authorize endpoint](oauth-authorize) for an 'access token' API credential, with which you can communicate with the Mollie API on behalf of the consenting merchant. This endpoint can only be accessed using **OAuth client credentials**. ### Parameters - `connection` (MollieAPI.Connection): Connection to server - `authorization` (String.t): The OAuth client ID and client secret as [basic access credentials](https://en.wikipedia.org/wiki/Basic_access_authentication). Pseudo code: `\"Basic \" + toBase64(client_id + \":\" + client_secret)` For example: `Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==` - `opts` (keyword): Optional parameters - `:"Content-Type"` (String.t): This header value must match the type of the request body you send, if there is a request body. For example, if you send the request body as JSON, this header must be set to `application/json`, and if you send it as form encoded you must set this header to `application/x-www-form-urlencoded`. - `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string. - `:body` (OauthGenerateTokensRequest): ### Returns - `{:ok, MollieAPI.Model.OauthGenerateTokens200Response.t}` on success - `{:error, Tesla.Env.t}` on failure """ @spec oauth_generate_tokens(Tesla.Env.client, String.t, keyword()) :: {:ok, MollieAPI.Model.ErrorResponse.t} | {:ok, MollieAPI.Model.OauthGenerateTokens200Response.t} | {:error, Tesla.Env.t} def oauth_generate_tokens(connection, authorization, opts \\ []) do optional_params = %{ :"Content-Type" => :headers, :"idempotency-key" => :headers, :body => :body } request = %{} |> method(:post) |> url("/oauth2/tokens") |> add_param(:headers, :Authorization, authorization) |> add_optional_params(optional_params, opts) |> ensure_body() |> Enum.into([]) connection |> Connection.request(request) |> evaluate_response([ {200, MollieAPI.Model.OauthGenerateTokens200Response}, {429, MollieAPI.Model.ErrorResponse} ]) end @doc """ Revoke tokens Revoke an access token or refresh token. Once revoked, the token can no longer be used. Revoking a refresh token revokes all access tokens that were created using the same authorization. This endpoint can only be accessed using **OAuth client credentials**. ### Parameters - `connection` (MollieAPI.Connection): Connection to server - `authorization` (String.t): The OAuth client ID and client secret as [basic access credentials](https://en.wikipedia.org/wiki/Basic_access_authentication). Pseudo code: `\"Basic \" + toBase64(client_id + \":\" + client_secret)` For example: `Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==` - `opts` (keyword): Optional parameters - `:"Content-Type"` (String.t): This header value must match the type of the request body you send, if there is a request body. For example, if you send the request body as JSON, this header must be set to `application/json`, and if you send it as form encoded you must set this header to `application/x-www-form-urlencoded`. - `:"idempotency-key"` (String.t): A unique key to ensure idempotent requests. This key should be a UUID v4 string. - `:body` (OauthRevokeTokensRequest): ### Returns - `{:ok, nil}` on success - `{:error, Tesla.Env.t}` on failure """ @spec oauth_revoke_tokens(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, MollieAPI.Model.ErrorResponse.t} | {:error, Tesla.Env.t} def oauth_revoke_tokens(connection, authorization, opts \\ []) do optional_params = %{ :"Content-Type" => :headers, :"idempotency-key" => :headers, :body => :body } request = %{} |> method(:delete) |> url("/oauth2/tokens") |> add_param(:headers, :Authorization, authorization) |> add_optional_params(optional_params, opts) |> Enum.into([]) connection |> Connection.request(request) |> evaluate_response([ {204, false}, {429, MollieAPI.Model.ErrorResponse} ]) end end