Class: Betfair::Client
- Inherits:
-
Object
- Object
- Betfair::Client
- Defined in:
- lib/em-betfair/betfair_client.rb
Instance Attribute Summary collapse
-
#session_token ⇒ Object
Returns the value of attribute session_token.
Instance Method Summary collapse
-
#get_all_markets(countries = nil, event_type_ids = nil, to_date = nil, from_date = nil, &block) ⇒ Betfair::Response
Returns all the available markets on Betfair.
-
#get_market(market_id, &block) ⇒ Betfair::Response
Returns the details for a specifc market.
-
#get_market_prices_compressed(market_id, currency_code = nil, &block) ⇒ Betfair::Response
Returns the compressed market prices for a specifc market.
-
#get_market_traded_volume_compressed(market_id, currency_code = nil, &block) ⇒ Betfair::Response
Returns the compressed traded volumes for a specifc market.
-
#get_silks_v2(market_ids, &block) ⇒ Betfair::Response
Returns the runner details for specifc markets.
-
#initialize(config) ⇒ Client
constructor
config - hash of betfair credentials & API endpoints { “username” => “<YOUR BETFAIR USERNAME>”, “password” => “<YOUR BETFAIR PASSWORD>”, “product_id” => “<YOUR BETFAIR PRODUCTID>”, “exchange_endpoint” => “api.betfair.com/exchange/v5/BFExchangeService”, “global_endpoint” => “api.betfair.com/global/v3/BFGlobalService” }.
-
#login(&block) ⇒ Object
Creates a session on the Betfair API, used by Betfair::Client internally to maintain session.
Constructor Details
#initialize(config) ⇒ Client
config - hash of betfair credentials & API endpoints
{ "username" => "<YOUR BETFAIR USERNAME>", "password" => "<YOUR BETFAIR PASSWORD>", "product_id" => "<YOUR BETFAIR PRODUCTID>", "exchange_endpoint" => "https://api.betfair.com/exchange/v5/BFExchangeService", "global_endpoint" => "https://api.betfair.com/global/v3/BFGlobalService" }
20 21 22 23 24 25 |
# File 'lib/em-betfair/betfair_client.rb', line 20 def initialize config @config = config @session_token = nil @num_requests = {} EventMachine::PeriodicTimer.new(60) { reset_requests } if EM.reactor_running? end |
Instance Attribute Details
#session_token ⇒ Object
Returns the value of attribute session_token.
16 17 18 |
# File 'lib/em-betfair/betfair_client.rb', line 16 def session_token @session_token end |
Instance Method Details
#get_all_markets(countries = nil, event_type_ids = nil, to_date = nil, from_date = nil, &block) ⇒ Betfair::Response
Returns all the available markets on Betfair.
39 40 41 42 43 |
# File 'lib/em-betfair/betfair_client.rb', line 39 def get_all_markets countries=nil, event_type_ids=nil, to_date=nil, from_date=nil, &block with_session do build_request "exchange", "get_all_markets", {"countries" => countries, "event_type_ids" => event_type_ids, "to_date" => to_date, "from_date" => from_date}, block end end |
#get_market(market_id, &block) ⇒ Betfair::Response
Returns the details for a specifc market.
49 50 51 52 53 |
# File 'lib/em-betfair/betfair_client.rb', line 49 def get_market market_id, &block with_session do build_request "exchange", "get_market", {"market_id" => market_id }, block end end |
#get_market_prices_compressed(market_id, currency_code = nil, &block) ⇒ Betfair::Response
Returns the compressed market prices for a specifc market.
70 71 72 73 74 |
# File 'lib/em-betfair/betfair_client.rb', line 70 def get_market_prices_compressed market_id, currency_code=nil, &block with_session do build_request "exchange", "get_market_prices_compressed", {"market_id" => market_id, "currency_code" => currency_code}, block end end |
#get_market_traded_volume_compressed(market_id, currency_code = nil, &block) ⇒ Betfair::Response
Returns the compressed traded volumes for a specifc market.
81 82 83 84 85 |
# File 'lib/em-betfair/betfair_client.rb', line 81 def get_market_traded_volume_compressed market_id, currency_code=nil, &block with_session do build_request "exchange", "get_market_traded_volume_compressed", {"market_id" => market_id, "currency_code" => currency_code}, block end end |
#get_silks_v2(market_ids, &block) ⇒ Betfair::Response
Returns the runner details for specifc markets.
59 60 61 62 63 |
# File 'lib/em-betfair/betfair_client.rb', line 59 def get_silks_v2 market_ids, &block with_session do build_request "exchange", "get_silks_v2", {"market_ids" => market_ids }, block end end |
#login(&block) ⇒ Object
Creates a session on the Betfair API, used by Betfair::Client internally to maintain session.
28 29 30 |
# File 'lib/em-betfair/betfair_client.rb', line 28 def login &block build_request "global", "login", {"username" => @config["username"], "password" => @config["password"], "product_id" => @config["product_id"]}, block end |