Skip to content

Commit

Permalink
[USERGRID-333] Adding convenience methods to post token with query pa…
Browse files Browse the repository at this point in the history
…rameters
  • Loading branch information
r3b committed Feb 18, 2015
1 parent 7865f9a commit 07a5714
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@



import com.sun.jersey.api.client.WebResource;
import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
import org.apache.usergrid.rest.test.resource2point0.model.Token;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;

Expand All @@ -36,6 +38,22 @@ public TokenResource(final ClientContext context, final UrlResource parent) {
}



/**
* Obtains an access token and sets the token for the context to use in later calls
*
* @return
*/
public Token post(QueryParameters params) {
WebResource resource = getResource();
resource = addParametersToResource(resource, params);
Token token = resource.type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON)
.get(Token.class);

this.context.setToken(token);
return token;
}

/**
* Obtains an access token and sets the token for the context to use in later calls
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.sun.jersey.api.client.WebResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.NamedResource;
import org.apache.usergrid.rest.test.resource2point0.endpoints.UrlResource;
import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
import org.apache.usergrid.rest.test.resource2point0.model.Token;
import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
Expand All @@ -48,6 +49,21 @@ public Token post() {
return token;
}

/**
* Obtains an access token and sets the token for the context to use in later calls
*
* @return
*/
public Token post(QueryParameters params) {
WebResource resource = getResource();
resource = addParametersToResource(resource, params);
Token token = resource.type(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON)
.get(Token.class);

this.context.setToken(token);
return token;
}

/**
* Obtains an access token and sets the token for the context to use in later calls
*
Expand Down

0 comments on commit 07a5714

Please sign in to comment.