Class: Interwetten::MarketsClient

Inherits:
Object
  • Object
show all
Includes:
CommonMethods
Defined in:
lib/interwetten/clients/markets_client.rb

Instance Attribute Summary

Attributes included from CommonMethods

#language, #sport_id, #xml

Instance Method Summary collapse

Methods included from CommonMethods

get_sports, #initialize

Instance Method Details

#feed_paramsObject



5
6
7
# File 'lib/interwetten/clients/markets_client.rb', line 5

def feed_params
  "BettingOffers"
end

#get_competitionsObject



9
10
11
# File 'lib/interwetten/clients/markets_client.rb', line 9

def get_competitions
  @competitions ||= @xml.search("LEAGUE").map { |value| value.get_attribute("NAME") }
end

#get_competitions_with_idObject



13
14
15
# File 'lib/interwetten/clients/markets_client.rb', line 13

def get_competitions_with_id
  @competitions_with_id ||= @xml.search("LEAGUE").map { |value| { :name => value.get_attribute("NAME"), :id => value.get_attribute("ID") } }
end

#get_events_for_competition(competition_id) ⇒ Object



17
18
19
20
# File 'lib/interwetten/clients/markets_client.rb', line 17

def get_events_for_competition(competition_id)
  @xml.search("LEAGUE[ID='#{competition_id}']").search("EVENT").map { |value| { :name => value.get_attribute("NAME"),
    :time => value.get_attribute("START_TIME") + " +2", :id => value.get_attribute("EVENTID") } }
end

#get_market_for_event(event_id, type) ⇒ Object



30
31
32
33
34
# File 'lib/interwetten/clients/markets_client.rb', line 30

def get_market_for_event(event_id, type)
  @xml.search("EVENT[EVENTID='#{event_id}']").search("BET[TYPENAME='#{type}']").map { |value| { :id => value.get_attribute("ID"),
    :player1 => value.get_attribute("PLAYER1"), :player2 => value.get_attribute("PLAYER2"), :tip => value.get_attribute("TIP"), 
    :odds => value.get_attribute("QUOTE") } }
end

#get_market_types_for_competition(competition_id) ⇒ Object



36
37
38
# File 'lib/interwetten/clients/markets_client.rb', line 36

def get_market_types_for_competition(competition_id)
  @xml.search("LEAGUE[ID='#{competition_id}']").search("BET").map { |value| value.get_attribute "TYPENAME" }.uniq
end

#get_market_types_for_event(event_id) ⇒ Object



40
41
42
# File 'lib/interwetten/clients/markets_client.rb', line 40

def get_market_types_for_event(event_id)
  @xml.search("EVENT[EVENTID='#{event_id}']").search("BET").map { |value| value.get_attribute "TYPENAME" }.uniq
end

#get_markets_for_competition(competition_id, type) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/interwetten/clients/markets_client.rb', line 22

def get_markets_for_competition(competition_id, type)
  xml_events = @xml.search("LEAGUE[ID='#{competition_id}']").search("EVENT")
  xml_events.map do |xml_event|
    xml_event.search("BET[TYPENAME='#{type}']").map { |value| { :id => value.get_attribute("ID"), :player1 => value.get_attribute("PLAYER1"),
      :player2 => value.get_attribute("PLAYER2"), :tip => value.get_attribute("TIP"), :odds => value.get_attribute("QUOTE") } }
  end
end

#get_odds_for_option(option_id) ⇒ Object



49
50
51
# File 'lib/interwetten/clients/markets_client.rb', line 49

def get_odds_for_option(option_id)
  @xml.search("BET[ID='#{option_id}']").first.get_attribute("QUOTE")
end

#get_option(option_id) ⇒ Object



44
45
46
47
# File 'lib/interwetten/clients/markets_client.rb', line 44

def get_option(option_id)
  option = @xml.search("BET[ID='#{option_id}']").first
  { :odds => option.get_attribute("QUOTE"), :player1 => option.get_attribute("PLAYER1"), :player2 => option.get_attribute("PLAYER2"), :tip => option.get_attribute("TIP") } if option
end