package ru.yandex.autotests.directapi.model.api5.campaignsext;


import com.yandex.direct.api.v5.campaignsext.TextCampaignSearchStrategyAdd;
import com.yandex.direct.api.v5.campaignsext.TextCampaignSearchStrategyTypeEnum;

import ru.yandex.autotests.direct.utils.money.Currency;

/**
 * Created by pavryabov on 05.08.15.
 */
public class TextCampaignSearchStrategyAddMap extends TextCampaignStrategyAddBaseMap<TextCampaignSearchStrategyAddMap> {

    public static final String BIDDING_STRATEGY_TYPE = "biddingStrategyType";

    public TextCampaignSearchStrategyAddMap() {
        super();
        setBean(new TextCampaignSearchStrategyAdd());
    }

    public TextCampaignSearchStrategyAddMap(TextCampaignSearchStrategyAdd textCampaignSearchStrategy) {
        super();
        setBean(textCampaignSearchStrategy);
    }

    public TextCampaignSearchStrategyAddMap put(String fieldName, Object value) {
        super.put(fieldName, value);
        return this;
    }

    public TextCampaignSearchStrategyAddMap withBiddingStrategyType(
            TextCampaignSearchStrategyTypeEnum biddingStrategyType)
    {
        this.put(BIDDING_STRATEGY_TYPE, biddingStrategyType);
        return this;
    }

    public TextCampaignSearchStrategyAddMap defaultServingOff() {
        return this.withBiddingStrategyType(TextCampaignSearchStrategyTypeEnum.SERVING_OFF);
    }

    public TextCampaignSearchStrategyAddMap defaultHighestPosition() {
        return this.withBiddingStrategyType(TextCampaignSearchStrategyTypeEnum.HIGHEST_POSITION);
    }

    public TextCampaignSearchStrategyAddMap defaultWbMaximumClicks(Currency currency) {
        return this.withBiddingStrategyType(TextCampaignSearchStrategyTypeEnum.WB_MAXIMUM_CLICKS)
                .withWbMaximumClicks(new StrategyMaximumClicksAddMap()
                        .defaultStrategyMaximumClicks(currency));
    }

    public TextCampaignSearchStrategyAddMap defaultWbMaximumConversionRate(Currency currency, Long goalId) {
        return this.withBiddingStrategyType(TextCampaignSearchStrategyTypeEnum.WB_MAXIMUM_CONVERSION_RATE)
                .withWbMaximumConversionRate(new StrategyMaximumConversionRateAddMap()
                        .defaultMaximumConversionRateParams(currency)
                        .withGoalId(goalId));
    }

    public TextCampaignSearchStrategyAddMap defaultAverageCpc(Currency currency) {
        return this.withBiddingStrategyType(TextCampaignSearchStrategyTypeEnum.AVERAGE_CPC)
                .withAverageCpc(new StrategyAverageCpcAddMap()
                        .defaultStrategyAverageCpc(currency));
    }

    public TextCampaignSearchStrategyAddMap defaultAverageCpa(Currency currency, Long goalId) {
        return this.withBiddingStrategyType(TextCampaignSearchStrategyTypeEnum.AVERAGE_CPA)
                .withAverageCpa(new StrategyAverageCpaAddMap()
                        .defaultStrategyAverageCpa(currency)
                        .withGoalId(goalId));
    }

    public TextCampaignSearchStrategyAddMap defaultAverageRoi(Long goalId) {
        return this.withBiddingStrategyType(TextCampaignSearchStrategyTypeEnum.AVERAGE_ROI)
                .withAverageRoi(new StrategyAverageRoiAddMap()
                        .defaultStrategyAverageRoi()
                        .withGoalId(goalId));
    }
}
