How to use the bingads.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 / bulk / entities / targets / bulk_targets.py View on Github external
super(_BulkDeviceOsTargetBid, self).__init__(
            status=status,
            target_id=target_id,
            entity_id=entity_id,
            entity_name=entity_name,
            parent_entity_name=parent_entity_name
        )

    _MAPPINGS = [
        _SimpleBulkMapping(
            header=_StringTable.Target,
            field_to_csv=lambda c: bulk_str(c.device_os_target_bid.DeviceName),
            csv_to_field=lambda c, v: setattr(c.device_os_target_bid, 'DeviceName', v),
        ),
        _SimpleBulkMapping(
            header=_StringTable.OsNames,
            field_to_csv=lambda c: ';'.join(
                c.device_os_target_bid.OSNames.string) if c.device_os_target_bid.OSNames.string else None,
            csv_to_field=lambda c, v: setattr(
                c.device_os_target_bid.OSNames,
                'string',
                list(filter(None, v.split(';'))) if v else [],
            ),
        ),
        _SimpleBulkMapping(
            header=_StringTable.BidAdjustment,
            field_to_csv=lambda c: bulk_str(c.device_os_target_bid.BidAdjustment),
            csv_to_field=lambda c, v: setattr(c.device_os_target_bid, 'BidAdjustment', int(v))
        ),
    ]

    @property
github BingAds / BingAds-Python-SDK / bingads / bulk / entities / targets / bulk_targets.py View on Github external
def campaign_id(self, value):
        self._entity_id = value

    @property
    def campaign_name(self):
        return self._entity_name

    @campaign_name.setter
    def campaign_name(self, value):
        self._entity_name = value


