Skip to content

Commit

Permalink
less code, same great functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
BrentonPoke committed Oct 6, 2020
1 parent fdae5cc commit f34d7cf
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/main/java/com/toornament/concepts/FinalStandings.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,25 @@ public FinalStandings(ToornamentClient client) {
public List<Standings> getFinalStandings(String range, StandingsQuery query){
HttpUrl.Builder urlBuilder = new HttpUrl.Builder();
Request.Builder requestBuilder;
String scope = "viewer";

if (client.getScope().contains(Scope.ORGANIZER_RESULT))
scope = "organizer";

if (client.getScope().contains(Scope.ORGANIZER_RESULT)) {
urlBuilder
.scheme("https")
.host("api.toornament.com")
.addEncodedPathSegment("organizer")
.addEncodedPathSegment(scope)
.addEncodedPathSegment("v2")
.addEncodedPathSegment("standings");

logger.debug("url: {}",urlBuilder.build().toString());
requestBuilder = client.getAuthenticatedRequestBuilder();
}
else {
urlBuilder
.scheme("https")
.host("api.toornament.com")
.addEncodedPathSegment("viewer")
.addEncodedPathSegment("v2")
.addEncodedPathSegment("standings");
if(scope.equals("viewer")){

logger.debug("url: {}",urlBuilder.build().toString());
requestBuilder = client.getRequestBuilder();
} else {
logger.debug("url: {}",urlBuilder.build().toString());
requestBuilder = client.getAuthenticatedRequestBuilder();
}

if(!query.getParticipantIds().isEmpty())
Expand Down

0 comments on commit f34d7cf

Please sign in to comment.