How to use the bingads.v11.internal.bulk.string_table._StringTable function in bingads

To help you get started, we’ve selected a few bingads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BingAds / BingAds-Python-SDK / bingads / v11 / internal / bulk / csv_headers.py View on Github external
from .string_table import _StringTable


class _CsvHeaders:
    HEADERS = [
        # Common
        _StringTable.Type,
        _StringTable.Status,
        _StringTable.Id,
        _StringTable.ParentId,
        _StringTable.SubType,
        _StringTable.Campaign,
        _StringTable.AdGroup,
        _StringTable.Website,
        _StringTable.SyncTime,
        _StringTable.ClientId,
        _StringTable.LastModifiedTime,

        # Campaign
        _StringTable.TimeZone,
        _StringTable.Budget,
        _StringTable.BudgetType,
        _StringTable.BudgetName,
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / bulk_ad_group.py View on Github external
_SimpleBulkMapping(
            header=_StringTable.ContentNetwork,
            field_to_csv=lambda c: None if not c.ad_group.AdDistribution else 'On' if 'Content' in c.ad_group.AdDistribution else 'Off',
            csv_to_field=lambda c, v: v == 'On' and setattr(
                c.ad_group,
                'AdDistribution',
                (c.ad_group.AdDistribution + ' ' + 'Content').strip()
            )
        ),
        _SimpleBulkMapping(
            header=_StringTable.SearchBid,
            field_to_csv=lambda c: ad_group_bid_bulk_str(c.ad_group.SearchBid),
            csv_to_field=lambda c, v: setattr(c.ad_group, 'SearchBid', parse_ad_group_bid(v))
        ),
        _SimpleBulkMapping(
            header=_StringTable.ContentBid,
            field_to_csv=lambda c: ad_group_bid_bulk_str(c.ad_group.ContentMatchBid),
            csv_to_field=lambda c, v: setattr(c.ad_group, 'ContentMatchBid', parse_ad_group_bid(v))
        ),
        _SimpleBulkMapping(
            header=_StringTable.Language,
            field_to_csv=lambda c: bulk_str(c.ad_group.Language),
            csv_to_field=lambda c, v: setattr(c.ad_group, 'Language', v if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.BidAdjustment,
            field_to_csv=lambda c: bulk_str(c.ad_group.NativeBidAdjustment),
            csv_to_field=lambda c, v: setattr(
                c.ad_group,
                'NativeBidAdjustment',
                int(v) if v else None
            )
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / target_criterions / bulk_ad_group_radius_criterion.py View on Github external
* :class:`.BulkFileWriter`
    """

    def __init__(self,
                 biddable_ad_group_criterion=None,
                 campaign_name=None,
                 ad_group_name=None, ):
        super(BulkAdGroupRadiusCriterion, self).__init__()

        self._biddable_ad_group_criterion = biddable_ad_group_criterion
        self._campaign_name = campaign_name
        self._ad_group_name =ad_group_name

    _MAPPINGS = [
        _SimpleBulkMapping(
            _StringTable.Status,
            field_to_csv=lambda c: bulk_str(c.biddable_ad_group_criterion.Status),
            csv_to_field=lambda c, v: setattr(c.biddable_ad_group_criterion, 'Status', v if v else None)
        ),
        _SimpleBulkMapping(
            _StringTable.Id,
            field_to_csv=lambda c: bulk_str(c.biddable_ad_group_criterion.Id),
            csv_to_field=lambda c, v: setattr(c.biddable_ad_group_criterion, 'Id', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            _StringTable.ParentId,
            field_to_csv=lambda c: bulk_str(c.biddable_ad_group_criterion.AdGroupId),
            csv_to_field=lambda c, v: setattr(c.biddable_ad_group_criterion, 'AdGroupId', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            _StringTable.Campaign,
            field_to_csv=lambda c: c.campaign_name,
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / bulk_ads.py View on Github external
header=_StringTable.LandscapeImageMediaId,
            field_to_csv=lambda c: c.responsive_ad.LandscapeImageMediaId,
            csv_to_field=lambda c, v: setattr(c.responsive_ad, 'LandscapeImageMediaId', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.LandscapeLogoMediaId,
            field_to_csv=lambda c: c.responsive_ad.LandscapeLogoMediaId,
            csv_to_field=lambda c, v: setattr(c.responsive_ad, 'LandscapeLogoMediaId', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.SquareImageMediaId,
            field_to_csv=lambda c: c.responsive_ad.SquareImageMediaId,
            csv_to_field=lambda c, v: setattr(c.responsive_ad, 'SquareImageMediaId', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.SquareLogoMediaId,
            field_to_csv=lambda c: c.responsive_ad.SquareLogoMediaId,
            csv_to_field=lambda c, v: setattr(c.responsive_ad, 'SquareLogoMediaId', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.Text,
            field_to_csv=lambda c: c.responsive_ad.Text,
            csv_to_field=lambda c, v: setattr(c.responsive_ad, 'Text', v)
        ),
    ]

    def process_mappings_from_row_values(self, row_values):
        self.responsive_ad = _CAMPAIGN_OBJECT_FACTORY_V11.create('ResponsiveAd')
        self.responsive_ad.Type = 'Responsive'
        super(BulkResponsiveAd, self).process_mappings_from_row_values(row_values)
        row_values.convert_to_entity(self, BulkResponsiveAd._MAPPINGS)
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / target_criterions / bulk_campaign_age_criterion.py View on Github external
def __init__(self,
                 biddable_campaign_criterion=None,
                 campaign_name=None, ):
        super(BulkCampaignAgeCriterion, self).__init__()

        self._biddable_campaign_criterion = biddable_campaign_criterion
        self._campaign_name = campaign_name

    _MAPPINGS = [
        _SimpleBulkMapping(
            _StringTable.Status,
            field_to_csv=lambda c: bulk_str(c.biddable_campaign_criterion.Status),
            csv_to_field=lambda c, v: setattr(c.biddable_campaign_criterion, 'Status', v if v else None)
        ),
        _SimpleBulkMapping(
            _StringTable.Id,
            field_to_csv=lambda c: bulk_str(c.biddable_campaign_criterion.Id),
            csv_to_field=lambda c, v: setattr(c.biddable_campaign_criterion, 'Id', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            _StringTable.ParentId,
            field_to_csv=lambda c: bulk_str(c.biddable_campaign_criterion.CampaignId),
            csv_to_field=lambda c, v: setattr(c.biddable_campaign_criterion, 'CampaignId', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            _StringTable.Campaign,
            field_to_csv=lambda c: c.campaign_name,
            csv_to_field=lambda c, v: setattr(c, 'campaign_name', v)
        ),
        _SimpleBulkMapping(
            _StringTable.BidAdjustment,
            field_to_csv=lambda c: field_to_csv_BidAdjustment(c.biddable_campaign_criterion),
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / common.py View on Github external
header=_StringTable.Spend,
            field_to_csv=lambda c: bulk_str(c.spend),
            csv_to_field=lambda c, v: setattr(c, '_spend', float(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.Impressions,
            field_to_csv=lambda c: bulk_str(c.impressions),
            csv_to_field=lambda c, v: setattr(c, '_impressions', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.Clicks,
            field_to_csv=lambda c: bulk_str(c.clicks),
            csv_to_field=lambda c, v: setattr(c, '_clicks', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.CTR,
            field_to_csv=lambda c: bulk_str(c.click_through_rate),
            csv_to_field=lambda c, v: setattr(c, '_click_through_rate', float(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.AvgCPC,
            field_to_csv=lambda c: bulk_str(c.average_cost_per_click),
            csv_to_field=lambda c, v: setattr(c, '_average_cost_per_click', float(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.AvgCPM,
            field_to_csv=lambda c: bulk_str(c.average_cost_per_thousand_impressions),
            csv_to_field=lambda c, v: setattr(
                c,
                '_average_cost_per_thousand_impressions',
                float(v) if v else None
            )
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / bulk_ad_group.py View on Github external
:rtype: QualityScoreData
        """
        return self._quality_score_data

    @property
    def performance_data(self):
        """ The historical performance data for the ad group.

        :rtype: PerformanceData
        """

        return self._performance_data

    _MAPPINGS = [
        _SimpleBulkMapping(
            header=_StringTable.Id,
            field_to_csv=lambda c: bulk_str(c.ad_group.Id),
            csv_to_field=lambda c, v: setattr(c.ad_group, 'Id', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.Status,
            field_to_csv=lambda c: 'Expired' if c.is_expired else bulk_str(c.ad_group.Status),
            csv_to_field=csv_to_status
        ),
        _SimpleBulkMapping(
            header=_StringTable.ParentId,
            field_to_csv=lambda c: bulk_str(c.campaign_id),
            csv_to_field=lambda c, v: setattr(c, 'campaign_id', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.Campaign,
            field_to_csv=lambda c: c.campaign_name,
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / bulk_campaign_product_scope.py View on Github external
self._campaign_name = campaign_name
        self._status = status
        self._biddable_campaign_criterion = biddable_campaign_criterion

    @classmethod
    def _add_product_condition_to_row_values(cls, entity, value):
        criterion = entity.biddable_campaign_criterion.Criterion
        if criterion is not None and hasattr(criterion, 'Conditions') and criterion.Conditions is not None and \
                hasattr(criterion.Conditions, 'ProductCondition'):
            return _ProductConditionHelper.add_row_values_from_conditions(criterion.Conditions.ProductCondition, value)
        return None

    _MAPPINGS = [
        _SimpleBulkMapping(
            _StringTable.Status,
            field_to_csv=lambda c: c.biddable_campaign_criterion.Status,
            csv_to_field=lambda c, v: setattr(c.biddable_campaign_criterion, 'Status', v)
        ),
        _SimpleBulkMapping(
            header=_StringTable.Id,
            field_to_csv=lambda c: bulk_str(c.biddable_campaign_criterion.Id),
            csv_to_field=lambda c, v: setattr(c.biddable_campaign_criterion, 'Id', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.ParentId,
            field_to_csv=lambda c: bulk_str(c.biddable_campaign_criterion.CampaignId),
            csv_to_field=lambda c, v: setattr(c.biddable_campaign_criterion, 'CampaignId', int(v))
        ),
        _SimpleBulkMapping(
            header=_StringTable.Campaign,
            field_to_csv=lambda c: c.campaign_name,
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / bulk_keyword.py View on Github external
c.keyword,
                'Bid',
                parse_keyword_bid(v)
            )
        ),
        _SimpleBulkMapping(
            header=_StringTable.Param1,
            field_to_csv=lambda c: bulk_optional_str(c.keyword.Param1),
            csv_to_field=lambda c, v: setattr(
                c.keyword,
                'Param1',
                v if v else ''
            )
        ),
        _SimpleBulkMapping(
            header=_StringTable.Param2,
            field_to_csv=lambda c: bulk_optional_str(c.keyword.Param2),
            csv_to_field=lambda c, v: setattr(
                c.keyword,
                'Param2',
                v if v else ''
            )
        ),
        _SimpleBulkMapping(
            header=_StringTable.Param3,
            field_to_csv=lambda c: bulk_optional_str(c.keyword.Param3),
            csv_to_field=lambda c, v: setattr(
                c.keyword,
                'Param3',
                v if v else ''
            )
        ),
github BingAds / BingAds-Python-SDK / bingads / v11 / bulk / entities / bulk_ads.py View on Github external
return self._ad

    @dynamic_search_ad.setter
    def dynamic_search_ad(self, dynamic_search_ad):
        if dynamic_search_ad is not None and not isinstance(dynamic_search_ad, DynamicSearchAd):
            raise ValueError('Not an instance of DynamicSearchAd')
        self._ad = dynamic_search_ad

    _MAPPINGS = [
        _SimpleBulkMapping(
            header=_StringTable.Text,
            field_to_csv=lambda c: c.dynamic_search_ad.Text,
            csv_to_field=lambda c, v: setattr(c.dynamic_search_ad, 'Text', v)
        ),
        _SimpleBulkMapping(
            header=_StringTable.Path1,
            field_to_csv=lambda c: c.dynamic_search_ad.Path1,
            csv_to_field=lambda c, v: setattr(c.dynamic_search_ad, 'Path1', v)
        ),
        _SimpleBulkMapping(
            header=_StringTable.Path2,
            field_to_csv=lambda c: c.dynamic_search_ad.Path2,
            csv_to_field=lambda c, v: setattr(c.dynamic_search_ad, 'Path2', v)
        ),
    ]

    def process_mappings_from_row_values(self, row_values):
        self.dynamic_search_ad = _CAMPAIGN_OBJECT_FACTORY_V11.create('DynamicSearchAd')
        self.dynamic_search_ad.Type = 'DynamicSearch'
        super(BulkDynamicSearchAd, self).process_mappings_from_row_values(row_values)
        row_values.convert_to_entity(self, BulkDynamicSearchAd._MAPPINGS)