Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

Commit 3e8a184

Browse files
committed
Readme update
1 parent c8fd4e7 commit 3e8a184

20 files changed

Lines changed: 950 additions & 537 deletions

src/main/java/com/thebluealliance/TBA.java

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.thebluealliance.api.v3;
2+
3+
import com.thebluealliance.api.v3.requests.DataRequest;
4+
import com.thebluealliance.api.v3.requests.DistrictRequest;
5+
import com.thebluealliance.api.v3.requests.EventRequest;
6+
import com.thebluealliance.api.v3.requests.MatchRequest;
7+
import com.thebluealliance.api.v3.requests.TeamRequest;
8+
9+
/** Base class used to access the The Blue Alliance API.
10+
* A TBA object must be created to use this client library.
11+
*
12+
*/
13+
public class TBA {
14+
15+
public static String AUTH_KEY;
16+
17+
/** A {@link DataRequest} object to make direct calls to the API
18+
*
19+
*/
20+
public final DataRequest dataRequest;
21+
22+
/** A {@link TeamRequest} object to make calls in which a <code>teamNumber</code> is the primary argument
23+
*
24+
*/
25+
public final TeamRequest teamRequest;
26+
27+
/** An {@link EventRequest} object to make calls in which an <code>eventKey</code> is the primary argument
28+
*
29+
*/
30+
public final EventRequest eventRequest;
31+
32+
/** A {@link DistrictRequest} object to make calls in which a <code>districtKey</code> is the primary argument
33+
*/
34+
public final DistrictRequest districtRequest;
35+
36+
/** A {@link MatchRequest} object to make calls in which a <code>matchKey</code> is the primary argument
37+
*
38+
*/
39+
public final MatchRequest matchRequest;
40+
41+
/** Create a TBA object to make API requests
42+
*
43+
* @param authKey The Read API Key, generated on your <a href="https://www.thebluealliance.com/account">Account Dashboard</a> on The Blue Alliance
44+
*/
45+
public TBA(String authKey){
46+
AUTH_KEY = authKey;
47+
dataRequest = new DataRequest(AUTH_KEY);
48+
teamRequest = new TeamRequest(dataRequest);
49+
eventRequest = new EventRequest(dataRequest);
50+
districtRequest = new DistrictRequest(dataRequest);
51+
matchRequest = new MatchRequest(dataRequest);
52+
}
53+
54+
}

src/main/java/com/thebluealliance/models/Team.java renamed to src/main/java/com/thebluealliance/api/v3/models/Team.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,49 @@
1-
package com.thebluealliance.models;
1+
package com.thebluealliance.api.v3.models;
22

33
import java.util.HashMap;
44

