google-adwords-api 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/ChangeLog +3 -0
- data/examples/v201402/basic_operations/delete_ad_group.rb +1 -22
- data/examples/{v201309/basic_operations/delete_ad_group.rb → v201402/basic_operations/delete_ad_group.rb~} +2 -8
- data/examples/v201402/basic_operations/delete_campaign.rb +2 -23
- data/examples/{v201309/basic_operations/update_campaign.rb → v201402/basic_operations/delete_campaign.rb~} +13 -12
- data/examples/v201406/basic_operations/remove_ad_group.rb +1 -22
- data/examples/{v201309/basic_operations/update_ad_group.rb → v201406/basic_operations/remove_ad_group.rb~} +14 -13
- data/examples/v201406/basic_operations/remove_campaign.rb +4 -24
- data/examples/{v201309/basic_operations/delete_campaign.rb → v201406/basic_operations/remove_campaign.rb~} +11 -11
- data/lib/adwords_api.rb +5 -8
- data/lib/adwords_api/api_config.rb +0 -76
- data/lib/adwords_api/report_utils.rb +9 -0
- data/lib/adwords_api/report_utils.rb~ +283 -0
- data/lib/adwords_api/version.rb +1 -1
- data/lib/adwords_api/version.rb~ +26 -0
- data/test/adwords_api/test_adwords_api.rb +5 -21
- data/test/adwords_api/test_adwords_api.rb~ +114 -0
- data/test/adwords_api/test_api_config.rb +8 -8
- data/test/adwords_api/test_report_utils.rb +29 -1
- data/test/adwords_api/test_report_utils.rb~ +216 -0
- data/test/templates/{v201309 → v201402}/basic_operations_get_campaigns.def +7 -7
- data/test/templates/{v201309 → v201402}/misc_use_oauth2_jwt.def +7 -7
- data/test/templates/v201406/basic_operations_get_campaigns.def +114 -0
- data/test/templates/v201406/misc_use_oauth2_jwt.def +131 -0
- metadata +14 -139
- data/examples/v201309/account_management/create_account.rb +0 -95
- data/examples/v201309/account_management/get_account_alerts.rb +0 -122
- data/examples/v201309/account_management/get_account_changes.rb +0 -145
- data/examples/v201309/account_management/get_account_hierarchy.rb +0 -103
- data/examples/v201309/advanced_operations/add_ad_group_bid_modifier.rb +0 -105
- data/examples/v201309/advanced_operations/add_click_to_download_ad.rb +0 -137
- data/examples/v201309/advanced_operations/add_site_links.rb +0 -306
- data/examples/v201309/advanced_operations/create_and_attach_shared_keyword_set.rb +0 -147
- data/examples/v201309/advanced_operations/find_and_remove_criteria_from_shared_set.rb +0 -181
- data/examples/v201309/advanced_operations/get_ad_group_bid_modifiers.rb +0 -106
- data/examples/v201309/advanced_operations/update_site_links.rb +0 -194
- data/examples/v201309/advanced_operations/upload_offline_conversions.rb +0 -117
- data/examples/v201309/advanced_operations/use_shared_bidding_strategy.rb +0 -163
- data/examples/v201309/basic_operations/add_ad_groups.rb +0 -143
- data/examples/v201309/basic_operations/add_campaigns.rb +0 -162
- data/examples/v201309/basic_operations/add_keywords.rb +0 -116
- data/examples/v201309/basic_operations/add_text_ads.rb +0 -113
- data/examples/v201309/basic_operations/delete_ad.rb +0 -93
- data/examples/v201309/basic_operations/delete_keyword.rb +0 -98
- data/examples/v201309/basic_operations/get_ad_groups.rb +0 -106
- data/examples/v201309/basic_operations/get_campaigns.rb +0 -101
- data/examples/v201309/basic_operations/get_campaigns_with_awql.rb +0 -93
- data/examples/v201309/basic_operations/get_keywords.rb +0 -112
- data/examples/v201309/basic_operations/get_text_ads.rb +0 -114
- data/examples/v201309/basic_operations/pause_ad.rb +0 -92
- data/examples/v201309/basic_operations/update_keyword.rb +0 -110
- data/examples/v201309/campaign_management/add_experiment.rb +0 -166
- data/examples/v201309/campaign_management/add_keywords_in_bulk.rb +0 -158
- data/examples/v201309/campaign_management/add_location_extension.rb +0 -125
- data/examples/v201309/campaign_management/get_all_disapproved_ads.rb +0 -101
- data/examples/v201309/campaign_management/get_all_disapproved_ads_with_awql.rb +0 -93
- data/examples/v201309/campaign_management/promote_experiment.rb +0 -85
- data/examples/v201309/campaign_management/set_ad_parameters.rb +0 -122
- data/examples/v201309/campaign_management/set_criterion_bid_modifier.rb +0 -108
- data/examples/v201309/campaign_management/validate_text_ad.rb +0 -114
- data/examples/v201309/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201309/error_handling/handle_partial_failures.rb +0 -134
- data/examples/v201309/error_handling/handle_policy_violation_error.rb +0 -145
- data/examples/v201309/error_handling/handle_two_factor_authorization_error.rb +0 -88
- data/examples/v201309/misc/get_all_images_and_videos.rb +0 -108
- data/examples/v201309/misc/setup_oauth2.rb +0 -88
- data/examples/v201309/misc/upload_image.rb +0 -97
- data/examples/v201309/misc/use_oauth2_jwt.rb +0 -97
- data/examples/v201309/optimization/estimate_keyword_traffic.rb +0 -137
- data/examples/v201309/optimization/get_keyword_bid_simulations.rb +0 -100
- data/examples/v201309/optimization/get_keyword_ideas.rb +0 -130
- data/examples/v201309/optimization/get_placement_ideas.rb +0 -112
- data/examples/v201309/remarketing/add_audience.rb +0 -123
- data/examples/v201309/remarketing/add_conversion_tracker.rb +0 -104
- data/examples/v201309/reporting/download_criteria_report.rb +0 -87
- data/examples/v201309/reporting/download_criteria_report_with_awql.rb +0 -86
- data/examples/v201309/reporting/get_report_fields.rb +0 -79
- data/examples/v201309/reporting/parallel_report_download.rb +0 -171
- data/examples/v201309/targeting/add_campaign_targeting_criteria.rb +0 -123
- data/examples/v201309/targeting/add_demographic_targeting_criteria.rb +0 -116
- data/examples/v201309/targeting/get_campaign_targeting_criteria.rb +0 -110
- data/examples/v201309/targeting/get_targetable_languages_and_carriers.rb +0 -94
- data/examples/v201309/targeting/lookup_location.rb +0 -112
- data/lib/adwords_api/v201309/ad_group_ad_service.rb +0 -42
- data/lib/adwords_api/v201309/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/ad_group_bid_modifier_service.rb +0 -38
- data/lib/adwords_api/v201309/ad_group_bid_modifier_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/ad_group_criterion_service.rb +0 -42
- data/lib/adwords_api/v201309/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/ad_group_feed_service.rb +0 -38
- data/lib/adwords_api/v201309/ad_group_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/ad_group_service.rb +0 -42
- data/lib/adwords_api/v201309/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/ad_param_service.rb +0 -38
- data/lib/adwords_api/v201309/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/adwords_user_list_service.rb +0 -38
- data/lib/adwords_api/v201309/adwords_user_list_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/alert_service.rb +0 -34
- data/lib/adwords_api/v201309/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/bidding_strategy_service.rb +0 -38
- data/lib/adwords_api/v201309/bidding_strategy_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/budget_order_service.rb +0 -42
- data/lib/adwords_api/v201309/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/budget_service.rb +0 -38
- data/lib/adwords_api/v201309/budget_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/campaign_ad_extension_service.rb +0 -38
- data/lib/adwords_api/v201309/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/campaign_criterion_service.rb +0 -42
- data/lib/adwords_api/v201309/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/campaign_feed_service.rb +0 -38
- data/lib/adwords_api/v201309/campaign_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/campaign_service.rb +0 -42
- data/lib/adwords_api/v201309/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/campaign_shared_set_service.rb +0 -38
- data/lib/adwords_api/v201309/campaign_shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201309/constant_data_service.rb +0 -62
- data/lib/adwords_api/v201309/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/conversion_tracker_service.rb +0 -38
- data/lib/adwords_api/v201309/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/customer_service.rb +0 -34
- data/lib/adwords_api/v201309/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/customer_sync_service.rb +0 -34
- data/lib/adwords_api/v201309/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201309/data_service.rb +0 -38
- data/lib/adwords_api/v201309/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/experiment_service.rb +0 -38
- data/lib/adwords_api/v201309/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/feed_item_service.rb +0 -38
- data/lib/adwords_api/v201309/feed_item_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/feed_mapping_service.rb +0 -38
- data/lib/adwords_api/v201309/feed_mapping_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/feed_service.rb +0 -38
- data/lib/adwords_api/v201309/feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/geo_location_service.rb +0 -34
- data/lib/adwords_api/v201309/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/location_criterion_service.rb +0 -34
- data/lib/adwords_api/v201309/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/managed_customer_service.rb +0 -50
- data/lib/adwords_api/v201309/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/media_service.rb +0 -38
- data/lib/adwords_api/v201309/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/mutate_job_service.rb +0 -42
- data/lib/adwords_api/v201309/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/offline_conversion_feed_service.rb +0 -34
- data/lib/adwords_api/v201309/offline_conversion_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/report_definition_service.rb +0 -34
- data/lib/adwords_api/v201309/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/shared_criterion_service.rb +0 -38
- data/lib/adwords_api/v201309/shared_criterion_service_registry.rb +0 -47
- data/lib/adwords_api/v201309/shared_set_service.rb +0 -38
- data/lib/adwords_api/v201309/shared_set_service_registry.rb +0 -47
- data/lib/adwords_api/v201309/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201309/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201309/traffic_estimator_service.rb +0 -34
- data/lib/adwords_api/v201309/traffic_estimator_service_registry.rb +0 -46
- data/test/bugs/test_issue_00000031.rb +0 -75
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODRhZTMxOWI0ZjZlYTZmMDRhZDA1M2I4YjgxNDJiMTU4YTdlMGNkMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZThlNzE5ZTUzNWFlMDcyZmU0NTczMjdjOTAyYjdiZDc1ODg4MWMyZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTNiZjMxOTEwNjA3MmRkNGYzZjFiMGI1ZmRhODE5NmZlNTBlOGRlNzg3ZWZh
|
10
|
+
YTg4MDVhNTlhNWI4Yjg5YjUxZGI2NzRlMDA0ZjJlZTVhZTNkOGU3NzFhMTcx
|
11
|
+
MmZkZWUxZDhhMjQzYTZmZGNkZTVjOTkwOTNjYmY1ZjlhNTQwZjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzI0ZmYxODE3ZmRhNzhlODQ5MmM0OGNhNjM4YjViYzI1Y2U0NDcxNjRhNzU0
|
14
|
+
OWJmZWNhZTc4Nzg4NTg1MWJiMmExZWRmZmVmMThkMmIzNjljYjhlNzA5NDc1
|
15
|
+
YTliYjMzZjU5YmIwNzE3MDlhMmM5YzY0OTc5YTEzMGE3YzVjNjc=
|
data/ChangeLog
CHANGED
@@ -36,31 +36,11 @@ def delete_ad_group(ad_group_id)
|
|
36
36
|
|
37
37
|
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
38
38
|
|
39
|
-
# Retrieve the ad group to obtain its name. This is optional but recommended
|
40
|
-
# to keep deleted objects searchable. In production the name is already known
|
41
|
-
# in most cases.
|
42
|
-
selector = {
|
43
|
-
:fields => ['Id', 'Name'],
|
44
|
-
:predicates => [
|
45
|
-
{:field => 'Id', :operator => 'EQUALS', :values => [ad_group_id]}
|
46
|
-
]
|
47
|
-
}
|
48
|
-
result = ad_group_srv.get(selector)
|
49
|
-
|
50
|
-
if result.nil? or result[:entries].empty?
|
51
|
-
raise StandardError, "Ad group with ID %d was not found." % ad_group_id
|
52
|
-
end
|
53
|
-
|
54
|
-
# We recommend renaming object on delete to avoid name conflicts later.
|
55
|
-
ad_group_name = result[:entries].first[:name]
|
56
|
-
ad_group_name += Time.now.strftime(" (deleted on %Y-%m-%d %H:%M:%S)")
|
57
|
-
|
58
39
|
# Prepare for deleting ad group.
|
59
40
|
operation = {
|
60
41
|
:operator => 'SET',
|
61
42
|
:operand => {
|
62
43
|
:id => ad_group_id,
|
63
|
-
:name => ad_group_name,
|
64
44
|
:status => 'DELETED'
|
65
45
|
}
|
66
46
|
}
|
@@ -69,8 +49,7 @@ def delete_ad_group(ad_group_id)
|
|
69
49
|
response = ad_group_srv.mutate([operation])
|
70
50
|
if response and response[:value]
|
71
51
|
ad_group = response[:value].first
|
72
|
-
puts "Ad group ID %d was successfully deleted
|
73
|
-
[ad_group[:id], ad_group[:name]]
|
52
|
+
puts "Ad group ID %d was successfully deleted." % [ad_group[:id]]
|
74
53
|
else
|
75
54
|
puts 'No ad group was updated.'
|
76
55
|
end
|
@@ -51,16 +51,11 @@ def delete_ad_group(ad_group_id)
|
|
51
51
|
raise StandardError, "Ad group with ID %d was not found." % ad_group_id
|
52
52
|
end
|
53
53
|
|
54
|
-
# We recommend renaming object on delete to avoid name conflicts later.
|
55
|
-
ad_group_name = result[:entries].first[:name]
|
56
|
-
ad_group_name += Time.now.strftime(" (deleted on %Y-%m-%d %H:%M:%S)")
|
57
|
-
|
58
54
|
# Prepare for deleting ad group.
|
59
55
|
operation = {
|
60
56
|
:operator => 'SET',
|
61
57
|
:operand => {
|
62
58
|
:id => ad_group_id,
|
63
|
-
:name => ad_group_name,
|
64
59
|
:status => 'DELETED'
|
65
60
|
}
|
66
61
|
}
|
@@ -69,15 +64,14 @@ def delete_ad_group(ad_group_id)
|
|
69
64
|
response = ad_group_srv.mutate([operation])
|
70
65
|
if response and response[:value]
|
71
66
|
ad_group = response[:value].first
|
72
|
-
puts "Ad group ID %d was successfully deleted
|
73
|
-
[ad_group[:id], ad_group[:name]]
|
67
|
+
puts "Ad group ID %d was successfully deleted." % [ad_group[:id]]
|
74
68
|
else
|
75
69
|
puts 'No ad group was updated.'
|
76
70
|
end
|
77
71
|
end
|
78
72
|
|
79
73
|
if __FILE__ == $0
|
80
|
-
API_VERSION = :
|
74
|
+
API_VERSION = :v201402
|
81
75
|
|
82
76
|
begin
|
83
77
|
# ID of an ad group to delete.
|
@@ -36,32 +36,12 @@ def delete_campaign(campaign_id)
|
|
36
36
|
|
37
37
|
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
38
38
|
|
39
|
-
# Retrieve the campaign to obtain its name. This is optional but recommended
|
40
|
-
# to keep deleted objects searchable. In production the name is already known
|
41
|
-
# in most cases.
|
42
|
-
selector = {
|
43
|
-
:fields => ['Id', 'Name'],
|
44
|
-
:predicates => [
|
45
|
-
{:field => 'Id', :operator => 'EQUALS', :values => [campaign_id]}
|
46
|
-
]
|
47
|
-
}
|
48
|
-
result = campaign_srv.get(selector)
|
49
|
-
|
50
|
-
if result.nil? or result[:entries].empty?
|
51
|
-
raise StandardError, "Campaign with ID %d was not found." % campaign_id
|
52
|
-
end
|
53
|
-
|
54
|
-
# We recommend renaming object on delete to avoid name conflicts later.
|
55
|
-
campaign_name = result[:entries].first[:name]
|
56
|
-
campaign_name += Time.now.strftime(" (deleted on %Y-%m-%d %H:%M:%S)")
|
57
|
-
|
58
39
|
# Prepare for deleting campaign.
|
59
40
|
operation = {
|
60
41
|
:operator => 'SET',
|
61
42
|
:operand => {
|
62
43
|
:id => campaign_id,
|
63
|
-
:
|
64
|
-
:status => 'DELETED',
|
44
|
+
:status => 'DELETED'
|
65
45
|
}
|
66
46
|
}
|
67
47
|
|
@@ -70,8 +50,7 @@ def delete_campaign(campaign_id)
|
|
70
50
|
|
71
51
|
if response and response[:value]
|
72
52
|
campaign = response[:value].first
|
73
|
-
puts "Campaign ID %d was
|
74
|
-
[campaign[:id], campaign[:name]]
|
53
|
+
puts "Campaign ID %d was deleted." % [campaign[:id]]
|
75
54
|
else
|
76
55
|
puts 'No campaign was updated.'
|
77
56
|
end
|
@@ -18,14 +18,14 @@
|
|
18
18
|
# See the License for the specific language governing permissions and
|
19
19
|
# limitations under the License.
|
20
20
|
#
|
21
|
-
# This example
|
22
|
-
#
|
21
|
+
# This example deletes a campaign by setting the status to 'DELETED'. To get
|
22
|
+
# campaigns, run get_campaigns.rb.
|
23
23
|
#
|
24
24
|
# Tags: CampaignService.mutate
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
def
|
28
|
+
def delete_campaign(campaign_id)
|
29
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
30
|
# when called without parameters.
|
31
31
|
adwords = AdwordsApi::Api.new
|
@@ -36,33 +36,34 @@ def update_campaign(campaign_id)
|
|
36
36
|
|
37
37
|
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
38
38
|
|
39
|
-
# Prepare for
|
39
|
+
# Prepare for deleting campaign.
|
40
40
|
operation = {
|
41
41
|
:operator => 'SET',
|
42
42
|
:operand => {
|
43
43
|
:id => campaign_id,
|
44
|
-
:status => '
|
44
|
+
:status => 'DELETED'
|
45
45
|
}
|
46
46
|
}
|
47
47
|
|
48
|
-
#
|
48
|
+
# Delete campaign.
|
49
49
|
response = campaign_srv.mutate([operation])
|
50
|
+
|
50
51
|
if response and response[:value]
|
51
52
|
campaign = response[:value].first
|
52
|
-
puts "Campaign ID %d was
|
53
|
-
[campaign[:id], campaign[:
|
53
|
+
puts "Campaign ID %d was renamed to '%s' and deleted." %
|
54
|
+
[campaign[:id], campaign[:name]]
|
54
55
|
else
|
55
|
-
puts 'No
|
56
|
+
puts 'No campaign was updated.'
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
60
|
if __FILE__ == $0
|
60
|
-
API_VERSION = :
|
61
|
+
API_VERSION = :v201402
|
61
62
|
|
62
63
|
begin
|
63
|
-
# ID of a campaign to
|
64
|
+
# ID of a campaign to delete.
|
64
65
|
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
65
|
-
|
66
|
+
delete_campaign(campaign_id)
|
66
67
|
|
67
68
|
# Authorization error.
|
68
69
|
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
@@ -36,31 +36,11 @@ def remove_ad_group(ad_group_id)
|
|
36
36
|
|
37
37
|
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
38
38
|
|
39
|
-
# Retrieve the ad group to obtain its name. This is optional but recommended
|
40
|
-
# to keep remove objects searchable. In production the name is already known
|
41
|
-
# in most cases.
|
42
|
-
selector = {
|
43
|
-
:fields => ['Id', 'Name'],
|
44
|
-
:predicates => [
|
45
|
-
{:field => 'Id', :operator => 'EQUALS', :values => [ad_group_id]}
|
46
|
-
]
|
47
|
-
}
|
48
|
-
result = ad_group_srv.get(selector)
|
49
|
-
|
50
|
-
if result.nil? or result[:entries].empty?
|
51
|
-
raise StandardError, "Ad group with ID %d was not found." % ad_group_id
|
52
|
-
end
|
53
|
-
|
54
|
-
# We recommend renaming object on remove to avoid name conflicts later.
|
55
|
-
ad_group_name = result[:entries].first[:name]
|
56
|
-
ad_group_name += Time.now.strftime(" (removed on %Y-%m-%d %H:%M:%S)")
|
57
|
-
|
58
39
|
# Prepare for deleting ad group.
|
59
40
|
operation = {
|
60
41
|
:operator => 'SET',
|
61
42
|
:operand => {
|
62
43
|
:id => ad_group_id,
|
63
|
-
:name => ad_group_name,
|
64
44
|
:status => 'REMOVED'
|
65
45
|
}
|
66
46
|
}
|
@@ -69,8 +49,7 @@ def remove_ad_group(ad_group_id)
|
|
69
49
|
response = ad_group_srv.mutate([operation])
|
70
50
|
if response and response[:value]
|
71
51
|
ad_group = response[:value].first
|
72
|
-
puts "Ad group ID %d was successfully removed
|
73
|
-
[ad_group[:id], ad_group[:name]]
|
52
|
+
puts "Ad group ID %d was successfully removed." % [ad_group[:id]]
|
74
53
|
else
|
75
54
|
puts 'No ad group was updated.'
|
76
55
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# Encoding: utf-8
|
3
3
|
#
|
4
|
-
# Author:: api.
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
5
|
#
|
6
6
|
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
7
|
#
|
@@ -18,14 +18,14 @@
|
|
18
18
|
# See the License for the specific language governing permissions and
|
19
19
|
# limitations under the License.
|
20
20
|
#
|
21
|
-
# This example
|
22
|
-
#
|
21
|
+
# This example removes an ad group by setting the status to 'REMOVED'. To get ad
|
22
|
+
# groups, run get_ad_groups.rb.
|
23
23
|
#
|
24
24
|
# Tags: AdGroupService.mutate
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
def
|
28
|
+
def remove_ad_group(ad_group_id)
|
29
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
30
|
# when called without parameters.
|
31
31
|
adwords = AdwordsApi::Api.new
|
@@ -36,32 +36,33 @@ def update_ad_group(ad_group_id)
|
|
36
36
|
|
37
37
|
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
38
38
|
|
39
|
-
# Prepare for
|
39
|
+
# Prepare for deleting ad group.
|
40
40
|
operation = {
|
41
41
|
:operator => 'SET',
|
42
42
|
:operand => {
|
43
|
-
:
|
44
|
-
:
|
43
|
+
:id => ad_group_id,
|
44
|
+
:status => 'REMOVED'
|
45
45
|
}
|
46
46
|
}
|
47
47
|
|
48
|
-
#
|
48
|
+
# Remove ad group.
|
49
49
|
response = ad_group_srv.mutate([operation])
|
50
50
|
if response and response[:value]
|
51
51
|
ad_group = response[:value].first
|
52
|
-
puts
|
52
|
+
puts "Ad group ID %d was successfully removed." %
|
53
|
+
[ad_group[:id]]
|
53
54
|
else
|
54
|
-
puts 'No ad
|
55
|
+
puts 'No ad group was updated.'
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
58
59
|
if __FILE__ == $0
|
59
|
-
API_VERSION = :
|
60
|
+
API_VERSION = :v201406
|
60
61
|
|
61
62
|
begin
|
62
|
-
# ID of an ad group to
|
63
|
+
# ID of an ad group to remove.
|
63
64
|
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
64
|
-
|
65
|
+
remove_ad_group(ad_group_id)
|
65
66
|
|
66
67
|
# Authorization error.
|
67
68
|
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
@@ -36,32 +36,12 @@ def remove_campaign(campaign_id)
|
|
36
36
|
|
37
37
|
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
38
38
|
|
39
|
-
|
40
|
-
# to keep removed objects searchable. In production the name is already known
|
41
|
-
# in most cases.
|
42
|
-
selector = {
|
43
|
-
:fields => ['Id', 'Name'],
|
44
|
-
:predicates => [
|
45
|
-
{:field => 'Id', :operator => 'EQUALS', :values => [campaign_id]}
|
46
|
-
]
|
47
|
-
}
|
48
|
-
result = campaign_srv.get(selector)
|
49
|
-
|
50
|
-
if result.nil? or result[:entries].empty?
|
51
|
-
raise StandardError, "Campaign with ID %d was not found." % campaign_id
|
52
|
-
end
|
53
|
-
|
54
|
-
# We recommend renaming object on remove to avoid name conflicts later.
|
55
|
-
campaign_name = result[:entries].first[:name]
|
56
|
-
campaign_name += Time.now.strftime(" (removed on %Y-%m-%d %H:%M:%S)")
|
57
|
-
|
58
|
-
# Prepare for deleting campaign.
|
39
|
+
# Prepare for deleting campaign.
|
59
40
|
operation = {
|
60
41
|
:operator => 'SET',
|
61
42
|
:operand => {
|
62
43
|
:id => campaign_id,
|
63
|
-
|
64
|
-
:status => 'REMOVED',
|
44
|
+
:status => 'REMOVED'
|
65
45
|
}
|
66
46
|
}
|
67
47
|
|
@@ -70,8 +50,8 @@ def remove_campaign(campaign_id)
|
|
70
50
|
|
71
51
|
if response and response[:value]
|
72
52
|
campaign = response[:value].first
|
73
|
-
puts "Campaign ID %d was
|
74
|
-
[campaign[:id]
|
53
|
+
puts "Campaign ID %d was removed." %
|
54
|
+
[campaign[:id]]
|
75
55
|
else
|
76
56
|
puts 'No campaign was updated.'
|
77
57
|
end
|
@@ -18,14 +18,14 @@
|
|
18
18
|
# See the License for the specific language governing permissions and
|
19
19
|
# limitations under the License.
|
20
20
|
#
|
21
|
-
# This example
|
21
|
+
# This example removes a campaign by setting the status to 'REMOVED'. To get
|
22
22
|
# campaigns, run get_campaigns.rb.
|
23
23
|
#
|
24
24
|
# Tags: CampaignService.mutate
|
25
25
|
|
26
26
|
require 'adwords_api'
|
27
27
|
|
28
|
-
def
|
28
|
+
def remove_campaign(campaign_id)
|
29
29
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
30
|
# when called without parameters.
|
31
31
|
adwords = AdwordsApi::Api.new
|
@@ -37,7 +37,7 @@ def delete_campaign(campaign_id)
|
|
37
37
|
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
38
38
|
|
39
39
|
# Retrieve the campaign to obtain its name. This is optional but recommended
|
40
|
-
# to keep
|
40
|
+
# to keep removed objects searchable. In production the name is already known
|
41
41
|
# in most cases.
|
42
42
|
selector = {
|
43
43
|
:fields => ['Id', 'Name'],
|
@@ -51,9 +51,9 @@ def delete_campaign(campaign_id)
|
|
51
51
|
raise StandardError, "Campaign with ID %d was not found." % campaign_id
|
52
52
|
end
|
53
53
|
|
54
|
-
# We recommend renaming object on
|
54
|
+
# We recommend renaming object on remove to avoid name conflicts later.
|
55
55
|
campaign_name = result[:entries].first[:name]
|
56
|
-
campaign_name += Time.now.strftime(" (
|
56
|
+
campaign_name += Time.now.strftime(" (removed on %Y-%m-%d %H:%M:%S)")
|
57
57
|
|
58
58
|
# Prepare for deleting campaign.
|
59
59
|
operation = {
|
@@ -61,16 +61,16 @@ def delete_campaign(campaign_id)
|
|
61
61
|
:operand => {
|
62
62
|
:id => campaign_id,
|
63
63
|
:name => campaign_name,
|
64
|
-
:status => '
|
64
|
+
:status => 'REMOVED',
|
65
65
|
}
|
66
66
|
}
|
67
67
|
|
68
|
-
#
|
68
|
+
# Remove campaign.
|
69
69
|
response = campaign_srv.mutate([operation])
|
70
70
|
|
71
71
|
if response and response[:value]
|
72
72
|
campaign = response[:value].first
|
73
|
-
puts "Campaign ID %d was renamed to '%s' and
|
73
|
+
puts "Campaign ID %d was renamed to '%s' and removed." %
|
74
74
|
[campaign[:id], campaign[:name]]
|
75
75
|
else
|
76
76
|
puts 'No campaign was updated.'
|
@@ -78,12 +78,12 @@ def delete_campaign(campaign_id)
|
|
78
78
|
end
|
79
79
|
|
80
80
|
if __FILE__ == $0
|
81
|
-
API_VERSION = :
|
81
|
+
API_VERSION = :v201406
|
82
82
|
|
83
83
|
begin
|
84
|
-
# ID of a campaign to
|
84
|
+
# ID of a campaign to remove.
|
85
85
|
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
86
|
-
|
86
|
+
remove_campaign(campaign_id)
|
87
87
|
|
88
88
|
# Authorization error.
|
89
89
|
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|