Skip to content

Commit

Permalink
update riot api to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
ecly committed Mar 2, 2019
1 parent 0528d1d commit 204c62e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions apps/riot_api/lib/riot_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defmodule RiotApi do
in a result tuple.
## Examples
iex> RiotApi.request("/lol/summoner/v3/summoners/by-name/Lethly", :euw)
iex> RiotApi.request("/lol/summoner/v4/summoners/by-name/Lethly", :euw)
{:ok %{"name" => "Lethly"...}}
"""
def request(path, region) do
Expand All @@ -52,27 +52,27 @@ defmodule RiotApi do
end

defp fetch_summoner(name, region) do
"/lol/summoner/v3/summoners/by-name/#{name}"
"/lol/summoner/v4/summoners/by-name/#{name}"
|> request(region)
end

defp fetch_match(match_id, region) do
"/lol/match/v3/matches/#{match_id}"
"/lol/match/v4/matches/#{match_id}"
|> request(region)
end

defp fetch_leagues(id, region) do
"/lol/league/v3/positions/by-summoner/#{id}"
"/lol/league/v4/positions/by-summoner/#{id}"
|> request(region)
end

defp fetch_recent_matches_any_queue(account_id, amount, region) do
"/lol/match/v3/matchlists/by-account/#{account_id}?endIndex=#{amount}"
"/lol/match/v4/matchlists/by-account/#{account_id}?endIndex=#{amount}"
|> request(region)
end

defp fetch_recent_matches_for_queue(account_id, amount, queue, region) do
"/lol/match/v3/matchlists/by-account/#{account_id}?queue=#{queue}&endIndex=#{amount}"
"/lol/match/v4/matchlists/by-account/#{account_id}?queue=#{queue}&endIndex=#{amount}"
|> request(region)
end

Expand Down
12 changes: 6 additions & 6 deletions apps/riot_api/test/riot_api_mock_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ defmodule RiotApi.ApiMockTest do
match_id = 3_412_307_012
Application.put_env(:riot_api, :riot_api_key, key)

summoner_url = RiotApi.format_url("/lol/summoner/v3/summoners/by-name/#{name}", region)
summoner_url = RiotApi.format_url("/lol/summoner/v4/summoners/by-name/#{name}", region)

matchlist_solo_url =
RiotApi.format_url(
"/lol/match/v3/matchlists/by-account/#{account_id}?queue=420&endIndex=20",
"/lol/match/v4/matchlists/by-account/#{account_id}?queue=420&endIndex=20",
region
)

matchlist_any_url =
RiotApi.format_url("/lol/match/v3/matchlists/by-account/#{account_id}?endIndex=20", region)
RiotApi.format_url("/lol/match/v4/matchlists/by-account/#{account_id}?endIndex=20", region)

leagues_url = RiotApi.format_url("/lol/league/v3/positions/by-summoner/#{id}", region)
leagues_url = RiotApi.format_url("/lol/league/v4/positions/by-summoner/#{id}", region)

solo_match_url =
RiotApi.format_url(
"/lol/match/v3/matchlists/by-account/#{account_id}?queue=420&endIndex=1",
"/lol/match/v4/matchlists/by-account/#{account_id}?queue=420&endIndex=1",
region
)

match_url = RiotApi.format_url("/lol/match/v3/matches/#{match_id}", region)
match_url = RiotApi.format_url("/lol/match/v4/matches/#{match_id}", region)

summoner_json = File.read!("test/mock_json/summoner.json")
matchlist_json = File.read!("test/mock_json/matchlist.json")
Expand Down

0 comments on commit 204c62e

Please sign in to comment.