5+
/** Represents a FIRST Robotics Competition team
6+
*
7+
*/
58
public class Team extends SimpleTeam{
69

710
private String postal_code, website, motto;
811
private int rookie_year;
912

1013
private HashMap<String, String> home_championship;
1114

15+
/**
16+
* @return Postal code from the team address.
17+
*/
1218
public String getPostalCode() {
1319
return postal_code;
1420
}
1521

22+
/**
23+
* @return Official website associated with the team.
24+
*/
1625
public String getWebsite() {
1726
return website;
1827
}
1928

29+
/**
30+
* @return Team’s motto as provided by FIRST.
31+
*/
2032
public String getMotto() {
2133
return motto;
2234
}
2335

24-
36+
/**
37+
* @return First year the team officially competed.
38+
*/
2539
public int getRookieYear() {
2640
return rookie_year;
2741
}
2842

43+
/**
44+
* @param year An year to query. Must be greater than or equal to 2017.
45+
* @return Location of the team’s home championship for the particular <code>year</code>
46+
*/
2947
public String getHomeChampionship(int year) {
3048
return home_championship.get(Integer.toString(year));
3149
}

src/main/java/com/thebluealliance/models/TeamEventStatus.java renamed to src/main/java/com/thebluealliance/api/v3/models/TeamEventStatus.java

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,100 @@
1-
package com.thebluealliance.models;
2-
1+
package com.thebluealliance.api.v3.models;
32

3+
/** Represents a team's status during an event
4+
*
5+
*/
46
public class TeamEventStatus {
57

68
private Rank qual;
79
private Alliance alliance;
810
private PlayoffStatus playoff;
911
private String alliance_status_str, playoff_status_str, overall_status_str;
1012

13+
/** Holds rank information of a team during an event
14+
*
15+
*/
1116
public class Rank{
1217
private int num_teams;
1318
private String status;
1419
private Ranking ranking;
1520

1621

22+
/**
23+
* @return Number of teams ranked.
24+
*/
1725
public int getNumTeams() {
1826
return num_teams;
1927
}
2028

2129

30+
/**
31+
* @return Either <code>completed</code> or <code>ongoing</code>
32+
*/
2233
public String getStatus() {
2334
return status;
2435
}
2536

26-
37+
/**
38+
* @return A {@link Ranking} describing the team's status in the qualification tournament
39+
*/
2740
public Ranking getRanking() {
2841
return ranking;
2942
}
3043

3144
}
3245

46+
/** Describes a team's alliance during the playoff tournament
47+
*/
3348
public class Alliance{
3449
private String name;
3550
private int number, pick;
3651
private AllianceBackup backup;
3752

53+
/** Describes the backup status of an alliance
54+
*/
3855
public class AllianceBackup{
3956
private String out, in;
4057

58+
/**
59+
* @return TBA key for the team replaced by the backup.
60+
*/
4161
public String getOut() {
4262
return out;
4363
}
44-
64+
65+
/**
66+
* @return TBA key for the backup team called in.
67+
*/
4568
public String getIn() {
4669
return in;
4770
}
4871

4972
}
5073

74+
/**
75+
* @return Alliance name, may be null.
76+
*/
5177
public String getName() {
5278
return name;
5379
}
5480

81+
/**
82+
* @return Alliance number
83+
*/
5584
public int getNumber() {
5685
return number;
5786
}
5887

88+
/**
89+
* @return Order the team was picked in the alliance from 0-2, with 0 being alliance captain.
90+
*/
5991
public int getPick() {
6092
return pick;
6193
}
6294

95+
/**
96+
* @return Backup status, may be null
97+
*/
6398
public AllianceBackup getBackup() {
6499
return backup;
65100
}
@@ -82,26 +117,44 @@ public String getStatus() {
82117
}
83118
}
84119

120+
/**
121+
* @return The team's {@link Rank} during the qualification matches
122+
*/
85123
public Rank getQual() {
86124
return qual;
87125
}
88126

127+
/**
128+
* @return The team's alliance selection information
129+
*/
89130
public Alliance getAlliance() {
90131
return alliance;
91132
}
92133

134+
/**
135+
* @return Playoff status for this team, may be null if the team did not make playoffs, or playoffs have not begun.
136+
*/
93137
public PlayoffStatus getPlayoffStatus() {
94138
return playoff;
95139
}
96140

141+
/**
142+
* @return An HTML formatted string suitable for display to the user containing the team’s alliance pick status.
143+
*/
97144
public String getAllianceStatusStr() {
98145
return alliance_status_str;
99146
}
100147

148+
/**
149+
* @return An HTML formatter string suitable for display to the user containing the team’s playoff status.
150+
*/
101151
public String getPlayoffStatusStr() {
102152
return playoff_status_str;
103153
}
104154

155+
/**
156+
* @return An HTML formatted string suitable for display to the user containing the team’s overall status summary of the event.
157+
*/
105158
public String getOverallStatusStr() {
106159
return overall_status_str;
107160
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.thebluealliance.api.v3.models;
2+
3+
/** A Win-Loss-Tie record for a team, or an alliance.
4+
*
5+
*/
6+
public class WLTRecord{
7+
private int losses, wins, ties;
8+
9+
/**
10+
* @return Number of losses
11+
*/
12+
public int getLosses() {
13+
return losses;
14+
}
15+
16+
/**
17+
* @return Number of wins
18+
*/
19+
public int getWins() {
20+
return wins;
21+
}
22+
23+
/**
24+
* @return Number of ties
25+
*/
26+
public int getTies() {
27+
return ties;
28+
}
29+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** Provides the classes necessary to access The Blue Alliance API
2+
* and deserialize JSON data obtained from the API into object models
3+
*
4+
*/
5+
package com.thebluealliance.api.v3;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.thebluealliance.api.v3.requests;
2+
3+
/** Holds a response from The Blue Alliance API v3
4+
*
5+
*/
6+
public class APIResponse {
7+
8+
private final String jsonContent, lastModified;
9+
10+
/**
11+
* @return The JSON string returned by the API. May be null if the <code>
12+
* responseCode</code> is not 200.
13+
*/
14+
public String getJson() {
15+
return jsonContent;
16+
}
17+
18+
/**
19+
* @return The date and time the data returned was last updated. Used by clients in the `If-Modified-Since` request header.
20+
*/
21+
public String getLastModified() {
22+
return lastModified;
23+
}
24+
25+
/**
26+
* @return The HTTP response code given by the API.
27+
* Value is 200 if the response is successful, 304 if data was not modified and the <code>If-Modified-Since</code>
28+
* header is used, 401 if no TBA v3 API Key was provided, or it is not valid, or 404 if the URL or parameter(s) provided is invalid
29+
*/
30+
public int getResponseCode() {
31+
return responseCode;
32+
}
33+
34+
private final int responseCode;
35+
36+
/** Creates an APIResponse object
37+
* @param jsonContent JSON data returned by the API
38+
* @param lastModified The <code>Last-Modified</code> response header
39+
* @param responseCode The HTTP response code
40+
*/
41+
public APIResponse(String jsonContent, String lastModified, int responseCode){
42+
this.jsonContent = jsonContent;
43+
this.lastModified = lastModified;
44+
this.responseCode = responseCode;
45+
}
46+
47+
}

0 commit comments

Comments
 (0)