Skip to content

Commit

Permalink
Add new endpoint /locations/global/rankings/tournaments/{tournamentTa…
Browse files Browse the repository at this point in the history
…g} (#159)

* Add new endpoint /locations/global/rankings/tournaments/{tournamentTag}

* Fix pom

---------

Co-authored-by: Michael Lieshoff <[email protected]>
  • Loading branch information
mlieshoff and Michael Lieshoff authored Jul 13, 2023
1 parent 8a16d3a commit 6f961a4
Show file tree
Hide file tree
Showing 13 changed files with 432 additions and 8 deletions.
24 changes: 21 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@

## [Unreleased]

## [2.1.2] - 2023-07-13

## [2.1.1] - 2023-07-12
### Added

- new endpoint /locations/global/rankings/tournaments/{tournamentTag}

### Changed

- E2E testing to check if received JSON was empty

## [2.1.1] - 2023-07-13

### Added

- new endpoint /locations/{locationId}/pathoflegend/players (#158)
- possibility to create cached connector for E2E testing (for now)

## [2.1.0] - 2023-07-12

### Changed

Expand Down Expand Up @@ -41,7 +57,9 @@

- Create a Release job (#152)

[unreleased]: https://github.com/mlieshoff/jcrapi2/compare/v2.1.1...HEAD
[2.1.1]: https://github.com/mlieshoff/jcrapi2/compare/v2.0.6...v2.1.1
[unreleased]: https://github.com/mlieshoff/jcrapi2/compare/v2.1.2...HEAD
[2.1.2]: https://github.com/mlieshoff/jcrapi2/compare/v2.1.1...v2.1.2}
[2.1.1]: https://github.com/mlieshoff/jcrapi2/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/mlieshoff/jcrapi2/compare/v2.0.6...v2.1.0
[2.0.6]: https://github.com/mlieshoff/jcrapi2/compare/v2.0.5...v2.0.6
[2.0.5]: https://github.com/mlieshoff/jcrapi2/compare/v2.0.5...v2.0.5
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![](https://img.shields.io/badge/java-packagecloud.io-844fec.svg)](https://packagecloud.io/)

# jcrapi2 2.1.1
# jcrapi2 2.1.2
A Java Wrapper For Official Supercell Clash Royal Api

## Why we don't use the Swagger scheme?
Expand Down Expand Up @@ -318,6 +318,19 @@ list all supported apis
.build()
).get();
```
```java
// getTopPlayerTournamentRankings
TopPlayerTournamentRankingsResponse response = api.getTopPlayerTournamentRankings(topPlayerTournamentRankingsRequest.builder()
.tournamentTag()
// pagination
.limit()
.after()
.before()
// store raw response
.storeRawResponse()
.build()
).get();
```
#### ChallengeApi
```java
// create an instance for the api
Expand Down Expand Up @@ -385,15 +398,15 @@ All requests are returning *java.concurrent.Future*. The execution will be async

to Gradle:
```groovy
implementation group: 'jcrapi2', name: 'jcrapi2', version: '2.1.1'
implementation group: 'jcrapi2', name: 'jcrapi2', version: '2.1.2'
```

to Maven:
```xml
<dependency>
<groupId>jcrapi2</groupId>
<artifactId>jcrapi2</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.1
v2.1.2
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jcrapi2</artifactId>
<packaging>jar</packaging>
<version>2.1.1</version>
<version>2.1.2</version>
<groupId>jcrapi2</groupId>
<url>https://maven.apache.org</url>
<inceptionYear>2018</inceptionYear>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/jcrapi2/api/intern/locations/LocationApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import jcrapi2.api.intern.locations.seasons.global.rankings.TopPlayerLeagueSeasonRankingsResponse;
import jcrapi2.api.intern.locations.seasons.global.rankings.pathoflegend.TopPlayerPathOfLegendSeasonRankingsRequest;
import jcrapi2.api.intern.locations.seasons.global.rankings.pathoflegend.TopPlayerPathOfLegendSeasonRankingsResponse;
import jcrapi2.api.intern.locations.seasons.global.rankings.tournament.TopPlayerTournamentRankingsRequest;
import jcrapi2.api.intern.locations.seasons.global.rankings.tournament.TopPlayerTournamentRankingsResponse;

import java.util.concurrent.Future;

Expand Down Expand Up @@ -60,4 +62,7 @@ Future<TopPlayerLeagueSeasonRankingsResponse> getTopPlayerLeagueSeasonRankings(

Future<TopPlayerPathOfLegendSeasonRankingsResponse> getTopPlayerPathOfLegendSeasonRankings(
TopPlayerPathOfLegendSeasonRankingsRequest topPlayerPathOfLegendSeasonRankingsRequest);

Future<TopPlayerTournamentRankingsResponse> getTopPlayerTournamentRankings(
TopPlayerTournamentRankingsRequest topPlayerTournamentRankingsRequest);
}
10 changes: 10 additions & 0 deletions src/main/java/jcrapi2/api/intern/locations/LocationApiImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import jcrapi2.api.intern.locations.seasons.global.rankings.TopPlayerLeagueSeasonRankingsResponse;
import jcrapi2.api.intern.locations.seasons.global.rankings.pathoflegend.TopPlayerPathOfLegendSeasonRankingsRequest;
import jcrapi2.api.intern.locations.seasons.global.rankings.pathoflegend.TopPlayerPathOfLegendSeasonRankingsResponse;
import jcrapi2.api.intern.locations.seasons.global.rankings.tournament.TopPlayerTournamentRankingsRequest;
import jcrapi2.api.intern.locations.seasons.global.rankings.tournament.TopPlayerTournamentRankingsResponse;

import java.util.concurrent.Future;

Expand Down Expand Up @@ -108,4 +110,12 @@ public Future<TopPlayerLeagueSeasonRankingsResponse> getTopPlayerLeagueSeasonRan
topPlayerPathOfLegendSeasonRankingsRequest,
TopPlayerPathOfLegendSeasonRankingsResponse.class);
}

public Future<TopPlayerTournamentRankingsResponse> getTopPlayerTournamentRankings(
TopPlayerTournamentRankingsRequest topPlayerTournamentRankingsRequest) {
return get(
"/locations/global/rankings/tournaments/{tournamentTag}",
topPlayerTournamentRankingsRequest,
TopPlayerTournamentRankingsResponse.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jcrapi2.api.intern.locations.seasons.global.rankings.tournament;

import com.google.gson.annotations.SerializedName;

import lombok.Data;

@Data
public class Clan {

@SerializedName("tag")
private String tag;

@SerializedName("name")
private String name;

@SerializedName("badgeId")
private long badgeId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jcrapi2.api.intern.locations.seasons.global.rankings.tournament;

import com.google.gson.annotations.SerializedName;

import lombok.Data;

@Data
public class TopPlayerTournamentRanking {

@SerializedName("tag")
private String tag;

@SerializedName("name")
private String name;

@SerializedName("wins")
private int wins;

@SerializedName("losses")
private int losses;

@SerializedName("rank")
private int rank;

@SerializedName("previousRank")
private int previousRank;

@SerializedName("clan")
private Clan clan;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jcrapi2.api.intern.locations.seasons.global.rankings.tournament;

import jcrapi2.common.PaginationRequest;

import lombok.Builder;

import java.util.Map;

public class TopPlayerTournamentRankingsRequest extends PaginationRequest {

private final String tournamentTag;

@Builder
private TopPlayerTournamentRankingsRequest(
int limit,
String after,
String before,
boolean storeRawResponse,
String tournamentTag) {
super(limit, after, before, storeRawResponse);
this.tournamentTag = tournamentTag;
}

public static TopPlayerTournamentRankingsRequestBuilder builder(String tournamentTag) {
return new TopPlayerTournamentRankingsRequestBuilder().tournamentTag(tournamentTag);
}

@Override
public Map<String, Object> getRestParameters() {
Map<String, Object> map = super.getRestParameters();
map.put("tournamentTag", tournamentTag);
return map;
}

@Override
public Map<String, Object> getQueryParameters() {
Map<String, Object> map = super.getQueryParameters();
return map;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jcrapi2.api.intern.locations.seasons.global.rankings.tournament;

import jcrapi2.common.PaginationResponse;

public class TopPlayerTournamentRankingsResponse
extends PaginationResponse<TopPlayerTournamentRanking> {}
21 changes: 21 additions & 0 deletions src/test/java/jcrapi2/EndToEnd.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package jcrapi2;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import static wiremock.org.apache.commons.lang3.StringUtils.EMPTY;

Expand Down Expand Up @@ -65,6 +66,8 @@
import jcrapi2.api.intern.locations.seasons.global.rankings.TopPlayerLeagueSeasonRankingsResponse;
import jcrapi2.api.intern.locations.seasons.global.rankings.pathoflegend.TopPlayerPathOfLegendSeasonRankingsRequest;
import jcrapi2.api.intern.locations.seasons.global.rankings.pathoflegend.TopPlayerPathOfLegendSeasonRankingsResponse;
import jcrapi2.api.intern.locations.seasons.global.rankings.tournament.TopPlayerTournamentRankingsRequest;
import jcrapi2.api.intern.locations.seasons.global.rankings.tournament.TopPlayerTournamentRankingsResponse;
import jcrapi2.api.intern.players.PlayerApi;
import jcrapi2.api.intern.players.battlelog.BattleLogRequest;
import jcrapi2.api.intern.players.battlelog.BattleLogResponse;
Expand Down Expand Up @@ -93,6 +96,7 @@ class EndToEnd {
private static final Gson GSON = new GsonBuilder().disableHtmlEscaping().create();

private static final String CLAN_TAG = "#RP88QQG";
private static final String GLOBAL_TOURNAMENT_TAG = "#URP0P0LU0";
private static final String PATH_OF_LEGEND_SEASON_ID = "2023-04";
private static final String PLAYER_TAG = "#2PGGCJJL";
private static final String TOURNAMENT_NAME = "de";
Expand Down Expand Up @@ -132,6 +136,7 @@ void setUp() {
}

private static void assertDiff(String expected, String actual) {
assertNotEquals("", actual);
JsonValue source = Json.createReader(new StringReader(actual)).readValue();
JsonValue target = Json.createReader(new StringReader(expected)).readValue();
JsonPatch diff;
Expand Down Expand Up @@ -501,4 +506,20 @@ void locations_getTopPlayerPathOfLegendSeasonRankings() throws Exception {

assertDiff(expected, actual);
}

@Test
void locations_getTopPlayerTournamentRankings() throws Exception {
TopPlayerTournamentRankingsResponse response =
locationApi
.getTopPlayerTournamentRankings(
TopPlayerTournamentRankingsRequest.builder(GLOBAL_TOURNAMENT_TAG)
.storeRawResponse(true)
.limit(10)
.build())
.get();
String actual = GSON.toJson(response);
String expected = response.getRawResponse().getRaw();

assertDiff(expected, actual);
}
}
Loading

0 comments on commit 6f961a4

Please sign in to comment.