@Override public String getHttpRequestContentType() { if (isAuthenticated()) { return "application/octet-stream"; } else { return "application/json"; } }
@Override public @NonNull byte[] renderData() throws Exception { String jsonString = marshallForSending().toString(); ApptentiveLog.v(PAYLOADS, jsonString); // authenticated payloads get encrypted before sending if (isAuthenticated()) { byte[] bytes = jsonString.getBytes(); return Encryptor.encrypt(getEncryptionKey(), bytes); } return jsonString.getBytes(); }
final JSONObject marshallForSending() throws JSONException { JSONObject result; String container = getJsonContainer(); if (container != null) { result = new JSONObject(); result.put(container, jsonObject); } else { result = jsonObject; } if (isAuthenticated()) { result.put("token", getConversationToken()); } if (hasSessionId()) { result.put("session_id", getSessionId()); } return result; }
values.put(PayloadEntry.COLUMN_CONTENT_TYPE.name, notNull(payload.getHttpRequestContentType())); if (!payload.isAuthenticated()) { writeToFile(dest, payload.renderData(), !payload.isAuthenticated()); values.put(PayloadEntry.COLUMN_AUTHENTICATED.name, payload.isAuthenticated() ? TRUE : FALSE);