-
Notifications
You must be signed in to change notification settings - Fork 8
(For David) Add support for Rescore User and Get User Score APIs #30
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
(For David) Add support for Rescore User and Get User Score APIs #30
Conversation
| .addPathSegment(userSoreFieldSet.getUserId()) | ||
| .addPathSegment("score") | ||
| .addQueryParameter("api_key", userSoreFieldSet.getApiKey()); | ||
| if (userSoreFieldSet.getAbuseTypes() != null && userSoreFieldSet.getAbuseTypes().size() > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: size() > 0 -> !isEmpty()
There was a problem hiding this comment.
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 + ","); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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())
There was a problem hiding this comment.
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.
263a357 to
c026154
Compare
c026154 to
46d5de2
Compare
| @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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); | ||
|
|
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@ehrmann
Purpose
Adds support for the new GET|Post /v205/users/{userId}/score APIs to this client library.
Testing Plan