init push - laying out the project
This commit is contained in:
40
portal/app/lib/integrations/betfair/base.rb
Normal file
40
portal/app/lib/integrations/betfair/base.rb
Normal file
@ -0,0 +1,40 @@
|
||||
module Integrations
|
||||
module Betfair
|
||||
class Base
|
||||
include HTTParty
|
||||
|
||||
API_BETTING_ENDPOINT = 'https://api.betfair.com/exchange/betting/rest/v1.0'.freeze
|
||||
API_ACCOUNT_ENDPOINT = 'https://api.betfair.com/exchange/account/rest/v1.0'.freeze
|
||||
|
||||
def initialize(account_friendly_id)
|
||||
@account = ExchangeAccount.find_by_id(account_friendly_id)
|
||||
unless @account
|
||||
puts "No exchange account for '#{account_friendly_id}'. Stopping"
|
||||
return
|
||||
end
|
||||
self.class.pem @account.ssl_pem
|
||||
@connection = Integrations::Betfair::Connection.new(@account)
|
||||
end
|
||||
|
||||
def minimum_stake
|
||||
1
|
||||
end
|
||||
|
||||
def list_events(filter)
|
||||
body = { filter: filter }
|
||||
self.class.post("#{API_BETTING_ENDPOINT}/listEvents/", { headers: @connection.api_headers, body: body.to_json })
|
||||
end
|
||||
|
||||
def debug_list_market_types
|
||||
body = { filter: {} }
|
||||
marketTypes = self.class.post("#{API_BETTING_ENDPOINT}/listMarketTypes/", { headers: @connection.api_headers, body: body.to_json })
|
||||
results = []
|
||||
marketTypes.each do |market|
|
||||
results << market['marketType']
|
||||
end
|
||||
File.write(Rails.root.join('samples/bf_market_types.json'), results.join("\n"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user