fantasydata 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +19 -0
- data/.travis.yml +13 -0
- data/Gemfile +17 -0
- data/Guardfile +70 -0
- data/LICENSE +22 -0
- data/README.md +32 -0
- data/Rakefile +2 -0
- data/fantasydata.gemspec +22 -0
- data/lib/fantasydata.rb +47 -0
- data/lib/fantasydata/api/box_score.rb +104 -0
- data/lib/fantasydata/api/bye_weeks.rb +24 -0
- data/lib/fantasydata/api/fantasy.rb +68 -0
- data/lib/fantasydata/api/game.rb +31 -0
- data/lib/fantasydata/api/news.rb +22 -0
- data/lib/fantasydata/api/player_details.rb +26 -0
- data/lib/fantasydata/api/player_stat.rb +33 -0
- data/lib/fantasydata/api/schedule.rb +13 -0
- data/lib/fantasydata/api/stadium.rb +14 -0
- data/lib/fantasydata/api/standings.rb +14 -0
- data/lib/fantasydata/api/team.rb +18 -0
- data/lib/fantasydata/api/utils.rb +65 -0
- data/lib/fantasydata/api/week.rb +22 -0
- data/lib/fantasydata/base.rb +91 -0
- data/lib/fantasydata/bye_week.rb +8 -0
- data/lib/fantasydata/client.rb +77 -0
- data/lib/fantasydata/configurable.rb +79 -0
- data/lib/fantasydata/daily_fantasy_player.rb +11 -0
- data/lib/fantasydata/daily_fantasy_player_stats.rb +35 -0
- data/lib/fantasydata/daily_fantasy_points.rb +8 -0
- data/lib/fantasydata/default.rb +82 -0
- data/lib/fantasydata/error.rb +33 -0
- data/lib/fantasydata/error/bad_gateway.rb +11 -0
- data/lib/fantasydata/error/bad_request.rb +10 -0
- data/lib/fantasydata/error/client_error.rb +24 -0
- data/lib/fantasydata/error/configuration_error.rb +8 -0
- data/lib/fantasydata/error/forbidden.rb +10 -0
- data/lib/fantasydata/error/gateway_timeout.rb +11 -0
- data/lib/fantasydata/error/internal_server_error.rb +11 -0
- data/lib/fantasydata/error/not_acceptable.rb +10 -0
- data/lib/fantasydata/error/not_found.rb +10 -0
- data/lib/fantasydata/error/server_error.rb +28 -0
- data/lib/fantasydata/error/service_unavailable.rb +11 -0
- data/lib/fantasydata/error/too_many_requests.rb +12 -0
- data/lib/fantasydata/error/unauthorized.rb +10 -0
- data/lib/fantasydata/error/unprocessable_entity.rb +10 -0
- data/lib/fantasydata/fantasy_player_adp.rb +10 -0
- data/lib/fantasydata/game_stat.rb +93 -0
- data/lib/fantasydata/news.rb +8 -0
- data/lib/fantasydata/player_detail.rb +27 -0
- data/lib/fantasydata/player_game_stat.rb +46 -0
- data/lib/fantasydata/player_season_stat.rb +54 -0
- data/lib/fantasydata/response/parse_json.rb +25 -0
- data/lib/fantasydata/response/raise_error.rb +32 -0
- data/lib/fantasydata/schedule.rb +14 -0
- data/lib/fantasydata/scoring_detail.rb +10 -0
- data/lib/fantasydata/stadium.rb +9 -0
- data/lib/fantasydata/standings.rb +13 -0
- data/lib/fantasydata/team_detail.rb +20 -0
- data/lib/fantasydata/version.rb +3 -0
- data/spec/fantasydata/api/box_score_spec.rb +17 -0
- data/spec/fantasydata/api/bye_weeks_spec.rb +31 -0
- data/spec/fantasydata/api/daily_fantasy_spec.rb +189 -0
- data/spec/fantasydata/api/game_spec.rb +84 -0
- data/spec/fantasydata/api/news_spec.rb +66 -0
- data/spec/fantasydata/api/player_details_spec.rb +107 -0
- data/spec/fantasydata/api/player_stat_spec.rb +138 -0
- data/spec/fantasydata/api/schedule_spec.rb +37 -0
- data/spec/fantasydata/api/stadium_spec.rb +32 -0
- data/spec/fantasydata/api/standings_spec.rb +30 -0
- data/spec/fantasydata/api/team_spec.rb +56 -0
- data/spec/fantasydata/api/week_spec.rb +69 -0
- data/spec/fantasydata/box_score_spec.rb +64 -0
- data/spec/fantasydata/client_spec.rb +77 -0
- data/spec/fantasydata/error_spec.rb +37 -0
- data/spec/fantasydata_spec.rb +64 -0
- data/spec/fixtures/bye_weeks/bye_weeks.json +1 -0
- data/spec/fixtures/daily_fantasy/adp.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_defense_game.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_defense_seasons_proj.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_defense_seasons_stats.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_players.json +1 -0
- data/spec/fixtures/daily_fantasy/daily_points.json +1 -0
- data/spec/fixtures/daily_fantasy/defense_game_stats_projected.json +1 -0
- data/spec/fixtures/error_response.json +4 -0
- data/spec/fixtures/game/game_stats_by_season.json +1 -0
- data/spec/fixtures/game/game_stats_by_week.json +1 -0
- data/spec/fixtures/game/in_progress.json +1 -0
- data/spec/fixtures/game/in_progress_false.json +1 -0
- data/spec/fixtures/game/in_progress_true.json +1 -0
- data/spec/fixtures/news/by_player.json +1 -0
- data/spec/fixtures/news/by_team.json +1 -0
- data/spec/fixtures/news/recent.json +1 -0
- data/spec/fixtures/player_details/active.json +1 -0
- data/spec/fixtures/player_details/by_team.json +1 -0
- data/spec/fixtures/player_details/free_agents.json +1 -0
- data/spec/fixtures/player_details/player_find.json +1 -0
- data/spec/fixtures/player_stat/stat_by_delta.json +1 -0
- data/spec/fixtures/player_stat/stat_by_game_projection.json +1 -0
- data/spec/fixtures/player_stat/stat_by_player_id.json +1 -0
- data/spec/fixtures/player_stat/stat_by_week.json +1 -0
- data/spec/fixtures/player_stat/stat_by_week_and_team.json +1 -0
- data/spec/fixtures/player_stat/stat_by_week_and_team_projected.json +1 -0
- data/spec/fixtures/schedule/for_year.json +1 -0
- data/spec/fixtures/stadium/index.json +1 -0
- data/spec/fixtures/standings/by_year.json +1 -0
- data/spec/fixtures/team/active.json +1 -0
- data/spec/fixtures/team/by_year.json +1 -0
- data/spec/fixtures/week/current.json +1 -0
- data/spec/fixtures/week/last_completed.json +1 -0
- data/spec/fixtures/week/upcoming.json +1 -0
- data/spec/helper.rb +42 -0
- metadata +242 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'fantasydata/base'
|
2
|
+
|
3
|
+
module Fantasydata
|
4
|
+
class FantasyPlayerAdp < Fantasydata::Base
|
5
|
+
attr_reader :fantasy_player_key, :player_id, :name, :team,
|
6
|
+
:position, :average_draft_position,
|
7
|
+
:average_draft_position_ppr, :bye_week,
|
8
|
+
:last_season_fantasy_points, :projected_fantasy_points
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'fantasydata/base'
|
2
|
+
|
3
|
+
module Fantasydata
|
4
|
+
class GameStat < Fantasydata::Base
|
5
|
+
attr_reader :game_key, :date, :season_type, :season, :week, :stadium,
|
6
|
+
:playing_surface, :temperature, :humidity, :wind_speed,
|
7
|
+
:away_team, :home_team, :away_score, :home_score, :total_score,
|
8
|
+
:over_under, :point_spread, :away_score_quarter1,
|
9
|
+
:away_score_quarter2, :away_score_quarter3,
|
10
|
+
:away_score_quarter4, :away_score_overtime,
|
11
|
+
:home_score_quarter1, :home_score_quarter2,
|
12
|
+
:home_score_quarter3, :home_score_quarter4,
|
13
|
+
:home_score_overtime, :away_time_of_possession,
|
14
|
+
:home_time_of_possession, :away_first_downs, :home_first_downs,
|
15
|
+
:away_first_downs_by_rushing, :home_first_downs_by_rushing,
|
16
|
+
:away_first_downs_by_passing, :home_first_downs_by_passing,
|
17
|
+
:away_first_downs_by_penalty, :home_first_downs_by_penalty,
|
18
|
+
:away_offensive_plays, :home_offensive_plays,
|
19
|
+
:away_offensive_yards, :home_offensive_yards,
|
20
|
+
:away_offensive_yards_per_play, :home_offensive_yards_per_play,
|
21
|
+
:away_touchdowns, :home_touchdowns, :away_rushing_attempts,
|
22
|
+
:home_rushing_attempts, :away_rushing_yards,
|
23
|
+
:home_rushing_yards, :away_rushing_yards_per_attempt,
|
24
|
+
:home_rushing_yards_per_attempt, :away_rushing_touchdowns,
|
25
|
+
:home_rushing_touchdowns, :away_passing_attempts,
|
26
|
+
:home_passing_attempts, :away_passing_completions,
|
27
|
+
:home_passing_completions, :away_passing_yards,
|
28
|
+
:home_passing_yards, :away_passing_touchdowns,
|
29
|
+
:home_passing_touchdowns, :away_passing_interceptions,
|
30
|
+
:home_passing_interceptions, :away_passing_yards_per_attempt,
|
31
|
+
:home_passing_yards_per_attempt, :away_passing_yards_per_completion,
|
32
|
+
:home_passing_yards_per_completion, :away_completion_percentage,
|
33
|
+
:home_completion_percentage, :away_passer_rating, :home_passer_rating,
|
34
|
+
:away_third_down_attempts, :home_third_down_attempts,
|
35
|
+
:away_third_down_conversions, :home_third_down_conversions,
|
36
|
+
:away_third_down_percentage, :home_third_down_percentage,
|
37
|
+
:away_fourth_down_attempts, :home_fourth_down_attempts,
|
38
|
+
:away_fourth_down_conversions, :home_fourth_down_conversions,
|
39
|
+
:away_fourth_down_percentage, :home_fourth_down_percentage,
|
40
|
+
:away_red_zone_attempts, :home_red_zone_attempts, :away_red_zone_conversions,
|
41
|
+
:home_red_zone_conversions, :away_goal_to_go_attempts,
|
42
|
+
:home_goal_to_go_attempts, :away_goal_to_go_conversions,
|
43
|
+
:home_goal_to_go_conversions, :away_return_yards, :home_return_yards,
|
44
|
+
:away_penalties, :home_penalties, :away_penalty_yards, :home_penalty_yards,
|
45
|
+
:away_fumbles, :home_fumbles, :away_fumbles_lost, :home_fumbles_lost,
|
46
|
+
:away_times_sacked, :home_times_sacked, :away_times_sacked_yards,
|
47
|
+
:home_times_sacked_yards, :away_safeties, :home_safeties, :away_punts,
|
48
|
+
:home_punts, :away_punt_yards, :home_punt_yards, :away_punt_average,
|
49
|
+
:home_punt_average, :away_giveaways, :home_giveaways, :away_takeaways,
|
50
|
+
:home_takeaways, :away_turnover_differential, :home_turnover_differential,
|
51
|
+
:away_kickoffs, :home_kickoffs, :away_kickoffs_in_end_zone,
|
52
|
+
:home_kickoffs_in_end_zone, :away_kickoff_touchbacks, :home_kickoff_touchbacks,
|
53
|
+
:away_punts_had_blocked, :home_punts_had_blocked, :away_punt_net_average,
|
54
|
+
:home_punt_net_average, :away_extra_point_kicking_attempts,
|
55
|
+
:home_extra_point_kicking_attempts, :away_extra_point_kicking_conversions,
|
56
|
+
:home_extra_point_kicking_conversions, :away_extra_points_had_blocked,
|
57
|
+
:home_extra_points_had_blocked, :away_extra_point_passing_attempts,
|
58
|
+
:home_extra_point_passing_attempts, :away_extra_point_passing_conversions,
|
59
|
+
:home_extra_point_passing_conversions, :away_extra_point_rushing_attempts,
|
60
|
+
:home_extra_point_rushing_attempts, :away_extra_point_rushing_conversions,
|
61
|
+
:home_extra_point_rushing_conversions, :away_field_goal_attempts,
|
62
|
+
:home_field_goal_attempts, :away_field_goals_made, :home_field_goals_made,
|
63
|
+
:away_field_goals_had_blocked, :home_field_goals_had_blocked,
|
64
|
+
:away_punt_returns, :home_punt_returns, :away_punt_return_yards,
|
65
|
+
:home_punt_return_yards, :away_kick_returns, :home_kick_returns,
|
66
|
+
:away_kick_return_yards, :home_kick_return_yards, :away_interception_returns,
|
67
|
+
:home_interception_returns, :away_interception_return_yards,
|
68
|
+
:home_interception_return_yards, :away_solo_tackles, :away_assisted_tackles,
|
69
|
+
:away_quarterback_hits, :away_tackles_for_loss, :away_sacks,
|
70
|
+
:away_sack_yards, :away_passes_defended, :away_fumbles_forced,
|
71
|
+
:away_fumbles_recovered, :away_fumble_return_yards,
|
72
|
+
:away_fumble_return_touchdowns, :away_interception_return_touchdowns,
|
73
|
+
:away_blocked_kicks, :away_punt_return_touchdowns, :away_punt_return_long,
|
74
|
+
:away_kick_return_touchdowns, :away_kick_return_long,
|
75
|
+
:away_blocked_kick_return_yards, :away_blocked_kick_return_touchdowns,
|
76
|
+
:away_field_goal_return_yards, :away_field_goal_return_touchdowns,
|
77
|
+
:away_punt_net_yards, :home_solo_tackles, :home_assisted_tackles,
|
78
|
+
:home_quarterback_hits, :home_tackles_for_loss, :home_sacks,
|
79
|
+
:home_sack_yards, :home_passes_defended, :home_fumbles_forced,
|
80
|
+
:home_fumbles_recovered, :home_fumble_return_yards,
|
81
|
+
:home_fumble_return_touchdowns, :home_interception_return_touchdowns,
|
82
|
+
:home_blocked_kicks, :home_punt_return_touchdowns,
|
83
|
+
:home_punt_return_long, :home_kick_return_touchdowns,
|
84
|
+
:home_kick_return_long, :home_blocked_kick_return_yards,
|
85
|
+
:home_blocked_kick_return_touchdowns, :home_field_goal_return_yards,
|
86
|
+
:home_field_goal_return_touchdowns, :home_punt_net_yards, :is_game_over,
|
87
|
+
:game_id, :stadium_id, :away_two_point_conversion_returns, :home_two_point_conversion_returns
|
88
|
+
|
89
|
+
def stadium
|
90
|
+
@stadium ||= Fantasydata::Stadium.new(@attrs[:stadium_details])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fantasydata/base'
|
2
|
+
|
3
|
+
module Fantasydata
|
4
|
+
class PlayerDetail < Fantasydata::Base
|
5
|
+
attr_reader :player_id, :team, :number, :first_name, :last_name,
|
6
|
+
:position, :status, :height, :weight, :birth_date, :college,
|
7
|
+
:experience, :fantasy_position, :active, :position_category,
|
8
|
+
:name, :age, :experience_string, :birth_date_string, :photo_url,
|
9
|
+
:bye_week, :upcoming_game_opponent, :upcoming_game_week,
|
10
|
+
:short_name, :average_draft_position, :depth_position_category,
|
11
|
+
:depth_position, :depth_order, :depth_display_order, :current_team,
|
12
|
+
:college_draft_team, :college_draft_year, :college_draft_round,
|
13
|
+
:college_draft_pick, :is_undrafted_free_agent, :height_feet,
|
14
|
+
:height_inches, :upcoming_opponent_rank, :upcoming_opponent_position_rank,
|
15
|
+
:current_status, :upcoming_salary
|
16
|
+
|
17
|
+
# @return [Fantasydata::PlayerSeasonStat]
|
18
|
+
def season_stats
|
19
|
+
@season_stats ||= Fantasydata::PlayerSeasonStat.new(@attrs[:player_season])
|
20
|
+
end
|
21
|
+
|
22
|
+
def latest_news
|
23
|
+
@latest_news ||= map_collection(Fantasydata::News, :latest_news)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fantasydata/base'
|
2
|
+
|
3
|
+
module Fantasydata
|
4
|
+
class PlayerGameStat < Fantasydata::Base
|
5
|
+
attr_reader :custom_d365_fantasy_points, :game_key, :player_id,
|
6
|
+
:season_type, :season, :game_date, :week, :team, :opponent, :home_or_away,
|
7
|
+
:number, :name, :position, :position_category, :activated, :played, :started,
|
8
|
+
:passing_attempts, :passing_completions, :passing_yards, :passing_completion_percentage,
|
9
|
+
:passing_yards_per_attempt, :passing_yards_per_completion, :passing_touchdowns,
|
10
|
+
:passing_interceptions, :passing_rating, :passing_long, :passing_sacks,
|
11
|
+
:passing_sack_yards, :rushing_attempts, :rushing_yards, :rushing_yards_per_attempt,
|
12
|
+
:rushing_touchdowns, :rushing_long, :receiving_targets, :receptions, :receiving_yards,
|
13
|
+
:receiving_yards_per_reception, :receiving_touchdowns, :receiving_long, :fumbles,
|
14
|
+
:fumbles_lost, :punt_returns, :punt_return_yards, :punt_return_yards_per_attempt,
|
15
|
+
:punt_return_touchdowns, :punt_return_long, :kick_returns, :kick_return_yards,
|
16
|
+
:kick_return_yards_per_attempt, :kick_return_touchdowns, :kick_return_long,
|
17
|
+
:solo_tackles, :assisted_tackles, :tackles_for_loss, :sacks, :sack_yards,
|
18
|
+
:quarterback_hits, :passes_defended, :fumbles_forced, :fumbles_recovered,
|
19
|
+
:fumble_return_yards, :fumble_return_touchdowns, :interceptions,
|
20
|
+
:interception_return_yards, :interception_return_touchdowns, :blocked_kicks,
|
21
|
+
:special_teams_solo_tackles, :special_teams_assisted_tackles, :misc_solo_tackles,
|
22
|
+
:misc_assisted_tackles, :punts, :punt_yards, :punt_average, :field_goals_attempted,
|
23
|
+
:field_goals_made, :field_goals_longest_made, :extra_points_made,
|
24
|
+
:two_point_conversion_passes, :two_point_conversion_runs,
|
25
|
+
:two_point_conversion_receptions, :fantasy_points, :fantasy_points_ppr,
|
26
|
+
:reception_percentage, :receiving_yards_per_target, :tackles, :offensive_touchdowns,
|
27
|
+
:defensive_touchdowns, :special_teams_touchdowns, :touchdowns, :fantasy_position,
|
28
|
+
:field_goal_percentage, :player_game_id, :fumbles_own_recoveries,
|
29
|
+
:fumbles_out_of_bounds, :kick_return_fair_catches, :punt_return_fair_catches,
|
30
|
+
:punt_touchbacks, :punt_inside20, :punt_net_average, :extra_points_attempted,
|
31
|
+
:blocked_kick_return_touchdowns, :field_goal_return_touchdowns, :safeties,
|
32
|
+
:field_goals_had_blocked, :punts_had_blocked, :extra_points_had_blocked, :punt_long,
|
33
|
+
:blocked_kick_return_yards, :field_goal_return_yards, :punt_net_yards,
|
34
|
+
:special_teams_fumbles_forced, :special_teams_fumbles_recovered, :misc_fumbles_forced,
|
35
|
+
:misc_fumbles_recovered, :short_name, :playing_surface, :is_game_over, :safeties_allowed,
|
36
|
+
:stadium, :temperature, :humidity, :wind_speed, :fan_duel_salary, :draft_kings_salary,
|
37
|
+
:fantasy_data_salary, :offensive_snaps_played, :defensive_snaps_played,
|
38
|
+
:special_teams_snaps_played, :offensive_team_snaps, :defensive_team_snaps,
|
39
|
+
:special_teams_team_snaps, :victiv_salary
|
40
|
+
|
41
|
+
def scoring_details
|
42
|
+
@scoring_details ||= map_collection(Fantasydata::ScoringDetail, :scoring_details)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'fantasydata/base'
|
2
|
+
|
3
|
+
module Fantasydata
|
4
|
+
class PlayerSeasonStat < Fantasydata::Base
|
5
|
+
attr_reader :custom_d365_fantasy_points, :scoring_details, :player_id,
|
6
|
+
:season_type, :season, :team, :number, :name, :position,
|
7
|
+
:position_category, :activated, :played, :started,
|
8
|
+
:passing_attempts, :passing_completions, :passing_yards,
|
9
|
+
:passing_completion_percentage, :passing_yards_per_attempt,
|
10
|
+
:passing_yards_per_completion, :passing_touchdowns,
|
11
|
+
:passing_interceptions, :passing_rating, :passing_long,
|
12
|
+
:passing_sacks, :passing_sack_yards, :rushing_attempts,
|
13
|
+
:rushing_yards, :rushing_yards_per_attempt, :rushing_touchdowns,
|
14
|
+
:rushing_long, :receiving_targets, :receptions, :receiving_yards,
|
15
|
+
:receiving_yards_per_reception, :receiving_touchdowns,
|
16
|
+
:receiving_long, :fumbles, :fumbles_lost, :punt_returns,
|
17
|
+
:punt_return_yards, :punt_return_yards_per_attempt,
|
18
|
+
:punt_return_touchdowns, :punt_return_long, :kick_returns,
|
19
|
+
:kick_return_yards, :kick_return_yards_per_attempt,
|
20
|
+
:kick_return_touchdowns, :kick_return_long, :solo_tackles,
|
21
|
+
:assisted_tackles, :tackles_for_loss, :sacks, :sack_yards,
|
22
|
+
:quarterback_hits, :passes_defended, :fumbles_forced,
|
23
|
+
:fumbles_recovered, :fumble_return_yards, :fumble_return_touchdowns,
|
24
|
+
:interceptions, :interception_return_yards,
|
25
|
+
:interception_return_touchdowns, :blocked_kicks,
|
26
|
+
:special_teams_solo_tackles, :special_teams_assisted_tackles,
|
27
|
+
:misc_solo_tackles, :misc_assisted_tackles, :punts, :punt_yards,
|
28
|
+
:punt_average, :field_goals_attempted, :field_goals_made,
|
29
|
+
:field_goals_longest_made, :extra_points_made,
|
30
|
+
:two_point_conversion_passes, :two_point_conversion_runs,
|
31
|
+
:two_point_conversion_receptions, :fantasy_points,
|
32
|
+
:fantasy_points_ppr, :reception_percentage,
|
33
|
+
:receiving_yards_per_target, :tackles, :offensive_touchdowns,
|
34
|
+
:defensive_touchdowns, :special_teams_touchdowns, :touchdowns,
|
35
|
+
:fantasy_position, :field_goal_percentage, :player_season_id,
|
36
|
+
:fumbles_own_recoveries, :fumbles_out_of_bounds,
|
37
|
+
:kick_return_fair_catches, :punt_return_fair_catches, :punt_touchbacks,
|
38
|
+
:punt_inside20, :punt_net_average, :extra_points_attempted,
|
39
|
+
:blocked_kick_return_touchdowns, :field_goal_return_touchdowns,
|
40
|
+
:safeties, :field_goals_had_blocked, :punts_had_blocked,
|
41
|
+
:extra_points_had_blocked, :punt_long, :blocked_kick_return_yards,
|
42
|
+
:field_goal_return_yards, :punt_net_yards, :special_teams_fumbles_forced,
|
43
|
+
:special_teams_fumbles_recovered, :misc_fumbles_forced, :misc_fumbles_recovered,
|
44
|
+
:short_name, :safeties_allowed, :temperature, :humidity,
|
45
|
+
:wind_speed, :offensive_snaps_played, :defensive_snaps_played,
|
46
|
+
:special_teams_snaps_played, :offensive_team_snaps, :defensive_team_snaps,
|
47
|
+
:special_teams_team_snaps, :auction_value, :auction_value_ppr
|
48
|
+
|
49
|
+
# @return [Array]
|
50
|
+
def scoring_details
|
51
|
+
@scoring_details ||= map_collection(Fantasydata::ScoringDetail, :scoring_details)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module Fantasydata
|
5
|
+
module Response
|
6
|
+
class ParseJson < Faraday::Response::Middleware
|
7
|
+
|
8
|
+
def parse(body)
|
9
|
+
case body
|
10
|
+
when /\A^\s*$\z/, nil
|
11
|
+
nil
|
12
|
+
else
|
13
|
+
MultiJson.decode(body, :symbolize_keys => true)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_complete(env)
|
18
|
+
if respond_to?(:parse)
|
19
|
+
env[:body] = parse(env[:body]) unless [204, 301, 302, 304].include?(env[:status])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'fantasydata/error/bad_gateway'
|
3
|
+
require 'fantasydata/error/bad_request'
|
4
|
+
require 'fantasydata/error/forbidden'
|
5
|
+
require 'fantasydata/error/gateway_timeout'
|
6
|
+
require 'fantasydata/error/internal_server_error'
|
7
|
+
require 'fantasydata/error/not_acceptable'
|
8
|
+
require 'fantasydata/error/not_found'
|
9
|
+
require 'fantasydata/error/service_unavailable'
|
10
|
+
require 'fantasydata/error/too_many_requests'
|
11
|
+
require 'fantasydata/error/unauthorized'
|
12
|
+
require 'fantasydata/error/unprocessable_entity'
|
13
|
+
|
14
|
+
module Fantasydata
|
15
|
+
module Response
|
16
|
+
class RaiseError < Faraday::Response::Middleware
|
17
|
+
|
18
|
+
def on_complete(env)
|
19
|
+
status_code = env[:status].to_i
|
20
|
+
error_class = @klass.errors[status_code]
|
21
|
+
raise error_class.from_response(env) if error_class
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(app, klass)
|
25
|
+
|
26
|
+
@klass = klass
|
27
|
+
super(app)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'fantasydata/base'
|
2
|
+
|
3
|
+
module Fantasydata
|
4
|
+
class Schedule < Fantasydata::Base
|
5
|
+
attr_reader :game_key, :season_type, :season, :week, :date,
|
6
|
+
:away_team, :home_team, :channel, :point_spread,
|
7
|
+
:over_under, :stadium_id
|
8
|
+
|
9
|
+
def stadium
|
10
|
+
@stadium ||= Fantasydata::Stadium.new(@attrs[:stadium_details])
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'fantasydata/base'
|
2
|
+
|
3
|
+
module Fantasydata
|
4
|
+
class Standings < Fantasydata::Base
|
5
|
+
attr_reader :season_type, :season, :conference,
|
6
|
+
:division, :team, :name, :wins,
|
7
|
+
:losses, :ties, :percentage, :points_for,
|
8
|
+
:points_against, :net_points, :touchdowns,
|
9
|
+
:division_wins, :division_losses,
|
10
|
+
:conference_wins, :conference_losses
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'fantasydata/base'
|
2
|
+
|
3
|
+
module Fantasydata
|
4
|
+
class TeamDetail < Fantasydata::Base
|
5
|
+
attr_reader :key, :team_id, :player_id,
|
6
|
+
:city, :name, :conference, :division, :full_name,
|
7
|
+
:stadium_id, :bye_week, :average_draft_position,
|
8
|
+
:average_draft_position_ppr, :head_coach,
|
9
|
+
:offensive_coordinator, :defensive_coordinator,
|
10
|
+
:special_teams_coach, :offensive_scheme,
|
11
|
+
:defensive_scheme, :upcoming_salary,
|
12
|
+
:upcoming_opponent_rank, :upcoming_opponent_position_rank
|
13
|
+
|
14
|
+
|
15
|
+
def stadium
|
16
|
+
@stadium ||= Fantasydata::Stadium.new(@attrs[:stadium_details])
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Fantasydata::API::ByeWeeks do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = new_test_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#bye_weeks_season' do
|
10
|
+
before do
|
11
|
+
stub_get("/nfl/v2/JSON/Byes/2015REG").
|
12
|
+
to_return(:body => fixture("bye_weeks/bye_weeks.json"),
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requests correct resource" do
|
17
|
+
bye_weeks = @client.bye_weeks_for_season('2015REG')
|
18
|
+
expect(a_get("/nfl/v2/JSON/Byes/2015REG")).to have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns byeweeks" do
|
22
|
+
byeweeks = @client.bye_weeks_for_season('2015REG')
|
23
|
+
expect(byeweeks).to be_an Array
|
24
|
+
expect(byeweeks.first.season).to eq 2015
|
25
|
+
expect(byeweeks.first.week).to eq 4
|
26
|
+
expect(byeweeks.first.team).to eq 'NE'
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Fantasydata::API::Fantasy do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = new_test_client
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#daily_fantasy_players' do
|
10
|
+
before do
|
11
|
+
stub_get("/nfl/v2/JSON/DailyFantasyPlayers/2014-SEP-21").
|
12
|
+
to_return(:body => fixture("daily_fantasy/daily_players.json"),
|
13
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requests correct resource - pass string" do
|
17
|
+
@client.daily_fantasy_players_for_day('2014-SEP-21')
|
18
|
+
expect(a_get("/nfl/v2/JSON/DailyFantasyPlayers/2014-SEP-21")).to have_been_made
|
19
|
+
end
|
20
|
+
|
21
|
+
it "requests correct resource - pass date" do
|
22
|
+
@client.daily_fantasy_players_for_day(DateTime.parse("2014/09/21"))
|
23
|
+
expect(a_get("/nfl/v2/JSON/DailyFantasyPlayers/2014-SEP-21")).to have_been_made
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns players" do
|
27
|
+
players = @client.daily_fantasy_players_for_day('2014-SEP-21')
|
28
|
+
|
29
|
+
expect(players).to be_an Array
|
30
|
+
expect(players.first.player_id).to eq 7328
|
31
|
+
expect(players.first.date).to eq '2014-09-21T16:25:00'
|
32
|
+
expect(players.first.short_name).to eq 'P.Manning'
|
33
|
+
expect(players.first.name).to eq 'Peyton Manning'
|
34
|
+
expect(players.first.team).to eq 'DEN'
|
35
|
+
expect(players.first.opponent).to eq 'SEA'
|
36
|
+
expect(players.first.position).to eq 'QB'
|
37
|
+
expect(players.first.salary).to eq 9900
|
38
|
+
expect(players.first.last_game_fantasy_points).to eq 10.44
|
39
|
+
expect(players.first.projected_fantasy_points).to eq 17.32
|
40
|
+
expect(players.first.opponent_rank).to eq 11
|
41
|
+
expect(players.first.opponent_position_rank).to eq 16
|
42
|
+
expect(players.first.status).to eq 'Healthy'
|
43
|
+
expect(players.first.status_code).to eq 'ACT'
|
44
|
+
expect(players.first.status_color).to eq 'green'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#daily_fantasy_results' do
|
49
|
+
before do
|
50
|
+
stub_get("/nfl/v2/JSON/DailyFantasyPoints/2014-SEP-21").
|
51
|
+
to_return(:body => fixture("daily_fantasy/daily_points.json"),
|
52
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
53
|
+
end
|
54
|
+
|
55
|
+
it "requests correct resource - pass string" do
|
56
|
+
@client.daily_fantasy_points_for_day('2014-SEP-21')
|
57
|
+
expect(a_get("/nfl/v2/JSON/DailyFantasyPoints/2014-SEP-21")).to have_been_made
|
58
|
+
end
|
59
|
+
|
60
|
+
it "requests correct resource - pass date" do
|
61
|
+
@client.daily_fantasy_points_for_day(DateTime.parse("2014/09/21"))
|
62
|
+
expect(a_get("/nfl/v2/JSON/DailyFantasyPoints/2014-SEP-21")).to have_been_made
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns player data" do
|
66
|
+
players = @client.daily_fantasy_points_for_day('2014-SEP-21')
|
67
|
+
|
68
|
+
expect(players).to be_an Array
|
69
|
+
expect(players.first.player_id).to eq 2593
|
70
|
+
expect(players.first.name).to eq 'Aaron Rodgers'
|
71
|
+
expect(players.first.fantasy_points).to eq 28.64
|
72
|
+
expect(players.first.has_started).to eq true
|
73
|
+
expect(players.first.is_in_progress).to eq false
|
74
|
+
expect(players.first.is_over).to eq true
|
75
|
+
expect(players.first.date).to eq nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#daily_fantasy_defense_game_stats' do
|
80
|
+
before do
|
81
|
+
stub_get("/nfl/v2/JSON/FantasyDefenseByGame/2014/12").
|
82
|
+
to_return(:body => fixture("daily_fantasy/daily_defense_game.json"),
|
83
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
84
|
+
end
|
85
|
+
|
86
|
+
it "requests correct resource" do
|
87
|
+
@client.daily_fantasy_defense_game_stats(2014, 12)
|
88
|
+
expect(a_get("/nfl/v2/JSON/FantasyDefenseByGame/2014/12")).to have_been_made
|
89
|
+
end
|
90
|
+
|
91
|
+
it "returns player data" do
|
92
|
+
defenses = @client.daily_fantasy_defense_game_stats(2014, 12)
|
93
|
+
|
94
|
+
expect(defenses).to be_an Array
|
95
|
+
expect(defenses.first.scoring_details).to be_an Array
|
96
|
+
|
97
|
+
expect(defenses.first.team).to eq 'BAL'
|
98
|
+
expect(defenses.first.scoring_details.first.game_key).to eq "201411222"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#daily_fantasy_defense_game_stats_projected' do
|
103
|
+
before do
|
104
|
+
stub_get("/nfl/v2/JSON/FantasyDefenseProjectionsByGame/2014/12").
|
105
|
+
to_return(:body => fixture("daily_fantasy/defense_game_stats_projected.json"),
|
106
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
107
|
+
end
|
108
|
+
|
109
|
+
it "requests correct resource" do
|
110
|
+
@client.daily_fantasy_defense_game_projected_stats(2014, 12)
|
111
|
+
expect(a_get("/nfl/v2/JSON/FantasyDefenseProjectionsByGame/2014/12")).to have_been_made
|
112
|
+
end
|
113
|
+
|
114
|
+
it "returns player data" do
|
115
|
+
defenses = @client.daily_fantasy_defense_game_projected_stats(2014, 12)
|
116
|
+
|
117
|
+
expect(defenses).to be_an Array
|
118
|
+
expect(defenses.first.scoring_details).to be_an Array
|
119
|
+
|
120
|
+
expect(defenses.first.team).to eq 'OAK'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#daily_fantasy_defense_game_year_stats' do
|
125
|
+
before do
|
126
|
+
stub_get("/nfl/v2/JSON/FantasyDefenseBySeason/2014").
|
127
|
+
to_return(:body => fixture("daily_fantasy/daily_defense_seasons_stats.json"),
|
128
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
129
|
+
end
|
130
|
+
|
131
|
+
it "requests correct resource" do
|
132
|
+
@client.daily_fantasy_defense_season_stats(2014)
|
133
|
+
expect(a_get("/nfl/v2/JSON/FantasyDefenseBySeason/2014")).to have_been_made
|
134
|
+
end
|
135
|
+
|
136
|
+
it "returns player data" do
|
137
|
+
defenses = @client.daily_fantasy_defense_season_stats(2014)
|
138
|
+
|
139
|
+
expect(defenses).to be_an Array
|
140
|
+
expect(defenses.first.scoring_details).to be_an Array
|
141
|
+
|
142
|
+
expect(defenses.first.team).to eq 'ARI'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe '#daily_fantasy_defense_game_year_stats_projected' do
|
147
|
+
before do
|
148
|
+
stub_get("/nfl/v2/JSON/FantasyDefenseProjectionsBySeason/2014").
|
149
|
+
to_return(:body => fixture("daily_fantasy/daily_defense_seasons_proj.json"),
|
150
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
151
|
+
end
|
152
|
+
|
153
|
+
it "requests correct resource" do
|
154
|
+
@client.daily_fantasy_defense_season_projected_stats(2014)
|
155
|
+
expect(a_get("/nfl/v2/JSON/FantasyDefenseProjectionsBySeason/2014")).to have_been_made
|
156
|
+
end
|
157
|
+
|
158
|
+
it "returns player data" do
|
159
|
+
defenses = @client.daily_fantasy_defense_season_projected_stats(2014)
|
160
|
+
|
161
|
+
expect(defenses).to be_an Array
|
162
|
+
expect(defenses.first.scoring_details).to be_an Array
|
163
|
+
|
164
|
+
expect(defenses.first.team).to eq 'ARI'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe '#fantasy_players_adp' do
|
169
|
+
before do
|
170
|
+
stub_get("/nfl/v2/JSON/FantasyPlayers").
|
171
|
+
to_return(:body => fixture("daily_fantasy/adp.json"),
|
172
|
+
:headers => {:content_type => "application/json; charset=utf-8"})
|
173
|
+
end
|
174
|
+
|
175
|
+
it "requests correct resource" do
|
176
|
+
@client.fantasy_players_adp
|
177
|
+
expect(a_get("/nfl/v2/JSON/FantasyPlayers")).to have_been_made
|
178
|
+
end
|
179
|
+
|
180
|
+
it "returns player data" do
|
181
|
+
adps = @client.fantasy_players_adp
|
182
|
+
expect(adps).to be_an Array
|
183
|
+
expect(adps.first.player_id).to eq 4807
|
184
|
+
expect(adps.first.fantasy_player_key).to eq "4807"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
end
|