Skip to content

Commit f0b2138

Browse files
author
Evan Greer
committed
feat: refactors getEmbeddedPlacements
1 parent c20df54 commit f0b2138

1 file changed

Lines changed: 11 additions & 17 deletions

File tree

android/src/main/java/com/iterable/reactnative/RNIterableAPIModule.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -489,32 +489,26 @@ public void updateVisibleRows(ReadableArray visibleRows) {
489489
public void getEmbeddedPlacements(Promise promise) {
490490
IterableLogger.d(TAG, "getEmbeddedPlacements");
491491

492-
// Create test data
493492
JSONArray testPlacements = new JSONArray();
493+
int[] testPlacementIds = {808, 1121, 112};
494+
494495
try {
495-
// Test placement 1
496-
JSONObject placement1 = new JSONObject();
497-
placement1.put("placementId", 808);
498-
testPlacements.put(placement1);
499-
500-
// Test placement 2
501-
JSONObject placement2 = new JSONObject();
502-
placement2.put("placementId", 1121);
503-
testPlacements.put(placement2);
504-
505-
// Test placement 2
506-
JSONObject placement3 = new JSONObject();
507-
placement3.put("placementId", 112);
508-
testPlacements.put(placement3);
509-
496+
for (int placementId : testPlacementIds) {
497+
testPlacements.put(createTestPlacement(placementId));
498+
}
510499

511500
promise.resolve(Serialization.convertJsonToArray(testPlacements));
512501
} catch (JSONException e) {
513-
514502
promise.reject("", "Failed to create test placements");
515503
}
516504
}
517505

506+
private JSONObject createTestPlacement(int placementId) throws JSONException {
507+
JSONObject placement = new JSONObject();
508+
placement.put("placementId", placementId);
509+
return placement;
510+
}
511+
518512
// ---------------------------------------------------------------------------------------
519513
// endregion
520514

0 commit comments

Comments
 (0)