如果您需要同時對不同類型的實體執行作業,或是偏好針對單一端點寫入,而不是針對每個資源類型使用個別端點,則可以使用 GoogleAdsService.Mutate
端點執行所有支援的變異操作。
修改作業
每個 MutateGoogleAdsRequest
都會接受重複的 MutateOperation
,每個 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])
與其他服務一樣,這個端點支援部分失敗和僅驗證。