Class: Scorespro::SoccerMatch
- Inherits:
-
Object
- Object
- Scorespro::SoccerMatch
- Defined in:
- lib/scorespro_parser/soccer_match.rb
Constant Summary collapse
- SPORT_ID =
1
Class Method Summary collapse
- .between(initial_date, finish_date) ⇒ Object
- .get_latest_soccer_hid ⇒ Object
- .live(last_update) ⇒ Object
Class Method Details
.between(initial_date, finish_date) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/scorespro_parser/soccer_match.rb', line 6 def self.between(initial_date, finish_date) = { state: 'clientUpdate', usr: Scorespro.user, pwd: Scorespro.password, type: Scorespro::Type::BETWEEN_DATES, start: initial_date, :end => finish_date, s: SPORT_ID, tz: "America/Sao_Paulo" } http_response = JSON.parse(HTTParty.get('http://data2.scorespro.com/exporter/json.php', query: )) if http_response["error"] result = { error: http_response["error"], matches: {} } else matches = http_response["list"]["Sport"]["1"].key?("Matchday") ? http_response["list"]["Sport"]["1"]["Matchday"][Date.today.to_s]["Match"] : {} result = { matches: matches} end result end |
.get_latest_soccer_hid ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/scorespro_parser/soccer_match.rb', line 52 def self.get_latest_soccer_hid = { state: 'clientStructure', type: Scorespro::Type::SPORTS, } response = JSON.parse(HTTParty.get('http://data2.scorespro.com/exporter/json.php', query: )) soccer_last_hid = response["list"]["1"]["hid"] soccer_last_hid end |
.live(last_update) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/scorespro_parser/soccer_match.rb', line 29 def self.live(last_update) hid = last_update.blank? ? SoccerMatch.get_latest_soccer_hid : last_update = { state: 'clientUpdate', usr: Scorespro.user, pwd: Scorespro.password, type: Scorespro::Type::LIVE, s: SPORT_ID, h: hid, tz: "America/Sao_Paulo" } http_response = JSON.parse(HTTParty.get('http://data2.scorespro.com/exporter/json.php', query: )) if http_response["error"] result = { error: http_response["error"], matches: {} } else matches = http_response["list"]["Sport"]["1"].key?("Matchday") ? http_response["list"]["Sport"]["1"]["Matchday"][Date.today.to_s]["Match"] : {} result = { hid: http_response["list"]["Sport"]["1"]["hid"], matches: matches} end result end |