use of com.instructure.canvasapi.model.ErrorReportResult in project instructure-android by instructure.
the class ZendeskDialogStyled method saveZendeskTicket.
public void saveZendeskTicket() {
String comment = descriptionEditText.getText().toString();
String subject = subjectEditText.getText().toString();
if (comment.isEmpty() || subject.isEmpty()) {
Toast.makeText(getContext(), R.string.empty_feedback, Toast.LENGTH_LONG).show();
return;
}
// contact the user
if (fromLogin) {
if (emailAddressEditText.getText() != null && emailAddressEditText.getText().toString() != null) {
User user = new User();
user.setEmail(emailAddressEditText.getText().toString());
APIHelpers.setCacheUser(getActivity(), user);
}
}
final String email = APIHelpers.getCacheUser(getActivity()).getEmail();
String domain = APIHelpers.getDomain(getActivity());
if (domain == null) {
domain = DEFAULT_DOMAIN;
}
// add device info to comment
// try to get the version number and version code
PackageInfo pInfo = null;
String versionName = "";
int versionCode = 0;
try {
pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
versionName = pInfo.versionName;
versionCode = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
Utils.d(e.getMessage());
}
String deviceInfo = "";
deviceInfo += getString(R.string.device) + " " + Build.MANUFACTURER + " " + Build.MODEL + "\n" + getString(R.string.osVersion) + " " + Build.VERSION.RELEASE + "\n" + getString(R.string.versionNum) + ": " + versionName + " " + versionCode + "\n" + getString(R.string.zendesk_severityText) + " " + getUserSeveritySelectionTag() + "\n" + getString(R.string.utils_installDate) + " " + getInstallDateString() + "\n\n";
comment = deviceInfo + comment;
if (mUseDefaultDomain) {
ErrorReportAPI.postGenericErrorReport(subject, domain, email, comment, getUserSeveritySelectionTag(), new CanvasCallback<ErrorReportResult>((APIStatusDelegate) resultListener) {
@Override
public void firstPage(ErrorReportResult errorReportResult, LinkHeaders linkHeaders, Response response) {
resetCachedUser();
resultListener.onTicketPost();
}
@Override
public boolean onFailure(RetrofitError retrofitError) {
resetCachedUser();
resultListener.onTicketError();
return super.onFailure(retrofitError);
}
});
} else {
ErrorReportAPI.postErrorReport(subject, domain, email, comment, getUserSeveritySelectionTag(), new CanvasCallback<ErrorReportResult>((APIStatusDelegate) resultListener) {
@Override
public void cache(ErrorReportResult errorReportResult) {
resetCachedUser();
}
@Override
public void firstPage(ErrorReportResult errorReportResult, LinkHeaders linkHeaders, Response response) {
cache(errorReportResult);
resultListener.onTicketPost();
}
@Override
public boolean onFailure(RetrofitError retrofitError) {
resetCachedUser();
resultListener.onTicketError();
return super.onFailure(retrofitError);
}
});
}
}
Aggregations