package com.friday.tooldriver.dto.uipath.response;

import com.alibaba.fastjson.annotation.JSONField;
import com.friday.operation.api.tooldriver.dto.rpa.CodePackageDto;
import com.friday.tooldriver.dto.uipath.request.ArgumentMetadata;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ProcessResponseDto implements Serializable {
    @JSONField(name = "IsActive")
    private boolean active;
    @JSONField(name = "Arguments")
    private ArgumentMetadata arguments;
    @JSONField(name = "Title")
    private String title;
    @JSONField(name = "Version")
    private String version;
    @JSONField(name = "VersionId")
    private Integer versionId;
    @JSONField(name = "Key")
    private String key;
    @JSONField(name = "Description")
    private String description;
    @JSONField(name = "Published")
    private String published;
    @JSONField(name = "IsLatestVersion")
    private boolean latestVersion;
    @JSONField(name = "OldVersion")
    private String oldVersion;
    @JSONField(name = "ReleaseNotes")
    private String releaseNotes;
    @JSONField(name = "Authors")
    private String authors;
    @JSONField(name = "Id")
    private String id;

    public CodePackageDto transToCodePackage(){
        return CodePackageDto.builder()
                .name(this.getId())
                .version(this.getVersion())
                .key(String.join(":", this.getId(), this.getVersion()))
                .build();
    }
}