Class: SecApi::Objects::DocumentFormatFile

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/sec_api/objects/document_format_file.rb

Overview

Represents a document file within an SEC filing.

DocumentFormatFile objects contain metadata about individual documents within a filing, such as the main filing document, exhibits, and attachments. All instances are immutable (frozen).

Examples:

Accessing document files from a filing

filing = client.query.ticker("AAPL").form_type("10-K").search.first
filing.documents.each do |doc|
  puts "#{doc.sequence}: #{doc.description} (#{doc.type})"
  puts "URL: #{doc.url}, Size: #{doc.size} bytes"
end

See Also:

Direct Known Subclasses

DataFile

Class Method Summary collapse

Class Method Details

.from_api(data) ⇒ DocumentFormatFile

Creates a DocumentFormatFile from API response data.

Normalizes camelCase keys from the API to snake_case format.

Parameters:

  • data (Hash)

    API response hash with document data

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sec_api/objects/document_format_file.rb', line 38

def self.from_api(data)
  data[:url] = data.delete(:documentUrl) if data.key?(:documentUrl)

  # API sometimes returns whitespace (including non-breaking spaces) for size
  # Use POSIX [[:space:]] to match all unicode whitespace including NBSP
  [:size, "size"].each do |key|
    if data.key?(key) && data[key].is_a?(String) && data[key].match?(/\A[[:space:]]*\z/)
      data.delete(key)
    end
  end

  new(data)
end