Skip to content

Commit

Permalink
Update map type (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiansimson authored Jun 4, 2021
1 parent cf809e1 commit ede1e1f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/main/java/io/castle/client/Castle.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public CastleResponse get(String path) {
* @param payload request payload
* @return a decoded json response
*/
public CastleResponse post(String path, ImmutableMap<String, Object> payload) {
public CastleResponse post(String path, ImmutableMap<Object, Object> payload) {
return client().post(path, payload);
}
/**
Expand All @@ -291,7 +291,7 @@ public CastleResponse put(String path) {
* @param payload request payload
* @return a decoded json response
*/
public CastleResponse put(String path, ImmutableMap<String, Object> payload) {
public CastleResponse put(String path, ImmutableMap<Object, Object> payload) {
return client().put(path, payload);
}

Expand All @@ -312,7 +312,7 @@ public CastleResponse delete(String path) {
* @param payload request payload
* @return a decoded json response
*/
public CastleResponse delete(String path, ImmutableMap<String, Object> payload) {
public CastleResponse delete(String path, ImmutableMap<Object, Object> payload) {
return client().delete(path, payload);
}
}
12 changes: 6 additions & 6 deletions src/main/java/io/castle/client/api/CastleApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,37 +289,37 @@ public interface CastleApi {

CastleResponse get(String path);

CastleResponse post(String path, ImmutableMap<String, Object> payload);
CastleResponse post(String path, ImmutableMap<Object, Object> payload);

CastleResponse put(String path);

CastleResponse put(String path, ImmutableMap<String, Object> payload);
CastleResponse put(String path, ImmutableMap<Object, Object> payload);

CastleResponse delete(String path);

CastleResponse delete(String path, ImmutableMap<String, Object> payload);
CastleResponse delete(String path, ImmutableMap<Object, Object> payload);

/**
* Makes a sync POST request to the risk endpoint.
*
* @param payload Event parameters
* @return
*/
CastleResponse risk(ImmutableMap<String, Object> payload);
CastleResponse risk(ImmutableMap<Object, Object> payload);

/**
* Makes a sync POST request to the filter endpoint.
*
* @param payload Event parameters
* @return
*/
CastleResponse filter(ImmutableMap<String, Object> payload);
CastleResponse filter(ImmutableMap<Object, Object> payload);

/**
* Makes a sync POST request to the log endpoint.
*
* @param payload Event parameters
* @return
*/
CastleResponse log(ImmutableMap<String, Object> payload);
CastleResponse log(ImmutableMap<Object, Object> payload);
}
12 changes: 6 additions & 6 deletions src/main/java/io/castle/client/internal/CastleApiImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public CastleResponse get(String path) {
}

@Override
public CastleResponse post(String path, ImmutableMap<String, Object> payload) {
public CastleResponse post(String path, ImmutableMap<Object, Object> payload) {
RestApi restApi = configuration.getRestApiFactory().buildBackend();
return restApi.post(path, payload);
}
Expand All @@ -297,7 +297,7 @@ public CastleResponse put(String path) {
}

@Override
public CastleResponse put(String path, ImmutableMap<String, Object> payload) {
public CastleResponse put(String path, ImmutableMap<Object, Object> payload) {
RestApi restApi = configuration.getRestApiFactory().buildBackend();
return restApi.put(path, payload);
}
Expand All @@ -309,26 +309,26 @@ public CastleResponse delete(String path) {
}

@Override
public CastleResponse delete(String path, ImmutableMap<String, Object> payload) {
public CastleResponse delete(String path, ImmutableMap<Object, Object> payload) {
RestApi restApi = configuration.getRestApiFactory().buildBackend();
return restApi.delete(path, payload);
}

public CastleResponse risk(ImmutableMap<String, Object> payload) {
public CastleResponse risk(ImmutableMap<Object, Object> payload) {
Preconditions.checkNotNull(payload);
RestApi restApi = configuration.getRestApiFactory().buildBackend();
return restApi.post(Castle.URL_RISK, payload);
}

@Override
public CastleResponse filter(ImmutableMap<String, Object> payload) {
public CastleResponse filter(ImmutableMap<Object, Object> payload) {
Preconditions.checkNotNull(payload);
RestApi restApi = configuration.getRestApiFactory().buildBackend();
return restApi.post(Castle.URL_FILTER, payload);
}

@Override
public CastleResponse log(ImmutableMap<String, Object> payload) {
public CastleResponse log(ImmutableMap<Object, Object> payload) {
Preconditions.checkNotNull(payload);
RestApi restApi = configuration.getRestApiFactory().buildBackend();
return restApi.post(Castle.URL_LOG, payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public CastleResponse put(String path) {
}

@Override
public CastleResponse put(String path, ImmutableMap<String, Object> payload) {
public CastleResponse put(String path, ImmutableMap<Object, Object> payload) {
return makeRequest(path, model.getGson().toJsonTree(payload), METHOD_PUT);
}

Expand All @@ -265,12 +265,12 @@ public CastleResponse delete(String path) {
}

@Override
public CastleResponse delete(String path, ImmutableMap<String, Object> payload) {
public CastleResponse delete(String path, ImmutableMap<Object, Object> payload) {
return makeRequest(path, model.getGson().toJsonTree(payload), METHOD_DELETE);
}

@Override
public CastleResponse post(String path, ImmutableMap<String, Object> payload) {
public CastleResponse post(String path, ImmutableMap<Object, Object> payload) {
return makeRequest(path, model.getGson().toJsonTree(payload), METHOD_POST);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/castle/client/internal/backend/RestApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public interface RestApi {
* @param payload request payload
* @return a decoded json response
*/
CastleResponse post(String path, ImmutableMap<String, Object> payload);
CastleResponse post(String path, ImmutableMap<Object, Object> payload);

/**
* Make a PUT request to a Castle API endpoint such as /v1/devices/{deviceToken}/report
Expand All @@ -120,7 +120,7 @@ public interface RestApi {
* @param payload request payload
* @return a decoded json response
*/
CastleResponse put(String path, ImmutableMap<String, Object> payload);
CastleResponse put(String path, ImmutableMap<Object, Object> payload);

/**
* Make a DELETE request to a Castle API endpoint such as /v1/impersonate
Expand All @@ -137,5 +137,5 @@ public interface RestApi {
* @param payload request payload
* @return a decoded json response
*/
CastleResponse delete(String path, ImmutableMap<String, Object> payload);
CastleResponse delete(String path, ImmutableMap<Object, Object> payload);
}
6 changes: 3 additions & 3 deletions src/test/java/io/castle/client/CastleGenericAPIHttpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void postRequest() throws InterruptedException, JSONException {
.build();

// and an authenticate request is made
CastleResponse response = sdk.onRequest(request).post("/v1/authenticate", new ImmutableMap.Builder<String, Object>()
CastleResponse response = sdk.onRequest(request).post("/v1/authenticate", ImmutableMap.builder()
.put("event", "$login.succeeded")
.put("userId", "12345")
.put("context", payload)
Expand Down Expand Up @@ -85,7 +85,7 @@ public void putRequest() throws InterruptedException, JSONException {
HttpServletRequest request = new MockHttpServletRequest();

// Request is made
CastleResponse response = sdk.onRequest(request).put("/v1/test", new ImmutableMap.Builder<String, Object>()
CastleResponse response = sdk.onRequest(request).put("/v1/test", ImmutableMap.builder()
.put("event", "test")
.put("userId", "12345")
.build());
Expand Down Expand Up @@ -135,7 +135,7 @@ public void deleteRequest() throws InterruptedException, JSONException {
HttpServletRequest request = new MockHttpServletRequest();

// Request is made
CastleResponse response = sdk.onRequest(request).delete("/v1/test", new ImmutableMap.Builder<String, Object>()
CastleResponse response = sdk.onRequest(request).delete("/v1/test", ImmutableMap.builder()
.put("event", "test")
.put("userId", "12345")
.build());
Expand Down

0 comments on commit ede1e1f

Please sign in to comment.