import { BinaryWriter } from "../binary";
import { isSet } from "../helpers";
function createBaseAttachment() {
  return {
    name: "",
    size: BigInt(0),
    sha: "",
    uploader: ""
  };
}
export const Attachment = {
  typeUrl: "/gitopia.gitopia.gitopia.Attachment",
  encode(message, writer = BinaryWriter.create()) {
    if (message.name !== "") {
      writer.uint32(10).string(message.name);
    }
    if (message.size !== BigInt(0)) {
      writer.uint32(16).uint64(message.size);
    }
    if (message.sha !== "") {
      writer.uint32(26).string(message.sha);
    }
    if (message.uploader !== "") {
      writer.uint32(34).string(message.uploader);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      name: isSet(object.name) ? String(object.name) : "",
      size: isSet(object.size) ? BigInt(object.size.toString()) : BigInt(0),
      sha: isSet(object.sha) ? String(object.sha) : "",
      uploader: isSet(object.uploader) ? String(object.uploader) : ""
    };
  },
  fromPartial(object) {
    var _object$name, _object$sha, _object$uploader;
    const message = createBaseAttachment();
    message.name = (_object$name = object.name) !== null && _object$name !== void 0 ? _object$name : "";
    message.size = object.size !== undefined && object.size !== null ? BigInt(object.size.toString()) : BigInt(0);
    message.sha = (_object$sha = object.sha) !== null && _object$sha !== void 0 ? _object$sha : "";
    message.uploader = (_object$uploader = object.uploader) !== null && _object$uploader !== void 0 ? _object$uploader : "";
    return message;
  },
  fromAmino(object) {
    const message = createBaseAttachment();
    if (object.name !== undefined && object.name !== null) {
      message.name = object.name;
    }
    if (object.size !== undefined && object.size !== null) {
      message.size = BigInt(object.size);
    }
    if (object.sha !== undefined && object.sha !== null) {
      message.sha = object.sha;
    }
    if (object.uploader !== undefined && object.uploader !== null) {
      message.uploader = object.uploader;
    }
    return message;
  },
  toAmino(message) {
    const obj = {};
    obj.name = message.name === "" ? undefined : message.name;
    obj.size = message.size !== BigInt(0) ? message.size.toString() : undefined;
    obj.sha = message.sha === "" ? undefined : message.sha;
    obj.uploader = message.uploader === "" ? undefined : message.uploader;
    return obj;
  },
  fromAminoMsg(object) {
    return Attachment.fromAmino(object.value);
  },
  fromProtoMsg(message) {
    return Attachment.decode(message.value);
  },
  toProto(message) {
    return Attachment.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/gitopia.gitopia.gitopia.Attachment",
      value: Attachment.encode(message).finish()
    };
  }
};