Skip to content

Commit

Permalink
8.16.0 Version (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidBazaarVoice committed May 23, 2024
1 parent 6b4068a commit 2ef9a5f
Show file tree
Hide file tree
Showing 27 changed files with 560 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

# 8.16.0
## Add Video Submission.

* Allow SDK clients on submitreview.json to collect video natively.
* Allow SDK clients on progressive endpoint to collect video natively.

# 8.15.0
## Add Product Level Attribution.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class DemoConstants {
// Ad/Recommendations Other Config Options
// User auth string pre-populated with a small profile
// interested in men's and women's apparel -- for testing and demonstration purposes
public static final String BV_USER_AUTH_STRING = "0ce436b29697d6bc74f30f724b9b0bb6646174653d31323334267573657269643d5265636f6d6d656e646174696f6e7353646b54657374";
public static final String BV_USER_AUTH_STRING = "auth_token";

// Ad Other Config Options
public static final String DFP_TEST_DEVICE_ID = "REPLACE_ME";
Expand Down
2 changes: 1 addition & 1 deletion bvauthiovation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repositories {
apply from: rootProject.file('gradle/bvsdk-module-android.gradle')

dependencies {
implementation('com.iovation.fraudforce.lib.FraudForce:fraudforce-lib-4.1.1-NEXUS_USER:4.1.1@aar')
implementation('com.iovation.fraudforce.lib.FraudForce:fraudforce-lib-4.1.1-release:4.1.1@aar')
implementation project(':bvconversations')
compileOnly project(':bvcommon')
compileOnly sdkDep.gson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void setup() throws Exception {
super.setup();
initMocks(this);
baseurl = server.url("example.com/").toString();
shopperApiKey = "testString123";
shopperApiKey = "testString"+Math.random();
okHttpClient = new OkHttpClient();
gson = new Gson();
bvLogger = new BVLogger(BVLogLevel.VERBOSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,10 @@ public AnswerSubmissionRequest build() {
PhotoUpload.ContentType getPhotoContentType() {
return PhotoUpload.ContentType.ANSWER;
}

@Override
VideoUpload.ContentType getVideoContentType() {
return VideoUpload.ContentType.ANSWER;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ public LoadCallSubmission<UserAuthenticationStringRequest, UserAuthenticationStr
public LoadCallProgressiveSubmission<PhotoUploadRequest, PhotoUploadResponse> prepareCall(PhotoUploadRequest request){
return factoryCreateProgressiveSubmissionCall(PhotoUploadResponse.class, request);
}
public LoadCallProgressiveSubmission<VideoUploadRequest, VideoUploadResponse> prepareCall(VideoUploadRequest request){
return factoryCreateProgressiveSubmissionCall(VideoUploadResponse.class, request);
}

public LoadCallProgressiveSubmission<InitiateSubmitRequest, InitiateSubmitResponse> prepareCall(InitiateSubmitRequest request) {
return factoryCreateProgressiveSubmissionCall(InitiateSubmitResponse.class, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,9 @@ public ChildBuilderType addVideoUrl(String videoUrl, String videoCaption) {
PhotoUpload.ContentType getPhotoContentType() {
return PhotoUpload.ContentType.REVIEW;
}

@Override
VideoUpload.ContentType getVideoContentType() {
return VideoUpload.ContentType.REVIEW;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class BasicRequestFactory implements RequestFactory {
private static final String kACTION = "action";
private static final String KEY_PHOTO_URL_TEMPLATE = "photourl_%d";
private static final String KEY_PHOTO_CAPTION_TEMPLATE = "photocaption_%d";
private static final String KEY_VIDEO_URL_TEMPLATE = "videourl_%d";
private static final String KEY_VIDEO_CAPTION_TEMPLATE = "videocaption_%d";
private static final String kPRODUCT_ID = "ProductId";
// endregion

Expand Down Expand Up @@ -170,7 +172,9 @@ class BasicRequestFactory implements RequestFactory {

// region Submit Photo Request Keys
private static final String PHOTO_SUBMIT_ENDPOINT = "data/uploadphoto.json";
private static final String VIDEO_SUBMIT_ENDPOINT = "data/uploadvideo.json";
private static final MediaType MEDIA_TYPE_JPG = MediaType.parse("image/jpg");
private static final MediaType MEDIA_TYPE_VIDEO = MediaType.parse("video/*");
// endregion

// region Get UAS Keys
Expand Down Expand Up @@ -257,7 +261,9 @@ public <RequestType extends ConversationsRequest> Request create(RequestType req
return createFromCommentSubmissionRequest((CommentSubmissionRequest) request);
} else if (request instanceof PhotoUploadRequest) {
return createFromPhotoUploadRequest((PhotoUploadRequest) request);
} else if (request instanceof UserAuthenticationStringRequest) {
} else if (request instanceof VideoUploadRequest) {
return createFromVideoUploadRequest((VideoUploadRequest) request);
}else if (request instanceof UserAuthenticationStringRequest) {
return createFromUserAuthenticationStringRequest((UserAuthenticationStringRequest) request);
} else if (request instanceof InitiateSubmitRequest) {
return createFromInitiateSubmitRequest((InitiateSubmitRequest) request);
Expand Down Expand Up @@ -1012,6 +1018,38 @@ private Request createFromPhotoUploadRequest(PhotoUploadRequest request) {
.build();
}

private Request createFromVideoUploadRequest(VideoUploadRequest request) {
Request.Builder okRequestBuilder = new Request.Builder();

HttpUrl.Builder httpUrlBuilder = HttpUrl.parse(bvRootApiUrl)
.newBuilder()
.addPathSegments(VIDEO_SUBMIT_ENDPOINT);

MultipartBody.Builder multiPartBuilder = new MultipartBody.Builder();

VideoUpload upload = request.getVideoUpload();

multiPartBuilder
.setType(MultipartBody.FORM)
.addFormDataPart(ConversationsRequest.kAPI_VERSION, API_VERSION)
.addFormDataPart(ConversationsRequest.kPASS_KEY, convApiKey)
.addFormDataPart(VideoUpload.kCONTENT_TYPE, upload.getContentType().getKey())
.addFormDataPart("video", "video.mp4", RequestBody.create(MEDIA_TYPE_VIDEO, upload.getVideoFile()));

RequestBody requestBody = multiPartBuilder.build();
HttpUrl httpUrl = httpUrlBuilder.build();

Headers.Builder headersBuilder = new Headers.Builder();
addCommonHeaders(headersBuilder, bvSdkUserAgent);
Headers headers = headersBuilder.build();

return okRequestBuilder
.url(httpUrl)
.headers(headers)
.post(requestBody)
.build();
}

private Request createFromUserAuthenticationStringRequest(UserAuthenticationStringRequest request) {
final Request.Builder okRequestBuilder = new Request.Builder();
final HttpUrl httpUrl = HttpUrl.parse(bvRootApiUrl)
Expand Down Expand Up @@ -1210,6 +1248,7 @@ private static void addCommonSubmissionFormParams(FormBody.Builder formBodyBuild
}

addSubmissionPhotosFormParams(formBodyBuilder, request);
addSubmissionVideosFormParams(formBodyBuilder, request);
}

private void addCommonProgressiveSubmissionJsonParams(JsonObject json, ConversationsSubmissionRequest request, String apiKey, BVMobileInfo bvMobileInfo, FingerprintProvider fingerprintProvider) {
Expand Down Expand Up @@ -1271,6 +1310,20 @@ private static void addSubmissionPhotosFormParams(FormBody.Builder formBodyBuild
}
}

private static void addSubmissionVideosFormParams(FormBody.Builder formBodyBuilder, ConversationsSubmissionRequest request) {
final List<Video> videos = request.getVideos();
if (videos != null) {
int idx = 0;
for (Video video : videos) {
final String keyVideoUrl = String.format(Locale.US, KEY_VIDEO_URL_TEMPLATE, idx);
final String keyVideoCaption = String.format(Locale.US, KEY_VIDEO_CAPTION_TEMPLATE, idx);
formPutSafe(formBodyBuilder, keyVideoUrl, video.getContent().getNormalUrl());
formPutSafe(formBodyBuilder, keyVideoCaption, video.getCaption());
idx++;
}
}
}

private static void addCommonReviewSubmissionFormParams(FormBody.Builder formBodyBuilder, BaseReviewSubmissionRequest request) {
formPutSafe(formBodyBuilder, kPRODUCT_ID, request.getProductId());
formPutSafe(formBodyBuilder, kIS_RECOMMENDED, request.getRecommended());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ PhotoUpload.ContentType getPhotoContentType() {
return PhotoUpload.ContentType.COMMENT;
}

@Override
VideoUpload.ContentType getVideoContentType() {
return VideoUpload.ContentType.COMMENT;
}

public CommentSubmissionRequest build() {
return new CommentSubmissionRequest(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
abstract class ConversationsSubmissionRequest extends ConversationsRequest {
private final Builder builder;
private List<Photo> photos;

private List<Video> videos;
private boolean forcePreview;

// region Builder Fields
Expand All @@ -49,6 +51,7 @@ abstract class ConversationsSubmissionRequest extends ConversationsRequest {
private final Action action;
private final List<FormPair> formPairs;
private final List<PhotoUpload> photoUploads;
private final List<VideoUpload> videoUploads;
// endregion

ConversationsSubmissionRequest(Builder builder) {
Expand All @@ -69,6 +72,7 @@ abstract class ConversationsSubmissionRequest extends ConversationsRequest {
this.action = builder.action;
this.formPairs = builder.formPairs;
this.photoUploads = builder.photoUploads;
this.videoUploads = builder.videoUploads;
}

Builder getBuilder() {
Expand All @@ -79,6 +83,11 @@ void setPhotos(List<Photo> photos) {
this.photos = photos;
}

void setVideos(List<Video> videos) {
this.videos = videos;
}


// TODO: Remove this stateful logic from the request object
void setForcePreview(boolean forcePreview) {
this.forcePreview = forcePreview;
Expand All @@ -92,6 +101,11 @@ List<Photo> getPhotos() {
return photos;
}

List<Video> getVideos() {
return videos;
}


boolean isForcePreview() {
return forcePreview;
}
Expand Down Expand Up @@ -160,6 +174,11 @@ List<PhotoUpload> getPhotoUploads() {
return photoUploads;
}

List<VideoUpload> getVideoUploads() {
return videoUploads;
}


static class FormPair {
private final String key, value;

Expand Down Expand Up @@ -195,8 +214,12 @@ public abstract static class Builder<BuilderChildType extends Builder> {
private final List<FormPair> formPairs;
transient final List<PhotoUpload> photoUploads = new ArrayList<>();

transient final List<VideoUpload> videoUploads = new ArrayList<>();

abstract PhotoUpload.ContentType getPhotoContentType();

abstract VideoUpload.ContentType getVideoContentType();

Builder(@NonNull Action action) {
this.action = action;
this.formPairs = new ArrayList<>();
Expand Down Expand Up @@ -315,5 +338,11 @@ public BuilderChildType addPhoto(@NonNull File photo, @Nullable String caption)
photoUploads.add(upload);
return (BuilderChildType)this;
}

public BuilderChildType addVideo(@NonNull File video, @Nullable String caption) {
VideoUpload upload = new VideoUpload(video, caption, getVideoContentType());
videoUploads.add(upload);
return (BuilderChildType)this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ PhotoUpload.ContentType getPhotoContentType() {
// TODO: Return unsupported?
return PhotoUpload.ContentType.QUESTION;
}

@Override
VideoUpload.ContentType getVideoContentType() {
return VideoUpload.ContentType.QUESTION;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,10 @@ public InitiateSubmitRequest build() {
PhotoUpload.ContentType getPhotoContentType() {
return null;
}

@Override
VideoUpload.ContentType getVideoContentType() {
return null;
}
}
}
Loading

0 comments on commit 2ef9a5f

Please sign in to comment.