mirror of
https://github.com/we-promise/sure.git
synced 2026-05-07 12:54:04 +00:00
* feat: add Binance support (Items, Accounts, Importers, Processor, and Sync) * refactor: deduplicate 'stablecoins' constant and push stale_rate filter to SQL --------- Signed-off-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
28 lines
533 B
Ruby
28 lines
533 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Family::BinanceConnectable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
has_many :binance_items, dependent: :destroy
|
|
end
|
|
|
|
def can_connect_binance?
|
|
true
|
|
end
|
|
|
|
def create_binance_item!(api_key:, api_secret:, item_name: nil)
|
|
item = binance_items.create!(
|
|
name: item_name || "Binance",
|
|
api_key: api_key,
|
|
api_secret: api_secret
|
|
)
|
|
item.sync_later
|
|
item
|
|
end
|
|
|
|
def has_binance_credentials?
|
|
binance_items.where.not(api_key: nil).exists?
|
|
end
|
|
end
|