Skip to content

Commit

Permalink
feedback response management
Browse files Browse the repository at this point in the history
feedback response management
  • Loading branch information
fSergio101 committed Apr 10, 2016
1 parent 99eac4e commit 72f3a67
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ protected void receivedResponse(BusinessObject obj, Class<T> responseClass) {
@Override public void run() {
Message message = new Message();
message.obj = performRequest();

if (message.obj == null){
message.obj = new ErrorObject();
}

handler.sendMessage(message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.applivery.applvsdklib.network.api.requests.FeedbackRequest;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidCurrentAppInfo;
import com.applivery.applvsdklib.tools.androidimplementations.AndroidDeviceDetailsInfo;
import com.applivery.applvsdklib.ui.views.feedback.UserFeedbackPresenter;

/**
* Created by Sergio Martinez Rodriguez
Expand All @@ -41,11 +42,12 @@ public class FeedbackInteractor extends BaseInteractor<FeedbackResult> {
private final FeedbackWrapper feedbackWrapper;

public FeedbackInteractor(AppliveryApiService appliveryApiService, Feedback feedback,
CurrentAppInfo currentAppInfo, DeviceDetailsInfo deviceDetailsInfo) {
CurrentAppInfo currentAppInfo, DeviceDetailsInfo deviceDetailsInfo,
InteractorCallback interactorCallback) {

this.feedbackWrapper = FeedbackWrapper.createWrapper(feedback, currentAppInfo, deviceDetailsInfo);
this.feedbackRequest = new FeedbackRequest(appliveryApiService, feedbackWrapper);
this.feedbackCallback = new FeedbackInteractorCallback();
this.feedbackCallback = interactorCallback;
}

@Override protected void receivedResponse(BusinessObject result) {
Expand All @@ -64,13 +66,14 @@ public FeedbackInteractor(AppliveryApiService appliveryApiService, Feedback feed
return feedbackRequest.execute();
}

public static Runnable getInstance(AppliveryApiService service, Feedback feedback) {
public static Runnable getInstance(AppliveryApiService service, Feedback feedback, UserFeedbackPresenter
userFeedbackPresenter) {

CurrentAppInfo currentAppInfo = new AndroidCurrentAppInfo(AppliverySdk.getApplicationContext());
DeviceDetailsInfo deviceDetailsInfo = new AndroidDeviceDetailsInfo();

FeedbackInteractor feedbackInteractor = new FeedbackInteractor(service, feedback,
currentAppInfo, deviceDetailsInfo);
currentAppInfo, deviceDetailsInfo, userFeedbackPresenter);

return feedbackInteractor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public ErrorObject(ApiAppliveryServerErrorResponse serverResponse) {
isBusinessError = serverResponse.isBusinessError();
}

public ErrorObject() {
businessCode = -99;
message = "Unknown Error";
isBusinessError = false;
}

@Override public ErrorObject getObject() {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class UserFeedback implements Feedback {

private FeedBackType feedBackType;
private boolean screenshotAttached;
private boolean screenshotAttached = true;
private String feedbackMessage;
private ScreenCapture screenCapture;

Expand Down Expand Up @@ -54,7 +54,12 @@ public class UserFeedback implements Feedback {
}

@Override public String getBase64ScreenCapture() {
return screenCapture.getBase64();
if (screenCapture!=null){
return screenCapture.getBase64();
}else{
return null;
}

}

@Override public FeedBackType getType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.applivery.applvsdklib.network.api.requests;

import com.applivery.applvsdklib.network.api.requests.mappers.ApiFeedbackResponseMapper;
import com.applivery.applvsdklib.network.api.AppliveryApiService;
import com.applivery.applvsdklib.domain.model.BusinessObject;
import com.applivery.applvsdklib.domain.model.FeedbackResult;
import com.applivery.applvsdklib.domain.model.FeedbackWrapper;
import com.applivery.applvsdklib.network.api.model.ApiFeedbackData;
import com.applivery.applvsdklib.network.api.requests.mappers.ApiDeviceInfoRequestMapper;
Expand All @@ -38,10 +38,12 @@ public class FeedbackRequest extends ServerRequest {
private final AppliveryApiService apiService;
private final FeedbackWrapper feedbackWrapper;
private final ApiFeedbackRequestMapper apiFeedbackRequestMapper;
private final ApiFeedbackResponseMapper apiFeedbackResponseMapper;

public FeedbackRequest(AppliveryApiService apiService, FeedbackWrapper feedbackWrapper) {
this.apiService = apiService;
this.feedbackWrapper = feedbackWrapper;
this.apiFeedbackResponseMapper = new ApiFeedbackResponseMapper();
this.apiFeedbackRequestMapper = createMappers();
}

Expand All @@ -62,7 +64,8 @@ private ApiFeedbackRequestMapper createMappers() {
ApiFeedbackData apiFeedbackData = apiFeedbackRequestMapper.modelToData(feedbackWrapper);
Call<ApiFeedbackResponse> response = apiService.sendFeedback(apiFeedbackData);
ApiFeedbackResponse apiFeedbackResponse = super.performRequest(response);
return new FeedbackResult(apiFeedbackResponse.getStatus());
BusinessObject businessObject = apiFeedbackResponseMapper.map(apiFeedbackResponse);
return businessObject;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public abstract class ServerRequest {

public final BusinessObject execute() {
try {
return performRequest();
BusinessObject businessObject = performRequest();
return businessObject;
}catch (RequestHttpException re){
return new ErrorObject(re.getServerResponse().getError());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2016 Applivery
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.applivery.applvsdklib.network.api.requests.mappers;

import com.applivery.applvsdklib.domain.model.BusinessObject;
import com.applivery.applvsdklib.domain.model.FeedbackResult;
import com.applivery.applvsdklib.network.api.responses.ApiFeedbackResponse;

/**
* Created by Sergio Martinez Rodriguez
* Date 10/4/16.
*/
public class ApiFeedbackResponseMapper extends BaseMapper<FeedbackResult, Object> {

public ApiFeedbackResponseMapper() {
}

public BusinessObject map(ApiFeedbackResponse apiFeedbackResponse) {
return super.map(apiFeedbackResponse);
}

@Override protected FeedbackResult mapBusinessObject(Object serverResponse) {
FeedbackResult feedbackResult = new FeedbackResult(true);
return feedbackResult;
}

//@Override protected AppConfig mapBusinessObject(ApiAppConfigData apiAppConfigData) {
//
// AppConfig appConfig = new AppConfig();
//
// appConfig.setBuildsCount(apiAppConfigData.getBuildsCount());
//
// appConfig.setCreated(DateUtils.stringToDateWithFormat(apiAppConfigData.getCreated(),
// DateFormatConstants.DATE_FORMAT));
//
// appConfig.setModified(DateUtils.stringToDateWithFormat(apiAppConfigData.getModified(),
// DateFormatConstants.DATE_FORMAT));
//
// appConfig.setDescription(apiAppConfigData.getDescription());
// appConfig.setId(apiAppConfigData.getId());
// appConfig.setName(apiAppConfigData.getName());
// appConfig.setTotalDownloads(apiAppConfigData.getTotalDownloads());
// appConfig.setCrashesCount(apiAppConfigData.getCrashesCount());
// appConfig.setFeedBackCount(apiAppConfigData.getFeedbackCount());
// appConfig.setSitesCount(apiAppConfigData.getSitesCount());
// appConfig.setSo(apiAppConfigData.getSo());
// appConfig.setTotalDownloads(apiAppConfigData.getTotalDownloads());
// appConfig.setSdk(sdkMapper.dataToModel(apiAppConfigData.getSdk()));
//
// return appConfig;
//}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

package com.applivery.applvsdklib.network.api.responses;

import com.applivery.applvsdklib.network.api.model.ApiFeedbackData;

/**
* Created by Sergio Martinez Rodriguez
* Date 2/1/16.
*/
public class ApiFeedbackResponse extends ServerResponse<ApiFeedbackData> {
public class ApiFeedbackResponse extends ServerResponse<Object> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,12 @@ public void sendFeedbackInfo(String feedbackMessage) {

if (feedback.mustAttachScreenshot()){
feedback.setScreenCapture(screenCapture);
}else{
feedback.setScreenCapture(null);
}

AppliverySdk.getExecutor().execute(FeedbackInteractor.getInstance(appliveryApiService, feedback));
AppliverySdk.getExecutor().execute(FeedbackInteractor.getInstance(appliveryApiService,
feedback, this));

}

Expand Down

0 comments on commit 72f3a67

Please sign in to comment.