Skip to content

Commit

Permalink
Add toJSONObject method to OSInAppMessage
Browse files Browse the repository at this point in the history
- Add this method for the wrappers to use
- `OSInAppMessageInternal` extends `OSInAppMessage` so its `toJSONObject` method must be `public` because we can't override to reduce visibility
  • Loading branch information
nan-li committed Nov 1, 2021
1 parent 2dd1948 commit 3c59786
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@

import androidx.annotation.NonNull;

import org.json.JSONException;
import org.json.JSONObject;

public class OSInAppMessage {

public static final String IAM_ID = "messageId";

/**
* The unique identifier for this in-app message
*/
Expand All @@ -46,4 +51,16 @@ public String getMessageId() {
return messageId;
}

public JSONObject toJSONObject() {
JSONObject mainObj = new JSONObject();
try {
mainObj.put(IAM_ID, messageId);
}
catch(JSONException e) {
e.printStackTrace();
}

return mainObj;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ protected ArrayList<ArrayList<OSTrigger>> parseTriggerJson(JSONArray triggersJso
return parsedTriggers;
}

JSONObject toJSONObject() {
@Override
public JSONObject toJSONObject() {
JSONObject json = new JSONObject();

try {
Expand Down

0 comments on commit 3c59786

Please sign in to comment.