2022-01-10 04:19:50 +00:00
|
|
|
import requests
|
|
|
|
from exceptions import APIError
|
2022-02-19 06:19:13 +00:00
|
|
|
from dep import load_config
|
2022-01-10 04:19:50 +00:00
|
|
|
|
|
|
|
url = "https://titanscouting.epochml.org"
|
2022-01-10 20:23:14 +00:00
|
|
|
config_tra = {}
|
|
|
|
load_config("config.json", config_tra)
|
2022-01-10 04:19:50 +00:00
|
|
|
trakey = config_tra['persistent']['key']['tra']
|
|
|
|
|
|
|
|
def get_team_competition():
|
2022-01-10 20:23:14 +00:00
|
|
|
endpoint = '/api/fetchTeamCompetition'
|
|
|
|
params = {
|
|
|
|
"CLIENT_ID": trakey['CLIENT_ID'],
|
|
|
|
"CLIENT_SECRET": trakey['CLIENT_SECRET']
|
|
|
|
}
|
2022-02-24 02:56:08 +00:00
|
|
|
response = requests.request("GET", url + endpoint, params=params)
|
2022-01-10 20:23:14 +00:00
|
|
|
json = response.json()
|
|
|
|
if json['success']:
|
|
|
|
return json['competition']
|
|
|
|
else:
|
2022-02-19 06:50:34 +00:00
|
|
|
raise APIError(json)
|
2022-01-10 04:19:50 +00:00
|
|
|
|
|
|
|
def get_team():
|
2022-01-10 20:23:14 +00:00
|
|
|
endpoint = '/api/fetchTeamCompetition'
|
|
|
|
params = {
|
|
|
|
"CLIENT_ID": trakey['CLIENT_ID'],
|
|
|
|
"CLIENT_SECRET": trakey['CLIENT_SECRET']
|
|
|
|
}
|
2022-02-24 02:56:08 +00:00
|
|
|
response = requests.request("GET", url + endpoint, params=params)
|
2022-01-10 20:23:14 +00:00
|
|
|
json = response.json()
|
|
|
|
if json['success']:
|
|
|
|
return json['team']
|
|
|
|
else:
|
2022-02-19 06:50:34 +00:00
|
|
|
raise APIError(json)
|
2022-01-10 04:19:50 +00:00
|
|
|
|
|
|
|
def get_team_match_data(competition, team_num):
|
2022-01-10 20:23:14 +00:00
|
|
|
endpoint = '/api/fetchAllTeamMatchData'
|
|
|
|
params = {
|
|
|
|
"competition": competition,
|
|
|
|
"teamScouted": team_num,
|
|
|
|
"CLIENT_ID": trakey['CLIENT_ID'],
|
|
|
|
"CLIENT_SECRET": trakey['CLIENT_SECRET']
|
|
|
|
}
|
2022-02-24 02:56:08 +00:00
|
|
|
response = requests.request("GET", url + endpoint, params=params)
|
2022-01-10 20:23:14 +00:00
|
|
|
json = response.json()
|
|
|
|
if json['success']:
|
|
|
|
return json['data'][team_num]
|
|
|
|
else:
|
2022-02-19 06:50:34 +00:00
|
|
|
raise APIError(json)
|
2022-01-10 04:19:50 +00:00
|
|
|
|
|
|
|
def get_teams_at_competition(competition):
|
2022-01-10 20:23:14 +00:00
|
|
|
endpoint = '/api/fetchAllTeamNicknamesAtCompetition'
|
|
|
|
params = {
|
|
|
|
"competition": competition,
|
|
|
|
"CLIENT_ID": trakey['CLIENT_ID'],
|
|
|
|
"CLIENT_SECRET": trakey['CLIENT_SECRET']
|
|
|
|
}
|
2022-02-24 02:56:08 +00:00
|
|
|
response = requests.request("GET", url + endpoint, params=params)
|
2022-01-10 20:23:14 +00:00
|
|
|
json = response.json()
|
|
|
|
if json['success']:
|
|
|
|
return list(json['data'].keys())
|
|
|
|
else:
|
2022-02-19 06:50:34 +00:00
|
|
|
raise APIError(json)
|