# 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.FilingMetadata do
  @moduledoc """
  API calls for all endpoints tagged `FilingMetadata`.
  """

  alias FinFeedAPISECRESTAPI.Connection
  import FinFeedAPISECRESTAPI.RequestBuilder

  @doc """
  Query SEC filing metadata
  Retrieves metadata for SEC filings based on various filter criteria with pagination and sorting support.  ### Available Sort Fields  Field Name | Description -----------|------------- AccessionNumber | SEC filing accession number FilingDate | Date when filing was submitted AcceptanceDateTime | Date and time of filing acceptance ReportDate | Date of the report Size | Size of the filing document  ### Date Format All dates must be provided in YYYY-MM-DD format  ### Form Types Form types can be provided as comma-separated values, e.g.: \"10-K,8-K,10-Q\"  :::tip For optimal performance, use date ranges and form types to narrow down your search :::

  ### Parameters

  - `connection` (FinFeedAPISECRESTAPI.Connection): Connection to server
  - `opts` (keyword): Optional parameters
    - `:cik` (integer()): Filter by Central Index Key (CIK)
    - `:ticker` (String.t): Filter by stock ticker symbol
    - `:form_type` (String.t): Filter by form type(s) (e.g., \"10-K\", \"8-K\"). Multiple values can be comma-separated
    - `:filling_date_start` (String.t): Filter by filling date start (inclusive), format YYYY-MM-DD
    - `:filling_date_end` (String.t): Filter by filling date end (inclusive), format YYYY-MM-DD
    - `:report_date_start` (String.t): Filter by report date start (inclusive), format YYYY-MM-DD
    - `:report_date_end` (String.t): Filter by report date end (inclusive), format YYYY-MM-DD
    - `:items_contain` (String.t): Filter filings where the 'Items' field contains the specified text
    - `:page_size` (integer()): Number of results per page (default: 50, max: 200)
    - `:page_number` (integer()): Page number to retrieve (default: 1)
    - `:sort_by` (DtoFilingSortBy): Field to sort results by (default: AccessionNumber)
    - `:sort_order` (String.t): Sort order (asc or desc, default: desc)

  ### Returns

  - `{:ok, [%DtoFilingMetadataDto{}, ...]}` on success
  - `{:error, Tesla.Env.t}` on failure
  """
  @spec v1_filings_get(Tesla.Env.client, keyword()) :: {:ok, FinFeedAPISECRESTAPI.Model.MvcValidationProblemDetails.t} | {:ok, FinFeedAPISECRESTAPI.Model.MvcProblemDetails.t} | {:ok, [FinFeedAPISECRESTAPI.Model.DtoFilingMetadataDto.t]} | {:error, Tesla.Env.t}
  def v1_filings_get(connection, opts \\ []) do
    optional_params = %{
      :cik => :query,
      :ticker => :query,
      :form_type => :query,
      :filling_date_start => :query,
      :filling_date_end => :query,
      :report_date_start => :query,
      :report_date_end => :query,
      :items_contain => :query,
      :page_size => :query,
      :page_number => :query,
      :sort_by => :query,
      :sort_order => :query
    }

    request =
      %{}
      |> method(:get)
      |> url("/v1/filings")
      |> add_optional_params(optional_params, opts)
      |> Enum.into([])

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