package com.workfusion.odf.impl.connector;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.inject.Named;

import com.workfusion.odf.api.connector.TransactionSupplier;
import com.workfusion.odf.api.domain.Document;
import com.workfusion.odf.api.domain.Transaction;


public class DummyS3TransactionSupplier implements TransactionSupplier {
    private final Map<String, String> params;

    @Inject
    public DummyS3TransactionSupplier(@Named("botConfigParams") final Map<String, String> params) {
        this.params = params;
    }

    @Override
    public Collection<Transaction> get() {
        String[] links =  params.entrySet().stream().map(e->e.getValue()).collect(Collectors.toList()).toArray(new String[params.size()]) ;

        Transaction transaction = new Transaction();
        transaction.setId(UUID.randomUUID().toString());
        List<Document> docs = new ArrayList<>();

        for (int i = 0; i < links.length; i++) {
            Document doc1 = new Document();
            doc1.setId(UUID.randomUUID().toString());
            doc1.setOriginalDocumentLink(links[i]);
            docs.add(doc1);
        }

        transaction.setDocs(docs);


        List<Transaction> transactions = new ArrayList<>();
        transactions.add(transaction);

        return transactions;
    }
}
