class FplGsheet::Entry
Attributes
id[R]
name[R]
Public Class Methods
new(entry_id)
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 6 def initialize(entry_id) entry_json=JSON.load(open("https://fantasy.premierleague.com/api/entry/#{entry_id}/", {ssl_verify_mode: 0})) @entry_data=entry_json.reject { |e| e.is_a? Hash } @league_data=entry_json['leagues'] @name=@entry_data['name'] @id=@entry_data['id'] @historical_gameweeks = Hash.new() #@fixtures = fixtures.map { |f| TeamFixture.new(f, @data['id']) } end
Public Instance Methods
chips()
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 30 def chips; history["chips"]; end
gameweek_history()
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 36 def gameweek_history; history["current"]; end
history()
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 20 def history @history ||= JSON.load(open("https://fantasy.premierleague.com/api/entry/#{id}/history/", {ssl_verify_mode: 0})) end
manager_name()
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 16 def manager_name @entry_data['player_first_name'] + ' ' + @entry_data['player_last_name'] end
past_seasons()
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 34 def past_seasons; history["past"]; end
picks()
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 38 def picks latest_gameweek = gameweek_history.last['event'] picks_for_gameweek[latest_gameweek] end
picks_for_gameweek(gw)
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 43 def picks_for_gameweek(gw) return @historical_gameweeks[gw] if @historical_gameweeks.key?(gw) api ||= JSON.load(open("https://fantasy.premierleague.com/api/entry/#{id}/event/#{gw}/picks/", {ssl_verify_mode: 0})) @historical_gameweeks[gw] = api['picks'].map { |p| Pick.new(p)} end
summary()
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 32 def summary; history["entry"]; end
transfers()
click to toggle source
# File lib/fpl_gsheet/entry.rb, line 25 def transfers @transfer_data ||= JSON.load(open("https://fantasy.premierleague.com/api/entry/#{id}/transfers/", {ssl_verify_mode: 0})) @transfer_data.reverse # At some point FPL changed to have newest transfers first; that's just silly end