-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #96 from sreejithKExalture/verification_api_impl
Support of Verification API
- Loading branch information
Showing
17 changed files
with
843 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/siftscience/VerificationCheckRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.siftscience; | ||
|
||
import com.siftscience.model.VerificationCheckFieldSet; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.HttpUrl; | ||
import okhttp3.Response; | ||
import okhttp3.Request; | ||
import okhttp3.Credentials; | ||
import okhttp3.MediaType; | ||
import okhttp3.RequestBody; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
/** | ||
* The check call is used for verifying the OTP provided by the end user to Sift. | ||
* Check out https://sift.com/developers/docs/java/verification-api/check for more information on our request/response structure. | ||
*/ | ||
public class VerificationCheckRequest extends SiftRequest<VerificationCheckResponse> { | ||
|
||
VerificationCheckRequest(HttpUrl baseUrl, String accountId, OkHttpClient okClient, VerificationCheckFieldSet fields) { | ||
super(baseUrl, accountId, okClient, fields); | ||
} | ||
|
||
@Override | ||
protected HttpUrl path(HttpUrl baseUrl) { | ||
return baseUrl.newBuilder() | ||
.addPathSegment("v1") | ||
.addPathSegment("verification") | ||
.addPathSegment("check").build(); | ||
} | ||
|
||
@Override | ||
VerificationCheckResponse buildResponse(Response response, FieldSet requestFields) throws IOException { | ||
return new VerificationCheckResponse(response, requestFields); | ||
} | ||
|
||
@Override | ||
protected void modifyRequestBuilder(Request.Builder builder) { | ||
super.modifyRequestBuilder(builder); | ||
builder.header("Authorization", Credentials.basic(fieldSet.getApiKey(), "")).get(); | ||
builder.post(RequestBody.create(MediaType.parse("application/json"), fieldSet.toJson())); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/siftscience/VerificationCheckResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.siftscience; | ||
|
||
import com.siftscience.model.VerificationCheckResponseBody; | ||
import okhttp3.Response; | ||
|
||
import java.io.IOException; | ||
|
||
public class VerificationCheckResponse extends SiftResponse<VerificationCheckResponseBody> { | ||
VerificationCheckResponse(Response okResponse, FieldSet requestBody) throws IOException { | ||
super(okResponse, requestBody); | ||
} | ||
|
||
@Override | ||
public void populateBodyFromJson(String jsonBody) { | ||
body = VerificationCheckResponseBody.fromJson(jsonBody); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/siftscience/VerificationResendRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.siftscience; | ||
|
||
import com.siftscience.model.VerificationResendFieldSet; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.HttpUrl; | ||
import okhttp3.Response; | ||
import okhttp3.Request; | ||
import okhttp3.Credentials; | ||
import okhttp3.MediaType; | ||
import okhttp3.RequestBody; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* The resend call generates a new OTP and sends it to the original recipient with the same settings. | ||
* Check out https://sift.com/developers/docs/java/verification-api/resend for more information on our request/response structuree. | ||
* */ | ||
public class VerificationResendRequest extends SiftRequest<VerificationResendResponse> { | ||
|
||
VerificationResendRequest(HttpUrl baseUrl, String accountId, OkHttpClient okClient, VerificationResendFieldSet fields) { | ||
super(baseUrl, accountId, okClient, fields); | ||
} | ||
|
||
@Override | ||
protected HttpUrl path(HttpUrl baseUrl) { | ||
return baseUrl.newBuilder() | ||
.addPathSegment("v1") | ||
.addPathSegment("verification") | ||
.addPathSegment("resend").build(); | ||
} | ||
|
||
@Override | ||
VerificationResendResponse buildResponse(Response response, FieldSet requestFields) throws IOException { | ||
return new VerificationResendResponse(response, requestFields); | ||
} | ||
|
||
@Override | ||
protected void modifyRequestBuilder(Request.Builder builder) { | ||
super.modifyRequestBuilder(builder); | ||
builder.header("Authorization", Credentials.basic(fieldSet.getApiKey(), "")).get(); | ||
builder.post(RequestBody.create(MediaType.parse("application/json"), fieldSet.toJson())); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/siftscience/VerificationResendResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.siftscience; | ||
|
||
import com.siftscience.model.VerificationResendResponseBody; | ||
import okhttp3.Response; | ||
|
||
import java.io.IOException; | ||
|
||
public class VerificationResendResponse extends SiftResponse<VerificationResendResponseBody> { | ||
VerificationResendResponse(Response okResponse, FieldSet requestBody) throws IOException { | ||
super(okResponse, requestBody); | ||
} | ||
|
||
@Override | ||
public void populateBodyFromJson(String jsonBody) { | ||
body = VerificationResendResponseBody.fromJson(jsonBody); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/siftscience/VerificationSendRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.siftscience; | ||
|
||
import com.siftscience.model.VerificationSendFieldSet; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.HttpUrl; | ||
import okhttp3.Response; | ||
import okhttp3.Request; | ||
import okhttp3.Credentials; | ||
import okhttp3.MediaType; | ||
import okhttp3.RequestBody; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
*The send call triggers the generation of an OTP code that is stored by Sift | ||
* and email/sms the code to the user. | ||
* Check out https://sift.com/developers/docs/java/verification-api/send for more information on our request/response structure. | ||
* */ | ||
public class VerificationSendRequest extends SiftRequest<VerificationSendResponse> { | ||
|
||
VerificationSendRequest(HttpUrl baseUrl, String accountId, OkHttpClient okClient, VerificationSendFieldSet fields) { | ||
super(baseUrl, accountId, okClient, fields); | ||
} | ||
|
||
@Override | ||
protected HttpUrl path(HttpUrl baseUrl) { | ||
return baseUrl.newBuilder() | ||
.addPathSegment("v1") | ||
.addPathSegment("verification") | ||
.addPathSegment("send").build(); | ||
} | ||
|
||
@Override | ||
VerificationSendResponse buildResponse(Response response, FieldSet requestFields) throws IOException { | ||
return new VerificationSendResponse(response, requestFields); | ||
} | ||
|
||
@Override | ||
protected void modifyRequestBuilder(Request.Builder builder) { | ||
super.modifyRequestBuilder(builder); | ||
builder.header("Authorization", Credentials.basic(fieldSet.getApiKey(), "")).get(); | ||
builder.post(RequestBody.create(MediaType.parse("application/json"), fieldSet.toJson())); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/siftscience/VerificationSendResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.siftscience; | ||
|
||
import com.siftscience.model.VerificationSendResponseBody; | ||
import okhttp3.Response; | ||
|
||
import java.io.IOException; | ||
|
||
public class VerificationSendResponse extends SiftResponse<VerificationSendResponseBody> { | ||
VerificationSendResponse(Response okResponse, FieldSet requestBody) throws IOException { | ||
super(okResponse, requestBody); | ||
} | ||
|
||
@Override | ||
public void populateBodyFromJson(String jsonBody) { | ||
body = VerificationSendResponseBody.fromJson(jsonBody); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.siftscience.model; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
public class Event { | ||
|
||
@Expose @SerializedName("$session_id") private String sessionId; | ||
@Expose @SerializedName("$verified_event") private String verifiedEvent; | ||
@Expose @SerializedName("$reason") private String reason; | ||
@Expose @SerializedName("$ip") private String ip; | ||
|
||
@Expose @SerializedName("$browser") private Browser browser; | ||
|
||
@Expose @SerializedName("$app") private App app; | ||
|
||
public String getSessionId() { | ||
return sessionId; | ||
} | ||
|
||
public Event setSessionId(String sessionId) { | ||
this.sessionId = sessionId; | ||
return this; | ||
} | ||
|
||
public String getVerifiedEvent() { | ||
return verifiedEvent; | ||
} | ||
|
||
public Event setVerifiedEvent(String verifiedEvent) { | ||
this.verifiedEvent = verifiedEvent; | ||
return this; | ||
} | ||
|
||
public String getReason() { | ||
return reason; | ||
} | ||
|
||
public Event setReason(String reason) { | ||
this.reason = reason; | ||
return this; | ||
} | ||
|
||
public String getIp() { | ||
return ip; | ||
} | ||
|
||
public Event setIp(String ip) { | ||
this.ip = ip; | ||
return this; | ||
} | ||
|
||
public Browser getBrowser() { | ||
return browser; | ||
} | ||
|
||
public Event setBrowser(Browser browser) { | ||
this.browser = browser; | ||
return this; | ||
} | ||
|
||
public App getApp() { | ||
return app; | ||
} | ||
|
||
public Event setApp(App app) { | ||
this.app = app; | ||
return this; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/siftscience/model/VerificationCheckFieldSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.siftscience.model; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
import com.siftscience.FieldSet; | ||
|
||
public class VerificationCheckFieldSet extends FieldSet<VerificationCheckFieldSet> { | ||
|
||
public static VerificationCheckFieldSet fromJson(String json) { | ||
return gson.fromJson(json, VerificationCheckFieldSet.class); | ||
} | ||
@Expose @SerializedName(USER_ID) private String userId; | ||
@Expose @SerializedName("$code") private String code; | ||
@Expose @SerializedName("$verified_event") private String verifiedEvent; | ||
@Expose @SerializedName("$verified_entity_id") private String verifiedEntityId; | ||
|
||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
public VerificationCheckFieldSet setUserId(String userId) { | ||
this.userId = userId; | ||
return this; | ||
} | ||
|
||
public String getVerifiedEvent() { | ||
return verifiedEvent; | ||
} | ||
|
||
public VerificationCheckFieldSet setVerifiedEvent(String verifiedEvent) { | ||
this.verifiedEvent = verifiedEvent; | ||
return this; | ||
} | ||
|
||
public String getVerifiedEntityId() { | ||
return verifiedEntityId; | ||
} | ||
|
||
public VerificationCheckFieldSet setVerifiedEntityId(String verifiedEntityId) { | ||
this.verifiedEntityId = verifiedEntityId; | ||
return this; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public VerificationCheckFieldSet setCode(String code) { | ||
this.code = code; | ||
return this; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/siftscience/model/VerificationCheckResponseBody.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.siftscience.model; | ||
|
||
import com.google.gson.annotations.Expose; | ||
import com.google.gson.annotations.SerializedName; | ||
|
||
public class VerificationCheckResponseBody extends BaseResponseBody<VerificationCheckResponseBody> { | ||
|
||
@Expose @SerializedName("checked_at") private Long checkedAt; | ||
|
||
public static VerificationCheckResponseBody fromJson(String json) { | ||
return gson.fromJson(json, VerificationCheckResponseBody.class); | ||
} | ||
|
||
public Long getCheckedAt() { | ||
return checkedAt; | ||
} | ||
|
||
public VerificationCheckResponseBody setCheckedAt(Long checkedAt) { | ||
this.checkedAt = checkedAt; | ||
return this; | ||
} | ||
} | ||
|
Oops, something went wrong.