google-adwords-api 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README.md +5 -5
- data/adwords_api.yml +1 -9
- data/examples/v201402/advanced_operations/add_places_location_extensions.rb +0 -0
- data/examples/v201406/advanced_operations/add_ad_customizer.rb +277 -0
- data/examples/v201406/advanced_operations/add_places_location_extensions.rb +0 -0
- data/examples/v201406/advanced_operations/add_text_ad_with_upgraded_urls.rb +0 -0
- data/examples/v201406/campaign_management/add_campaign_labels.rb +0 -0
- data/examples/v201406/campaign_management/get_campaigns_by_label.rb +0 -0
- data/examples/v201406/misc/create_ad_words_session_without_properties_file.rb +0 -0
- data/examples/v201406/shopping_campaigns/add_product_partition_tree.rb +0 -0
- data/examples/v201406/shopping_campaigns/add_product_scope.rb +0 -0
- data/examples/v201406/shopping_campaigns/add_shopping_campaign.rb +0 -0
- data/examples/v201406/shopping_campaigns/get_product_category_taxonomy.rb +0 -0
- data/examples/v201406/shopping_campaigns/set_product_sales_channel.rb +0 -0
- data/lib/adwords_api.rb +0 -7
- data/lib/adwords_api/api_config.rb +5 -7
- data/lib/adwords_api/credential_handler.rb +0 -5
- data/lib/adwords_api/v201402/ad_group_ad_service.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_ad_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_bid_modifier_service.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_bid_modifier_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_criterion_service.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_criterion_service_registry.rb +2 -2
- data/lib/adwords_api/v201402/ad_group_feed_service.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_service.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/ad_param_service.rb +1 -1
- data/lib/adwords_api/v201402/ad_param_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/adwords_user_list_service.rb +1 -1
- data/lib/adwords_api/v201402/adwords_user_list_service_registry.rb +2 -2
- data/lib/adwords_api/v201402/alert_service.rb +1 -1
- data/lib/adwords_api/v201402/alert_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/bidding_strategy_service.rb +1 -1
- data/lib/adwords_api/v201402/bidding_strategy_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/budget_order_service.rb +1 -1
- data/lib/adwords_api/v201402/budget_order_service_registry.rb +2 -2
- data/lib/adwords_api/v201402/budget_service.rb +1 -1
- data/lib/adwords_api/v201402/budget_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/campaign_ad_extension_service.rb +1 -1
- data/lib/adwords_api/v201402/campaign_ad_extension_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/campaign_criterion_service.rb +1 -1
- data/lib/adwords_api/v201402/campaign_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/campaign_feed_service.rb +1 -1
- data/lib/adwords_api/v201402/campaign_feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/campaign_service.rb +1 -1
- data/lib/adwords_api/v201402/campaign_service_registry.rb +2 -2
- data/lib/adwords_api/v201402/campaign_shared_set_service.rb +1 -1
- data/lib/adwords_api/v201402/campaign_shared_set_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/constant_data_service.rb +1 -1
- data/lib/adwords_api/v201402/constant_data_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/conversion_tracker_service.rb +1 -1
- data/lib/adwords_api/v201402/conversion_tracker_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/customer_feed_service.rb +1 -1
- data/lib/adwords_api/v201402/customer_feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/customer_service.rb +1 -1
- data/lib/adwords_api/v201402/customer_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/customer_sync_service.rb +1 -1
- data/lib/adwords_api/v201402/customer_sync_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/data_service.rb +1 -1
- data/lib/adwords_api/v201402/data_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/experiment_service.rb +1 -1
- data/lib/adwords_api/v201402/experiment_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/feed_item_service.rb +1 -1
- data/lib/adwords_api/v201402/feed_item_service_registry.rb +2 -2
- data/lib/adwords_api/v201402/feed_mapping_service.rb +1 -1
- data/lib/adwords_api/v201402/feed_mapping_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/feed_service.rb +1 -1
- data/lib/adwords_api/v201402/feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/geo_location_service.rb +1 -1
- data/lib/adwords_api/v201402/geo_location_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/location_criterion_service.rb +1 -1
- data/lib/adwords_api/v201402/location_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/managed_customer_service.rb +1 -1
- data/lib/adwords_api/v201402/managed_customer_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/media_service.rb +1 -1
- data/lib/adwords_api/v201402/media_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/mutate_job_service.rb +1 -1
- data/lib/adwords_api/v201402/mutate_job_service_registry.rb +2 -2
- data/lib/adwords_api/v201402/offline_conversion_feed_service.rb +1 -1
- data/lib/adwords_api/v201402/offline_conversion_feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/report_definition_service.rb +1 -1
- data/lib/adwords_api/v201402/report_definition_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/shared_criterion_service.rb +1 -1
- data/lib/adwords_api/v201402/shared_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/shared_set_service.rb +1 -1
- data/lib/adwords_api/v201402/shared_set_service_registry.rb +1 -1
- data/lib/adwords_api/v201402/targeting_idea_service.rb +1 -1
- data/lib/adwords_api/v201402/targeting_idea_service_registry.rb +2 -2
- data/lib/adwords_api/v201402/traffic_estimator_service.rb +1 -1
- data/lib/adwords_api/v201402/traffic_estimator_service_registry.rb +2 -2
- data/lib/adwords_api/v201406/ad_group_ad_service.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_ad_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_bid_modifier_service.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_bid_modifier_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_criterion_service.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_feed_service.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_service.rb +1 -1
- data/lib/adwords_api/v201406/ad_group_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/ad_param_service.rb +1 -1
- data/lib/adwords_api/v201406/ad_param_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/adwords_user_list_service.rb +1 -1
- data/lib/adwords_api/v201406/adwords_user_list_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/alert_service.rb +1 -1
- data/lib/adwords_api/v201406/alert_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/bidding_strategy_service.rb +1 -1
- data/lib/adwords_api/v201406/bidding_strategy_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/budget_order_service.rb +1 -1
- data/lib/adwords_api/v201406/budget_order_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/budget_service.rb +1 -1
- data/lib/adwords_api/v201406/budget_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/campaign_ad_extension_service.rb +1 -1
- data/lib/adwords_api/v201406/campaign_ad_extension_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/campaign_criterion_service.rb +1 -1
- data/lib/adwords_api/v201406/campaign_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/campaign_feed_service.rb +1 -1
- data/lib/adwords_api/v201406/campaign_feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/campaign_service.rb +1 -1
- data/lib/adwords_api/v201406/campaign_service_registry.rb +2 -2
- data/lib/adwords_api/v201406/campaign_shared_set_service.rb +1 -1
- data/lib/adwords_api/v201406/campaign_shared_set_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/constant_data_service.rb +1 -1
- data/lib/adwords_api/v201406/constant_data_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/conversion_tracker_service.rb +1 -1
- data/lib/adwords_api/v201406/conversion_tracker_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/customer_feed_service.rb +1 -1
- data/lib/adwords_api/v201406/customer_feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/customer_service.rb +1 -1
- data/lib/adwords_api/v201406/customer_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/customer_sync_service.rb +1 -1
- data/lib/adwords_api/v201406/customer_sync_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/data_service.rb +1 -1
- data/lib/adwords_api/v201406/data_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/experiment_service.rb +1 -1
- data/lib/adwords_api/v201406/experiment_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/feed_item_service.rb +1 -1
- data/lib/adwords_api/v201406/feed_item_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/feed_mapping_service.rb +1 -1
- data/lib/adwords_api/v201406/feed_mapping_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/feed_service.rb +1 -1
- data/lib/adwords_api/v201406/feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/geo_location_service.rb +1 -1
- data/lib/adwords_api/v201406/geo_location_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/label_service.rb +1 -1
- data/lib/adwords_api/v201406/label_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/location_criterion_service.rb +1 -1
- data/lib/adwords_api/v201406/location_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/managed_customer_service.rb +1 -1
- data/lib/adwords_api/v201406/managed_customer_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/media_service.rb +1 -1
- data/lib/adwords_api/v201406/media_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/mutate_job_service.rb +1 -1
- data/lib/adwords_api/v201406/mutate_job_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/offline_conversion_feed_service.rb +1 -1
- data/lib/adwords_api/v201406/offline_conversion_feed_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/report_definition_service.rb +1 -1
- data/lib/adwords_api/v201406/report_definition_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/shared_criterion_service.rb +1 -1
- data/lib/adwords_api/v201406/shared_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/shared_set_service.rb +1 -1
- data/lib/adwords_api/v201406/shared_set_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/targeting_idea_service.rb +1 -1
- data/lib/adwords_api/v201406/targeting_idea_service_registry.rb +1 -1
- data/lib/adwords_api/v201406/traffic_estimator_service.rb +1 -1
- data/lib/adwords_api/v201406/traffic_estimator_service_registry.rb +1 -1
- data/lib/adwords_api/version.rb +1 -1
- metadata +167 -171
- checksums.yaml +0 -15
- data/examples/v201402/basic_operations/delete_ad_group.rb~ +0 -104
- data/examples/v201402/basic_operations/delete_campaign.rb~ +0 -91
- data/examples/v201406/basic_operations/remove_ad_group.rb~ +0 -90
- data/examples/v201406/basic_operations/remove_campaign.rb~ +0 -111
- data/lib/adwords_api/client_login_header_handler.rb +0 -37
- data/lib/adwords_api/report_utils.rb~ +0 -283
- data/lib/adwords_api/version.rb~ +0 -26
- data/test/adwords_api/test_adwords_api.rb~ +0 -114
- data/test/adwords_api/test_report_utils.rb~ +0 -216
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ODRhZTMxOWI0ZjZlYTZmMDRhZDA1M2I4YjgxNDJiMTU4YTdlMGNkMw==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZThlNzE5ZTUzNWFlMDcyZmU0NTczMjdjOTAyYjdiZDc1ODg4MWMyZg==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MTNiZjMxOTEwNjA3MmRkNGYzZjFiMGI1ZmRhODE5NmZlNTBlOGRlNzg3ZWZh
|
10
|
-
YTg4MDVhNTlhNWI4Yjg5YjUxZGI2NzRlMDA0ZjJlZTVhZTNkOGU3NzFhMTcx
|
11
|
-
MmZkZWUxZDhhMjQzYTZmZGNkZTVjOTkwOTNjYmY1ZjlhNTQwZjQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YzI0ZmYxODE3ZmRhNzhlODQ5MmM0OGNhNjM4YjViYzI1Y2U0NDcxNjRhNzU0
|
14
|
-
OWJmZWNhZTc4Nzg4NTg1MWJiMmExZWRmZmVmMThkMmIzNjljYjhlNzA5NDc1
|
15
|
-
YTliYjMzZjU5YmIwNzE3MDlhMmM5YzY0OTc5YTEzMGE3YzVjNjc=
|
@@ -1,104 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example deletes an ad group by setting the status to 'DELETED'. To get ad
|
22
|
-
# groups, run get_ad_groups.rb.
|
23
|
-
#
|
24
|
-
# Tags: AdGroupService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def delete_ad_group(ad_group_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
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
|
-
# Prepare for deleting ad group.
|
55
|
-
operation = {
|
56
|
-
:operator => 'SET',
|
57
|
-
:operand => {
|
58
|
-
:id => ad_group_id,
|
59
|
-
:status => 'DELETED'
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
# Delete ad group.
|
64
|
-
response = ad_group_srv.mutate([operation])
|
65
|
-
if response and response[:value]
|
66
|
-
ad_group = response[:value].first
|
67
|
-
puts "Ad group ID %d was successfully deleted." % [ad_group[:id]]
|
68
|
-
else
|
69
|
-
puts 'No ad group was updated.'
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
if __FILE__ == $0
|
74
|
-
API_VERSION = :v201402
|
75
|
-
|
76
|
-
begin
|
77
|
-
# ID of an ad group to delete.
|
78
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
79
|
-
delete_ad_group(ad_group_id)
|
80
|
-
|
81
|
-
# Authorization error.
|
82
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
83
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
84
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
85
|
-
"to retrieve and store OAuth2 tokens."
|
86
|
-
puts "See this wiki page for more details:\n\n " +
|
87
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
88
|
-
|
89
|
-
# HTTP errors.
|
90
|
-
rescue AdsCommon::Errors::HttpError => e
|
91
|
-
puts "HTTP Error: %s" % e
|
92
|
-
|
93
|
-
# API errors.
|
94
|
-
rescue AdwordsApi::Errors::ApiException => e
|
95
|
-
puts "Message: %s" % e.message
|
96
|
-
puts 'Errors:'
|
97
|
-
e.errors.each_with_index do |error, index|
|
98
|
-
puts "\tError [%d]:" % (index + 1)
|
99
|
-
error.each do |field, value|
|
100
|
-
puts "\t\t%s: %s" % [field, value]
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example deletes a campaign by setting the status to 'DELETED'. To get
|
22
|
-
# campaigns, run get_campaigns.rb.
|
23
|
-
#
|
24
|
-
# Tags: CampaignService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def delete_campaign(campaign_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
38
|
-
|
39
|
-
# Prepare for deleting campaign.
|
40
|
-
operation = {
|
41
|
-
:operator => 'SET',
|
42
|
-
:operand => {
|
43
|
-
:id => campaign_id,
|
44
|
-
:status => 'DELETED'
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
# Delete campaign.
|
49
|
-
response = campaign_srv.mutate([operation])
|
50
|
-
|
51
|
-
if response and response[:value]
|
52
|
-
campaign = response[:value].first
|
53
|
-
puts "Campaign ID %d was renamed to '%s' and deleted." %
|
54
|
-
[campaign[:id], campaign[:name]]
|
55
|
-
else
|
56
|
-
puts 'No campaign was updated.'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
if __FILE__ == $0
|
61
|
-
API_VERSION = :v201402
|
62
|
-
|
63
|
-
begin
|
64
|
-
# ID of a campaign to delete.
|
65
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
66
|
-
delete_campaign(campaign_id)
|
67
|
-
|
68
|
-
# Authorization error.
|
69
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
70
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
71
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
72
|
-
"to retrieve and store OAuth2 tokens."
|
73
|
-
puts "See this wiki page for more details:\n\n " +
|
74
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
75
|
-
|
76
|
-
# HTTP errors.
|
77
|
-
rescue AdsCommon::Errors::HttpError => e
|
78
|
-
puts "HTTP Error: %s" % e
|
79
|
-
|
80
|
-
# API errors.
|
81
|
-
rescue AdwordsApi::Errors::ApiException => e
|
82
|
-
puts "Message: %s" % e.message
|
83
|
-
puts 'Errors:'
|
84
|
-
e.errors.each_with_index do |error, index|
|
85
|
-
puts "\tError [%d]:" % (index + 1)
|
86
|
-
error.each do |field, value|
|
87
|
-
puts "\t\t%s: %s" % [field, value]
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example removes an ad group by setting the status to 'REMOVED'. To get ad
|
22
|
-
# groups, run get_ad_groups.rb.
|
23
|
-
#
|
24
|
-
# Tags: AdGroupService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def remove_ad_group(ad_group_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
ad_group_srv = adwords.service(:AdGroupService, API_VERSION)
|
38
|
-
|
39
|
-
# Prepare for deleting ad group.
|
40
|
-
operation = {
|
41
|
-
:operator => 'SET',
|
42
|
-
:operand => {
|
43
|
-
:id => ad_group_id,
|
44
|
-
:status => 'REMOVED'
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
# Remove ad group.
|
49
|
-
response = ad_group_srv.mutate([operation])
|
50
|
-
if response and response[:value]
|
51
|
-
ad_group = response[:value].first
|
52
|
-
puts "Ad group ID %d was successfully removed." %
|
53
|
-
[ad_group[:id]]
|
54
|
-
else
|
55
|
-
puts 'No ad group was updated.'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
if __FILE__ == $0
|
60
|
-
API_VERSION = :v201406
|
61
|
-
|
62
|
-
begin
|
63
|
-
# ID of an ad group to remove.
|
64
|
-
ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
|
65
|
-
remove_ad_group(ad_group_id)
|
66
|
-
|
67
|
-
# Authorization error.
|
68
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
69
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
70
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
71
|
-
"to retrieve and store OAuth2 tokens."
|
72
|
-
puts "See this wiki page for more details:\n\n " +
|
73
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
74
|
-
|
75
|
-
# HTTP errors.
|
76
|
-
rescue AdsCommon::Errors::HttpError => e
|
77
|
-
puts "HTTP Error: %s" % e
|
78
|
-
|
79
|
-
# API errors.
|
80
|
-
rescue AdwordsApi::Errors::ApiException => e
|
81
|
-
puts "Message: %s" % e.message
|
82
|
-
puts 'Errors:'
|
83
|
-
e.errors.each_with_index do |error, index|
|
84
|
-
puts "\tError [%d]:" % (index + 1)
|
85
|
-
error.each do |field, value|
|
86
|
-
puts "\t\t%s: %s" % [field, value]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example removes a campaign by setting the status to 'REMOVED'. To get
|
22
|
-
# campaigns, run get_campaigns.rb.
|
23
|
-
#
|
24
|
-
# Tags: CampaignService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def remove_campaign(campaign_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
campaign_srv = adwords.service(:CampaignService, API_VERSION)
|
38
|
-
|
39
|
-
# Retrieve the campaign to obtain its name. This is optional but recommended
|
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.
|
59
|
-
operation = {
|
60
|
-
:operator => 'SET',
|
61
|
-
:operand => {
|
62
|
-
:id => campaign_id,
|
63
|
-
:name => campaign_name,
|
64
|
-
:status => 'REMOVED',
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
# Remove campaign.
|
69
|
-
response = campaign_srv.mutate([operation])
|
70
|
-
|
71
|
-
if response and response[:value]
|
72
|
-
campaign = response[:value].first
|
73
|
-
puts "Campaign ID %d was renamed to '%s' and removed." %
|
74
|
-
[campaign[:id], campaign[:name]]
|
75
|
-
else
|
76
|
-
puts 'No campaign was updated.'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
if __FILE__ == $0
|
81
|
-
API_VERSION = :v201406
|
82
|
-
|
83
|
-
begin
|
84
|
-
# ID of a campaign to remove.
|
85
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
86
|
-
remove_campaign(campaign_id)
|
87
|
-
|
88
|
-
# Authorization error.
|
89
|
-
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
90
|
-
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
91
|
-
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
92
|
-
"to retrieve and store OAuth2 tokens."
|
93
|
-
puts "See this wiki page for more details:\n\n " +
|
94
|
-
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
95
|
-
|
96
|
-
# HTTP errors.
|
97
|
-
rescue AdsCommon::Errors::HttpError => e
|
98
|
-
puts "HTTP Error: %s" % e
|
99
|
-
|
100
|
-
# API errors.
|
101
|
-
rescue AdwordsApi::Errors::ApiException => e
|
102
|
-
puts "Message: %s" % e.message
|
103
|
-
puts 'Errors:'
|
104
|
-
e.errors.each_with_index do |error, index|
|
105
|
-
puts "\tError [%d]:" % (index + 1)
|
106
|
-
error.each do |field, value|
|
107
|
-
puts "\t\t%s: %s" % [field, value]
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# Encoding: utf-8
|
2
|
-
#
|
3
|
-
# Authors:: 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
|
-
# Handles SOAP headers and namespaces definition for ClientLogin type header.
|
21
|
-
|
22
|
-
require 'ads_common/savon_headers/base_header_handler'
|
23
|
-
|
24
|
-
module AdwordsApi
|
25
|
-
class ClientLoginHeaderHandler < AdsCommon::SavonHeaders::BaseHeaderHandler
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
# Generates AdWords API specific request header with ClientLogin data.
|
30
|
-
def generate_request_header()
|
31
|
-
request_header = super()
|
32
|
-
credentials = @credential_handler.credentials
|
33
|
-
request_header['authToken'] = @auth_handler.get_token(credentials)
|
34
|
-
return request_header
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|