-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new endpoint /leaderboards (#198)
- Loading branch information
Showing
14 changed files
with
266 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v4.0.6 | ||
v4.0.7 |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/jcrapi2/api/intern/leaderboards/Leaderboard.java
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,31 @@ | ||
/* | ||
* 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.leaderboards; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class Leaderboard { | ||
|
||
@SerializedName("id") | ||
private long id; | ||
|
||
@SerializedName("name") | ||
private String name; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/jcrapi2/api/intern/leaderboards/LeaderboardApi.java
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,26 @@ | ||
/* | ||
* 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.leaderboards; | ||
|
||
import supercell.api.wrapper.essentials.api.Api; | ||
|
||
import java.util.concurrent.Future; | ||
|
||
public interface LeaderboardApi extends Api { | ||
|
||
Future<LeaderboardsResponse> findAll(LeaderboardsRequest leaderboardsRequest); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/jcrapi2/api/intern/leaderboards/LeaderboardApiImpl.java
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,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.leaderboards; | ||
|
||
import supercell.api.wrapper.essentials.api.ApiContext; | ||
import supercell.api.wrapper.essentials.api.BaseApi; | ||
|
||
import java.util.concurrent.Future; | ||
|
||
class LeaderboardApiImpl extends BaseApi implements LeaderboardApi { | ||
|
||
LeaderboardApiImpl(ApiContext apiContext) { | ||
super(apiContext); | ||
} | ||
|
||
@Override | ||
public Future<LeaderboardsResponse> findAll(LeaderboardsRequest leaderboardsRequest) { | ||
return get("/leaderboards", leaderboardsRequest, LeaderboardsResponse.class); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/jcrapi2/api/intern/leaderboards/LeaderboardsRequest.java
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,33 @@ | ||
/* | ||
* 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.leaderboards; | ||
|
||
import lombok.Builder; | ||
|
||
import supercell.api.wrapper.essentials.common.PaginationRequest; | ||
|
||
public class LeaderboardsRequest extends PaginationRequest { | ||
|
||
@Builder | ||
private LeaderboardsRequest(int limit, String after, String before, boolean storeRawResponse) { | ||
super(limit, after, before, storeRawResponse); | ||
} | ||
|
||
public static LeaderboardsRequestBuilder builder() { | ||
return new LeaderboardsRequestBuilder(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/jcrapi2/api/intern/leaderboards/LeaderboardsResponse.java
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,21 @@ | ||
/* | ||
* 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.leaderboards; | ||
|
||
import supercell.api.wrapper.essentials.common.PaginationResponse; | ||
|
||
public class LeaderboardsResponse extends PaginationResponse<Leaderboard> {} |
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
57 changes: 57 additions & 0 deletions
57
src/test/java/jcrapi2/api/intern/leaderboards/LeaderboardApiImplIntegrationTest.java
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,57 @@ | ||
/* | ||
* 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.leaderboards; | ||
|
||
import jcrapi2.IntegrationTestBase; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class LeaderboardApiImplIntegrationTest extends IntegrationTestBase { | ||
|
||
private LeaderboardApi unitUnderTest; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
unitUnderTest = getJCrApi().getApi(LeaderboardApi.class); | ||
} | ||
|
||
@Test | ||
void findAll() throws Exception { | ||
jcrapi2.api.intern.leaderboards.LeaderboardsRequest.LeaderboardsRequestBuilder builder = | ||
jcrapi2.api.intern.leaderboards.LeaderboardsRequest.builder(); | ||
jcrapi2.api.intern.leaderboards.LeaderboardsRequest request = | ||
builder.limit(100).before("zzz").after("aaa").storeRawResponse(true).build(); | ||
prepare("/leaderboards", EMPTY, "src/test/resources/leaderboard-findAll.json", request); | ||
|
||
jcrapi2.api.intern.leaderboards.LeaderboardsResponse expected = | ||
toJson(jcrapi2.api.intern.leaderboards.LeaderboardsResponse.class, getExpected()); | ||
|
||
run(expected, () -> unitUnderTest.findAll(request).get()); | ||
} | ||
|
||
@Test | ||
void findAll_whenWithException() { | ||
jcrapi2.api.intern.leaderboards.LeaderboardsRequest.LeaderboardsRequestBuilder builder = | ||
jcrapi2.api.intern.leaderboards.LeaderboardsRequest.builder(); | ||
jcrapi2.api.intern.leaderboards.LeaderboardsRequest request = | ||
builder.limit(100).before("zzz").after("aaa").storeRawResponse(true).build(); | ||
|
||
prepareWithErrorAndRun( | ||
"/leaderboards", EMPTY, request, () -> unitUnderTest.findAll(request).get()); | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"id": 170000001, | ||
"name": "Goblin Queen's Journey" | ||
} | ||
] | ||
} |