Skip to content

Commit

Permalink
Implement Team
Browse files Browse the repository at this point in the history
Data returns is a little weird, will refine how we handle it in classes
  • Loading branch information
petems committed Dec 14, 2013
1 parent 1f73cda commit bf5e64f
Show file tree
Hide file tree
Showing 4 changed files with 885 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/riot_api/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def summoner
RiotApi::Resource::Summoner.new(@faraday, @region)
end

def team
RiotApi::Resource::Team.new(@faraday, @region)
end

def default_faraday
Faraday.new(:url => @base_url, :ssl => @ssl) do |faraday|
faraday.use Faraday::Response::RaiseError if @raise_status_errors
Expand Down
21 changes: 21 additions & 0 deletions lib/riot_api/resource/team.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module RiotApi
module Resource
class Team < BaseV21

def by_summoner(summoner_id)
@connection.get(by_summoner_path(summoner_id)).body
end

private

def by_summoner_path(summoner_id)
"#{base_path}/by-summoner/#{summoner_id}"
end

def base_path
"#{endpoint_precursor}/team"
end

end
end
end
16 changes: 16 additions & 0 deletions spec/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,20 @@
end
end


describe '#team', :vcr do
let(:summoner_id) { '19531813' }

describe '#by_summoner' do
let(:response) {
subject.league.by_summoner summoner_id
}

it 'should return team data for summoner' do
response.count.should > 0
response.first.first.should == 'timestamp'
end
end
end

end
Loading

0 comments on commit bf5e64f

Please sign in to comment.