package com.workfusion.odf.core;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import groovy.lang.Binding;

public class IntakeBuilder {
    private Binding context;
    private Map<String, String> params = new HashMap<>();
    private List<Module> overrideModules;
    private Object injectContext;

    public IntakeBuilder(Binding context) {
        this.context = context;
    }

    public IntakeBuilder params(Map<String, String> params) {
        this.params = params;
        return this;
    }

    public IntakeBuilder override(Module... modules) {
        overrideModules = Arrays.asList(modules);
        return this;
    }

    public IntakeBuilder injectFields(Object context) {
        this.injectContext = context;
        return this;
    }

    public Intake get() {
        Module intakeModule = new IntakeModule(params);
        Module shareFolderModule = new ShareFolderModule();
        Module mailModule = new MailModule();
        List<Module> intakeModules = Arrays.asList(
                intakeModule,
                shareFolderModule,
                mailModule
        );
        return new Intake(context, params, intakeModules, overrideModules, injectContext);
    }
}
