y_fantasy 0.1.0

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.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/.pryrc +8 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +20 -0
  5. data/.standard.yml +2 -0
  6. data/CHANGELOG.md +5 -0
  7. data/CODE_OF_CONDUCT.md +3 -0
  8. data/Gemfile +5 -0
  9. data/Gemfile.lock +220 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +41 -0
  12. data/Rakefile +12 -0
  13. data/exe/y_fantasy +9 -0
  14. data/lib/y_fantasy/api/authentication.rb +177 -0
  15. data/lib/y_fantasy/api/client.rb +84 -0
  16. data/lib/y_fantasy/api/subresource_param_builder.rb +138 -0
  17. data/lib/y_fantasy/api/url_builder.rb +91 -0
  18. data/lib/y_fantasy/cli.rb +46 -0
  19. data/lib/y_fantasy/concerns/subresourceable.rb +87 -0
  20. data/lib/y_fantasy/ref/nfl.rb +57 -0
  21. data/lib/y_fantasy/resources/base_resource.rb +117 -0
  22. data/lib/y_fantasy/resources/base_subresource.rb +31 -0
  23. data/lib/y_fantasy/resources/game/game_week.rb +26 -0
  24. data/lib/y_fantasy/resources/game/position_type.rb +20 -0
  25. data/lib/y_fantasy/resources/game.rb +136 -0
  26. data/lib/y_fantasy/resources/group/settings.rb +53 -0
  27. data/lib/y_fantasy/resources/group/standings.rb +11 -0
  28. data/lib/y_fantasy/resources/group.rb +76 -0
  29. data/lib/y_fantasy/resources/league/scoreboard.rb +12 -0
  30. data/lib/y_fantasy/resources/league/settings.rb +51 -0
  31. data/lib/y_fantasy/resources/league/standings.rb +25 -0
  32. data/lib/y_fantasy/resources/league.rb +187 -0
  33. data/lib/y_fantasy/resources/pickem_team/pick.rb +31 -0
  34. data/lib/y_fantasy/resources/pickem_team/week_pick.rb +28 -0
  35. data/lib/y_fantasy/resources/pickem_team.rb +98 -0
  36. data/lib/y_fantasy/resources/player/draft_analysis.rb +26 -0
  37. data/lib/y_fantasy/resources/player/ownership_percentage.rb +26 -0
  38. data/lib/y_fantasy/resources/player/stat_collection.rb +32 -0
  39. data/lib/y_fantasy/resources/player.rb +157 -0
  40. data/lib/y_fantasy/resources/shared_subresources/draft_result.rb +39 -0
  41. data/lib/y_fantasy/resources/shared_subresources/matchup.rb +61 -0
  42. data/lib/y_fantasy/resources/shared_subresources/roster_position.rb +38 -0
  43. data/lib/y_fantasy/resources/shared_subresources/stat.rb +16 -0
  44. data/lib/y_fantasy/resources/shared_subresources/stat_category.rb +22 -0
  45. data/lib/y_fantasy/resources/shared_subresources/stat_modifier.rb +10 -0
  46. data/lib/y_fantasy/resources/shared_subresources/stat_winner.rb +8 -0
  47. data/lib/y_fantasy/resources/team/manager.rb +23 -0
  48. data/lib/y_fantasy/resources/team/roster.rb +18 -0
  49. data/lib/y_fantasy/resources/team/standings.rb +33 -0
  50. data/lib/y_fantasy/resources/team/stat_collection.rb +38 -0
  51. data/lib/y_fantasy/resources/team.rb +175 -0
  52. data/lib/y_fantasy/subresource_validator.rb +67 -0
  53. data/lib/y_fantasy/transformations/base_transform.rb +62 -0
  54. data/lib/y_fantasy/transformations/collection_transformer.rb +22 -0
  55. data/lib/y_fantasy/transformations/default_transformer.rb +22 -0
  56. data/lib/y_fantasy/transformations/game/position_types_transformer.rb +21 -0
  57. data/lib/y_fantasy/transformations/game_transformer.rb +54 -0
  58. data/lib/y_fantasy/transformations/group_transformer.rb +39 -0
  59. data/lib/y_fantasy/transformations/instantiator.rb +25 -0
  60. data/lib/y_fantasy/transformations/key_unwrapper.rb +12 -0
  61. data/lib/y_fantasy/transformations/league/scoreboard_transformer.rb +21 -0
  62. data/lib/y_fantasy/transformations/league/settings_transformer.rb +25 -0
  63. data/lib/y_fantasy/transformations/league/standings_transformer.rb +22 -0
  64. data/lib/y_fantasy/transformations/league_transformer.rb +57 -0
  65. data/lib/y_fantasy/transformations/matchups_transformer.rb +22 -0
  66. data/lib/y_fantasy/transformations/pickem_team/week_picks_transformer.rb +29 -0
  67. data/lib/y_fantasy/transformations/pickem_team_transformer.rb +41 -0
  68. data/lib/y_fantasy/transformations/player/ownership_percentage_transformer.rb +21 -0
  69. data/lib/y_fantasy/transformations/player/stats_transformer.rb +32 -0
  70. data/lib/y_fantasy/transformations/player_transformer.rb +34 -0
  71. data/lib/y_fantasy/transformations/stat_categories_transformer.rb +19 -0
  72. data/lib/y_fantasy/transformations/stat_modifiers_transformer.rb +19 -0
  73. data/lib/y_fantasy/transformations/t.rb +44 -0
  74. data/lib/y_fantasy/transformations/team/manager_transformer.rb +19 -0
  75. data/lib/y_fantasy/transformations/team/roster_transformer.rb +27 -0
  76. data/lib/y_fantasy/transformations/team/standings_transformer.rb +42 -0
  77. data/lib/y_fantasy/transformations/team/stats_transformer.rb +30 -0
  78. data/lib/y_fantasy/transformations/team_transformer.rb +54 -0
  79. data/lib/y_fantasy/transformations/user_transformer.rb +17 -0
  80. data/lib/y_fantasy/transformations.rb +54 -0
  81. data/lib/y_fantasy/version.rb +5 -0
  82. data/lib/y_fantasy.rb +36 -0
  83. data/sig/y_fantasy.rbs +4 -0
  84. data/y_fantasy.gemspec +49 -0
  85. metadata +364 -0
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ # Represents a Yahoo Fantasy Pick'em Team in a NFL Survival Group
5
+ class PickemTeam < BaseResource
6
+ # --- REQUIRED ATTRIBUTES ------------------------------------------------------------------------------------------
7
+
8
+ # @!attribute [r] team_key
9
+ # @return [String] The unique key for this PickemTeam
10
+ option :team_key
11
+
12
+ # @!attribute [r] team_id
13
+ # @return [Integer] The ID for this PickemTeam
14
+ option :team_id, type: Types::Coercible::Integer
15
+
16
+ # @!attribute [r] name
17
+ # @return [String] The name of the PickemTeam
18
+ option :name
19
+
20
+ # @!attribute [r] total_strikes
21
+ # @return [Integer] The total number of strikes this team has
22
+ option :total_strikes, type: Types::Coercible::Integer
23
+
24
+ # @!attribute [r] elimination_week
25
+ # @return [Integer] The week number when this team was eliminated
26
+ option :elimination_week, type: Types::Coercible::Integer
27
+
28
+ # --- OPTIONAL ATTRIBUTES ------------------------------------------------------------------------------------------
29
+
30
+ # @!attribute [r] can_edit_current_week
31
+ # @return [Boolean, nil] whether picks are editable for the current week
32
+ option :can_edit_current_week, optional: true, type: Types::Params::Bool
33
+
34
+ # @!attribute [r] current_pick
35
+ # @return [String, nil] the current pick for this team
36
+ option :current_pick, optional: true
37
+
38
+ # @!attribute [r] current_picks
39
+ # @return [Array, nil] the current picks for this team
40
+ option :current_picks, optional: true
41
+
42
+ # @!attribute [r] eliminated
43
+ # @return [Boolean, nil] whether this team has been eliminated
44
+ option :eliminated, optional: true, type: Types::Params::Bool
45
+
46
+ # @!attribute [r] elimination_pick
47
+ # @return [String, nil] the pick that caused this team's elimination
48
+ option :elimination_pick, optional: true
49
+
50
+ # @!attribute [r] is_in_contest
51
+ # @return [Boolean, nil] whether this team is in a contest
52
+ option :is_in_contest, optional: true, type: Types::Params::Bool
53
+
54
+ # @!attribute [r] is_owned_by_current_login
55
+ # @return [Boolean, nil] whether this team is owned by the current user
56
+ option :is_owned_by_current_login, optional: true, type: Types::Params::Bool
57
+
58
+ # @!attribute [r] last_editable_week
59
+ # @return [String, nil] the last week number that can be edited
60
+ option :last_editable_week, optional: true
61
+
62
+ # @!attribute [r] manager
63
+ # @return [Team::Manager, nil] the manager of this PickemTeam
64
+ option :manager, optional: true, type: instance_of(Team::Manager)
65
+
66
+ # @!attribute [r] status
67
+ # @return [String, nil] the status of this PickemTeam
68
+ option :status, optional: true
69
+
70
+ # --- SUBRESOURCES -------------------------------------------------------------------------------------------------
71
+
72
+ # @!attribute [r] week_picks
73
+ # @return [Array<WeekPick>, nil] the weekly picks for this team
74
+ option :week_picks, optional: true, type: array_of(WeekPick)
75
+
76
+ has_subresource :week_picks, klass: WeekPick
77
+
78
+ # --- INSTANCE METHODS ---------------------------------------------------------------------------------------------
79
+
80
+ # Returns the key of this PickemTeam
81
+ # @return [String] the team key
82
+ def key
83
+ team_key
84
+ end
85
+
86
+ # Returns the group key for this PickemTeam
87
+ # @return [String] the group key
88
+ def group_key
89
+ @group_key ||= team_key.sub(/\.t\.\d+/, "")
90
+ end
91
+
92
+ # Returns the group this PickemTeam belongs to
93
+ # @return [Group] the group object
94
+ def group
95
+ @group ||= Group.find(group_key)
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class Player
5
+ # Draft statistics for a player in Yahoo Fantasy Sports
6
+ class DraftAnalysis < BaseSubresource
7
+ # --- REQUIRED ATTRIBUTES ----------------------------------------------------------------------------------------
8
+
9
+ # @!attribute [r] average_cost
10
+ # @return [Float] the average cost of this player in auction drafts
11
+ option :average_cost, type: ->(v) { Transformations::T.floatize(v) }
12
+
13
+ # @!attribute [r] average_pick
14
+ # @return [Float] the average pick used to draft this player
15
+ option :average_pick, type: ->(v) { Transformations::T.floatize(v) }
16
+
17
+ # @!attribute [r] average_round
18
+ # @return [Float] the player's average draft round
19
+ option :average_round, type: ->(v) { Transformations::T.floatize(v) }
20
+
21
+ # @!attribute [r] percent_drafted
22
+ # @return [Float] the percentage of drafts in which this player was selected
23
+ option :percent_drafted, type: ->(v) { Transformations::T.floatize(v) * 100 }
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class Player
5
+ # Represents ownership percentage data for a player in Yahoo Fantasy Sports.
6
+ class OwnershipPercentage < BaseSubresource
7
+ # --- REQUIRED ATTRIBUTES ----------------------------------------------------------------------------------------
8
+
9
+ # @!attribute [r] coverage_type
10
+ # @return [String] the type of coverage (e.g., "week")
11
+ option :coverage_type
12
+
13
+ # @!attribute [r] delta
14
+ # @return [Integer] the change in ownership percentage
15
+ option :delta, type: Types::Coercible::Integer
16
+
17
+ # @!attribute [r] value
18
+ # @return [Integer] the ownership percentage, given as a whole number
19
+ option :value, type: Types::Coercible::Integer
20
+
21
+ # @!attribute [r] week
22
+ # @return [Integer] the week for which ownership percentage is reported
23
+ option :week, type: Types::Coercible::Integer
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class Player
5
+ # A collection of stats for a player, for a given time period (e.g., season, week).
6
+ class StatCollection < BaseSubresource
7
+ # --- REQUIRED ATTRIBUTES ----------------------------------------------------------------------------------------
8
+
9
+ # @!attribute [r] coverage_type
10
+ # @return [String] the type of coverage (e.g., "week", "season")
11
+ option :coverage_type
12
+
13
+ # @!attribute [r] standard_stats
14
+ # @return [Array<Stat>] standard stats for this player
15
+ option :standard_stats, type: array_of(Stat)
16
+
17
+ # --- OPTIONAL ATTRIBUTES ----------------------------------------------------------------------------------------
18
+
19
+ # @!attribute [r] advanced_stats
20
+ # @return [Array<Stat>] advanced stats for this player
21
+ option :advanced_stats, optional: true, type: array_of(Stat)
22
+
23
+ # @!attribute [r] season
24
+ # @return [Integer] the season for which stats are reported
25
+ option :season, optional: true, type: Types::Coercible::Integer
26
+
27
+ # @!attribute [r] week
28
+ # @return [Integer] the week for which stats are reported (nil if coverage_type is "season")
29
+ option :week, optional: true, type: Types::Coercible::Integer
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,157 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ # Represents a Yahoo Fantasy Player
5
+ class Player < BaseResource
6
+ # --- REQUIRED ATTRIBUTES ------------------------------------------------------------------------------------------
7
+
8
+ # @!attribute [r] player_key
9
+ # @return [String] the unique key for this player, within a Game
10
+ option :player_key
11
+
12
+ # @!attribute [r] player_id
13
+ # @return [Integer] the ID for this player
14
+ option :player_id, type: Types::Coercible::Integer
15
+
16
+ # @!attribute [r] display_position
17
+ # @return [String] the display position of the player
18
+ # @note When a player has more than one position, this will be a comma-separated string of positions
19
+ option :display_position
20
+
21
+ # @!attribute [r] editorial_player_key
22
+ # @return [String] the editorial key for this player
23
+ option :editorial_player_key
24
+
25
+ # @!attribute [r] editorial_team_abbr
26
+ # @return [String] the abbreviation of the player's real-life team
27
+ option :editorial_team_abbr
28
+
29
+ # @!attribute [r] editorial_team_full_name
30
+ # @return [String] the full name of the player's real-life team
31
+ option :editorial_team_full_name
32
+
33
+ # @!attribute [r] editorial_team_key
34
+ # @return [String] the key of the player's real-life team
35
+ option :editorial_team_key
36
+
37
+ # @!attribute [r] editorial_team_url
38
+ # @return [String] the URL to the player's real-life team page
39
+ option :editorial_team_url
40
+
41
+ # @!attribute [r] eligible_positions
42
+ # @return [String, Array<String>] the eligible positions for this player (e.g. "QB", ["RB", "WR"])
43
+ option :eligible_positions, type: ->(h) { h[:position] }
44
+
45
+ # @!attribute [r] headshot
46
+ # @return [Hash] hash containing headshot information (size, url)
47
+ option :headshot
48
+
49
+ # @!attribute [r] image_url
50
+ # @return [String] the player's image URL
51
+ option :image_url
52
+
53
+ # @!attribute [r] is_keeper
54
+ # @return [Hash] A hash containing the player's keeper status and cost
55
+ option :is_keeper
56
+
57
+ # @!attribute [r] is_undroppable
58
+ # @return [Boolean] whether this player is undroppable
59
+ option :is_undroppable, type: Types::Params::Bool
60
+
61
+ # @!attribute [r] name
62
+ # @return [Hash] hash containing the player's name (first, last, full, ascii_first, ascii_last)
63
+ option :name
64
+
65
+ # @!attribute [r] position_type
66
+ # @return [String] the type of position (e.g. "O" for offense)
67
+ option :position_type
68
+
69
+ # @!attribute [r] uniform_number
70
+ # @return [String] the player's uniform number
71
+ option :uniform_number
72
+
73
+ # @!attribute [r] url
74
+ # @return [String] the URL to the player's Yahoo Fantasy page
75
+ option :url
76
+
77
+ # --- OPTIONAL ATTRIBUTES ------------------------------------------------------------------------------------------
78
+
79
+ # @!attribute [r] bye_weeks
80
+ # @return [Array<String>, nil] the bye weeks for this player
81
+ option :bye_weeks, optional: true, type: ->(h) { h[:week] }
82
+
83
+ # @!attribute [r] has_player_notes
84
+ # @return [Boolean, nil] whether this player has notes
85
+ option :has_player_notes, optional: true, type: Types::Params::Bool
86
+
87
+ # @!attribute [r] has_recent_player_notes
88
+ # @return [Boolean, nil] whether this player has recent notes
89
+ option :has_recent_player_notes, optional: true, type: Types::Params::Bool
90
+
91
+ # @!attribute [r] player_notes_last_timestamp
92
+ # @return [Integer, nil] the timestamp of the last player note
93
+ option :player_notes_last_timestamp, optional: true, type: Types::Coercible::Integer
94
+
95
+ # @!attribute [r] player_points
96
+ # Hash containing details about the player's fantasy points. Includes: coverage_type, total, week.
97
+ # @note Only available when requesting a player within a team's roster
98
+ # @return [Hash, nil] the player's fantasy points information
99
+ option :player_points, optional: true do
100
+ option :coverage_type
101
+ option :total, type: Types::Coercible::Float
102
+ option :week, optional: true, type: Types::Coercible::Integer
103
+ end
104
+
105
+ # @!attribute [r] selected_position
106
+ # Hash containing details about the player's selected position. Includes: coverage_type, is_flex, positition, week.
107
+ # @note Only available when requesting a player within a team's roster
108
+ # @return [Hash, nil] the player's selected position information
109
+ option :selected_position, optional: true do
110
+ option :coverage_type
111
+ option :is_flex, optional: true, type: Types::Params::Bool
112
+ option :position
113
+ option :week, optional: true, type: Types::Coercible::Integer
114
+ end
115
+
116
+ # --- SUBRESOURCES -------------------------------------------------------------------------------------------------
117
+
118
+ # @!attribute [r] draft_analysis
119
+ # @return [DraftAnalysis, nil] the draft analysis for this player
120
+ option :draft_analysis, optional: true, type: instance_of(DraftAnalysis)
121
+
122
+ # @!attribute [r] ownership_percentage
123
+ # @return [OwnershipPercentage, nil] the ownership percentage information for this player
124
+ option :ownership_percentage, optional: true, type: instance_of(OwnershipPercentage)
125
+
126
+ # @!attribute [r] stats
127
+ # @return [StatCollection, nil] the stat collection for this player
128
+ option :stats, optional: true, type: instance_of(StatCollection)
129
+
130
+ has_subresource :draft_analysis, klass: DraftAnalysis
131
+ has_subresource :ownership_percentage, klass: OwnershipPercentage
132
+ has_subresource :stats, klass: StatCollection
133
+
134
+ # --- INSTANCE METHODS ---------------------------------------------------------------------------------------------
135
+
136
+ # :nocov:
137
+
138
+ # Returns the player's first name
139
+ # @return [String] the player's first name
140
+ def first_name
141
+ name[:first]
142
+ end
143
+
144
+ # Returns the player's last name
145
+ # @return [String] the player's last name
146
+ def last_name
147
+ name[:last]
148
+ end
149
+
150
+ # Returns the player's full name
151
+ # @return [String] the player's full name
152
+ def full_name
153
+ name[:full]
154
+ end
155
+ # :nocov:
156
+ end
157
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ # Represents a single draft result in a Yahoo Fantasy league
5
+ class DraftResult < BaseSubresource
6
+ # --- REQUIRED ATTRIBUTES ------------------------------------------------------------------------------------------
7
+
8
+ # @!attribute [r] pick
9
+ # @return [Integer] the pick number
10
+ option :pick, type: Types::Coercible::Integer
11
+
12
+ # @!attribute [r] round
13
+ # @return [Integer] the draft round
14
+ option :round, type: Types::Coercible::Integer
15
+
16
+ # @!attribute [r] player_key
17
+ # @return [String] the unique key for the player drafted
18
+ option :player_key
19
+
20
+ # @!attribute [r] team_key
21
+ # @return [String] the unique key for the drafting team
22
+ option :team_key
23
+
24
+ # :nocov:
25
+
26
+ # Retrieves the Player resource associated with this draft result
27
+ # @return [Player] the player drafted
28
+ def player
29
+ self.class.find(:player, player_key)
30
+ end
31
+
32
+ # Retrieves the Team resource associated with this draft result
33
+ # @return [Team] the drafting team
34
+ def team
35
+ self.class.find(:team, team_key)
36
+ end
37
+ # :nocov:
38
+ end
39
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class Matchup < BaseSubresource
5
+ # Required attributes
6
+ option :is_consolation, type: Types::Params::Bool
7
+ option :is_playoffs, type: Types::Params::Bool
8
+ option :status
9
+ option :week, type: Types::Coercible::Integer
10
+ option :week_end, type: Types::Params::Date
11
+ option :week_start, type: Types::Params::Date
12
+
13
+ # Optional attributes
14
+ option :is_matchup_recap_available, optional: true, type: Types::Params::Bool
15
+ option :is_tied, optional: true, type: Types::Params::Bool
16
+ option :stat_winners, optional: true, type: array_of(StatWinner)
17
+ option :winner_team_key, optional: true
18
+
19
+ # Subresources
20
+ option :teams, type: array_of(Team)
21
+
22
+ def winning_team
23
+ return if is_tied
24
+
25
+ teams.find { |team| team.team_key == winner_team_key }
26
+ end
27
+
28
+ def losing_team
29
+ return if is_tied
30
+
31
+ teams.find { |team| team.team_key != winner_team_key }
32
+ end
33
+
34
+ def winner_total_points
35
+ winning_team&.stats&.team_points&.total
36
+ end
37
+
38
+ def winner_proj_points
39
+ winning_team&.stats&.team_projected_points&.total
40
+ end
41
+
42
+ def loser_total_points
43
+ losing_team&.stats&.team_points&.total
44
+ end
45
+
46
+ def loser_proj_points
47
+ losing_team&.stats&.team_projected_points&.total
48
+ end
49
+
50
+ def scores
51
+ teams.map do |team|
52
+ {
53
+ team_key: team.team_key,
54
+ team_name: team.name,
55
+ total: team.stats.team_points.total,
56
+ proj_total: team.stats.team_projected_points.total
57
+ }
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ # Reprsents a Yahoo Fantasy roster position
5
+ class RosterPosition < BaseSubresource
6
+ # --- REQUIRED ATTRIBUTES ------------------------------------------------------------------------------------------
7
+
8
+ # @!attribute [r] position
9
+ # @return [String] the position name (e.g., "QB")
10
+ option :position
11
+
12
+ # --- OPTIONAL ATTRIBUTES ------------------------------------------------------------------------------------------
13
+
14
+ # @!attribute [r] abbreviation
15
+ # @return [String] the position abbreviation
16
+ option :abbreviation, optional: true
17
+
18
+ # @!attribute [r] display_name
19
+ # @return [String] the position display name
20
+ option :display_name, optional: true
21
+
22
+ # @!attribute [r] position_type
23
+ # @return [String] the position type (e.g., "O", "DT", "K", "BN")
24
+ option :position_type, optional: true
25
+
26
+ # @!attribute [r] count
27
+ # @return [Integer] the number of this position type allowed on a roster
28
+ option :count, optional: true, type: Types::Coercible::Integer
29
+
30
+ # @!attribute [r] is_bench
31
+ # @return [Boolean] whether this position is a bench position
32
+ option :is_bench, optional: true, type: Types::Params::Bool
33
+
34
+ # @!attribute [r] is_starting_position
35
+ # @return [Boolean] whether this position is a starting position
36
+ option :is_starting_position, optional: true, type: Types::Params::Bool
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ # Represents
5
+ class Stat < BaseSubresource
6
+ # --- REQUIRED ATTRIBUTES ------------------------------------------------------------------------------------------
7
+
8
+ # @!attribute [r] stat_id
9
+ # @return [Integer] the Yahoo stat ID
10
+ option :stat_id, type: Types::Coercible::Integer
11
+
12
+ # @!attribute [r] value
13
+ # @return [String] the value for this stat
14
+ option :value
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class StatCategory < BaseSubresource
5
+ # Required attributes
6
+ option :stat_id, type: Types::Coercible::Integer
7
+
8
+ option :display_name
9
+ option :name
10
+ option :sort_order, type: Types::Coercible::Integer
11
+
12
+ # Optional attributes
13
+ option :abbr, optional: true
14
+ option :base_stats, optional: true, type: ->(h) { h.values.flatten }
15
+ option :enabled, optional: true, type: Types::Params::Bool
16
+ option :group, optional: true
17
+ option :is_composite_stat, optional: true, type: Types::Params::Bool
18
+ option :is_only_display_stat, optional: true, type: Types::Params::Bool
19
+ option :position_type, optional: true
20
+ option :position_types, optional: true, type: ->(h) { h.values.flatten }
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ # NOTE: StatModifiers are only included in settings for certain league scoring types.
5
+ class StatModifier < BaseSubresource
6
+ # Required attributes
7
+ option :stat_id, type: Types::Coercible::Integer
8
+ option :value, type: Types::Coercible::Float
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class StatWinner < BaseSubresource
5
+ option :stat_id, type: Types::Coercible::Integer
6
+ option :winner_team_key, optional: true
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class Team
5
+ class Manager < BaseSubresource
6
+ # Required attributes
7
+ option :manager_id, type: Types::Coercible::Integer
8
+ option :guid
9
+ option :nickname
10
+
11
+ # Optional attributes
12
+ option :email, optional: true
13
+ option :fantasy_profile_url, optional: true
14
+ option :felo_score, optional: true, type: Types::Coercible::Integer
15
+ option :felo_tier, optional: true
16
+ option :image_url, optional: true
17
+ option :is_comanager, optional: true, type: Types::Params::Bool
18
+ option :is_commissioner, optional: true, type: Types::Params::Bool
19
+ option :is_current_login, optional: true, type: Types::Params::Bool
20
+ option :profile_image_url, optional: true
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class Team
5
+ class Roster < BaseSubresource
6
+ # Required attributes
7
+ option :coverage_type
8
+ option :is_editable, type: Types::Params::Bool
9
+ option :players, type: array_of(Player)
10
+
11
+ # Optional attributes
12
+ option :date, optional: true, type: Types::Params::Date
13
+ option :week, optional: true, type: Types::Coercible::Integer
14
+
15
+ has_subresource :players, klass: Player
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class Team
5
+ class Standings < BaseSubresource
6
+ # Required attributes
7
+ option :points_for, type: Types::Coercible::Float
8
+ option :rank, type: Types::Coercible::Integer
9
+
10
+ # Optional attributes
11
+ option :games_back, optional: true, type: Types::Coercible::Float
12
+ option :playoff_seed, optional: true, type: Types::Coercible::Integer
13
+ option :points_against, optional: true, type: Types::Coercible::Float
14
+ option :points_back, optional: true, type: Types::Coercible::Float
15
+ option :points_change, optional: true, type: Types::Coercible::Float
16
+ option :streak, optional: true do
17
+ option :type
18
+ option :value, type: Types::Coercible::Integer
19
+ end
20
+ option :divisional_wins, optional: true, type: Types::Coercible::Integer
21
+ option :divisional_losses, optional: true, type: Types::Coercible::Integer
22
+ option :divisional_ties, optional: true, type: Types::Coercible::Integer
23
+ option :total_wins, optional: true, type: Types::Coercible::Integer
24
+ option :total_losses, optional: true, type: Types::Coercible::Integer
25
+ option :total_ties, optional: true, type: Types::Coercible::Integer
26
+ option :win_percentage, optional: true, type: Types::Coercible::Float
27
+
28
+ alias_method :wins, :total_wins
29
+ alias_method :losses, :total_losses
30
+ alias_method :ties, :total_ties
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YFantasy
4
+ class Team
5
+ class StatCollection < BaseSubresource
6
+ option :team_stats, optional: true, default: -> {} do
7
+ option :coverage_type, optional: true, default: -> {}
8
+ option :season, optional: true, default: -> {}
9
+ # Fully qualified class name needed because nested options create intermediate classes on the fly.
10
+ # At this level we have: YF::Team::StatCollection::TeamStats. TeamStats is created on-the-fly and does not
11
+ # inherit from BaseResource.
12
+ option :stats, optional: true, type: YFantasy::BaseResource.send(:array_of, Stat)
13
+ end
14
+
15
+ option :team_points, optional: true, default: -> {} do
16
+ option :coverage_type, optional: true, default: -> {}
17
+ option :season, optional: true, default: -> {}
18
+ option :total, optional: true, default: -> {}
19
+ option :week, optional: true, default: -> {}
20
+ end
21
+
22
+ option :team_projected_points, optional: true, default: -> {} do
23
+ option :coverage_type, optional: true, default: -> {}
24
+ option :season, optional: true, default: -> {}
25
+ option :total, optional: true, default: -> {}
26
+ option :week, optional: true, default: -> {}
27
+ end
28
+
29
+ option :team_remaining_games, optional: true, default: -> {} do
30
+ option :coverage_type, optional: true, default: -> {}
31
+ option :week, optional: true, default: -> {}
32
+ option :completed_games, optional: true, default: -> {}
33
+ option :live_games, optional: true, default: -> {}
34
+ option :remaining_games, optional: true, default: -> {}
35
+ end
36
+ end
37
+ end
38
+ end