class _BulkAdGroupTargetIdentifier(_BulkTargetIdentifier):
    _MAPPINGS = [
        _SimpleBulkMapping(
            header=_StringTable.Campaign,
            field_to_csv=lambda c: bulk_str(c.parent_entity_name),
            csv_to_field=lambda c, v: setattr(c, '_parent_entity_name', v)
        )
    ]

    def __eq__(self, other):
        is_name_not_empty = (
            self.campaign_name is not None and
            len(self.campaign_name) > 0 and
            self.ad_group_name is not None and
            len(self.ad_group_name) > 0
        )
        return (
            type(self) == type(other) and
            (
                self.ad_group_id == other.ad_group_id or
github BingAds / BingAds-Python-SDK / bingads / bulk / entities / bulk_campaign.py View on Github external
header=_StringTable.ParentId,
            field_to_csv=lambda c: bulk_str(c.account_id),
            csv_to_field=lambda c, v: setattr(c, '_account_id', int(v))
        ),
        _SimpleBulkMapping(
            header=_StringTable.Campaign,
            field_to_csv=lambda c: c.campaign.Name,
            csv_to_field=lambda c, v: setattr(c.campaign, 'Name', v)
        ),
        _SimpleBulkMapping(
            header=_StringTable.TimeZone,
            field_to_csv=lambda c: c.campaign.TimeZone,
            csv_to_field=lambda c, v: setattr(c.campaign, 'TimeZone', v)
        ),
        _SimpleBulkMapping(
            header=_StringTable.BudgetType,
            field_to_csv=lambda c: bulk_str(c.campaign.BudgetType),
            csv_to_field=lambda c, v: setattr(
                c.campaign,
                'BudgetType',
                v if v else None
            )
        ),
        _ComplexBulkMapping(budget_to_csv, csv_to_budget),
        _SimpleBulkMapping(
            header=_StringTable.BidAdjustment,
            field_to_csv=lambda c: bulk_str(c.campaign.NativeBidAdjustment),
            csv_to_field=lambda c, v: setattr(
                c.campaign,
                'NativeBidAdjustment',
                int(v) if v else None
            )
github BingAds / BingAds-Python-SDK / bingads / internal / bulk / bulk_object_factory.py View on Github external
_StringTable.Target,
            lambda: _BulkCampaignTargetIdentifier(target_bid_type=BulkCampaignLocationTargetBid)
        ),
        'Ad Group Negative Location Target': _EntityInfo(
            lambda: BulkAdGroupNegativeLocationTargetBid(),
            _StringTable.Target,
            lambda: _BulkAdGroupTargetIdentifier(target_bid_type=BulkAdGroupNegativeLocationTargetBid)
        ),
        'Campaign Negative Location Target': _EntityInfo(
            lambda: BulkCampaignNegativeLocationTargetBid(),
            _StringTable.Target,
            lambda: _BulkCampaignTargetIdentifier(target_bid_type=BulkCampaignNegativeLocationTargetBid)
        ),
        'Ad Group Radius Target': _EntityInfo(
            lambda: BulkAdGroupRadiusTargetBid(),
            _StringTable.Target,
            lambda: _BulkAdGroupTargetIdentifier(target_bid_type=BulkAdGroupRadiusTargetBid)
        ),
        'Campaign Radius Target': _EntityInfo(
            lambda: BulkCampaignRadiusTargetBid(),
            _StringTable.Target,
            lambda: _BulkCampaignTargetIdentifier(target_bid_type=BulkCampaignRadiusTargetBid)
        ),
        'Campaign Product Scope': _EntityInfo(lambda : BulkCampaignProductScope()),
        'Ad Group Product Partition': _EntityInfo(lambda : BulkAdGroupProductPartition())
    }

    ADDITIONAL_OBJECT_MAP = {
        'Format Version': lambda: _FormatVersion(),
        'Keyword Best Position Bid': lambda: BulkKeywordBestPositionBid(),
        'Keyword Main Line Bid': lambda: BulkKeywordMainLineBid(),
        'Keyword First Page Bid': lambda: BulkKeywordFirstPageBid(),
github BingAds / BingAds-Python-SDK / bingads / bulk / entities / ad_extensions / bulk_call_ad_extensions.py View on Github external
csv_to_field=lambda c, v: setattr(c.call_ad_extension, 'CountryCode', v)
        ),
        _SimpleBulkMapping(
            header=_StringTable.IsCallOnly,
            field_to_csv=lambda c: bulk_str(c.call_ad_extension.IsCallOnly),
            csv_to_field=lambda c, v: setattr(c.call_ad_extension, 'IsCallOnly',
                                              v.lower() == 'true' if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.IsCallTrackingEnabled,
            field_to_csv=lambda c: bulk_str(c.call_ad_extension.IsCallTrackingEnabled),
            csv_to_field=lambda c, v: setattr(c.call_ad_extension, 'IsCallTrackingEnabled',
                                              v.lower() == 'true' if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.RequireTollFreeTrackingNumber,
            field_to_csv=lambda c: bulk_str(c.call_ad_extension.RequireTollFreeTrackingNumber),
            csv_to_field=lambda c, v: setattr(c.call_ad_extension, 'RequireTollFreeTrackingNumber',
                                              v.lower() == 'true' if v else None)
        ),
    ]

    def process_mappings_from_row_values(self, row_values):
        self.call_ad_extension = _CAMPAIGN_OBJECT_FACTORY.create('CallAdExtension')
        self.call_ad_extension.Type = 'CallAdExtension'
        super(BulkCallAdExtension, self).process_mappings_from_row_values(row_values)
        row_values.convert_to_entity(self, BulkCallAdExtension._MAPPINGS)

    def process_mappings_to_row_values(self, row_values, exclude_readonly_data):
        self._validate_property_not_null(self.call_ad_extension, 'call_ad_extension')
        super(BulkCallAdExtension, self).process_mappings_to_row_values(row_values, exclude_readonly_data)
        self.convert_to_values(row_values, BulkCallAdExtension._MAPPINGS)
github BingAds / BingAds-Python-SDK / bingads / internal / bulk / csv_headers.py View on Github external
_StringTable.BusinessId,

        # DayTime Target
        _StringTable.FromHour,
        _StringTable.FromMinute,
        _StringTable.ToHour,
        _StringTable.ToMinute,

        # AdExtensions common
        _StringTable.Version,

        # SiteLink AdExtensions
        _StringTable.SiteLinkExtensionOrder,
        _StringTable.SiteLinkDisplayText,
        _StringTable.SiteLinkDestinationUrl,
        _StringTable.SiteLinkDescription1,
        _StringTable.SiteLinkDescription2,

        # Location AdExtensions
        _StringTable.GeoCodeStatus,
        _StringTable.IconMediaId,
        _StringTable.ImageMediaId,
        _StringTable.AddressLine1,
        _StringTable.AddressLine2,
        _StringTable.PostalCode,
        _StringTable.City,
        _StringTable.StateOrProvince,
        _StringTable.ProvinceName,
        _StringTable.Latitude,
        _StringTable.Longitude,

        # Call AdExtensions
github BingAds / BingAds-Python-SDK / bingads / bulk / entities / bulk_negative_sites.py View on Github external
    @property
    def entity_id(self):
        return self._entity_id

    @property
    def entity_name(self):
        return self._entity_name

    @property
    def _parent_column_name(self):
        raise NotImplementedError()

    _MAPPINGS = [
        _SimpleBulkMapping(
            header=_StringTable.Status,
            field_to_csv=lambda c: bulk_str(c._status),
            csv_to_field=lambda c, v: setattr(c, '_status', v if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.ParentId,
            field_to_csv=lambda c: None if c._entity_id == 0 else bulk_str(c._entity_id),
            csv_to_field=lambda c, v: setattr(c, '_entity_id', int(v) if v else 0)
        ),
        _DynamicColumnNameMapping(
            header_func=lambda c: c._parent_column_name,
            field_to_csv=lambda c: c._entity_name,
            csv_to_field=lambda c, v: setattr(c, '_entity_name', v)
        )
    ]

    @property
github BingAds / BingAds-Python-SDK / bingads / bulk / entities / ad_extensions / bulk_site_links_ad_extensions.py View on Github external
""" The version of the ad extension.

        Corresponds to the 'Version' field in the bulk file.

        :rtype: int
        """

        return self._identifier.version

    @version.setter
    def version(self, value):
        self._identifier._version = value

    _MAPPINGS = [
        _SimpleBulkMapping(
            header=_StringTable.SiteLinkExtensionOrder,
            field_to_csv=lambda c: bulk_str(c.order),
            csv_to_field=lambda c, v: setattr(c, 'order', int(v) if v else None)
        ),
        _SimpleBulkMapping(
            header=_StringTable.SiteLinkDisplayText,
            field_to_csv=lambda c: c.site_link.DisplayText,
            csv_to_field=lambda c, v: setattr(c.site_link, 'DisplayText', v)
        ),
        _SimpleBulkMapping(
            header=_StringTable.SiteLinkDestinationUrl,
            field_to_csv=lambda c: c.site_link.DestinationUrl,
            csv_to_field=lambda c, v: setattr(c.site_link, 'DestinationUrl', v)
        ),
        _SimpleBulkMapping(
            header=_StringTable.SiteLinkDescription1,
            field_to_csv=lambda c: c.site_link.Description1,
github BingAds / BingAds-Python-SDK / bingads / bulk / entities / targets / bulk_targets.py View on Github external
super(_BulkRadiusTargetBid, self).__init__(
            status=status,
            target_id=target_id,
            entity_id=entity_id,
            entity_name=entity_name,
            parent_entity_name=parent_entity_name
        )

    _MAPPINGS = [
        _SimpleBulkMapping(
            header=_StringTable.RadiusTargetId,
            field_to_csv=lambda c: bulk_str(c.radius_target_bid.Id),
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'Id', int(v) if v else None),
        ),
        _SimpleBulkMapping(
            header=_StringTable.Name,
            field_to_csv=lambda c: c.radius_target_bid.Name,
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'Name', v),
        ),
        _SimpleBulkMapping(
            header=_StringTable.Radius,
            field_to_csv=lambda c: bulk_str(c.radius_target_bid.Radius),
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'Radius', float(v)),
        ),
        _SimpleBulkMapping(
            header=_StringTable.Unit,
            field_to_csv=lambda c: c.radius_target_bid.RadiusUnit,
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'RadiusUnit', v),
        ),
        _SimpleBulkMapping(
            header=_StringTable.Latitude,
            field_to_csv=lambda c: bulk_str(c.radius_target_bid.LatitudeDegrees),
github BingAds / BingAds-Python-SDK / bingads / bulk / entities / targets / bulk_targets.py View on Github external
header=_StringTable.Radius,
            field_to_csv=lambda c: bulk_str(c.radius_target_bid.Radius),
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'Radius', float(v)),
        ),
        _SimpleBulkMapping(
            header=_StringTable.Unit,
            field_to_csv=lambda c: c.radius_target_bid.RadiusUnit,
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'RadiusUnit', v),
        ),
        _SimpleBulkMapping(
            header=_StringTable.Latitude,
            field_to_csv=lambda c: bulk_str(c.radius_target_bid.LatitudeDegrees),
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'LatitudeDegrees', float(v)),
        ),
        _SimpleBulkMapping(
            header=_StringTable.Longitude,
            field_to_csv=lambda c: bulk_str(c.radius_target_bid.LongitudeDegrees),
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'LongitudeDegrees', float(v)),
        ),
        _SimpleBulkMapping(
            header=_StringTable.BidAdjustment,
            field_to_csv=lambda c: bulk_str(c.radius_target_bid.BidAdjustment),
            csv_to_field=lambda c, v: setattr(c.radius_target_bid, 'BidAdjustment', int(v)),
        ),
        _SimpleBulkMapping(
            header=_StringTable.PhysicalIntent,
            field_to_csv=lambda c: bulk_str(c.intent_option),
            csv_to_field=lambda c, v: setattr(c, '_intent_option', v if v else None),
        ),
    ]

    @property