1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-25 16:19:40 +02:00
Maybe/app/models/security/synth_combobox_option.rb
Josh Pigford 31d9d926f7
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions
Fix for certain securities returning incorrect prices
2024-11-07 11:52:16 -06:00

27 lines
765 B
Ruby

class Security::SynthComboboxOption
include ActiveModel::Model
include Providable
attr_accessor :symbol, :name, :logo_url, :exchange_acronym, :exchange_mic, :exchange_country_code
class << self
def find_in_synth(query)
country = Current.family.country
country = "#{country},US" unless country == "US"
security_prices_provider.search_securities(
query:,
dataset: "limited",
country_code: country
).securities.map { |attrs| new(**attrs) }
end
end
def id
"#{symbol}|#{exchange_mic}|#{exchange_acronym}|#{exchange_country_code}" # submitted by combobox as value
end
def to_combobox_display
"#{symbol} - #{name} (#{exchange_acronym})" # shown in combobox input when selected
end
end