google-adx-buyer-api 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/README +43 -41
- data/Rakefile +3 -3
- data/examples/v201003/add_ad_group.rb +5 -5
- data/examples/v201003/add_ad_group_criteria.rb +5 -5
- data/examples/v201003/add_ads.rb +5 -5
- data/examples/v201003/add_campaign.rb +5 -5
- data/examples/v201003/add_negative_campaign_criterion.rb +5 -5
- data/examples/v201003/add_placement_performance_report_definition.rb +5 -5
- data/examples/v201003/check_campaigns.rb +5 -5
- data/examples/v201003/delete_ad.rb +5 -5
- data/examples/v201003/delete_ad_group.rb +5 -5
- data/examples/v201003/delete_ad_group_criterion.rb +5 -5
- data/examples/v201003/delete_campaign.rb +5 -5
- data/examples/v201003/download_report.rb +5 -0
- data/examples/v201003/get_all_active_ad_group_criteria.rb +5 -5
- data/examples/v201003/get_all_ad_group_criteria.rb +5 -5
- data/examples/v201003/get_all_ad_groups.rb +5 -5
- data/examples/v201003/get_all_ads.rb +5 -5
- data/examples/v201003/get_all_campaign_targets.rb +5 -5
- data/examples/v201003/get_all_campaigns.rb +5 -5
- data/examples/v201003/get_all_disapproved_ads.rb +5 -5
- data/examples/v201003/get_all_images.rb +5 -5
- data/examples/v201003/get_all_paused_campaigns.rb +5 -5
- data/examples/v201003/get_all_report_definitions.rb +5 -5
- data/examples/v201003/get_criterion_bid_landscape.rb +5 -5
- data/examples/v201003/get_geo_location_info.rb +5 -5
- data/examples/v201003/get_related_placements.rb +5 -5
- data/examples/v201003/get_report_fields.rb +5 -5
- data/examples/v201003/perform_bulk_mutate_job.rb +5 -5
- data/examples/v201003/set_campaign_targets.rb +5 -5
- data/examples/v201003/update_ad.rb +5 -5
- data/examples/v201003/update_ad_group.rb +5 -5
- data/examples/v201003/update_ad_group_criterion.rb +5 -5
- data/examples/v201003/update_campaign.rb +5 -5
- data/examples/v201003/upload_image.rb +5 -5
- data/examples/v201008/add_ad_group.rb +5 -5
- data/examples/v201008/add_ad_group_criteria.rb +5 -5
- data/examples/v201008/add_ads.rb +5 -5
- data/examples/v201008/add_campaign.rb +5 -5
- data/examples/v201008/add_negative_campaign_criterion.rb +5 -5
- data/examples/v201008/add_placement_performance_report_definition.rb +5 -5
- data/examples/v201008/add_user_list.rb +5 -5
- data/examples/v201008/check_campaigns.rb +5 -5
- data/examples/v201008/delete_ad.rb +5 -5
- data/examples/v201008/delete_ad_group.rb +5 -5
- data/examples/v201008/delete_ad_group_criterion.rb +5 -5
- data/examples/v201008/delete_bulk_mutate_job.rb +5 -5
- data/examples/v201008/delete_campaign.rb +5 -5
- data/examples/v201008/delete_user_list.rb +5 -5
- data/examples/v201008/download_report.rb +5 -0
- data/examples/v201008/get_all_account_changes.rb +5 -5
- data/examples/v201008/get_all_active_ad_group_criteria.rb +5 -5
- data/examples/v201008/get_all_ad_group_criteria.rb +5 -5
- data/examples/v201008/get_all_ad_groups.rb +5 -5
- data/examples/v201008/get_all_ads.rb +5 -5
- data/examples/v201008/get_all_campaign_targets.rb +5 -5
- data/examples/v201008/get_all_campaigns.rb +5 -5
- data/examples/v201008/get_all_disapproved_ads.rb +5 -5
- data/examples/v201008/get_all_images.rb +5 -5
- data/examples/v201008/get_all_paused_campaigns.rb +5 -5
- data/examples/v201008/get_all_report_definitions.rb +5 -5
- data/examples/v201008/get_all_user_lists.rb +5 -5
- data/examples/v201008/get_bulk_mutate_job.rb +5 -5
- data/examples/v201008/get_campaign_alerts.rb +5 -5
- data/examples/v201008/get_criterion_bid_landscape.rb +5 -5
- data/examples/v201008/get_geo_location_info.rb +5 -5
- data/examples/v201008/get_related_placements.rb +5 -5
- data/examples/v201008/get_report_fields.rb +5 -5
- data/examples/v201008/perform_bulk_mutate_job.rb +5 -5
- data/examples/v201008/set_campaign_targets.rb +5 -5
- data/examples/v201008/update_ad.rb +5 -5
- data/examples/v201008/update_ad_group.rb +5 -5
- data/examples/v201008/update_ad_group_criterion.rb +5 -5
- data/examples/v201008/update_campaign.rb +5 -5
- data/examples/v201008/update_user_list.rb +5 -5
- data/examples/v201008/upload_image.rb +5 -5
- data/examples/v201101/add_ad_group.rb +5 -5
- data/examples/v201101/add_ad_group_criteria.rb +5 -5
- data/examples/v201101/add_ads.rb +5 -5
- data/examples/v201101/add_campaign.rb +5 -5
- data/examples/v201101/add_conversion.rb +5 -5
- data/examples/v201101/add_negative_campaign_criterion.rb +5 -5
- data/examples/v201101/add_placement_performance_report_definition.rb +5 -5
- data/examples/v201101/add_rtb_campaign.rb +5 -5
- data/examples/v201101/add_user_list.rb +5 -5
- data/examples/v201101/check_campaigns.rb +5 -5
- data/examples/v201101/delete_ad.rb +5 -5
- data/examples/v201101/delete_ad_group.rb +5 -5
- data/examples/v201101/delete_ad_group_criterion.rb +5 -5
- data/examples/v201101/delete_bulk_mutate_job.rb +5 -5
- data/examples/v201101/delete_campaign.rb +5 -5
- data/examples/v201101/delete_user_list.rb +5 -5
- data/examples/v201101/download_report.rb +5 -0
- data/examples/v201101/get_ad_group_bid_landscape.rb +5 -5
- data/examples/v201101/get_all_account_changes.rb +5 -5
- data/examples/v201101/get_all_active_ad_group_criteria.rb +5 -5
- data/examples/v201101/get_all_ad_group_criteria.rb +5 -5
- data/examples/v201101/get_all_ad_groups.rb +5 -5
- data/examples/v201101/get_all_ads.rb +5 -5
- data/examples/v201101/get_all_campaign_targets.rb +5 -5
- data/examples/v201101/get_all_campaigns.rb +5 -5
- data/examples/v201101/get_all_conversions.rb +5 -5
- data/examples/v201101/get_all_disapproved_ads.rb +5 -5
- data/examples/v201101/get_all_images.rb +5 -5
- data/examples/v201101/get_all_paused_campaigns.rb +5 -5
- data/examples/v201101/get_all_report_definitions.rb +5 -5
- data/examples/v201101/get_all_user_lists.rb +5 -5
- data/examples/v201101/get_bulk_mutate_job.rb +5 -5
- data/examples/v201101/get_campaign_alerts.rb +5 -5
- data/examples/v201101/get_criterion_bid_landscape.rb +5 -5
- data/examples/v201101/get_geo_location_info.rb +5 -5
- data/examples/v201101/get_related_placements.rb +5 -5
- data/examples/v201101/get_report_fields.rb +5 -5
- data/examples/v201101/perform_bulk_mutate_job.rb +5 -5
- data/examples/v201101/set_campaign_targets.rb +5 -5
- data/examples/v201101/update_ad.rb +5 -5
- data/examples/v201101/update_ad_group.rb +5 -5
- data/examples/v201101/update_ad_group_criterion.rb +5 -5
- data/examples/v201101/update_campaign.rb +5 -5
- data/examples/v201101/update_conversion.rb +5 -5
- data/examples/v201101/update_user_list.rb +5 -5
- data/examples/v201101/upload_image.rb +5 -5
- data/examples/v201109/add_ad_group.rb +98 -0
- data/examples/v201109/add_ad_group_criteria.rb +100 -0
- data/examples/v201109/add_ads.rb +110 -0
- data/examples/v201109/add_campaign.rb +108 -0
- data/examples/v201109/add_campaign_targeting_criteria.rb +102 -0
- data/examples/v201109/add_conversion.rb +97 -0
- data/examples/{v201008/get_all_experiments.rb → v201109/add_negative_campaign_criterion.rb} +32 -30
- data/examples/v201109/add_rtb_campaign.rb +113 -0
- data/examples/v201109/add_user_list.rb +122 -0
- data/examples/v201109/check_campaigns.rb +132 -0
- data/examples/v201109/delete_ad.rb +94 -0
- data/examples/{v201101/delete_experiment.rb → v201109/delete_ad_group.rb} +20 -21
- data/examples/v201109/delete_ad_group_criterion.rb +95 -0
- data/examples/v201109/delete_bulk_mutate_job.rb +96 -0
- data/examples/{v201008/delete_experiment.rb → v201109/delete_campaign.rb} +21 -21
- data/examples/{v201008/promote_experiment.rb → v201109/delete_user_list.rb} +21 -22
- data/examples/v201109/download_adhoc_report.rb +79 -0
- data/examples/v201109/download_report.rb +76 -0
- data/examples/v201109/get_ad_group_bid_landscape.rb +103 -0
- data/examples/v201109/get_all_account_changes.rb +146 -0
- data/examples/v201109/get_all_active_ad_group_criteria.rb +106 -0
- data/examples/v201109/get_all_ad_group_criteria.rb +98 -0
- data/examples/{v201101/get_all_experiments.rb → v201109/get_all_ad_groups.rb} +21 -25
- data/examples/v201109/get_all_ads.rb +99 -0
- data/examples/v201109/get_all_campaign_targets.rb +83 -0
- data/examples/v201109/get_all_campaigns.rb +86 -0
- data/examples/v201109/get_all_carriers.rb +72 -0
- data/examples/v201109/get_all_conversions.rb +88 -0
- data/examples/v201109/get_all_disapproved_ads.rb +102 -0
- data/examples/v201109/get_all_images.rb +90 -0
- data/examples/v201109/get_all_languages.rb +73 -0
- data/examples/v201109/get_all_paused_campaigns.rb +92 -0
- data/examples/v201109/get_all_report_definitions.rb +84 -0
- data/examples/v201109/get_all_user_lists.rb +87 -0
- data/examples/v201109/get_bulk_mutate_job.rb +106 -0
- data/examples/v201109/get_campaign_alerts.rb +103 -0
- data/examples/v201109/get_client_customer_id.rb +87 -0
- data/examples/v201109/get_criterion_bid_landscape.rb +102 -0
- data/examples/v201109/get_geo_location_info.rb +108 -0
- data/examples/v201109/get_location_criteria.rb +103 -0
- data/examples/v201109/get_related_placements.rb +114 -0
- data/examples/v201109/get_report_fields.rb +81 -0
- data/examples/v201109/perform_bulk_mutate_job.rb +222 -0
- data/examples/v201109/perform_mutate_job.rb +151 -0
- data/examples/{v201101/promote_experiment.rb → v201109/update_ad.rb} +29 -22
- data/examples/v201109/update_ad_group.rb +90 -0
- data/examples/v201109/update_ad_group_criterion.rb +108 -0
- data/examples/v201109/update_campaign.rb +93 -0
- data/examples/v201109/update_conversion.rb +96 -0
- data/examples/v201109/update_user_list.rb +91 -0
- data/examples/v201109/upload_image.rb +97 -0
- metadata +164 -114
- data/examples/v201008/add_experiment.rb +0 -162
- data/examples/v201101/add_experiment.rb +0 -162
@@ -17,49 +17,48 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
|
-
# This example deletes an
|
21
|
-
#
|
20
|
+
# This example deletes an ad group by setting the status to 'DELETED'.
|
21
|
+
# To get ad groups, run get_all_ad_groups.rb.
|
22
22
|
#
|
23
|
-
# Tags:
|
23
|
+
# Tags: AdGroupService.mutate
|
24
24
|
|
25
25
|
require 'rubygems'
|
26
26
|
gem 'google-adwords-api'
|
27
27
|
require 'adwords_api'
|
28
28
|
|
29
|
-
API_VERSION = :
|
29
|
+
API_VERSION = :v201109
|
30
30
|
|
31
|
-
def
|
31
|
+
def delete_ad_group()
|
32
32
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
33
|
# when called without parameters.
|
34
34
|
adwords = AdwordsApi::Api.new
|
35
|
-
experiment_srv = adwords.service(:ExperimentService, API_VERSION)
|
36
35
|
|
37
|
-
|
36
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
37
|
+
# the configuration file or provide your own logger:
|
38
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
38
39
|
|
39
|
-
|
40
|
+
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
41
|
+
|
42
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
43
|
+
|
44
|
+
# Prepare for deleting ad group.
|
40
45
|
operation = {
|
41
46
|
:operator => 'SET',
|
42
47
|
:operand => {
|
43
|
-
:
|
44
|
-
:
|
48
|
+
:status => 'DELETED',
|
49
|
+
:id => ad_group_id
|
45
50
|
}
|
46
51
|
}
|
47
52
|
|
48
|
-
# Delete
|
49
|
-
response =
|
50
|
-
|
51
|
-
puts '
|
52
|
-
[experiment[:name], experiment[:id]]
|
53
|
+
# Delete ad group.
|
54
|
+
response = ad_group_srv.mutate([operation])
|
55
|
+
ad_group = response[:value].first
|
56
|
+
puts 'Ad group id %d was successfully deleted.' % ad_group[:id]
|
53
57
|
end
|
54
58
|
|
55
59
|
if __FILE__ == $0
|
56
|
-
# To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
|
57
|
-
# variable to 'true'. This can be done either from your operating system
|
58
|
-
# environment or via code, as done below.
|
59
|
-
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
60
|
-
|
61
60
|
begin
|
62
|
-
|
61
|
+
delete_ad_group()
|
63
62
|
|
64
63
|
# Connection error. Likely transitory.
|
65
64
|
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: api.sgomes@gmail.com (Sérgio Gomes)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# This example deletes an ad group criterion using the 'REMOVE' operator. To
|
21
|
+
# get ad group criteria, run get_all_ad_group_criteria.rb.
|
22
|
+
#
|
23
|
+
# Tags: AdGroupCriterionService.mutate
|
24
|
+
|
25
|
+
require 'rubygems'
|
26
|
+
gem 'google-adwords-api'
|
27
|
+
require 'adwords_api'
|
28
|
+
|
29
|
+
API_VERSION = :v201109
|
30
|
+
|
31
|
+
def delete_ad_group_criterion()
|
32
|
+
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
|
+
# when called without parameters.
|
34
|
+
adwords = AdwordsApi::Api.new
|
35
|
+
|
36
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
37
|
+
# the configuration file or provide your own logger:
|
38
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
39
|
+
|
40
|
+
ad_group_criterion_srv =
|
41
|
+
adwords.service(:AdGroupCriterionService, API_VERSION)
|
42
|
+
|
43
|
+
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
44
|
+
criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i
|
45
|
+
|
46
|
+
# Prepare for deleting ad group criterion.
|
47
|
+
operation = {
|
48
|
+
:operator => 'REMOVE',
|
49
|
+
:operand => {
|
50
|
+
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
51
|
+
# being created. It's only necessary when you must provide an explicit
|
52
|
+
# type that the client library can't infer.
|
53
|
+
:xsi_type => 'BiddableAdGroupCriterion',
|
54
|
+
:ad_group_id => ad_group_id,
|
55
|
+
:criterion => {
|
56
|
+
:id => criterion_id
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
# Delete criterion.
|
62
|
+
response = ad_group_criterion_srv.mutate([operation])
|
63
|
+
ad_group_criterion = response[:value].first
|
64
|
+
puts 'Criterion id %d was successfully deleted.' %
|
65
|
+
ad_group_criterion[:criterion][:id]
|
66
|
+
end
|
67
|
+
|
68
|
+
if __FILE__ == $0
|
69
|
+
begin
|
70
|
+
delete_ad_group_criterion()
|
71
|
+
|
72
|
+
# Connection error. Likely transitory.
|
73
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
74
|
+
puts 'Connection Error: %s' % e
|
75
|
+
puts 'Source: %s' % e.backtrace.first
|
76
|
+
|
77
|
+
# API Error.
|
78
|
+
rescue AdwordsApi::Errors::ApiException => e
|
79
|
+
puts 'API Exception caught.'
|
80
|
+
puts 'Message: %s' % e.message
|
81
|
+
puts 'Code: %d' % e.code if e.code
|
82
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
83
|
+
puts 'Errors:'
|
84
|
+
if e.errors
|
85
|
+
e.errors.each_with_index do |error, index|
|
86
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
87
|
+
error.each_pair do |field, value|
|
88
|
+
if field != :xsi_type
|
89
|
+
puts ' %s: %s' % [field, value]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: sgomes@google.com (Sérgio Gomes)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# This example deletes a bulk mutate job using the 'REMOVE' operator. Jobs may
|
21
|
+
# only deleted if they are in the 'PENDING' state and have not yet recieved
|
22
|
+
# all of their request parts. To get bulk mutate jobs, run
|
23
|
+
# get_all_bulk_mutate_jobs.rb.
|
24
|
+
#
|
25
|
+
# Tags: BulkMutateJobService.mutate
|
26
|
+
|
27
|
+
require 'rubygems'
|
28
|
+
gem 'google-adwords-api'
|
29
|
+
require 'adwords_api'
|
30
|
+
|
31
|
+
API_VERSION = :v201109
|
32
|
+
|
33
|
+
def delete_bulk_mutate_job()
|
34
|
+
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
35
|
+
# when called without parameters.
|
36
|
+
adwords = AdwordsApi::Api.new
|
37
|
+
|
38
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
39
|
+
# the configuration file or provide your own logger:
|
40
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
41
|
+
|
42
|
+
bulk_mutate_job_srv = adwords.service(:BulkMutateJobService, API_VERSION)
|
43
|
+
|
44
|
+
job_id = 'INSERT_BULK_MUTATE_JOB_ID_HERE'
|
45
|
+
|
46
|
+
# Create operation.
|
47
|
+
operation = {
|
48
|
+
:operator => 'REMOVE',
|
49
|
+
:operand => {
|
50
|
+
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
51
|
+
# being created. It's only necessary when you must provide an explicit
|
52
|
+
# type that the client library can't infer.
|
53
|
+
:xsi_type => 'BulkMutateJob',
|
54
|
+
:id => job_id
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
# Delete job.
|
59
|
+
response = bulk_mutate_job_srv.mutate(operation)
|
60
|
+
if response and response[:value]
|
61
|
+
job = response[:value].first
|
62
|
+
puts 'Job id %d was successfully deleted.' % job[:id]
|
63
|
+
else
|
64
|
+
puts 'No jobs were deleted.'
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
if __FILE__ == $0
|
70
|
+
begin
|
71
|
+
delete_bulk_mutate_job()
|
72
|
+
|
73
|
+
# Connection error. Likely transitory.
|
74
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
75
|
+
puts 'Connection Error: %s' % e
|
76
|
+
puts 'Source: %s' % e.backtrace.first
|
77
|
+
|
78
|
+
# API Error.
|
79
|
+
rescue AdwordsApi::Errors::ApiException => e
|
80
|
+
puts 'API Exception caught.'
|
81
|
+
puts 'Message: %s' % e.message
|
82
|
+
puts 'Code: %d' % e.code if e.code
|
83
|
+
puts 'Trigger: %s' % e.trigger if e.trigger
|
84
|
+
puts 'Errors:'
|
85
|
+
if e.errors
|
86
|
+
e.errors.each_with_index do |error, index|
|
87
|
+
puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
|
88
|
+
error.each_pair do |field, value|
|
89
|
+
if field != :xsi_type
|
90
|
+
puts ' %s: %s' % [field, value]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -17,49 +17,49 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
|
-
# This example deletes
|
21
|
-
#
|
20
|
+
# This example deletes a campaign by setting the status to 'DELETED'. To get
|
21
|
+
# campaigns, run get_all_campaigns.rb.
|
22
22
|
#
|
23
|
-
# Tags:
|
23
|
+
# Tags: CampaignService.mutate
|
24
24
|
|
25
25
|
require 'rubygems'
|
26
26
|
gem 'google-adwords-api'
|
27
27
|
require 'adwords_api'
|
28
28
|
|
29
|
-
API_VERSION = :
|
29
|
+
API_VERSION = :v201109
|
30
30
|
|
31
|
-
def
|
31
|
+
def delete_campaign()
|
32
32
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
33
33
|
# when called without parameters.
|
34
34
|
adwords = AdwordsApi::Api.new
|
35
|
-
experiment_srv = adwords.service(:ExperimentService, API_VERSION)
|
36
35
|
|
37
|
-
|
36
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
37
|
+
# the configuration file or provide your own logger:
|
38
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
38
39
|
|
39
|
-
|
40
|
+
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
41
|
+
|
42
|
+
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
43
|
+
|
44
|
+
# Prepare for deleting campaign.
|
40
45
|
operation = {
|
41
46
|
:operator => 'SET',
|
42
47
|
:operand => {
|
43
|
-
:id =>
|
44
|
-
:status => 'DELETED'
|
48
|
+
:id => campaign_id,
|
49
|
+
:status => 'DELETED',
|
45
50
|
}
|
46
51
|
}
|
47
52
|
|
48
|
-
# Delete
|
49
|
-
response =
|
50
|
-
|
51
|
-
puts '
|
52
|
-
[
|
53
|
+
# Delete campaign.
|
54
|
+
response = campaign_srv.mutate([operation])
|
55
|
+
campaign = response[:value].first
|
56
|
+
puts 'Campaign with name "%s" and id %d was deleted.' %
|
57
|
+
[campaign[:name], campaign[:id]]
|
53
58
|
end
|
54
59
|
|
55
60
|
if __FILE__ == $0
|
56
|
-
# To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
|
57
|
-
# variable to 'true'. This can be done either from your operating system
|
58
|
-
# environment or via code, as done below.
|
59
|
-
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
60
|
-
|
61
61
|
begin
|
62
|
-
|
62
|
+
delete_campaign()
|
63
63
|
|
64
64
|
# Connection error. Likely transitory.
|
65
65
|
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
@@ -17,50 +17,49 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
|
-
# This example
|
21
|
-
#
|
22
|
-
# experiments, run get_all_experiments.rb.
|
20
|
+
# This example deletes a user list by setting the status to 'CLOSED'. To get
|
21
|
+
# user lists, run get_all_user_lists.rb.
|
23
22
|
#
|
24
|
-
# Tags:
|
23
|
+
# Tags: UserListService.mutate
|
25
24
|
|
26
25
|
require 'rubygems'
|
27
26
|
gem 'google-adwords-api'
|
28
27
|
require 'adwords_api'
|
29
28
|
|
30
|
-
API_VERSION = :
|
29
|
+
API_VERSION = :v201109
|
31
30
|
|
32
|
-
def
|
31
|
+
def delete_user_list()
|
33
32
|
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
34
33
|
# when called without parameters.
|
35
34
|
adwords = AdwordsApi::Api.new
|
36
|
-
experiment_srv = adwords.service(:ExperimentService, API_VERSION)
|
37
35
|
|
38
|
-
|
36
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
37
|
+
# the configuration file or provide your own logger:
|
38
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
39
39
|
|
40
|
-
|
40
|
+
user_list_srv = adwords.service(:UserListService, API_VERSION)
|
41
|
+
|
42
|
+
user_list_id = 'INSERT_USER_LIST_ID_HERE'.to_i
|
43
|
+
|
44
|
+
# Prepare for deleting remarketing user list.
|
41
45
|
operation = {
|
42
46
|
:operator => 'SET',
|
43
47
|
:operand => {
|
44
|
-
:id =>
|
45
|
-
:status => '
|
48
|
+
:id => user_list_id,
|
49
|
+
:status => 'CLOSED'
|
46
50
|
}
|
47
51
|
}
|
48
52
|
|
49
|
-
#
|
50
|
-
response =
|
51
|
-
|
52
|
-
puts '
|
53
|
-
[
|
53
|
+
# Delete user list.
|
54
|
+
response = user_list_srv.mutate([operation])
|
55
|
+
user_list = response[:value].first
|
56
|
+
puts 'User list with name "%s" and id %d was deleted (closed).' %
|
57
|
+
[user_list[:name], user_list[:id]]
|
54
58
|
end
|
55
59
|
|
56
60
|
if __FILE__ == $0
|
57
|
-
# To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
|
58
|
-
# variable to 'true'. This can be done either from your operating system
|
59
|
-
# environment or via code, as done below.
|
60
|
-
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
61
|
-
|
62
61
|
begin
|
63
|
-
|
62
|
+
delete_user_list()
|
64
63
|
|
65
64
|
# Connection error. Likely transitory.
|
66
65
|
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
6
|
+
#
|
7
|
+
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# This example gets and downloads an Ad Hoc report from a XML report definition.
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'adwords_api'
|
24
|
+
|
25
|
+
API_VERSION = :v201109
|
26
|
+
|
27
|
+
def download_adhoc_report()
|
28
|
+
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
29
|
+
# when called without parameters.
|
30
|
+
adwords = AdwordsApi::Api.new
|
31
|
+
|
32
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
33
|
+
# the configuration file or provide your own logger:
|
34
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
35
|
+
|
36
|
+
# Get report utilities for the version.
|
37
|
+
report_utils = adwords.report_utils(API_VERSION)
|
38
|
+
|
39
|
+
# File name to write report to. To retrieve the report as return value, use
|
40
|
+
# "download_report" method.
|
41
|
+
file_name = 'INSERT_OUTPUT_FILE_NAME_HERE'
|
42
|
+
|
43
|
+
# Define report definition. You can also pass your own XML text as a string.
|
44
|
+
report_definition = {
|
45
|
+
:selector => {
|
46
|
+
:fields => ['CampaignId', 'Id', 'Impressions', 'Clicks', 'Cost'],
|
47
|
+
# Predicates are optional.
|
48
|
+
:predicates => {
|
49
|
+
:field => 'Status',
|
50
|
+
:operator => 'IN',
|
51
|
+
:values => ['ENABLED', 'PAUSED']
|
52
|
+
}
|
53
|
+
},
|
54
|
+
:report_name => 'Custom ADGROUP_PERFORMANCE_REPORT',
|
55
|
+
:report_type => 'ADGROUP_PERFORMANCE_REPORT',
|
56
|
+
:download_format => 'CSV',
|
57
|
+
:date_range_type => 'LAST_7_DAYS',
|
58
|
+
# Enable to get rows with zero impressions.
|
59
|
+
:include_zero_impressions => false
|
60
|
+
}
|
61
|
+
|
62
|
+
# Download report, using "download_report_as_file" utility method.
|
63
|
+
report_utils.download_report_as_file(report_definition, file_name)
|
64
|
+
puts "Report was downloaded to '%s'." % file_name
|
65
|
+
end
|
66
|
+
|
67
|
+
if __FILE__ == $0
|
68
|
+
begin
|
69
|
+
download_adhoc_report()
|
70
|
+
|
71
|
+
# HTTP errors.
|
72
|
+
rescue AdsCommon::Errors::HttpError => e
|
73
|
+
puts "HTTP Error: %s" % e
|
74
|
+
|
75
|
+
# API errors.
|
76
|
+
rescue AdwordsApi::Errors::ReportError => e
|
77
|
+
puts "Reporting Error: %s" % e.message
|
78
|
+
end
|
79
|
+
end
|