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

  alias DocuSign.Connection
  import DocuSign.RequestBuilder

  @doc """
  Deletes custom document fields from an existing envelope document.
  Deletes custom document fields from an existing envelope document.

  ### Parameters

  - `connection` (DocuSign.Connection): Connection to server
  - `account_id` (String.t): The external account number (int) or account ID GUID.
  - `document_id` (String.t): The unique ID of the document within the envelope.  Unlike other IDs in the eSignature API, you specify the `documentId` yourself. Typically the first document has the ID `1`, the second document `2`, and so on, but you can use any numbering scheme that fits within a 32-bit signed integer (1 through 2147483647).   Tab objects have a `documentId` property that specifies the document on which to place the tab.
  - `envelope_id` (String.t): The envelope's GUID.   Example: `93be49ab-xxxx-xxxx-xxxx-f752070d71ec`
  - `opts` (keyword): Optional parameters
    - `:body` (EnvelopeDocumentFields):

  ### Returns

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

    request =
      %{}
      |> method(:delete)
      |> url(
        "/v2.1/accounts/#{account_id}/envelopes/#{envelope_id}/documents/#{document_id}/fields"
      )
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

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

  @doc """
  Gets the custom document fields from an  existing envelope document.
  Retrieves the custom document field information from an existing envelope document.

  ### Parameters

  - `connection` (DocuSign.Connection): Connection to server
  - `account_id` (String.t): The external account number (int) or account ID GUID.
  - `document_id` (String.t): The unique ID of the document within the envelope.  Unlike other IDs in the eSignature API, you specify the `documentId` yourself. Typically the first document has the ID `1`, the second document `2`, and so on, but you can use any numbering scheme that fits within a 32-bit signed integer (1 through 2147483647).   Tab objects have a `documentId` property that specifies the document on which to place the tab.
  - `envelope_id` (String.t): The envelope's GUID.   Example: `93be49ab-xxxx-xxxx-xxxx-f752070d71ec`
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, DocuSign.Model.EnvelopeDocumentFields.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec document_fields_get_document_fields(
          Tesla.Env.client(),
          String.t(),
          String.t(),
          String.t(),
          keyword()
        ) ::
          {:ok, DocuSign.Model.EnvelopeDocumentFields.t()}
          | {:ok, DocuSign.Model.ErrorDetails.t()}
          | {:error, Tesla.Env.t()}
  def document_fields_get_document_fields(
        connection,
        account_id,
        document_id,
        envelope_id,
        _opts \\ []
      ) do
    request =
      %{}
      |> method(:get)
      |> url(
        "/v2.1/accounts/#{account_id}/envelopes/#{envelope_id}/documents/#{document_id}/fields"
      )
      |> Enum.into([])

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

  @doc """
  Creates custom document fields in an existing envelope document.
  Creates custom document fields in an existing envelope document.

  ### Parameters

  - `connection` (DocuSign.Connection): Connection to server
  - `account_id` (String.t): The external account number (int) or account ID GUID.
  - `document_id` (String.t): The unique ID of the document within the envelope.  Unlike other IDs in the eSignature API, you specify the `documentId` yourself. Typically the first document has the ID `1`, the second document `2`, and so on, but you can use any numbering scheme that fits within a 32-bit signed integer (1 through 2147483647).   Tab objects have a `documentId` property that specifies the document on which to place the tab.
  - `envelope_id` (String.t): The envelope's GUID.   Example: `93be49ab-xxxx-xxxx-xxxx-f752070d71ec`
  - `opts` (keyword): Optional parameters
    - `:body` (EnvelopeDocumentFields):

  ### Returns

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

    request =
      %{}
      |> method(:post)
      |> url(
        "/v2.1/accounts/#{account_id}/envelopes/#{envelope_id}/documents/#{document_id}/fields"
      )
      |> add_optional_params(optional_params, opts)
      |> ensure_body()
      |> Enum.into([])

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

  @doc """
  Updates existing custom document fields in an existing envelope document.
  Updates existing custom document fields in an existing envelope document.

  ### Parameters

  - `connection` (DocuSign.Connection): Connection to server
  - `account_id` (String.t): The external account number (int) or account ID GUID.
  - `document_id` (String.t): The unique ID of the document within the envelope.  Unlike other IDs in the eSignature API, you specify the `documentId` yourself. Typically the first document has the ID `1`, the second document `2`, and so on, but you can use any numbering scheme that fits within a 32-bit signed integer (1 through 2147483647).   Tab objects have a `documentId` property that specifies the document on which to place the tab.
  - `envelope_id` (String.t): The envelope's GUID.   Example: `93be49ab-xxxx-xxxx-xxxx-f752070d71ec`
  - `opts` (keyword): Optional parameters
    - `:body` (EnvelopeDocumentFields):

  ### Returns

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

    request =
      %{}
      |> method(:put)
      |> url(
        "/v2.1/accounts/#{account_id}/envelopes/#{envelope_id}/documents/#{document_id}/fields"
      )
      |> add_optional_params(optional_params, opts)
      |> ensure_body()
      |> Enum.into([])

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