-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from Decatur-Robotics/ftc-team-creation
- Loading branch information
Showing
9 changed files
with
251 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { League, Team } from "./Types"; | ||
|
||
async function request(suburl: string): Promise<any> { | ||
var res = await fetch(process.env.TOA_URL + suburl, { | ||
method: "GET", | ||
headers: { | ||
"X-Application-Origin": process.env.TOA_APP_ID, | ||
"X-TOA-Key": process.env.TOA_KEY, | ||
}, | ||
}); | ||
|
||
return res.json(); | ||
} | ||
|
||
export namespace TheOrangeAlliance { | ||
export type SimpleTeam = { | ||
/** Appears to be the same as team_number */ | ||
team_key: string; | ||
region_key: string; | ||
league_key: string; | ||
team_number: number; | ||
team_name_short: string; | ||
team_name_long: string; | ||
robot_name: string; | ||
last_active: string; | ||
city: string; | ||
state_prov: string; | ||
zip_code: number; | ||
country: string; | ||
rookie_year: number; | ||
website: string; | ||
} | ||
|
||
export async function getTeam(teamNumber: number): Promise<Team | undefined> { | ||
const teams = await request(`/team/${teamNumber}`) as SimpleTeam[]; | ||
|
||
if (teams.length === 0) | ||
return undefined; | ||
|
||
const team = teams[0]; | ||
if (!team?.team_number || !team?.team_name_short) | ||
return undefined; | ||
|
||
return new Team(team.team_name_short, team.team_name_long, team.robot_name, team.team_number, League.FTC); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.