package com.iqser.red.service.persistence.management.v1.processor.model;

import java.util.HashMap;
import java.util.Map;

import com.iqser.red.service.persistence.management.v1.processor.utils.StorageIdUtils;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldDefaults;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class PyInfraRequest {

    Map<String, String> targetFilePath = new HashMap<>();
    String responseFilePath;
    String dossierUuid; // can't be called dossierId, as pyInfra gets confused
    String fileUuid; // can't be called fileId, as pyInfra gets confused


    public PyInfraRequest(String dossierUuid, String fileUuid) {

        this.dossierUuid = dossierUuid;
        this.fileUuid = fileUuid;
        this.targetFilePath = new HashMap<>();
    }


    public void addTargetFilePath(String key, FileType fileType) {

        targetFilePath.put(key, StorageIdUtils.getStorageId(dossierUuid, fileUuid, fileType) + ".gz");
    }

    public void addTargetFilePath(String key, String fileName, String fileExtension) {

        targetFilePath.put(key, StorageIdUtils.getStorageId(dossierUuid, fileUuid, fileName, fileExtension) + ".gz");
    }


    public void setResponseFilePath(FileType fileType) {

        responseFilePath = StorageIdUtils.getStorageId(dossierUuid, fileUuid, fileType) + ".gz";
    }

}
