diff --git a/CHANGES.MD b/CHANGES.MD
index efe082f..7ac353b 100644
--- a/CHANGES.MD
+++ b/CHANGES.MD
@@ -1,3 +1,11 @@
+2.6.0 (2019-01-30)
+=================
+
+- Add support for `$account_types` to the `$create_account` event and the `$update_account` event
+- Add support for the new event `$update_password`
+- Add support for `$verified_event`, `$reason`, `$verified_entity_id` to the `$verification` event
+- Add support for `$ip`, `$browser`, `$app` to the `$verification` event
+
2.5.0 (2019-01-09)
=================
diff --git a/README.md b/README.md
index ff683a2..1e31cf8 100644
--- a/README.md
+++ b/README.md
@@ -11,13 +11,13 @@ Java 1.7 or later.
com.siftscience
sift-java
- 2.5.0
+ 2.6.0
```
### Gradle
```
dependencies {
- compile 'com.siftscience:sift-java:2.5.0'
+ compile 'com.siftscience:sift-java:2.6.0'
}
```
### Other
diff --git a/build.gradle b/build.gradle
index b848baf..33641c1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ apply plugin: 'signing'
apply plugin: 'java-library-distribution'
group = 'com.siftscience'
-version = '2.5.0'
+version = '2.6.0'
sourceCompatibility = 1.7
targetCompatibility = 1.7
diff --git a/src/main/java/com/siftscience/model/CreateAccountFieldSet.java b/src/main/java/com/siftscience/model/CreateAccountFieldSet.java
index 684986c..46e6bd1 100644
--- a/src/main/java/com/siftscience/model/CreateAccountFieldSet.java
+++ b/src/main/java/com/siftscience/model/CreateAccountFieldSet.java
@@ -10,6 +10,7 @@ public static CreateAccountFieldSet fromJson(String json) {
return gson.fromJson(json, CreateAccountFieldSet.class);
}
+ @Expose @SerializedName("$account_types") private List accountTypes;
@Expose @SerializedName("$promotions") private List promotions;
@Override
@@ -25,4 +26,11 @@ public CreateAccountFieldSet setPromotions(List promotions) {
this.promotions = promotions;
return this;
}
+
+ public List getAccountTypes() { return accountTypes; }
+
+ public CreateAccountFieldSet setAccountTypes(List accountTypes) {
+ this.accountTypes = accountTypes;
+ return this;
+ }
}
diff --git a/src/main/java/com/siftscience/model/UpdateAccountFieldSet.java b/src/main/java/com/siftscience/model/UpdateAccountFieldSet.java
index 7eb734f..2a504c8 100644
--- a/src/main/java/com/siftscience/model/UpdateAccountFieldSet.java
+++ b/src/main/java/com/siftscience/model/UpdateAccountFieldSet.java
@@ -3,11 +3,14 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
+import java.util.List;
+
public class UpdateAccountFieldSet extends BaseAccountFieldSet {
public static UpdateAccountFieldSet fromJson(String json) {
return gson.fromJson(json, UpdateAccountFieldSet.class);
}
+ @Expose @SerializedName("$account_types") private List accountTypes;
@Expose @SerializedName("$changed_password") private Boolean changedPassword;
@Override
@@ -23,4 +26,11 @@ public UpdateAccountFieldSet setChangedPassword(Boolean changedPassword) {
this.changedPassword = changedPassword;
return this;
}
+
+ public List getAccountTypes() { return accountTypes; }
+
+ public UpdateAccountFieldSet setAccountTypes(List accountTypes) {
+ this.accountTypes = accountTypes;
+ return this;
+ }
}
diff --git a/src/main/java/com/siftscience/model/UpdatePasswordFieldSet.java b/src/main/java/com/siftscience/model/UpdatePasswordFieldSet.java
new file mode 100644
index 0000000..d496e76
--- /dev/null
+++ b/src/main/java/com/siftscience/model/UpdatePasswordFieldSet.java
@@ -0,0 +1,32 @@
+package com.siftscience.model;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+
+public class UpdatePasswordFieldSet extends BaseAppBrowserFieldSet {
+ public static UpdatePasswordFieldSet fromJson(String json) {
+ return gson.fromJson(json, UpdatePasswordFieldSet.class);
+ }
+
+ @Expose @SerializedName("$reason") private String reason;
+ @Expose @SerializedName("$status") private String status;
+
+ @Override
+ public String getEventType() {
+ return "$update_password";
+ }
+
+ public String getReason() { return reason; }
+
+ public UpdatePasswordFieldSet setReason(String reason) {
+ this.reason = reason;
+ return this;
+ }
+
+ public String getStatus() { return status; }
+
+ public UpdatePasswordFieldSet setStatus(String status) {
+ this.status = status;
+ return this;
+ }
+}
diff --git a/src/main/java/com/siftscience/model/VerificationFieldSet.java b/src/main/java/com/siftscience/model/VerificationFieldSet.java
index cc80f81..9f85957 100644
--- a/src/main/java/com/siftscience/model/VerificationFieldSet.java
+++ b/src/main/java/com/siftscience/model/VerificationFieldSet.java
@@ -3,7 +3,7 @@
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
-public class VerificationFieldSet extends EventsApiRequestFieldSet {
+public class VerificationFieldSet extends BaseAppBrowserFieldSet {
public static VerificationFieldSet fromJson(String json) {
return gson.fromJson(json, VerificationFieldSet.class);
}
@@ -11,6 +11,9 @@ public static VerificationFieldSet fromJson(String json) {
@Expose @SerializedName("$status") private String status;
@Expose @SerializedName("$verification_type") private String verificationType;
@Expose @SerializedName("$verified_value") private String verifiedValue;
+ @Expose @SerializedName("$reason") private String reason;
+ @Expose @SerializedName("$verified_event") private String verifiedEvent;
+ @Expose @SerializedName("$verified_entity_id") private String verifiedEntityId;
@Override
public String getEventType() {
@@ -43,4 +46,25 @@ public VerificationFieldSet setVerifiedValue(String verifiedValue) {
this.verifiedValue = verifiedValue;
return this;
}
+
+ public String getReason() { return reason; }
+
+ public VerificationFieldSet setReason(String reason) {
+ this.reason = reason;
+ return this;
+ }
+
+ public String getVerifiedEvent() { return verifiedEvent; }
+
+ public VerificationFieldSet setVerifiedEvent(String verifiedEvent) {
+ this.verifiedEvent = verifiedEvent;
+ return this;
+ }
+
+ public String getVerifiedEntityId() { return verifiedEntityId; }
+
+ public VerificationFieldSet setVerifiedEntityId(String verifiedEntityId) {
+ this.verifiedEntityId = verifiedEntityId;
+ return this;
+ }
}
diff --git a/src/test/java/com/siftscience/BaseAppBrowserFieldSetTest.java b/src/test/java/com/siftscience/BaseAppBrowserFieldSetTest.java
index d09a5d5..81319e0 100644
--- a/src/test/java/com/siftscience/BaseAppBrowserFieldSetTest.java
+++ b/src/test/java/com/siftscience/BaseAppBrowserFieldSetTest.java
@@ -25,9 +25,11 @@
import com.siftscience.model.UpdateListingFieldSet;
import com.siftscience.model.UpdateMessageFieldSet;
import com.siftscience.model.UpdateOrderFieldSet;
+import com.siftscience.model.UpdatePasswordFieldSet;
import com.siftscience.model.UpdatePostFieldSet;
import com.siftscience.model.UpdateProfileFieldSet;
import com.siftscience.model.UpdateReviewFieldSet;
+import com.siftscience.model.VerificationFieldSet;
import okhttp3.HttpUrl;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
@@ -76,9 +78,11 @@ public void testAllSubclasses() {
UpdateListingFieldSet.class,
UpdateMessageFieldSet.class,
UpdateOrderFieldSet.class,
+ UpdatePasswordFieldSet.class,
UpdatePostFieldSet.class,
UpdateProfileFieldSet.class,
- UpdateReviewFieldSet.class
+ UpdateReviewFieldSet.class,
+ VerificationFieldSet.class
};
for (Class> subclass : subclasses) {
diff --git a/src/test/java/com/siftscience/CreateAccountEventTest.java b/src/test/java/com/siftscience/CreateAccountEventTest.java
index a835496..1e0fbaf 100644
--- a/src/test/java/com/siftscience/CreateAccountEventTest.java
+++ b/src/test/java/com/siftscience/CreateAccountEventTest.java
@@ -12,6 +12,7 @@
import org.skyscreamer.jsonassert.JSONAssert;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import static java.net.HttpURLConnection.HTTP_OK;
@@ -76,7 +77,8 @@ public void testCreateAccount() throws Exception {
" \"location\" : \"New London, NH\",\n" +
" \"referral_code\" : \"MIKEFRIENDS\",\n" +
" \"email_confirmed_status\" : \"$pending\",\n" +
- " \"phone_confirmed_status\" : \"$pending\"\n" +
+ " \"phone_confirmed_status\" : \"$pending\",\n" +
+ " \"$account_types\" : [\"merchant\", \"premium\"]\n" +
"}";
// Start a new mock server and enqueue a mock response.
@@ -124,7 +126,9 @@ public void testCreateAccount() throws Exception {
.setCustomField("location", "New London, NH")
.setCustomField("referral_code", "MIKEFRIENDS")
.setCustomField("email_confirmed_status", "$pending")
- .setCustomField("phone_confirmed_status", "$pending"));
+ .setCustomField("phone_confirmed_status", "$pending")
+ .setAccountTypes(Arrays.asList("merchant", "premium")));
+
SiftResponse siftResponse = request.send();
// Verify the request.
diff --git a/src/test/java/com/siftscience/UpdateAccountEventTest.java b/src/test/java/com/siftscience/UpdateAccountEventTest.java
index 87ff1f9..eb428ca 100644
--- a/src/test/java/com/siftscience/UpdateAccountEventTest.java
+++ b/src/test/java/com/siftscience/UpdateAccountEventTest.java
@@ -11,6 +11,7 @@
import org.skyscreamer.jsonassert.JSONAssert;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import static java.net.HttpURLConnection.HTTP_OK;
@@ -57,7 +58,8 @@ public void testUpdateAccount() throws Exception {
" },\n" +
" \"$social_sign_on_type\" : \"$twitter\",\n" +
" \"email_confirmed_status\" : \"$success\",\n" +
- " \"phone_confirmed_status\" : \"$success\"\n" +
+ " \"phone_confirmed_status\" : \"$success\",\n" +
+ " \"$account_types\" : [\"merchant\", \"premium\"]\n" +
"}";
// Start a new mock server and enqueue a mock response.
@@ -96,7 +98,8 @@ public void testUpdateAccount() throws Exception {
.setShippingAddress(TestUtils.sampleAddress2())
.setSocialSignOnType("$twitter")
.setCustomField("email_confirmed_status", "$success")
- .setCustomField("phone_confirmed_status", "$success"));
+ .setCustomField("phone_confirmed_status", "$success")
+ .setAccountTypes(Arrays.asList("merchant", "premium")));
SiftResponse siftResponse = request.send();
diff --git a/src/test/java/com/siftscience/UpdatePasswordEventTest.java b/src/test/java/com/siftscience/UpdatePasswordEventTest.java
new file mode 100644
index 0000000..836f41f
--- /dev/null
+++ b/src/test/java/com/siftscience/UpdatePasswordEventTest.java
@@ -0,0 +1,88 @@
+package com.siftscience;
+
+import com.siftscience.model.App;
+import com.siftscience.model.UpdatePasswordFieldSet;
+import okhttp3.HttpUrl;
+import okhttp3.mockwebserver.MockResponse;
+import okhttp3.mockwebserver.MockWebServer;
+import okhttp3.mockwebserver.RecordedRequest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.skyscreamer.jsonassert.JSONAssert;
+
+import static java.net.HttpURLConnection.HTTP_OK;
+
+/**
+ * Unit tests around the Update_password events.
+ */
+
+public class UpdatePasswordEventTest {
+ @Test
+ public void testUpdatePassword() throws Exception {
+ String expectedRequestBody = "{\n" +
+ " \"$type\" : \"$update_password\",\n" +
+ " \"$api_key\" : \"your_api_key_here\",\n" +
+ " \"$user_id\" : \"billy_jones_301\",\n" +
+ " \"$session_id\" : \"gigtleqddo84l8cm15qe4il\",\n" +
+ " \"$app\" : {\n" +
+ " \"$os\" : \"iOS\",\n" +
+ " \"$app_name\" : \"Calculator\",\n" +
+ " \"$device_manufacturer\" : \"Apple\",\n" +
+ " \"$device_model\" : \"iPhone 4,2\",\n" +
+ " \"$device_unique_id\" : \"A3D261E4-DE0A-470B-9E4A-720F3D3D22E6\",\n" +
+ " \"$app_version\" : \"3.2.7\",\n" +
+ " },\n" +
+ " \"$reason\" : \"$forced_reset\",\n" +
+ " \"$status\" : \"$success\",\n" +
+ " \"$ip\" : \"128.148.1.135\",\n" +
+ "}";
+
+ MockWebServer server = new MockWebServer();
+ MockResponse response = new MockResponse();
+ response.setResponseCode(HTTP_OK);
+ response.setBody("{\n" +
+ " \"status\" : 0,\n" +
+ " \"error_message\" : \"OK\",\n" +
+ " \"time\" : 1327604222,\n" +
+ " \"request\" : \"" + TestUtils.unescapeJson(expectedRequestBody) + "\"\n" +
+ "}");
+ server.enqueue(response);
+ server.start();
+ HttpUrl baseUrl = server.url("");
+
+ // Create a new client and link it to the mock server.
+ SiftClient client = new SiftClient("your_api_key_here");
+ client.setBaseUrl(baseUrl);
+
+ // Build and execute the request against the mock server.
+ UpdatePasswordFieldSet fieldSet = new UpdatePasswordFieldSet()
+ .setUserId("billy_jones_301")
+ .setSessionId("gigtleqddo84l8cm15qe4il")
+ .setReason("$forced_reset")
+ .setStatus("$success")
+ .setIp("128.148.1.135")
+ .setApp(new App()
+ .setAppName("Calculator")
+ .setAppVersion("3.2.7")
+ .setDeviceManufacturer("Apple")
+ .setDeviceModel("iPhone 4,2")
+ .setDeviceUniqueId("A3D261E4-DE0A-470B-9E4A-720F3D3D22E6")
+ .setOperatingSystem("iOS"));
+
+ SiftRequest request = client.buildRequest(fieldSet);
+ SiftResponse siftResponse = request.send();
+
+ //Verify the request
+ RecordedRequest request1 = server.takeRequest();
+ Assert.assertEquals("POST", request1.getMethod());
+ Assert.assertEquals("/v205/events", request1.getPath());
+ JSONAssert.assertEquals(expectedRequestBody, request.getFieldSet().toJson(), true);
+
+ // Verify the response.
+ Assert.assertEquals(HTTP_OK, siftResponse.getHttpStatusCode());
+ Assert.assertEquals(0, (int) siftResponse.getBody().getStatus());
+ JSONAssert.assertEquals(response.getBody().readUtf8(), siftResponse.getBody().toJson(), true);
+
+ server.shutdown();
+ }
+}
diff --git a/src/test/java/com/siftscience/VerificationEventTest.java b/src/test/java/com/siftscience/VerificationEventTest.java
index 266603a..00b9320 100644
--- a/src/test/java/com/siftscience/VerificationEventTest.java
+++ b/src/test/java/com/siftscience/VerificationEventTest.java
@@ -1,5 +1,6 @@
package com.siftscience;
+import com.siftscience.model.App;
import com.siftscience.model.VerificationFieldSet;
import okhttp3.HttpUrl;
import okhttp3.mockwebserver.MockResponse;
@@ -17,15 +18,30 @@ public class VerificationEventTest {
public void testVerification() throws Exception {
String sessionId = "gigtleqddo84l8cm15qe4il";
String verifiedValue = "14155551212";
+ String verifiedEvent = "$create_content";
+ String verifiedEntityId = "chekle212452";
+ String reason = "$user_setting";
String expectedRequestBody = "{\n" +
" \"$type\" : \"$verification\",\n" +
" \"$api_key\" : \"your_api_key_here\",\n" +
" \"$user_id\" : \"billy_jones_301\",\n" +
" \"$session_id\" : \"" + sessionId + "\",\n" +
+ " \"$app\" : {\n" +
+ " \"$os\" : \"iOS\",\n" +
+ " \"$app_name\" : \"Calculator\",\n" +
+ " \"$device_manufacturer\" : \"Apple\",\n" +
+ " \"$device_model\" : \"iPhone 4,2\",\n" +
+ " \"$device_unique_id\" : \"A3D261E4-DE0A-470B-9E4A-720F3D3D22E6\",\n" +
+ " \"$app_version\" : \"3.2.7\",\n" +
+ " },\n" +
" \"$status\" : \"$pending\",\n" +
" \"$verification_type\" : \"$sms\",\n" +
- " \"$verified_value\" : \"" + verifiedValue + "\"\n" +
+ " \"$verified_value\" : \"" + verifiedValue + "\",\n" +
+ " \"$verified_event\" : \"" + verifiedEvent + "\",\n" +
+ " \"$verified_entity_id\" : \"" + verifiedEntityId + "\",\n" +
+ " \"$reason\" : \"" + reason + "\",\n" +
+ " \"$ip\" : \"128.148.1.135\",\n" +
"}";
// Start a new mock server and enqueue a mock response.
@@ -52,7 +68,18 @@ public void testVerification() throws Exception {
.setSessionId(sessionId)
.setStatus("$pending")
.setVerificationType("$sms")
- .setVerifiedValue(verifiedValue));
+ .setVerifiedValue(verifiedValue)
+ .setReason(reason)
+ .setVerifiedEvent(verifiedEvent)
+ .setVerifiedEntityId(verifiedEntityId)
+ .setIp("128.148.1.135")
+ .setApp(new App()
+ .setAppName("Calculator")
+ .setAppVersion("3.2.7")
+ .setDeviceManufacturer("Apple")
+ .setDeviceModel("iPhone 4,2")
+ .setDeviceUniqueId("A3D261E4-DE0A-470B-9E4A-720F3D3D22E6")
+ .setOperatingSystem("iOS")));
SiftResponse siftResponse = request.send();
@@ -69,6 +96,5 @@ public void testVerification() throws Exception {
siftResponse.getBody().toJson(), true);
server.shutdown();
-
}
}