private static void BiddingSchemeToCsv(BulkCampaign c, RowValues values) { var biddingScheme = c.Campaign.BiddingScheme; if (biddingScheme == null) { return; } values[StringTable.BidStrategyType] = biddingScheme.ToBiddingSchemeBulkString(); var maxClicksBiddingScheme = biddingScheme as MaxClicksBiddingScheme; if (maxClicksBiddingScheme != null) { values[StringTable.BidStrategyMaxCpc] = maxClicksBiddingScheme.MaxCpc.ToBidBulkString(c.Campaign.Id); } else { var maxConversionsBiddingScheme = c.Campaign.BiddingScheme as MaxConversionsBiddingScheme; if (maxConversionsBiddingScheme != null) { values[StringTable.BidStrategyMaxCpc] = maxConversionsBiddingScheme.MaxCpc.ToBidBulkString(c.Campaign.Id); } else { var targetCpaBiddingScheme = c.Campaign.BiddingScheme as TargetCpaBiddingScheme; if (targetCpaBiddingScheme != null) { values[StringTable.BidStrategyMaxCpc] = targetCpaBiddingScheme.MaxCpc.ToBidBulkString(c.Campaign.Id); values[StringTable.BidStrategyTargetCpa] = targetCpaBiddingScheme.TargetCpa.ToBulkString(); } } } }
private static void CsvToBiddingScheme(RowValues values, BulkCampaign c) { string bidStrategyTypeRowValue; BiddingScheme biddingScheme; if (!values.TryGetValue(StringTable.BidStrategyType, out bidStrategyTypeRowValue) || (biddingScheme = bidStrategyTypeRowValue.ParseBiddingScheme()) == null) { return; } string maxCpcRowValue; string targetCpaRowValue; values.TryGetValue(StringTable.BidStrategyMaxCpc, out maxCpcRowValue); values.TryGetValue(StringTable.BidStrategyTargetCpa, out targetCpaRowValue); var maxCpcValue = maxCpcRowValue.ParseBid(); var targetCpaValue = targetCpaRowValue.ParseOptional <double>(); var maxClicksBiddingScheme = biddingScheme as MaxClicksBiddingScheme; if (maxClicksBiddingScheme != null) { c.Campaign.BiddingScheme = new MaxClicksBiddingScheme { MaxCpc = maxCpcValue, Type = "MaxClicks", }; } else { var maxConversionsBiddingScheme = biddingScheme as MaxConversionsBiddingScheme; if (maxConversionsBiddingScheme != null) { c.Campaign.BiddingScheme = new MaxConversionsBiddingScheme { MaxCpc = maxCpcValue, Type = "MaxConversions", }; } else { var targetCpaBiddingScheme = biddingScheme as TargetCpaBiddingScheme; if (targetCpaBiddingScheme != null) { c.Campaign.BiddingScheme = new TargetCpaBiddingScheme { MaxCpc = maxCpcValue, TargetCpa = targetCpaValue, Type = "TargetCpa", }; } else { c.Campaign.BiddingScheme = biddingScheme; } } } }
private static void CsvToBudget(RowValues values, BulkCampaign c) { string budgetTypeRowValue; BudgetLimitType?budgetType; if (!values.TryGetValue(StringTable.BudgetType, out budgetTypeRowValue) || (budgetType = budgetTypeRowValue.ParseOptional <BudgetLimitType>()) == null) { return; } string budgetRowValue; if (!values.TryGetValue(StringTable.Budget, out budgetRowValue)) { return; } var budgetValue = budgetRowValue.ParseOptional <double>(); c.Campaign.BudgetType = budgetType; if (budgetType == BudgetLimitType.DailyBudgetAccelerated || budgetType == BudgetLimitType.DailyBudgetStandard) { c.Campaign.DailyBudget = budgetValue; } }
private static void BudgetToCsv(BulkCampaign c, RowValues values) { var budgetType = c.Campaign.BudgetType; if (budgetType == null) { return; } values[StringTable.Budget] = c.Campaign.DailyBudget.ToBulkString(); }
private static void BiddingSchemeToCsv(BulkCampaign c, RowValues values) { var biddingScheme = c.Campaign.BiddingScheme; if (biddingScheme == null) { return; } values[StringTable.BidStrategyType] = biddingScheme.ToBiddingSchemeBulkString(); switch (biddingScheme) { case MaxClicksBiddingScheme maxClicksBiddingScheme: values[StringTable.BidStrategyMaxCpc] = maxClicksBiddingScheme.MaxCpc.ToBidBulkString(c.Campaign.Id); break; case MaxConversionsBiddingScheme maxConversionsBiddingScheme: values[StringTable.BidStrategyMaxCpc] = maxConversionsBiddingScheme.MaxCpc.ToBidBulkString(c.Campaign.Id); break; case MaxConversionValueBiddingScheme maxConversionValueBiddingScheme: values[StringTable.BidStrategyTargetRoas] = maxConversionValueBiddingScheme.TargetRoas.ToBulkString(); break; case TargetCpaBiddingScheme targetCpaBiddingScheme: values[StringTable.BidStrategyMaxCpc] = targetCpaBiddingScheme.MaxCpc.ToBidBulkString(c.Campaign.Id); values[StringTable.BidStrategyTargetCpa] = targetCpaBiddingScheme.TargetCpa.ToBulkString(); break; case TargetRoasBiddingScheme targetRoasBiddingScheme: values[StringTable.BidStrategyMaxCpc] = targetRoasBiddingScheme.MaxCpc.ToBidBulkString(c.Campaign.Id); values[StringTable.BidStrategyTargetRoas] = targetRoasBiddingScheme.TargetRoas.ToBulkString(); break; case TargetImpressionShareBiddingScheme targetImpressionShareBiddingScheme: values[StringTable.BidStrategyMaxCpc] = targetImpressionShareBiddingScheme.MaxCpc.ToBidBulkString(c.Campaign.Id); values[StringTable.BidStrategyTargetAdPosition] = targetImpressionShareBiddingScheme.TargetAdPosition.ToOptionalBulkString(c.Campaign.Id); values[StringTable.BidStrategyTargetImpressionShare] = targetImpressionShareBiddingScheme.TargetImpressionShare.ToBulkString(); break; default: break; } }
private static void CsvToBiddingScheme(RowValues values, BulkCampaign c) { string bidStrategyTypeRowValue; BiddingScheme biddingScheme; if (!values.TryGetValue(StringTable.BidStrategyType, out bidStrategyTypeRowValue) || (biddingScheme = bidStrategyTypeRowValue.ParseBiddingScheme()) == null) { return; } string maxCpcRowValue; string targetCpaRowValue; string targetRoasRowValue; string targetAdPositionRowValue; string targetImpressionShareRowValue; values.TryGetValue(StringTable.BidStrategyMaxCpc, out maxCpcRowValue); values.TryGetValue(StringTable.BidStrategyTargetCpa, out targetCpaRowValue); values.TryGetValue(StringTable.BidStrategyTargetRoas, out targetRoasRowValue); values.TryGetValue(StringTable.BidStrategyTargetAdPosition, out targetAdPositionRowValue); values.TryGetValue(StringTable.BidStrategyTargetImpressionShare, out targetImpressionShareRowValue); var maxCpcValue = maxCpcRowValue.ParseBid(); var targetCpaValue = targetCpaRowValue.ParseOptional <double>(); var targetRoasValue = targetRoasRowValue.ParseOptional <double>(); var targetAdPositionValue = targetAdPositionRowValue; var targetImpressionShareValue = targetImpressionShareRowValue.ParseOptional <double>(); switch (biddingScheme) { case MaxClicksBiddingScheme maxClicksBiddingScheme: c.Campaign.BiddingScheme = new MaxClicksBiddingScheme { MaxCpc = maxCpcValue, Type = "MaxClicks", }; break; case MaxConversionsBiddingScheme maxConversionsBiddingScheme: c.Campaign.BiddingScheme = new MaxConversionsBiddingScheme { MaxCpc = maxCpcValue, Type = "MaxConversions", }; break; case MaxConversionValueBiddingScheme maxConversionValueBiddingScheme: c.Campaign.BiddingScheme = new MaxConversionValueBiddingScheme { TargetRoas = targetRoasValue, Type = "MaxConversionValue", }; break; case TargetCpaBiddingScheme targetCpaBiddingScheme: c.Campaign.BiddingScheme = new TargetCpaBiddingScheme { MaxCpc = maxCpcValue, TargetCpa = targetCpaValue, Type = "TargetCpa", }; break; case TargetRoasBiddingScheme targetRoasBiddingScheme: c.Campaign.BiddingScheme = new TargetRoasBiddingScheme { MaxCpc = maxCpcValue, TargetRoas = targetRoasValue, Type = "TargetRoas", }; break; case TargetImpressionShareBiddingScheme targetImpressionShareBiddingScheme: c.Campaign.BiddingScheme = new TargetImpressionShareBiddingScheme { MaxCpc = maxCpcValue, TargetAdPosition = targetAdPositionValue, TargetImpressionShare = targetImpressionShareValue, Type = "TargetImpressionShare", }; break; default: c.Campaign.BiddingScheme = biddingScheme; break; } }