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

defmodule FinFeedAPISECRESTAPI.Api.FileDownload do
  @moduledoc """
  API calls for all endpoints tagged `FileDownload`.
  """

  alias FinFeedAPISECRESTAPI.Connection
  import FinFeedAPISECRESTAPI.RequestBuilder

  @doc """
  Download file from SEC EDGAR archive
  Downloads a specific file from the SEC EDGAR archive using the accession number and filename. The file is streamed directly from the SEC servers to the client.  ### Accession Number Format Accession numbers must be in the format: 0000000000-00-000000 (10 digits, dash, 2 digits, dash, 6 digits)  ### File Name Examples - Primary documents: `d123456d10k.htm`, `d789012d8k.htm` - XBRL files: `d123456d10k_htm.xml`, `FilingSummary.xml` - Exhibits: `d123456dexhibit99.htm`, `d123456dex101.htm`  ### File Types The endpoint supports downloading various file types from SEC filings: - HTML documents (.htm, .html) - XBRL files (.xml, .xsd) - Text files (.txt) - PDF files (.pdf) - Other document formats as submitted to SEC  :::tip You can find available filenames for a specific filing using the `/v1/filings` endpoint first :::  :::warning This endpoint streams files directly from the SEC. Large files may take longer to download. :::

  ### Parameters

  - `connection` (FinFeedAPISECRESTAPI.Connection): Connection to server
  - `accession_no` (String.t): SEC filing accession number in format: 0000000000-00-000000
  - `file_name` (String.t): Name of the file to download from the filing
  - `opts` (keyword): Optional parameters

  ### Returns

  - `{:ok, nil}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_download_get(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, FinFeedAPISECRESTAPI.Model.MvcValidationProblemDetails.t} | {:ok, FinFeedAPISECRESTAPI.Model.MvcProblemDetails.t} | {:error, Tesla.Env.t}
  def v1_download_get(connection, accession_no, file_name, _opts \\ []) do
    request =
      %{}
      |> method(:get)
      |> url("/v1/download")
      |> add_param(:query, :accession_no, accession_no)
      |> add_param(:query, :file_name, file_name)
      |> Enum.into([])

    connection
    |> Connection.request(request)
    |> evaluate_response([
      {200, false},
      {400, FinFeedAPISECRESTAPI.Model.MvcValidationProblemDetails},
      {404, FinFeedAPISECRESTAPI.Model.MvcProblemDetails},
      {500, FinFeedAPISECRESTAPI.Model.MvcProblemDetails}
    ])
  end
end
