use of im.actor.runtime.json.JSONArray in project actor-platform by actorapp.
the class ContactContent method create.
@NotNull
public static ContactContent create(@NotNull String name, @NotNull ArrayList<String> phones, @NotNull ArrayList<String> emails, @Nullable String base64photo) {
try {
JSONObject obj = new JSONObject();
obj.put("dataType", "contact");
JSONObject contact = new JSONObject();
contact.put("name", name);
if (base64photo != null) {
contact.put("photo", base64photo);
}
JSONArray phoneArray = new JSONArray();
for (String phone : phones) {
phoneArray.put(phone);
}
JSONArray emailArray = new JSONArray();
for (String phone : emails) {
emailArray.put(phone);
}
contact.put("emails", emailArray);
contact.put("phones", phoneArray);
JSONObject data = new JSONObject();
data.put("contact", contact);
obj.put("data", data);
return new ContactContent(new ContentRemoteContainer(new ApiJsonMessage(obj.toString())));
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
Aggregations