package pro.beam.api.resource.chat.events.data;

import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.Iterators;
import com.google.gson.annotations.SerializedName;
import pro.beam.api.resource.chat.AbstractChatEvent;

import java.util.List;

public class IncomingMessageData extends AbstractChatEvent.EventData {
    public int channel;
    public String id;
    public String user_name;
    public String user_id;
    public String user_role;
    public List<MessagePart> message;

    public String getMessage() {
        return Joiner.on(' ').join(Iterators.transform(this.message.iterator(), new Function<MessagePart, String>() {
            @Override public String apply(MessagePart part) {
                return part.type == MessagePart.Type.TEXT ? part.data : part.path;
            }
        }));
    }

    public static class MessagePart {
        public Type type;
        public String data;
        public String path;

        public static enum Type {
            @SerializedName("text") TEXT,
            @SerializedName("emoticon") EMOTICON;
        }
    }
}

@@ -820,20 +820,18 @@
 data
- 
 : part.
-path
+url
 ;%0A  
@@ -926,16 +926,43 @@
 e type;%0A
+        public String url;%0A
         
@@ -1134,16 +1134,58 @@
 EMOTICON
+,%0A            @SerializedName(%22link%22) LINK
 ;%0A      

Support parsing of links on the IncomingMessageData class