|
| 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 bingads.v13.internal.extensions import * |
| 6 | +from .common import _BulkAdExtensionBase |
| 7 | +from .common import _BulkCampaignAdExtensionAssociation |
| 8 | +from .common import _BulkAdGroupAdExtensionAssociation |
| 9 | +from .common import _BulkAccountAdExtensionAssociation |
| 10 | + |
| 11 | +_VideoAdExtension = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('VideoAdExtension')) |
| 12 | + |
| 13 | + |
| 14 | +class BulkVideoAdExtension(_BulkAdExtensionBase): |
| 15 | + """ Represents a video ad extension. |
| 16 | +
|
| 17 | + This class exposes the :attr:`video_ad_extension` property that can be read and written |
| 18 | + as fields of the Video Ad Extension record in a bulk file. |
| 19 | +
|
| 20 | + For more information, see Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127. |
| 21 | +
|
| 22 | + *See also:* |
| 23 | +
|
| 24 | + * :class:`.BulkServiceManager` |
| 25 | + * :class:`.BulkOperation` |
| 26 | + * :class:`.BulkFileReader` |
| 27 | + * :class:`.BulkFileWriter` |
| 28 | + """ |
| 29 | + |
| 30 | + def __init__(self, account_id=None, ad_extension=None): |
| 31 | + if ad_extension and not isinstance(ad_extension, _VideoAdExtension): |
| 32 | + raise ValueError('The type of ad_extension is: {0}, should be: {1}'.format( |
| 33 | + type(ad_extension), |
| 34 | + 'VideoAdExtension' |
| 35 | + )) |
| 36 | + super(BulkVideoAdExtension, self).__init__( |
| 37 | + account_id=account_id, |
| 38 | + ad_extension=ad_extension |
| 39 | + ) |
| 40 | + |
| 41 | + @property |
| 42 | + def video_ad_extension(self): |
| 43 | + """ The video ad extension. |
| 44 | +
|
| 45 | + see Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127. |
| 46 | + """ |
| 47 | + |
| 48 | + return self._ad_extension |
| 49 | + |
| 50 | + @video_ad_extension.setter |
| 51 | + def video_ad_extension(self, value): |
| 52 | + self._ad_extension = value |
| 53 | + |
| 54 | + _MAPPINGS = [ |
| 55 | + _SimpleBulkMapping( |
| 56 | + header=_StringTable.Name, |
| 57 | + field_to_csv=lambda c: bulk_optional_str(c.video_ad_extension.Name, c.video_ad_extension.Id), |
| 58 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'Name', v if v else '') |
| 59 | + ), |
| 60 | + _SimpleBulkMapping( |
| 61 | + header=_StringTable.DisplayText, |
| 62 | + field_to_csv=lambda c: bulk_optional_str(c.video_ad_extension.DisplayText, c.video_ad_extension.Id), |
| 63 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'DisplayText', v if v else '') |
| 64 | + ), |
| 65 | + _SimpleBulkMapping( |
| 66 | + header=_StringTable.AltText, |
| 67 | + field_to_csv=lambda c: bulk_str(c.video_ad_extension.AlternativeText), |
| 68 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'AlternativeText', v) |
| 69 | + ), |
| 70 | + _SimpleBulkMapping( |
| 71 | + header=_StringTable.ActionText, |
| 72 | + field_to_csv=lambda c: bulk_optional_str(c.video_ad_extension.ActionText, c.video_ad_extension.Id), |
| 73 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'ActionText', v if v else '') |
| 74 | + ), |
| 75 | + _SimpleBulkMapping( |
| 76 | + header=_StringTable.ThumbnailUrl, |
| 77 | + field_to_csv=lambda c: bulk_str(c.video_ad_extension.ThumbnailUrl), |
| 78 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'ThumbnailUrl', v) |
| 79 | + ), |
| 80 | + _SimpleBulkMapping( |
| 81 | + header=_StringTable.ThumbnailId, |
| 82 | + field_to_csv=lambda c: bulk_str(c.video_ad_extension.ThumbnailId), |
| 83 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'ThumbnailId', int(v) if v else None) |
| 84 | + ), |
| 85 | + _SimpleBulkMapping( |
| 86 | + header=_StringTable.VideoId, |
| 87 | + field_to_csv=lambda c: bulk_str(c.video_ad_extension.VideoId), |
| 88 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'VideoId', int(v) if v else None) |
| 89 | + ), |
| 90 | + _SimpleBulkMapping( |
| 91 | + header=_StringTable.FinalUrlSuffix, |
| 92 | + field_to_csv=lambda c: bulk_optional_str(c.video_ad_extension.FinalUrlSuffix, c.video_ad_extension.Id), |
| 93 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'FinalUrlSuffix', v) |
| 94 | + ), |
| 95 | + _SimpleBulkMapping( |
| 96 | + header=_StringTable.TrackingTemplate, |
| 97 | + field_to_csv=lambda c: bulk_str(c.video_ad_extension.TrackingUrlTemplate), |
| 98 | + csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'TrackingUrlTemplate', v if v else None) |
| 99 | + ), |
| 100 | + _SimpleBulkMapping( |
| 101 | + header=_StringTable.CustomParameter, |
| 102 | + field_to_csv=lambda c: field_to_csv_UrlCustomParameters(c.video_ad_extension), |
| 103 | + csv_to_field=lambda c, v: csv_to_field_UrlCustomParameters(c.video_ad_extension, v) |
| 104 | + ), |
| 105 | + _SimpleBulkMapping( |
| 106 | + header=_StringTable.FinalUrl, |
| 107 | + field_to_csv=lambda c: field_to_csv_Urls(c.video_ad_extension.FinalUrls, c.video_ad_extension.Id), |
| 108 | + csv_to_field=lambda c, v: csv_to_field_Urls(c.video_ad_extension.FinalUrls, v) |
| 109 | + ), |
| 110 | + _SimpleBulkMapping( |
| 111 | + header=_StringTable.FinalMobileUrl, |
| 112 | + field_to_csv=lambda c: field_to_csv_Urls(c.video_ad_extension.FinalMobileUrls, c.video_ad_extension.Id), |
| 113 | + csv_to_field=lambda c, v: csv_to_field_Urls(c.video_ad_extension.FinalMobileUrls, v) |
| 114 | + ) |
| 115 | + ] |
| 116 | + |
| 117 | + def process_mappings_from_row_values(self, row_values): |
| 118 | + self.video_ad_extension = _CAMPAIGN_OBJECT_FACTORY_V13.create('VideoAdExtension') |
| 119 | + self.video_ad_extension.Type = 'VideoAdExtension' |
| 120 | + super(BulkVideoAdExtension, self).process_mappings_from_row_values(row_values) |
| 121 | + row_values.convert_to_entity(self, BulkVideoAdExtension._MAPPINGS) |
| 122 | + |
| 123 | + def process_mappings_to_row_values(self, row_values, exclude_readonly_data): |
| 124 | + self._validate_property_not_null(self.video_ad_extension, 'video_ad_extension') |
| 125 | + super(BulkVideoAdExtension, self).process_mappings_to_row_values(row_values, exclude_readonly_data) |
| 126 | + self.convert_to_values(row_values, BulkVideoAdExtension._MAPPINGS) |
| 127 | + |
| 128 | + |
| 129 | +class BulkAccountVideoAdExtension(_BulkAccountAdExtensionAssociation): |
| 130 | + """ Represents an account level video ad extension. |
| 131 | +
|
| 132 | + This class exposes properties that can be read and written |
| 133 | + as fields of the Account Video Ad Extension record in a bulk file. |
| 134 | +
|
| 135 | + For more information, see Account Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127. |
| 136 | +
|
| 137 | + *See also:* |
| 138 | +
|
| 139 | + * :class:`.BulkServiceManager` |
| 140 | + * :class:`.BulkOperation` |
| 141 | + * :class:`.BulkFileReader` |
| 142 | + * :class:`.BulkFileWriter` |
| 143 | + """ |
| 144 | + |
| 145 | + pass |
| 146 | + |
| 147 | + |
| 148 | +class BulkCampaignVideoAdExtension(_BulkCampaignAdExtensionAssociation): |
| 149 | + """ Represents a campaign level video ad extension. |
| 150 | +
|
| 151 | + This class exposes properties that can be read and written |
| 152 | + as fields of the Campaign Video Ad Extension record in a bulk file. |
| 153 | +
|
| 154 | + For more information, see Campaign Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127. |
| 155 | +
|
| 156 | + *See also:* |
| 157 | +
|
| 158 | + * :class:`.BulkServiceManager` |
| 159 | + * :class:`.BulkOperation` |
| 160 | + * :class:`.BulkFileReader` |
| 161 | + * :class:`.BulkFileWriter` |
| 162 | + """ |
| 163 | + |
| 164 | + pass |
| 165 | + |
| 166 | +class BulkAdGroupVideoAdExtension(_BulkAdGroupAdExtensionAssociation): |
| 167 | + """ Represents an ad group level video ad extension. |
| 168 | +
|
| 169 | + This class exposes properties that can be read and written |
| 170 | + as fields of the Ad Group Video Ad Extension record in a bulk file. |
| 171 | +
|
| 172 | + For more information, see Ad Group Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127. |
| 173 | +
|
| 174 | + *See also:* |
| 175 | +
|
| 176 | + * :class:`.BulkServiceManager` |
| 177 | + * :class:`.BulkOperation` |
| 178 | + * :class:`.BulkFileReader` |
| 179 | + * :class:`.BulkFileWriter` |
| 180 | + """ |
| 181 | + |
| 182 | + pass |
0 commit comments