|
4 | 4 | from bingads.v13.internal.bulk.entities.single_record_bulk_entity import _SingleRecordBulkEntity |
5 | 5 | from bingads.v13.internal.bulk.mappings import _SimpleBulkMapping, _ComplexBulkMapping |
6 | 6 | from bingads.v13.internal.extensions import * |
| 7 | +from decimal import Decimal |
7 | 8 |
|
8 | 9 | _DynamicFeedSetting = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('DynamicFeedSetting')) |
9 | 10 | _TargetSetting = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('TargetSetting')) |
|
12 | 13 | _DisclaimerSetting = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('DisclaimerSetting')) |
13 | 14 | _VerifiedTrackingSetting = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('VerifiedTrackingSetting')) |
14 | 15 | _PerformanceMaxSetting = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('PerformanceMaxSetting')) |
| 16 | +_NewCustomerAcquisitionGoalSetting = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('NewCustomerAcquisitionGoalSetting')) |
15 | 17 |
|
16 | 18 | class BulkCampaign(_SingleRecordBulkEntity): |
17 | 19 | """ Represents a campaign that can be read or written in a bulk file. |
@@ -167,6 +169,9 @@ def _get_verified_tracking_setting(self): |
167 | 169 | def _get_performance_max_setting(self): |
168 | 170 | return self._get_setting(_PerformanceMaxSetting, 'PerformanceMaxSetting') |
169 | 171 |
|
| 172 | + def _get_new_customer_acquisition_goal_setting(self): |
| 173 | + return self._get_setting(_NewCustomerAcquisitionGoalSetting, 'NewCustomerAcquisitionGoalSetting') |
| 174 | + |
170 | 175 | def _get_setting(self, setting_type, setting_name): |
171 | 176 | if not self.campaign.Settings.Setting: |
172 | 177 | return None |
@@ -205,6 +210,7 @@ def _read_campaign_type(c, v): |
205 | 210 | if campaign_type.lower() == 'performancemax': |
206 | 211 | BulkCampaign._create_campaign_setting(c.campaign, 'PerformanceMaxSetting') |
207 | 212 | BulkCampaign._create_campaign_setting(c.campaign, 'ShoppingSetting') |
| 213 | + BulkCampaign._create_campaign_setting(c.campaign, 'NewCustomerAcquisitionGoalSetting') |
208 | 214 |
|
209 | 215 | @staticmethod |
210 | 216 | def _create_campaign_setting(campaign, setting_type): |
@@ -521,6 +527,72 @@ def _write_image_opt_out(c): |
521 | 527 | return None |
522 | 528 | return bulk_str(performance_max_setting.AutoGeneratedImageOptOut) |
523 | 529 |
|
| 530 | + @staticmethod |
| 531 | + def _read_new_customer_acquisition_bid_only_mode(c, v): |
| 532 | + if not c.campaign.CampaignType: |
| 533 | + return None |
| 534 | + campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType] |
| 535 | + if 'performancemax' in campgaign_types: |
| 536 | + new_customer_acquisition_goal_setting = c._get_new_customer_acquisition_goal_setting() |
| 537 | + if not new_customer_acquisition_goal_setting: |
| 538 | + return None |
| 539 | + new_customer_acquisition_goal_setting.NewCustomerAcquisitionBidOnlyMode = parse_bool(v) |
| 540 | + |
| 541 | + @staticmethod |
| 542 | + def _write_new_customer_acquisition_bid_only_mode(c): |
| 543 | + if not c.campaign.CampaignType: |
| 544 | + return None |
| 545 | + campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType] |
| 546 | + if 'performancemax' in campgaign_types: |
| 547 | + new_customer_acquisition_goal_setting = c._get_new_customer_acquisition_goal_setting() |
| 548 | + if not new_customer_acquisition_goal_setting: |
| 549 | + return None |
| 550 | + return bulk_str(new_customer_acquisition_goal_setting.NewCustomerAcquisitionBidOnlyMode) |
| 551 | + |
| 552 | + @staticmethod |
| 553 | + def _read_new_customer_acquisition_goal_id(c, v): |
| 554 | + if not c.campaign.CampaignType: |
| 555 | + return None |
| 556 | + campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType] |
| 557 | + if 'performancemax' in campgaign_types: |
| 558 | + new_customer_acquisition_goal_setting = c._get_new_customer_acquisition_goal_setting() |
| 559 | + if not new_customer_acquisition_goal_setting: |
| 560 | + return None |
| 561 | + new_customer_acquisition_goal_setting.NewCustomerAcquisitionGoalId = int(v) if v else None |
| 562 | + |
| 563 | + @staticmethod |
| 564 | + def _write_new_customer_acquisition_goal_id(c): |
| 565 | + if not c.campaign.CampaignType: |
| 566 | + return None |
| 567 | + campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType] |
| 568 | + if 'performancemax' in campgaign_types: |
| 569 | + new_customer_acquisition_goal_setting = c._get_new_customer_acquisition_goal_setting() |
| 570 | + if not new_customer_acquisition_goal_setting: |
| 571 | + return None |
| 572 | + return bulk_str(new_customer_acquisition_goal_setting.NewCustomerAcquisitionGoalId) |
| 573 | + |
| 574 | + @staticmethod |
| 575 | + def _read_additional_conversion_value(c, v): |
| 576 | + if not c.campaign.CampaignType: |
| 577 | + return None |
| 578 | + campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType] |
| 579 | + if 'performancemax' in campgaign_types: |
| 580 | + new_customer_acquisition_goal_setting = c._get_new_customer_acquisition_goal_setting() |
| 581 | + if not new_customer_acquisition_goal_setting: |
| 582 | + return None |
| 583 | + new_customer_acquisition_goal_setting.AdditionalConversionValue = Decimal(v) if v else None |
| 584 | + |
| 585 | + @staticmethod |
| 586 | + def _write_additional_conversion_value(c): |
| 587 | + if not c.campaign.CampaignType: |
| 588 | + return None |
| 589 | + campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType] |
| 590 | + if 'performancemax' in campgaign_types: |
| 591 | + new_customer_acquisition_goal_setting = c._get_new_customer_acquisition_goal_setting() |
| 592 | + if not new_customer_acquisition_goal_setting: |
| 593 | + return None |
| 594 | + return bulk_str(new_customer_acquisition_goal_setting.AdditionalConversionValue) |
| 595 | + |
524 | 596 | @staticmethod |
525 | 597 | def _read_website(c, v): |
526 | 598 | if not c.campaign.CampaignType: |
@@ -756,6 +828,21 @@ def _write_website(c): |
756 | 828 | field_to_csv=lambda c: field_to_csv_bool(c.should_serve_on_msan), |
757 | 829 | csv_to_field=lambda c, v: setattr(c, 'should_serve_on_msan', parse_bool(v)) |
758 | 830 | ), |
| 831 | + _SimpleBulkMapping( |
| 832 | + header=_StringTable.NewCustomerAcquisitionGoalId, |
| 833 | + field_to_csv=lambda c: BulkCampaign._write_new_customer_acquisition_goal_id(c), |
| 834 | + csv_to_field=lambda c, v: BulkCampaign._read_new_customer_acquisition_goal_id(c, v) |
| 835 | + ), |
| 836 | + _SimpleBulkMapping( |
| 837 | + header=_StringTable.NewCustomerAcquisitionBidOnlyMode, |
| 838 | + field_to_csv=lambda c: BulkCampaign._write_new_customer_acquisition_bid_only_mode(c), |
| 839 | + csv_to_field=lambda c, v: BulkCampaign._read_new_customer_acquisition_bid_only_mode(c, v) |
| 840 | + ), |
| 841 | + _SimpleBulkMapping( |
| 842 | + header=_StringTable.AdditionalConversionValue, |
| 843 | + field_to_csv=lambda c: BulkCampaign._write_additional_conversion_value(c), |
| 844 | + csv_to_field=lambda c, v: BulkCampaign._read_additional_conversion_value(c, v) |
| 845 | + ), |
759 | 846 | ] |
760 | 847 |
|
761 | 848 | def read_additional_data(self, stream_reader): |
|
0 commit comments