Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement request GetPlayerSummaries.
- Loading branch information
Showing
5 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
src/main/java/com/lukaspradel/steamapi/webapi/request/GetPlayerSummariesRequest.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,84 @@ | ||
package com.lukaspradel.steamapi.webapi.request; | ||
|
||
import java.util.List; | ||
|
||
import com.lukaspradel.steamapi.webapi.core.SteamWebApiInterface; | ||
import com.lukaspradel.steamapi.webapi.core.SteamWebApiInterfaceMethod; | ||
import com.lukaspradel.steamapi.webapi.core.SteamWebApiVersion; | ||
import com.lukaspradel.steamapi.webapi.request.builders.AbstractSteamWebApiRequestBuilder; | ||
|
||
/** | ||
* Steam Web API Request GetPlayerSummaries | ||
* | ||
* @see <a href= | ||
* "https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29" | ||
* >https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29</a> | ||
* @author lpradel | ||
* | ||
*/ | ||
public class GetPlayerSummariesRequest extends SteamWebApiRequest { | ||
|
||
private GetPlayerSummariesRequest(SteamWebApiRequestBuilder builder) { | ||
super(builder); | ||
} | ||
|
||
/** | ||
* Builder object to create instances of {@link SteamWebApiRequest} for | ||
* request type {@link GetPlayerSummariesRequest}. | ||
* | ||
* @author lpradel | ||
* | ||
*/ | ||
public static class GetPlayerSummariesRequestBuilder extends | ||
AbstractSteamWebApiRequestBuilder { | ||
|
||
private final List<String> steamIds; | ||
|
||
public static final String REQUEST_PARAM_STEAM_IDS = "steamids"; | ||
|
||
public GetPlayerSummariesRequestBuilder(List<String> steamIds) { | ||
|
||
if (steamIds.isEmpty()) { | ||
throw new IllegalArgumentException( | ||
"You must supply at least 1 Steam ID!"); | ||
} | ||
|
||
this.steamIds = steamIds; | ||
} | ||
|
||
@Override | ||
protected SteamWebApiInterface getInterface() { | ||
|
||
return SteamWebApiInterface.I_STEAM_USER; | ||
} | ||
|
||
@Override | ||
protected SteamWebApiInterfaceMethod getInterfaceMethod() { | ||
|
||
return SteamWebApiInterfaceMethod.GET_PLAYER_SUMMARIES; | ||
} | ||
|
||
@Override | ||
protected SteamWebApiVersion getVersion() { | ||
|
||
return SteamWebApiVersion.VERSION_TWO; | ||
} | ||
|
||
@Override | ||
public GetPlayerSummariesRequest buildRequest() { | ||
|
||
StringBuilder steamIdsParam = new StringBuilder(); | ||
|
||
// Steam IDs are transmitted as comma-separated list | ||
for (String steamId : steamIds) { | ||
steamIdsParam.append(steamId); | ||
steamIdsParam.append(","); | ||
} | ||
steamIdsParam.setLength(steamIdsParam.length() - 1); | ||
|
||
addParameter(REQUEST_PARAM_STEAM_IDS, steamIdsParam.toString()); | ||
|
||
return new GetPlayerSummariesRequest(this); | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
src/test/resources/com/lukaspradel/steamapi/webapi/client/GetPlayerSummaries.json
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 @@ | ||
{ | ||
"response": { | ||
"players": [ | ||
{ | ||
"steamid": "76561197960435530", | ||
"communityvisibilitystate": 3, | ||
"profilestate": 1, | ||
"personaname": "Robin", | ||
"lastlogoff": 1428786231, | ||
"profileurl": "http://steamcommunity.com/id/robinwalker/", | ||
"avatar": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4.jpg", | ||
"avatarmedium": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_medium.jpg", | ||
"avatarfull": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f1/f1dd60a188883caf82d0cbfccfe6aba0af1732d4_full.jpg", | ||
"personastate": 0, | ||
"realname": "Robin Walker", | ||
"primaryclanid": "103582791429521412", | ||
"timecreated": 1063407589, | ||
"personastateflags": 0, | ||
"loccountrycode": "US", | ||
"locstatecode": "WA", | ||
"loccityid": 3961 | ||
} | ||
] | ||
|
||
} | ||
} |