lib/chgk_rating/client.rb in chgk_rating-1.0.0 vs lib/chgk_rating/client.rb in chgk_rating-2.0.0

- old
+ new

@@ -45,23 +45,33 @@ # @raise [ChgkRating::Error::NotFound] Error raised when the requested Tournament or Team cannot be found. # @return [ChgkRating::Models::TournamentTeam] The requested TournamentTeam. # @param tournament_or_id [String, Integer or Tournament] Tournament to load team for. # @param team_or_id [String, Integer or Team] Team to search for. def team_at_tournament(tournament_or_id, team_or_id) - tournament(tournament_or_id, true).team(team_or_id) + tournament(tournament_or_id, true).team_by(team_or_id) end - # Returns Rating for a given Team in a given release + # Returns rating for a given Team in a given release # # @raise [ChgkRating::Error::NotFound] Error raised when the requested release or Team cannot be found. - # @return [ChgkRating::Models::Rating] The requested Rating. + # @return [ChgkRating::Models::TeamRating] The requested rating. # @param team_or_id [String, Integer or ChgkRating::Models::Team] Team to load rating for. # @param release_id [String or Integer] Release to load rating for. - def rating(team_or_id, release_id) + def team_rating(team_or_id, release_id) team(team_or_id, true).rating(release_id) end + # Returns rating for a given Player in a given release + # + # @raise [ChgkRating::Error::NotFound] Error raised when the requested release or Player cannot be found. + # @return [ChgkRating::Models::PlayerRating] The requested rating. + # @param player_or_id [String, Integer or ChgkRating::Models::Team] Player to load rating for. + # @param release_id [String or Integer] Release to load rating for. + def player_rating(player_or_id, release_id) + player(player_or_id, true).rating(release_id) + end + # Search # Returns a Players collection based on the search criteria. # # @return [ChgkRating::Collection::Players::Search] Found Players. @@ -125,22 +135,43 @@ # @return [ChgkRating::Collection::Tournaments] The collection of tournaments. # @param team_or_id [String, Integer or ChgkRating::Models::Team] Team to load tournaments for. # @param season_id [String or Integer] Season to load tournaments for # @option params [String or Integer] :page The requested page. Default is 1 def tournaments(team_or_id: nil, season_id: nil, params: {}) - ChgkRating::Collections::Tournaments.new params.merge(team: team_or_id, season_id: season_id) + ChgkRating::Collections::Tournaments.new params.merge( + team: team_or_id, season_id: season_id + ) end - # Returns an array-like Ratings collection for a given team. + # Returns a collection of Tournaments that the Player has participated in # + # @return [ChgkRating::Collection::PlayerTournaments] The collection of tournaments. + # @param player_or_id [String, Integer or ChgkRating::Models::Player] Player to load tournaments for. + # @param season_id [String or Integer] Season to load tournaments for + def player_tournaments(player_or_id, season_id = nil) + ChgkRating::Collections::PlayerTournaments.new player: player_or_id, + season_id: season_id + end + + # Returns an array-like Ratings collection for a given Team. + # # @raise [ChgkRating::Error::NotFound] Error raised when the requested Team cannot be found. # @return [ChgkRating::Collection::Ratings] The collection of ratings. # @param team_or_id [String, Integer or ChgkRating::Models::Team] Team to load ratings for. - def ratings(team_or_id) + def team_ratings(team_or_id) team(team_or_id, true).ratings end + # Returns an array-like Ratings collection for a given Player. + # + # @raise [ChgkRating::Error::NotFound] Error raised when the requested Player cannot be found. + # @return [ChgkRating::Collection::Ratings] The collection of ratings. + # @param player_or_id [String, Integer or ChgkRating::Models::Team] Player to load ratings for. + def player_ratings(player_or_id) + player(player_or_id, true).ratings + end + # Returns an array-like TournamentTeams collection specifying which teams participated in a given tournament # # @raise [ChgkRating::Error::NotFound] Error raised when the requested Tournament cannot be found. # @return [ChgkRating::Collection::Ratings] The collection of teams. # @param tournament_or_id [String, Integer or ChgkRating::Models::Tournament] Tournament to load teams for. @@ -157,14 +188,14 @@ # @param team_or_id [String, Integer or ChgkRating::Models::Team] Team to load results for. def team_results_at_tournament(tournament_or_id, team_or_id) team_at_tournament(tournament_or_id, team_or_id).results end - # Returns an array-like TournamentPlayers collection containing roster for a + # Returns an array-like TournamentTeamPlayers collection containing roster for a # given team at a given tournament. # # @raise [ChgkRating::Error::NotFound] Error raised when the requested Tournament or Team cannot be found. - # @return [ChgkRating::Collection::TournamentPlayers] The collection of results. + # @return [ChgkRating::Collection::TournamentTeamPlayers] The collection of results. # @param tournament_or_id [String, Integer or ChgkRating::Models::Tournament] Tournament to load players for. # @param team_or_id [String, Integer or ChgkRating::Models::Team] Team to load players for. def team_players_at_tournament(tournament_or_id, team_or_id) team_at_tournament(tournament_or_id, team_or_id).players end \ No newline at end of file