use of com.onesignal.influence.domain.OSInfluenceType in project OneSignal-Android-SDK by OneSignal.
the class OSOutcomeEvent method fromOutcomeEventParamsV2toOutcomeEventV1.
/**
* Creates an OutcomeEvent from an OSOutcomeEventParams in order to work on V1 from V2
*/
public static OSOutcomeEvent fromOutcomeEventParamsV2toOutcomeEventV1(OSOutcomeEventParams outcomeEventParams) {
OSInfluenceType influenceType = OSInfluenceType.UNATTRIBUTED;
JSONArray notificationId = null;
if (outcomeEventParams.getOutcomeSource() != null) {
OSOutcomeSource source = outcomeEventParams.getOutcomeSource();
if (source.getDirectBody() != null && source.getDirectBody().getNotificationIds() != null && source.getDirectBody().getNotificationIds().length() > 0) {
influenceType = OSInfluenceType.DIRECT;
notificationId = source.getDirectBody().getNotificationIds();
} else if (source.getIndirectBody() != null && source.getIndirectBody().getNotificationIds() != null && source.getIndirectBody().getNotificationIds().length() > 0) {
influenceType = OSInfluenceType.INDIRECT;
notificationId = source.getIndirectBody().getNotificationIds();
}
}
return new OSOutcomeEvent(influenceType, notificationId, outcomeEventParams.getOutcomeId(), outcomeEventParams.getTimestamp(), outcomeEventParams.getWeight());
}
use of com.onesignal.influence.domain.OSInfluenceType in project OneSignal-Android-SDK by OneSignal.
the class TestHelpers method getAllOutcomesRecords.
static List<OSOutcomeEventDB> getAllOutcomesRecords(OneSignalDb db) {
Cursor cursor = db.query(MockOSOutcomeEventsTable.TABLE_NAME, null, null, null, // group by
null, // filter by row groups
null, // sort order, new to old
null, // limit
null);
List<OSOutcomeEventDB> events = new ArrayList<>();
if (cursor.moveToFirst()) {
do {
String name = cursor.getString(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_NAME));
String iamIds = cursor.getString(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_IAM_IDS));
String iamInfluenceTypeString = cursor.getString(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_IAM_INFLUENCE_TYPE));
String notificationIds = cursor.getString(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_NOTIFICATION_IDS));
String notificationInfluenceTypeString = cursor.getString(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_NOTIFICATION_INFLUENCE_TYPE));
OSInfluenceType iamInfluenceType = OSInfluenceType.fromString(iamInfluenceTypeString);
OSInfluenceType notificationInfluenceType = OSInfluenceType.fromString(notificationInfluenceTypeString);
long timestamp = cursor.getLong(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_TIMESTAMP));
float weight = cursor.getFloat(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_WEIGHT));
try {
OSOutcomeEventDB event = new OSOutcomeEventDB(iamInfluenceType, notificationInfluenceType, new JSONArray(iamIds != null ? iamIds : "[]"), new JSONArray(notificationIds != null ? notificationIds : "[]"), name, timestamp, weight);
events.add(event);
} catch (JSONException e) {
e.printStackTrace();
}
} while (cursor.moveToNext());
}
cursor.close();
return events;
}
use of com.onesignal.influence.domain.OSInfluenceType in project OneSignal-Android-SDK by OneSignal.
the class TestHelpers method getAllOutcomesRecordsDBv5.
static List<OSOutcomeEvent> getAllOutcomesRecordsDBv5(OneSignalDb db) {
;
Cursor cursor = db.query(MockOSOutcomeEventsTable.TABLE_NAME, null, null, null, // group by
null, // filter by row groups
null, // sort order, new to old
null, // limit
null);
List<OSOutcomeEvent> events = new ArrayList<>();
if (cursor.moveToFirst()) {
do {
String notificationIds = cursor.getString(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_NOTIFICATION_IDS));
String name = cursor.getString(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_NAME));
String sessionString = cursor.getString(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_SESSION));
OSInfluenceType session = OSInfluenceType.fromString(sessionString);
long timestamp = cursor.getLong(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_TIMESTAMP));
float weight = cursor.getFloat(cursor.getColumnIndex(MockOSOutcomeEventsTable.COLUMN_NAME_WEIGHT));
try {
OSOutcomeEvent event = new OSOutcomeEvent(session, new JSONArray(notificationIds), name, timestamp, weight);
events.add(event);
} catch (JSONException e) {
e.printStackTrace();
}
} while (cursor.moveToNext());
}
cursor.close();
return events;
}
Aggregations