Skip to content

Conversation

@atpaino
Copy link
Contributor

@atpaino atpaino commented Aug 6, 2018

@ehrmann

Purpose
Adds support for the new GET|Post /v205/users/{userId}/score APIs to this client library.

Testing Plan

  1. Added new unit tests
  2. Tested manually on the Sift test account.

@atpaino atpaino requested a review from ehrmann August 6, 2018 18:54
.addPathSegment(userSoreFieldSet.getUserId())
.addPathSegment("score")
.addQueryParameter("api_key", userSoreFieldSet.getApiKey());
if (userSoreFieldSet.getAbuseTypes() != null && userSoreFieldSet.getAbuseTypes().size() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: size() > 0 -> !isEmpty()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I should've looked more closely before copy pasting from ScoreRequest.java.

if (userSoreFieldSet.getAbuseTypes() != null && userSoreFieldSet.getAbuseTypes().size() > 0) {
String queryParamVal = "";
for (String abuseType : userSoreFieldSet.getAbuseTypes()) {
queryParamVal += (abuseType + ",");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is n^2 in Java. I'm working on removing Guava in another PR, so I'll move a join method into a util class.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out StringUtils in #29

}

Decision o = (Decision) other;
return getId().equals(o.getId())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields look nullable. Maybe use Objects.equals(getId(), o.getId())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to Objects.equals for all the string comparisons here.

@atpaino atpaino force-pushed the atpaino_add_support_get_user_score_rescore_user branch from 263a357 to c026154 Compare August 6, 2018 21:31
@atpaino atpaino force-pushed the atpaino_add_support_get_user_score_rescore_user branch from c026154 to 46d5de2 Compare August 8, 2018 16:37
@Expose @SerializedName("score") private Double score;
@Expose @SerializedName("reasons") private List<Reason> reasons;
@Expose @SerializedName("status") private int status;
@Expose @SerializedName("error_message") private String error_message;
Copy link
Contributor

@ehrmann ehrmann Aug 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be camel case, along with the setters and getters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, whoops. Will fix.


UserScoreRequest request = client.buildRequest(userScoreFieldSet);
EntityScoreResponse siftResponse = request.send();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra newline


import java.util.List;

public class AbuseScoreV205 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broad question: do we really want to put V205 in this class name? It'd be the only class like that, and the library is already intended to be used for v205. I'd almost call it an EntityAbuseScore, but it's not really tied to entities. ExtendedAbuseScore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, I'm going to add these new fields to the existing AbuseScore instead of introducing a new AbuseScoreV205.

@atpaino atpaino merged commit 3b132ea into master Aug 10, 2018
@atpaino atpaino deleted the atpaino_add_support_get_user_score_rescore_user branch August 10, 2018 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants