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

Commit 8aaf4a1

Browse files
committed
Refactor away Constants class
1 parent b26360a commit 8aaf4a1

3 files changed

Lines changed: 16 additions & 23 deletions

File tree

build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
apply plugin: 'java'
2-
1+
plugins {
2+
'java'
3+
'java-library'
4+
}
35

46
repositories {
57
jcenter()
68
}
79

810

911
dependencies {
10-
11-
compile 'org.slf4j:slf4j-api:1.7.21'
12-
13-
14-
testCompile 'junit:junit:4.12'
15-
compile 'com.google.code.gson:gson:2.2.4'
12+
implementation 'org.slf4j:slf4j-api:1.7.21'
13+
testImplementation 'junit:junit:4.13'
14+
implementation 'com.google.code.gson:gson:2.8.6'
1615
}

src/main/java/com/thebluealliance/api/v3/Constants.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,3 @@
33
/**
44
* Collection of constants used to access The Blue Alliance API
55
*/
6-
public class Constants {
7-
8-
public static final String TBA_BASE_URL = "https://www.thebluealliance.com/api/v3";
9-
public static final String HEADER_AUTH = "X-TBA-Auth-Key";
10-
public static final String HEADER_MODIFIED = "If-Modified-Since";
11-
12-
13-
}

src/main/java/com/thebluealliance/api/v3/requests/DataRequest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.thebluealliance.api.v3.requests;
22

3-
import com.thebluealliance.api.v3.Constants;
4-
53
import java.io.BufferedReader;
64
import java.io.IOException;
75
import java.io.InputStreamReader;
@@ -13,6 +11,10 @@
1311
*/
1412
public class DataRequest {
1513

14+
public static final String TBA_BASE_URL = "https://www.thebluealliance.com/api/v3";
15+
public static final String HEADER_AUTH = "X-TBA-Auth-Key";
16+
public static final String HEADER_MODIFIED = "If-Modified-Since";
17+
1618
private String AUTH_KEY;
1719

1820
/**
@@ -34,9 +36,9 @@ public DataRequest(String authKey) {
3436
public APIResponse getDataTBA(String urlDirectory) throws IOException {
3537

3638
URL url;
37-
url = new URL(Constants.TBA_BASE_URL + urlDirectory);
39+
url = new URL(TBA_BASE_URL + urlDirectory);
3840
HttpURLConnection con = (HttpURLConnection) url.openConnection();
39-
con.addRequestProperty(Constants.HEADER_AUTH, AUTH_KEY);
41+
con.addRequestProperty(HEADER_AUTH, AUTH_KEY);
4042
return getData(con);
4143

4244
}
@@ -80,10 +82,10 @@ private APIResponse getData(HttpURLConnection con) {
8082
* @return An {@link APIResponse} object with the API's response
8183
*/
8284
public APIResponse getDataTBA(String urlDirectory, String ifModifiedSince) throws IOException {
83-
URL url = new URL(Constants.TBA_BASE_URL + urlDirectory);
85+
URL url = new URL(TBA_BASE_URL + urlDirectory);
8486
HttpURLConnection con = (HttpURLConnection) url.openConnection();
85-
con.addRequestProperty(Constants.HEADER_AUTH, AUTH_KEY);
86-
con.addRequestProperty(Constants.HEADER_MODIFIED, ifModifiedSince);
87+
con.addRequestProperty(HEADER_AUTH, AUTH_KEY);
88+
con.addRequestProperty(HEADER_MODIFIED, ifModifiedSince);
8789
return getData(con);
8890

8991

0 commit comments

Comments
 (0)