# NOTE: This file is auto generated by OpenAPI Generator 6.4.0 (
# Do not edit this file manually.

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

  alias DocuSign.Connection
  import DocuSign.RequestBuilder

  @doc """
  Returns the data that users entered in a PowerForm.
  This method enables Powerform Administrators or the sender of a PowerForm to download the data that recipients have entered into a PowerForm.  You specify the format in which you want to retrieve the data in the `Accept` header. This header accepts the following values:   - `application/json`: JSON format - `application/xml`: XML format - `text/csv`: Comma-separated value (CSV) format  **Note:** Only PowerForm Administrators or the PowerForm Sender can download the data associated with a PowerForm.

  ### Parameters

  - `connection` (DocuSign.Connection): Connection to server
  - `account_id` (String.t): The external account number (int) or account ID GUID.
  - `power_form_id` (String.t): The ID of the PowerForm.
  - `opts` (keyword): Optional parameters
    - `:data_layout` (String.t): The layout in which to return the PowerForm data. Valid values are:  - `Native` - `Csv_Classic` - `Csv_One_Envelope_Per_Line` - `Xml_Classic`
    - `:from_date` (String.t): The start date for a date range in UTC DateTime format.  **Note:** If this property is null, no date filtering is applied.
    - `:to_date` (String.t): The end date of a date range in UTC DateTime format. The default value is `UtcNow`.

  ### Returns

  - `{:ok, DocuSign.Model.PowerFormsFormDataResponse.t}` on success
  - `{:error, Tesla.Env.t}` on failure
  @spec power_forms_get_power_form_form_data(
        ) ::
          {:ok, DocuSign.Model.ErrorDetails.t()}
          | {:ok, DocuSign.Model.PowerFormsFormDataResponse.t()}
          | {:error, Tesla.Env.t()}
  def power_forms_get_power_form_form_data(connection, account_id, power_form_id, opts \\ []) do
    optional_params = %{
      :data_layout => :query,
      :from_date => :query,
      :to_date => :query

    request =
      |> method(:get)
      |> url("/v2.1/accounts/#{account_id}/powerforms/#{power_form_id}/form_data")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

    |> Connection.request(request)
    |> evaluate_response([
      {200, %DocuSign.Model.PowerFormsFormDataResponse{}},
      {400, %DocuSign.Model.ErrorDetails{}}