package im.actor.core.api.updates;
/*
* Generated by the Actor API Scheme generator. DO NOT EDIT!
*/
import im.actor.runtime.bser.*;
import im.actor.runtime.collections.*;
import static im.actor.runtime.bser.Utils.*;
import im.actor.core.network.parser.*;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
import com.google.j2objc.annotations.ObjectiveCName;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import im.actor.core.api.*;
public class UpdateMessage extends Update {
public static final int HEADER = 0x37;
public static UpdateMessage fromBytes(byte[] data) throws IOException {
return Bser.parse(new UpdateMessage(), data);
}
private ApiPeer peer;
private int senderUid;
private long date;
private long rid;
private ApiMessage message;
private ApiMessageAttributes attributes;
private ApiQuotedMessage quotedMessage;
public UpdateMessage(@NotNull ApiPeer peer, int senderUid, long date, long rid, @NotNull ApiMessage message, @Nullable ApiMessageAttributes attributes, @Nullable ApiQuotedMessage quotedMessage) {
this.peer = peer;
this.senderUid = senderUid;
this.date = date;
this.rid = rid;
this.message = message;
this.attributes = attributes;
this.quotedMessage = quotedMessage;
}
public UpdateMessage() {
}
@NotNull
public ApiPeer getPeer() {
return this.peer;
}
public int getSenderUid() {
return this.senderUid;
}
public long getDate() {
return this.date;
}
public long getRid() {
return this.rid;
}
@NotNull
public ApiMessage getMessage() {
return this.message;
}
@Nullable
public ApiMessageAttributes getAttributes() {
return this.attributes;
}
@Nullable
public ApiQuotedMessage getQuotedMessage() {
return this.quotedMessage;
}
@Override
public void parse(BserValues values) throws IOException {
this.peer = values.getObj(1, new ApiPeer());
this.senderUid = values.getInt(2);
this.date = values.getLong(3);
this.rid = values.getLong(4);
this.message = ApiMessage.fromBytes(values.getBytes(5));
this.attributes = values.optObj(6, new ApiMessageAttributes());
this.quotedMessage = values.optObj(7, new ApiQuotedMessage());
}
@Override
public void serialize(BserWriter writer) throws IOException {
if (this.peer == null) {
throw new IOException();
}
writer.writeObject(1, this.peer);
writer.writeInt(2, this.senderUid);
writer.writeLong(3, this.date);
writer.writeLong(4, this.rid);
if (this.message == null) {
throw new IOException();
}
writer.writeBytes(5, this.message.buildContainer());
if (this.attributes != null) {
writer.writeObject(6, this.attributes);
}
if (this.quotedMessage != null) {
writer.writeObject(7, this.quotedMessage);
}
}
@Override
public String toString() {
String res = "update Message{";
res += "peer=" + this.peer;
res += ", senderUid=" + this.senderUid;
res += ", date=" + this.date;
res += ", rid=" + this.rid;
res += ", message=" + this.message;
res += ", attributes=" + this.attributes;
res += ", quotedMessage=" + this.quotedMessage;
res += "}";
return res;
}
@Override
public int getHeaderKey() {
return HEADER;
}
}