|
| 1 | +from bingads.v13.internal.bulk.mappings import _SimpleBulkMapping |
| 2 | +from bingads.v13.internal.bulk.string_table import _StringTable |
| 3 | +from bingads.service_client import _CAMPAIGN_OBJECT_FACTORY_V13 |
| 4 | + |
| 5 | +from .common import _BulkAdExtensionBase |
| 6 | +from .common import _BulkAdGroupAdExtensionAssociation |
| 7 | +from .common import _BulkCampaignAdExtensionAssociation |
| 8 | +from .common import _BulkAccountAdExtensionAssociation |
| 9 | + |
| 10 | +from bingads.v13.internal.extensions import * |
| 11 | + |
| 12 | + |
| 13 | +_DisclaimerAdExtension = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('DisclaimerAdExtension')) |
| 14 | + |
| 15 | + |
| 16 | +class BulkDisclaimerAdExtension(_BulkAdExtensionBase): |
| 17 | + """ Represents a disclaimer ad extension. |
| 18 | +
|
| 19 | + This class exposes the :attr:`disclaimer_ad_extension` property that can be read and written |
| 20 | + as fields of the Disclaimer Ad Extension record in a bulk file. |
| 21 | +
|
| 22 | + For more information, see Disclaimer Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127. |
| 23 | +
|
| 24 | + *See also:* |
| 25 | +
|
| 26 | + * :class:`.BulkServiceManager` |
| 27 | + * :class:`.BulkOperation` |
| 28 | + * :class:`.BulkFileReader` |
| 29 | + * :class:`.BulkFileWriter` |
| 30 | + """ |
| 31 | + |
| 32 | + def __init__(self, account_id=None, ad_extension=None): |
| 33 | + if ad_extension and not isinstance(ad_extension, _DisclaimerAdExtension): |
| 34 | + raise ValueError('The type of ad_extension is: {0}, should be: {1}'.format( |
| 35 | + type(ad_extension), |
| 36 | + 'DisclaimerAdExtension' |
| 37 | + )) |
| 38 | + super(BulkDisclaimerAdExtension, self).__init__( |
| 39 | + account_id=account_id, |
| 40 | + ad_extension=ad_extension |
| 41 | + ) |
| 42 | + |
| 43 | + @property |
| 44 | + def disclaimer_ad_extension(self): |
| 45 | + """ The disclaimer ad extension. |
| 46 | +
|
| 47 | + see Disclaimer Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127. |
| 48 | + """ |
| 49 | + |
| 50 | + return self._ad_extension |
| 51 | + |
| 52 | + @disclaimer_ad_extension.setter |
| 53 | + def disclaimer_ad_extension(self, value): |
| 54 | + self._ad_extension = value |
| 55 | + |
| 56 | + _MAPPINGS = [ |
| 57 | + _SimpleBulkMapping( |
| 58 | + header=_StringTable.DisclaimerName, |
| 59 | + field_to_csv=lambda c: bulk_str(c.disclaimer_ad_extension.Name), |
| 60 | + csv_to_field=lambda c, v: setattr(c.disclaimer_ad_extension, 'Name', v) |
| 61 | + ), |
| 62 | + _SimpleBulkMapping( |
| 63 | + header=_StringTable.DisclaimerTitle, |
| 64 | + field_to_csv=lambda c: bulk_str(c.disclaimer_ad_extension.Title), |
| 65 | + csv_to_field=lambda c, v: setattr(c.disclaimer_ad_extension, 'Title', v) |
| 66 | + ), |
| 67 | + _SimpleBulkMapping( |
| 68 | + header=_StringTable.DisclaimerPopupText, |
| 69 | + field_to_csv=lambda c: bulk_str(c.disclaimer_ad_extension.PopupText), |
| 70 | + csv_to_field=lambda c, v: setattr(c.disclaimer_ad_extension, 'PopupText', v) |
| 71 | + ), |
| 72 | + _SimpleBulkMapping( |
| 73 | + header=_StringTable.DisclaimerLineText, |
| 74 | + field_to_csv=lambda c: bulk_str(c.disclaimer_ad_extension.LineText), |
| 75 | + csv_to_field=lambda c, v: setattr(c.disclaimer_ad_extension, 'LineText', v) |
| 76 | + ), |
| 77 | + _SimpleBulkMapping( |
| 78 | + header=_StringTable.DisclaimerLayout, |
| 79 | + field_to_csv=lambda c: bulk_str(c.disclaimer_ad_extension.DisclaimerLayout), |
| 80 | + csv_to_field=lambda c, v: setattr(c.disclaimer_ad_extension, 'DisclaimerLayout', v) |
| 81 | + ), |
| 82 | + _SimpleBulkMapping( |
| 83 | + header=_StringTable.FinalUrl, |
| 84 | + field_to_csv=lambda c: field_to_csv_Urls(c.disclaimer_ad_extension.FinalUrls, c.disclaimer_ad_extension.Id), |
| 85 | + csv_to_field=lambda c, v: csv_to_field_Urls(c.disclaimer_ad_extension.FinalUrls, v) |
| 86 | + ), |
| 87 | + _SimpleBulkMapping( |
| 88 | + header=_StringTable.FinalMobileUrl, |
| 89 | + field_to_csv=lambda c: field_to_csv_Urls(c.disclaimer_ad_extension.FinalMobileUrls, c.disclaimer_ad_extension.Id), |
| 90 | + csv_to_field=lambda c, v: csv_to_field_Urls(c.disclaimer_ad_extension.FinalMobileUrls, v) |
| 91 | + ), |
| 92 | + _SimpleBulkMapping( |
| 93 | + header=_StringTable.TrackingTemplate, |
| 94 | + field_to_csv=lambda c: bulk_optional_str(c.disclaimer_ad_extension.TrackingUrlTemplate, c.disclaimer_ad_extension.Id), |
| 95 | + csv_to_field=lambda c, v: setattr(c.disclaimer_ad_extension, 'TrackingUrlTemplate', v if v else '') |
| 96 | + ), |
| 97 | + _SimpleBulkMapping( |
| 98 | + header=_StringTable.CustomParameter, |
| 99 | + field_to_csv=lambda c: field_to_csv_UrlCustomParameters(c.disclaimer_ad_extension), |
| 100 | + csv_to_field=lambda c, v: csv_to_field_UrlCustomParameters(c.disclaimer_ad_extension, v) |
| 101 | + ), |
| 102 | + _SimpleBulkMapping( |
| 103 | + header=_StringTable.FinalUrlSuffix, |
| 104 | + field_to_csv=lambda c: bulk_optional_str(c.disclaimer_ad_extension.FinalUrlSuffix, c.disclaimer_ad_extension.Id), |
| 105 | + csv_to_field=lambda c, v: setattr(c.disclaimer_ad_extension, 'FinalUrlSuffix', v) |
| 106 | + ) |
| 107 | + ] |
| 108 | + |
| 109 | + def process_mappings_from_row_values(self, row_values): |
| 110 | + self.disclaimer_ad_extension = _CAMPAIGN_OBJECT_FACTORY_V13.create('DisclaimerAdExtension') |
| 111 | + self.disclaimer_ad_extension.Type = 'DisclaimerAdExtension' |
| 112 | + super(BulkDisclaimerAdExtension, self).process_mappings_from_row_values(row_values) |
| 113 | + row_values.convert_to_entity(self, BulkDisclaimerAdExtension._MAPPINGS) |
| 114 | + |
| 115 | + def process_mappings_to_row_values(self, row_values, exclude_readonly_data): |
| 116 | + self._validate_property_not_null(self.disclaimer_ad_extension, 'disclaimer_ad_extension') |
| 117 | + super(BulkDisclaimerAdExtension, self).process_mappings_to_row_values(row_values, exclude_readonly_data) |
| 118 | + self.convert_to_values(row_values, BulkDisclaimerAdExtension._MAPPINGS) |
| 119 | + |
| 120 | +class BulkCampaignDisclaimerAdExtension(_BulkCampaignAdExtensionAssociation): |
| 121 | + """ Represents a campaign level disclaimer ad extension. |
| 122 | +
|
| 123 | + This class exposes properties that can be read and written |
| 124 | + as fields of the Campaign Disclaimer Ad Extension record in a bulk file. |
| 125 | +
|
| 126 | + For more information, see Campaign Disclaimer Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127. |
| 127 | +
|
| 128 | + *See also:* |
| 129 | +
|
| 130 | + * :class:`.BulkServiceManager` |
| 131 | + * :class:`.BulkOperation` |
| 132 | + * :class:`.BulkFileReader` |
| 133 | + * :class:`.BulkFileWriter` |
| 134 | + """ |
| 135 | + |
| 136 | + pass |
0 commit comments