mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-25 08:09:38 +02:00
Initial pass at Synth-based ticker selection (#1392)
* Initial pass at Synth-based ticker selection * Update _tickers.turbo_stream.erb * Functional combobox display * A few cleanup steps * Linter * Prevent long strings * Another step towards functional combobox * Deprecated files * Custom Combobox implementation * Lint * Test suite fixes * Lint * Make direct use of mic codes * Update splits * Update trades_test.rb
This commit is contained in:
parent
490f44589e
commit
cd91e66618
20 changed files with 118 additions and 232 deletions
|
@ -122,6 +122,31 @@ class Provider::Synth
|
|||
raw_response: error
|
||||
end
|
||||
|
||||
def search_securities(query:, dataset: "limited", country_code:)
|
||||
response = client.get("#{base_url}/tickers/search") do |req|
|
||||
req.params["name"] = query
|
||||
req.params["dataset"] = dataset
|
||||
req.params["country_code"] = country_code
|
||||
end
|
||||
|
||||
parsed = JSON.parse(response.body)
|
||||
|
||||
securities = parsed.dig("data").map do |security|
|
||||
{
|
||||
symbol: security.dig("symbol"),
|
||||
name: security.dig("name"),
|
||||
logo_url: security.dig("logo_url"),
|
||||
exchange_acronym: security.dig("exchange", "acronym"),
|
||||
exchange_mic: security.dig("exchange", "mic_code")
|
||||
}
|
||||
end
|
||||
|
||||
SearchSecuritiesResponse.new \
|
||||
securities: securities,
|
||||
success?: true,
|
||||
raw_response: response
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :api_key
|
||||
|
@ -130,6 +155,7 @@ class Provider::Synth
|
|||
SecurityPriceResponse = Struct.new :prices, :success?, :error, :raw_response, keyword_init: true
|
||||
ExchangeRatesResponse = Struct.new :rates, :success?, :error, :raw_response, keyword_init: true
|
||||
UsageResponse = Struct.new :used, :limit, :utilization, :plan, :success?, :error, :raw_response, keyword_init: true
|
||||
SearchSecuritiesResponse = Struct.new :securities, :success?, :error, :raw_response, keyword_init: true
|
||||
|
||||
def base_url
|
||||
"https://api.synthfinance.com"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue