Class: TeamModule

Inherits:
SightstoneBaseModule show all
Defined in:
lib/sightstone/modules/team_module.rb

Instance Method Summary collapse

Constructor Details

#initialize(sightstone) ⇒ TeamModule

Returns a new instance of TeamModule.



6
7
8
# File 'lib/sightstone/modules/team_module.rb', line 6

def initialize(sightstone)
  @sightstone = sightstone
end

Instance Method Details

#teams(summoner, optional = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sightstone/modules/team_module.rb', line 10

def teams(summoner, optional={})
  region = optional[:region] || @sightstone.region
  id = if summoner.is_a? Summoner
    summoner.id
  else
    summoner
  end
  
  uri = "https://prod.api.pvp.net/api/#{region}/v2.1/team/by-summoner/#{id}"

  response = _get_api_response(uri)
  _parse_response(response) { |resp|
    data = JSON.parse(resp)
    teams = []
    data.each do |team|
      teams << Team.new(team)
    end
    return teams
  }
end