Class: SecApi::Objects::Entity
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- SecApi::Objects::Entity
- Defined in:
- lib/sec_api/objects/entity.rb
Overview
Represents a company or issuer entity from SEC EDGAR.
Entity objects are returned from mapping API calls and contain identifying information such as CIK, ticker, company name, and regulatory details. All instances are immutable (frozen).
Class Method Summary collapse
-
.from_api(data) ⇒ Entity
Creates an Entity from API response data.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Entity
constructor
Override constructor to ensure immutability.
Constructor Details
#initialize(attributes) ⇒ Entity
Override constructor to ensure immutability
52 53 54 55 |
# File 'lib/sec_api/objects/entity.rb', line 52 def initialize(attributes) super freeze end |
Class Method Details
.from_api(data) ⇒ Entity
Creates an Entity from API response data.
Normalizes camelCase keys from the API to snake_case and handles both symbol and string keys in the input hash.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/sec_api/objects/entity.rb', line 70 def self.from_api(data) # Non-destructive normalization - create new hash instead of mutating input normalized = { cik: data[:cik] || data["cik"], name: data[:name] || data[:companyName] || data["name"] || data["companyName"], irs_number: data[:irs_number] || data[:irsNo] || data["irs_number"] || data["irsNo"], state_of_incorporation: data[:state_of_incorporation] || data[:stateOfIncorporation] || data["state_of_incorporation"] || data["stateOfIncorporation"], fiscal_year_end: data[:fiscal_year_end] || data[:fiscalYearEnd] || data["fiscal_year_end"] || data["fiscalYearEnd"], type: data[:type] || data["type"], act: data[:act] || data["act"], file_number: data[:file_number] || data[:fileNo] || data["file_number"] || data["fileNo"], film_number: data[:film_number] || data[:filmNo] || data["film_number"] || data["filmNo"], sic: data[:sic] || data["sic"], ticker: data[:ticker] || data["ticker"], exchange: data[:exchange] || data["exchange"], cusip: data[:cusip] || data["cusip"] } new(normalized) end |