lib/open_xchange_client/api/passwordchange.ex

# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.

defmodule OpenXchangeClient.Api.Passwordchange do
  @moduledoc """
  API calls for all endpoints tagged `Passwordchange`.
  """

  alias OpenXchangeClient.Connection
  import OpenXchangeClient.RequestBuilder

  @doc """
  Updates or changes the password of the current use.
  #### Note The new password will be set without any checks. The client must ensure that it is the password the user wants to set.

  ## Parameters

  - connection (OpenXchangeClient.Connection): Connection to server
  - session (String.t): A session ID previously obtained from the login module.
  - body (PasswordChangeBody): A JSON object containing the old and the new password.
  - opts (KeywordList): [optional] Optional parameters
  ## Returns

  {:ok, OpenXchangeClient.Model.CommonResponse.t} on success
  {:error, Tesla.Env.t} on failure
  """
  @spec update_password(
          Tesla.Env.client(),
          String.t(),
          OpenXchangeClient.Model.PasswordChangeBody.t(),
          keyword()
        ) :: {:ok, OpenXchangeClient.Model.CommonResponse.t()} | {:error, Tesla.Env.t()}
  def update_password(connection, session, body, _opts \\ []) do
    %{}
    |> method(:put)
    |> url("/passwordchange?action=update")
    |> add_param(:query, :session, session)
    |> add_param(:body, :body, body)
    |> Enum.into([])
    |> (&Connection.request(connection, &1)).()
    |> evaluate_response([
      {200, %OpenXchangeClient.Model.CommonResponse{}}
    ])
  end
end