package cz.moneta.test.dsl.ilods;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.endpoints.ilodsserver.IlodsServerEndpoint;
import itSodTesting.sharedResources.objects.ilods.enumerations.IlApplTp;
import itSodTesting.sharedResources.objects.ilods.enumerations.IlBusProdClass;
import itSodTesting.sharedResources.objects.ilods.enumerations.IlSubType;
import itSodTesting.sharedResources.objects.ilods.enumerations.IlType;

public class Ilods {

    private final Harness harness;
    private IlodsServerEndpoint ilodsEndpoint;

    public Ilods(Harness harness) {
        this.harness = harness;
        this.ilodsEndpoint = harness.getEndpoint(IlodsServerEndpoint.class);
    }

    /**
     * Method for test Ilods server connection
     *
     * @return "OK" when everything is ok, Exception when everything else
     */
    public String sendTestRequest() {
        return ilodsEndpoint.sendTestRequest();
    }

    /**
     * Setting scorecard for entered client
     *
     * @param scoreCardId ID of required score card
     * @param rc          Client birth number
     * @param ico         Client IČ
     */
    public void setScore(String scoreCardId, String rc, String ico) {
        ilodsEndpoint.setScore(scoreCardId, rc, ico);
    }

    /**
     * Setting turnovers for entered client
     *
     * @param accNum         Account number
     * @param cif            Client CIF number
     * @param turnoversValue Value of turnovers (same for every month)
     * @return error code where 0 is OK, everything else means error
     */
    public String setTurnovers(String accNum, String cif, int turnoversValue) {
        return ilodsEndpoint.setTurnovers(accNum, cif, turnoversValue);
    }

    /**
     * Setting turnovers for entered client
     *
     * @param accNum          Account number
     * @param cif             Client CIF number
     * @param turnoversValues Array with values for 12 months
     *                        (ex.: new int[]{1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000})
     * @return error code where 0 is OK, everything else means error
     */
    public String setTurnovers(String accNum, String cif, int[] turnoversValues) {
        return ilodsEndpoint.setTurnovers(accNum, cif, turnoversValues);
    }

    /**
     * Setting infolimit for entered client
     *
     * @param busProdClass Product (choose from IlBusProdClass enum)
     * @param ilType       Infolimit Type (choose from IlType enum)
     * @param ilAmount     Infolimit Amount
     * @param applTpCode   ApplTp (choose from IlApplTp enum)
     * @param rcNum        Client birth number
     * @param icoNum       Client IČ
     * @return error code where 0 is OK, everything else means error
     */
    public String setInfolimit(IlBusProdClass busProdClass, IlType ilType, IlSubType ilSubType, double ilAmount, IlApplTp applTpCode, String rcNum, String icoNum) {
        return ilodsEndpoint.setInfolimit(busProdClass, ilType, ilSubType, ilAmount, applTpCode, rcNum, icoNum);
    }

    /**
     * Setting segment for entered client
     *
     * @param segmentCode      Segment type
     * @param segmentationCode Segmentation type
     * @param rcNum            Client birth number
     * @param icoNum           Client IČ
     */
    public String setSegment(String segmentCode, String segmentationCode, String rcNum, String icoNum) {
        return ilodsEndpoint.setSegment(segmentCode, segmentationCode, rcNum, icoNum);
    }
}
