Google Ads API is returning to beta status. Please read our blog post for more details.

批量转变

如果您需要同时对不同类型的实体执行操作,或者希望对单个端点进行写操作,而不愿每种资源类型使用单独的端点,则可以将 GoogleAdsService.Mutate 端点用于所有受支持的 mutate 操作。

Mutate 操作

每个 MutateGoogleAdsRequest 会接受一个重复的 MutateOperation,后者包含一个资源类型的单个操作。要在单个 GoogleAdsService.Mutate 调用中制作一个广告系列和创建一个广告组,您需要创建两个 MutateOperation 实体(一个用于 CampaignOperation,另一个用于 AdGroupOperation),然后将两者都传递给 GoogleAdsService

mutate_operation1 = client.operation(:Mutate)
mutate_operation2 = client.operation(:Mutate)

campaign_operation = client.operation(:Campaign)
ad_group_operation = client.operation(:AdGroup)

# Do some setup here to get campaign_operation and ad_group_operation into the
# state you would want them for a regular mutate call to their respective
# services.

mutate_operation1.campaign_operation = campaign_operation
mutate_operation2.ad_group_operation = ad_group_operation

google_ads_service.mutate(customer_id, [mutate_operation1, mutate_operation2])

与其他服务一样,此端点支持部分失败和仅验证功能。