I tried to connect to the Riot api to access the summoner info. I wrote 3 files:
- "RiotConsts": a file setting some constants such as "URL", "api_version", "region"
- "RiotAPI": the main functions
- "riot_main": to call the info I want.
I am receiving an error: "RiotAPI' object has no attribute '_request'".
class RiotAPI(object):
def __init__(self,api_key,region=Consts.REGIONS['europe_nordic_and_east']):
self.api_key = api_key
self.region = region
def request(self, api_key, params={}):
args = {'api_key': self.api_key}
for k,v in params.items():
if k not in args:
args[k] = v
response = requests.get(
Consts.URL['base'].format(
proxy = self.region,
region = self.region,
url = api_url
),
params=args
)
print (response.url)
return response.json()
def get_summoner_by_name(self, name):
api_url = Consts.URL['summoner_by_name'].format(
version=Consts.API_VERSIONS['summoner'],
summonerName=name
)
return self._request(api_url)
I expect to receive the summoner info but I got: 'RiotAPI' object has no attribute '_request'