diff --git a/lib/sightstone/modules/team_module.rb b/lib/sightstone/modules/team_module.rb index 5642ddc..f3a8c53 100644 --- a/lib/sightstone/modules/team_module.rb +++ b/lib/sightstone/modules/team_module.rb @@ -2,11 +2,16 @@ require 'sightstone/modules/sightstone_base_module' require 'sightstone/summoner' require 'sightstone/team' +# module to make calls to the team api class TeamModule < SightstoneBaseModule def initialize(sightstone) @sightstone = sightstone end + # call to receive all teams for a summoner + # @param [Summoner, Fixnum] summoner summoner object or id of a summoner + # @param optional [Hash] optional arguments: :region => replaces default region + # @ return [Array] An array containing all teams of the given summoner def teams(summoner, optional={}) region = optional[:region] || @sightstone.region id = if summoner.is_a? Summoner @@ -15,7 +20,7 @@ class TeamModule < SightstoneBaseModule summoner end - uri = "https://prod.api.pvp.net/api/#{region}/v2.1/team/by-summoner/#{id}" + uri = "https://prod.api.pvp.net/api/lol/#{region}/v2.2/team/by-summoner/#{id}" response = _get_api_response(uri) _parse_response(response) { |resp| diff --git a/lib/sightstone/team.rb b/lib/sightstone/team.rb index b0b1507..ae5508d 100644 --- a/lib/sightstone/team.rb +++ b/lib/sightstone/team.rb @@ -1,18 +1,32 @@ +# A Team +# @attr [Fixnum] createDate UNIX timestamp of team creation +# @attr [String] fullId id of the team +# @attr [Fixnum] lastGameDate UNIX timespamp of last game +# @attr [Fixnum] lastJoinDate UNIX timestamp of the date where the newest player joined the team +# @attr [Fixnum] lastJoinedRankedTeamQueueDate UNIX timestamp of latest team game +# @attr [Array] matchHistory List of latest games +# @attr [Fixnum] modifyDate UNIX timestamp of latest team modification +# @attr [String] name team name +# @attr [Roster] roster team roster +# @attr [Fixnum] secondLastJoinDate UNIX timestamp of second latest join date of a member +# @attr [String] status team status +# @attr [String] tag tag of the team +# @attr [Array] teamStatSummary array containing the stats of the team +# @attr [Fixnum] thridLastJoinDate UNIX timestamp of third latest join date of a member class Team - attr_accessor :teamStatSummary, :status, :tag, :roster, :lastGameDate, :modifyDate, :teamId, :timestamp, :lastJoinDate, :secondLastJoinDate, :matchHistory, :lastJoinedRankedTeamQueueDate, :name, :thirdLastJoinDate, :createDate + attr_accessor :teamStatSummary, :status, :tag, :roster, :lastGameDate, :modifyDate, :teamId, :lastJoinDate, :secondLastJoinDate, :matchHistory, :lastJoinedRankedTeamQueueDate, :name, :thirdLastJoinDate, :createDate def initialize(data) @status = data['status'] @tag = data['tag'] @roster = Roster.new(data['roster']) @lastGameDate = data['lastGameDate'] @modifyDate = data['modifyDate'] - @teamId = data['teamId']['fullId'] - @timestamp = data['timestamp'] + @teamId = data['fullId'] @lastJoinDate = data['lastJoinDate'] @secondLastJoinDate = data['secondLastJoinDate'] @matchHistory = [] data['matchHistory'].each do |game| - matchHistory << Game.new(game) + matchHistory << TeamHistoryGame.new(game) end @lastJoinedRankedTeamQueueDate=data['lastJoinedRankedTeamQueueDate'] @name = data['name'] @@ -26,6 +40,9 @@ class Team end end +# class to represent the roster of a team +# @attr [Fixnum] ownerId summoner ID of the team owner +# @attr [Array] memberList list of all team members class Roster attr_accessor :ownerId, :memberList def initialize(data) @@ -37,6 +54,11 @@ class Roster end end +# member of a team +# @attr [Fixnum] joinDate UNIX timestamp of join date +# @attr [Fixnum] inviteDate UNIX timestamp of invitation date +# @attr [String] status status of the team member +# @attr [Fixnum] playerId summoner ID of the member class Member attr_accessor :joinDate, :inviteDate, :status, :playerId def initialize(data) @@ -47,20 +69,37 @@ class Member end end -class TeamStat - attr_accessor :wins, :losses, :averageGamesPlayed, :teamId, :teamStatType +# statistical overview of a team +# @attr [Fixnum] wins number of won games +# @attr [Fixnum] losses number of lost games +# @attr [Fixnum] averageFamesPlayed average played games of member +# @attr [String] fullId id of the team +# @attr [String] teamStatType queue of the stat +class TeamStat + attr_accessor :wins, :losses, :averageGamesPlayed, :fullId, :teamStatType def initialize(data) @wins = data['wins'] @losses = data['losses'] @averageGamesPlayed = data['averageGamesPlayed'] - @teamId = data['teamId'] + @fullId = data['fullId'] @teamStatType = data['teamStatType'] end end -class Game - attr_accessor :gameMode, :mapId, :assists, :opposingTeamName, :invalid, :deaths, :gameId, :kills, :win, :date, :opposingTeamKills +# Recent game of a team +# @attr [Fixnum] gameMode mode of the game +# @attr [Fixnum] mapId ID of the map +# @attr [Fixnum] assists assists of the team +# @attr [String] opposingTeamName name of the enemy team +# @attr [Boolean] invalid Invalid flag # TODO what is this? +# @attr [Fixnum] deaths number of deaths summed over all players of the team +# @attr [Boolean] win true if game has been won by the team +# @attr [Fixnum] opposingTeamKills number of kills of the enemy team +# @attr [Fixnum] gameId ID of the game +# @attr [Fixnum] kills kills of the team +class TeamHistoryGame + attr_accessor :gameMode, :mapId, :assists, :opposingTeamName, :invalid, :deaths, :gameId, :kills, :win, :opposingTeamKills def initialize(data) @gameMode = data['gameMode'] @mapId = data['mapId'] @@ -71,7 +110,6 @@ class Game @gameId = data['gameId'] @kills = data['kills'] @win = data['win'] - @date = data['date'] @opposingTeamKills = data['opposingTeamKills'] end end \ No newline at end of file