Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support .srgs file extension #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions codekit/src/main/java/com/att/api/ads/service/ADSService.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ public ADSResponse getAdvertisement(Category category, String userAgent,
*/
public ADSResponse getAdvertisement(ADSArguments args) throws RESTException {

try {
final String responseBody = getAdvertisementAndReturnRawJson(args);
return ADSResponse.valueOf(new JSONObject(responseBody));
} catch (ParseException pe) {
throw new RESTException(pe);
}
}

public String getAdvertisementAndReturnRawJson(ADSArguments args) throws RESTException {

if (args == null)
throw new IllegalArgumentException("Arguments must not be null.");

Expand All @@ -177,11 +187,6 @@ public ADSResponse getAdvertisement(ADSArguments args) throws RESTException {

this.appendArguments(args, client);

try {
final String responseBody = client.httpGet().getResponseBody();
return ADSResponse.valueOf(new JSONObject(responseBody));
} catch (JSONException pe) {
throw new RESTException(pe);
}
return client.httpGet().getResponseBody();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ protected OAuthToken getFileToken() throws RESTException {
final String clientId = cfg.getClientId();
final String clientSecret = cfg.getClientSecret();
final OAuthService service = new OAuthService(
appConfig.getOauthFQDN(), clientId, clientSecret);
appConfig.getOauthFQDN(), clientId, clientSecret,
Long.parseLong(appConfig.getProperty("tokenExpireSeconds")));

token = service.getToken(cfg.getProperty("scope"));
token.saveToken(tokenFile);
Expand Down Expand Up @@ -82,7 +83,8 @@ protected OAuthToken getSessionToken(HttpServletRequest request,
final String code = (String) request.getParameter("code");
if (code != null) {
final OAuthService service = new OAuthService(
appConfig.getOauthFQDN(), clientId, clientSecret);
appConfig.getOauthFQDN(), clientId, clientSecret,
Long.parseLong(appConfig.getProperty("tokenExpireSeconds")));
token = service.getTokenUsingCode(code);
session.setAttribute("token", token);
return token;
Expand Down
16 changes: 10 additions & 6 deletions codekit/src/main/java/com/att/api/dc/service/DCService.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@ public DCService(final String fqdn, final OAuthToken token) {
public DCResponse getDeviceCapabilities() throws RESTException {
String endpoint = getFQDN() + "/rest/2/Devices/Info";

final String responseBody = new RESTClient(endpoint)
.addAuthorizationHeader(getToken())
.httpGet()
.getResponseBody();

try {
JSONObject jsonResponse = new JSONObject(responseBody);
JSONObject jsonResponse = new JSONObject(getDeviceCapabilitiesAndReturnRawJson());
return DCResponse.valueOf(jsonResponse);
} catch (JSONException pe) {
throw new RESTException(pe);
}
}

public String getDeviceCapabilitiesAndReturnRawJson() throws RESTException {
String endpoint = getFQDN() + "/rest/2/Devices/Info";

return new RESTClient(endpoint)
.addAuthorizationHeader(getToken())
.httpGet()
.getResponseBody();
}
}
Loading