lib/docusign/api/template_views.ex

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

defmodule DocuSign.Api.TemplateViews do
  @moduledoc """
  API calls for all endpoints tagged `TemplateViews`.
  """

  alias DocuSign.Connection
  import DocuSign.RequestBuilder

  @doc """
  Gets a URL for a template edit view.
  This method returns a URL for starting an edit view of a template that uses the DocuSign Template UI. The URL can only be used once.  To prevent the user from accessing the sending account, set the `returnUrl` value in the request body.  ## Information security notice  If the `returnUrl` value is not set, this method provides full access to the sending account. If the account has administrative privileges, then this method also provides administrator access.

  ### Parameters

  - `connection` (DocuSign.Connection): Connection to server
  - `account_id` (String.t): The external account number (int) or account ID GUID.
  - `template_id` (String.t): The ID of the template.
  - `opts` (keyword): Optional parameters
    - `:body` (ReturnUrlRequest):

  ### Returns

  - `{:ok, DocuSign.Model.ViewUrl.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec views_post_template_edit_view(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
          {:ok, DocuSign.Model.ErrorDetails.t()}
          | {:ok, DocuSign.Model.ViewUrl.t()}
          | {:error, Tesla.Env.t()}
  def views_post_template_edit_view(connection, account_id, template_id, opts \\ []) do
    optional_params = %{
      :body => :body
    }

    request =
      %{}
      |> method(:post)
      |> url("/v2.1/accounts/#{account_id}/templates/#{template_id}/views/edit")
      |> add_optional_params(optional_params, opts)
      |> ensure_body()
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {201, %DocuSign.Model.ViewUrl{}},
      {400, %DocuSign.Model.ErrorDetails{}}
    ])
  end
end