lib/docusign/api/template_document_visibility.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.TemplateDocumentVisibility do
  @moduledoc """
  API calls for all endpoints tagged `TemplateDocumentVisibility`.
  """

  alias DocuSign.Connection
  import DocuSign.RequestBuilder

  @doc """
  Returns document visibility for a template recipient
  This method returns information about document visibility for a template recipient.

  ### Parameters

  - `connection` (DocuSign.Connection): Connection to server
  - `account_id` (String.t): The external account number (int) or account ID GUID.
  - `recipient_id` (String.t): A local reference that senders use to map recipients to other objects, such as specific document tabs. Within an envelope, each `recipientId` must be unique, but there is no uniqueness requirement across envelopes. For example, many envelopes assign the first recipient a `recipientId` of `1`.
  - `template_id` (String.t): The ID of the template.
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, DocuSign.Model.DocumentVisibilityList.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec recipients_get_template_recipient_document_visibility(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          String.t(),
          keyword()
        ) ::
          {:ok, DocuSign.Model.ErrorDetails.t()}
          | {:ok, DocuSign.Model.DocumentVisibilityList.t()}
          | {:error, Tesla.Env.t()}
  def recipients_get_template_recipient_document_visibility(
        connection,
        account_id,
        recipient_id,
        template_id,
        _opts \\ []
      ) do
    request =
      %{}
      |> method(:get)
      |> url(
        "/v2.1/accounts/#{account_id}/templates/#{template_id}/recipients/#{recipient_id}/document_visibility"
      )
      |> Enum.into([])

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

  @doc """
  Updates document visibility for a template recipient
  This method updates the document visibility for a template recipient.  **Note:** A document cannot be hidden from a recipient if the recipient has tabs assigned to them on the document. Carbon Copy, Certified Delivery (Needs to Sign), Editor, and Agent recipients can always see all documents.

  ### Parameters

  - `connection` (DocuSign.Connection): Connection to server
  - `account_id` (String.t): The external account number (int) or account ID GUID.
  - `recipient_id` (String.t): A local reference that senders use to map recipients to other objects, such as specific document tabs. Within an envelope, each `recipientId` must be unique, but there is no uniqueness requirement across envelopes. For example, many envelopes assign the first recipient a `recipientId` of `1`.
  - `template_id` (String.t): The ID of the template.
  - `opts` (keyword): Optional parameters
    - `:body` (TemplateDocumentVisibilityList):

  ### Returns

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

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

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

  @doc """
  Updates document visibility for template recipients
  This method updates document visibility for one or more template recipients based on the `recipientId` and `visible` values that you include in the request body.   **Note:** A document cannot be hidden from a recipient if the recipient has tabs assigned to them on the document. Carbon Copy, Certified Delivery (Needs to Sign), Editor, and Agent recipients can always see all documents.

  ### 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` (TemplateDocumentVisibilityList):

  ### Returns

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

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

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