package meerkat.bulletinboard.service;

import com.google.protobuf.ByteString;
import com.google.protobuf.Message;
import meerkat.protobuf.Crypto;
import meerkat.protobuf.BulletinBoardApi.*;

import java.util.Arrays;
import java.util.List;

/**
 * Created by talm on 10/11/15.
 */
public class HelloProtoBuf {
    public Message sayHello() {
        BulletinBoardMessage.Builder msg = BulletinBoardMessage.newBuilder();

        UnsignedBulletinBoardMessage.Builder unsigned = UnsignedBulletinBoardMessage.newBuilder();
        unsigned.setData(ByteString.copyFromUtf8("Hello World!"));
        List<String> tags = Arrays.asList("Greetings", "FirstPrograms");
        unsigned.addAllTag(tags);
        msg.setMsg(unsigned);

        Crypto.Signature.Builder sig = Crypto.Signature.newBuilder();
        sig.setData(ByteString.copyFromUtf8("deadbeef"));
        msg.addSig(sig);

        return msg.build();
    }
}
