import {JsonObject, JsonProperty} from "json2typescript";

import {Attachment} from "../../../entity/attachment";

@JsonObject('AttachmentSerialized')
export class AttachmentSerialized {

  @JsonProperty('id', Number)
  id: number;

  @JsonProperty('type', String)
  type: string;

  @JsonProperty('size', Number)
  size: number;

  @JsonProperty('url', String)
  url: string;

  @JsonProperty('isLocal', Boolean)
  isLocal: boolean;

  public static createFromObj(attachment: Attachment): AttachmentSerialized {
    const inst = new AttachmentSerialized();
    inst.id = attachment.id;
    inst.type = attachment.type;
    inst.size = attachment.size;
    inst.url = attachment.url;
    inst.isLocal = attachment.isLocal;
    return inst;
  }

}
