Search in sources :

Example 6 with JSONObject

use of im.actor.runtime.json.JSONObject in project actor-platform by actorapp.

the class LocationContent method create.

@NotNull
public static LocationContent create(double longitude, double latitude, @Nullable String street, @Nullable String place) {
    try {
        JSONObject obj = new JSONObject();
        obj.put("dataType", "location");
        JSONObject location = new JSONObject();
        location.put("latitude", latitude);
        location.put("longitude", longitude);
        if (street != null) {
            location.put("street", street);
        }
        if (place != null) {
            location.put("place", place);
        }
        JSONObject data = new JSONObject();
        data.put("location", location);
        obj.put("data", data);
        return new LocationContent(new ContentRemoteContainer(new ApiJsonMessage(obj.toString())));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : JSONObject(im.actor.runtime.json.JSONObject) ContentRemoteContainer(im.actor.core.entity.content.internal.ContentRemoteContainer) JSONException(im.actor.runtime.json.JSONException) ApiJsonMessage(im.actor.core.api.ApiJsonMessage) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JSONObject (im.actor.runtime.json.JSONObject)6 JSONException (im.actor.runtime.json.JSONException)4 ApiJsonMessage (im.actor.core.api.ApiJsonMessage)3 ContentRemoteContainer (im.actor.core.entity.content.internal.ContentRemoteContainer)3 NotNull (org.jetbrains.annotations.NotNull)2 ApiDocumentExAnimation (im.actor.core.api.ApiDocumentExAnimation)1 ApiDocumentExPhoto (im.actor.core.api.ApiDocumentExPhoto)1 ApiDocumentExVideo (im.actor.core.api.ApiDocumentExVideo)1 ApiDocumentExVoice (im.actor.core.api.ApiDocumentExVoice)1 ApiDocumentMessage (im.actor.core.api.ApiDocumentMessage)1 ApiMessage (im.actor.core.api.ApiMessage)1 ApiServiceEx (im.actor.core.api.ApiServiceEx)1 ApiServiceExChangedAbout (im.actor.core.api.ApiServiceExChangedAbout)1 ApiServiceExChangedAvatar (im.actor.core.api.ApiServiceExChangedAvatar)1 ApiServiceExChangedTitle (im.actor.core.api.ApiServiceExChangedTitle)1 ApiServiceExChangedTopic (im.actor.core.api.ApiServiceExChangedTopic)1 ApiServiceExContactRegistered (im.actor.core.api.ApiServiceExContactRegistered)1 ApiServiceExGroupCreated (im.actor.core.api.ApiServiceExGroupCreated)1 ApiServiceExPhoneCall (im.actor.core.api.ApiServiceExPhoneCall)1 ApiServiceExPhoneMissed (im.actor.core.api.ApiServiceExPhoneMissed)1