google-adwords-api 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. data/ChangeLog +4 -0
  2. data/README.md +5 -5
  3. data/adwords_api.yml +1 -9
  4. data/examples/v201402/advanced_operations/add_places_location_extensions.rb +0 -0
  5. data/examples/v201406/advanced_operations/add_ad_customizer.rb +277 -0
  6. data/examples/v201406/advanced_operations/add_places_location_extensions.rb +0 -0
  7. data/examples/v201406/advanced_operations/add_text_ad_with_upgraded_urls.rb +0 -0
  8. data/examples/v201406/campaign_management/add_campaign_labels.rb +0 -0
  9. data/examples/v201406/campaign_management/get_campaigns_by_label.rb +0 -0
  10. data/examples/v201406/misc/create_ad_words_session_without_properties_file.rb +0 -0
  11. data/examples/v201406/shopping_campaigns/add_product_partition_tree.rb +0 -0
  12. data/examples/v201406/shopping_campaigns/add_product_scope.rb +0 -0
  13. data/examples/v201406/shopping_campaigns/add_shopping_campaign.rb +0 -0
  14. data/examples/v201406/shopping_campaigns/get_product_category_taxonomy.rb +0 -0
  15. data/examples/v201406/shopping_campaigns/set_product_sales_channel.rb +0 -0
  16. data/lib/adwords_api.rb +0 -7
  17. data/lib/adwords_api/api_config.rb +5 -7
  18. data/lib/adwords_api/credential_handler.rb +0 -5
  19. data/lib/adwords_api/v201402/ad_group_ad_service.rb +1 -1
  20. data/lib/adwords_api/v201402/ad_group_ad_service_registry.rb +1 -1
  21. data/lib/adwords_api/v201402/ad_group_bid_modifier_service.rb +1 -1
  22. data/lib/adwords_api/v201402/ad_group_bid_modifier_service_registry.rb +1 -1
  23. data/lib/adwords_api/v201402/ad_group_criterion_service.rb +1 -1
  24. data/lib/adwords_api/v201402/ad_group_criterion_service_registry.rb +2 -2
  25. data/lib/adwords_api/v201402/ad_group_feed_service.rb +1 -1
  26. data/lib/adwords_api/v201402/ad_group_feed_service_registry.rb +1 -1
  27. data/lib/adwords_api/v201402/ad_group_service.rb +1 -1
  28. data/lib/adwords_api/v201402/ad_group_service_registry.rb +1 -1
  29. data/lib/adwords_api/v201402/ad_param_service.rb +1 -1
  30. data/lib/adwords_api/v201402/ad_param_service_registry.rb +1 -1
  31. data/lib/adwords_api/v201402/adwords_user_list_service.rb +1 -1
  32. data/lib/adwords_api/v201402/adwords_user_list_service_registry.rb +2 -2
  33. data/lib/adwords_api/v201402/alert_service.rb +1 -1
  34. data/lib/adwords_api/v201402/alert_service_registry.rb +1 -1
  35. data/lib/adwords_api/v201402/bidding_strategy_service.rb +1 -1
  36. data/lib/adwords_api/v201402/bidding_strategy_service_registry.rb +1 -1
  37. data/lib/adwords_api/v201402/budget_order_service.rb +1 -1
  38. data/lib/adwords_api/v201402/budget_order_service_registry.rb +2 -2
  39. data/lib/adwords_api/v201402/budget_service.rb +1 -1
  40. data/lib/adwords_api/v201402/budget_service_registry.rb +1 -1
  41. data/lib/adwords_api/v201402/campaign_ad_extension_service.rb +1 -1
  42. data/lib/adwords_api/v201402/campaign_ad_extension_service_registry.rb +1 -1
  43. data/lib/adwords_api/v201402/campaign_criterion_service.rb +1 -1
  44. data/lib/adwords_api/v201402/campaign_criterion_service_registry.rb +1 -1
  45. data/lib/adwords_api/v201402/campaign_feed_service.rb +1 -1
  46. data/lib/adwords_api/v201402/campaign_feed_service_registry.rb +1 -1
  47. data/lib/adwords_api/v201402/campaign_service.rb +1 -1
  48. data/lib/adwords_api/v201402/campaign_service_registry.rb +2 -2
  49. data/lib/adwords_api/v201402/campaign_shared_set_service.rb +1 -1
  50. data/lib/adwords_api/v201402/campaign_shared_set_service_registry.rb +1 -1
  51. data/lib/adwords_api/v201402/constant_data_service.rb +1 -1
  52. data/lib/adwords_api/v201402/constant_data_service_registry.rb +1 -1
  53. data/lib/adwords_api/v201402/conversion_tracker_service.rb +1 -1
  54. data/lib/adwords_api/v201402/conversion_tracker_service_registry.rb +1 -1
  55. data/lib/adwords_api/v201402/customer_feed_service.rb +1 -1
  56. data/lib/adwords_api/v201402/customer_feed_service_registry.rb +1 -1
  57. data/lib/adwords_api/v201402/customer_service.rb +1 -1
  58. data/lib/adwords_api/v201402/customer_service_registry.rb +1 -1
  59. data/lib/adwords_api/v201402/customer_sync_service.rb +1 -1
  60. data/lib/adwords_api/v201402/customer_sync_service_registry.rb +1 -1
  61. data/lib/adwords_api/v201402/data_service.rb +1 -1
  62. data/lib/adwords_api/v201402/data_service_registry.rb +1 -1
  63. data/lib/adwords_api/v201402/experiment_service.rb +1 -1
  64. data/lib/adwords_api/v201402/experiment_service_registry.rb +1 -1
  65. data/lib/adwords_api/v201402/feed_item_service.rb +1 -1
  66. data/lib/adwords_api/v201402/feed_item_service_registry.rb +2 -2
  67. data/lib/adwords_api/v201402/feed_mapping_service.rb +1 -1
  68. data/lib/adwords_api/v201402/feed_mapping_service_registry.rb +1 -1
  69. data/lib/adwords_api/v201402/feed_service.rb +1 -1
  70. data/lib/adwords_api/v201402/feed_service_registry.rb +1 -1
  71. data/lib/adwords_api/v201402/geo_location_service.rb +1 -1
  72. data/lib/adwords_api/v201402/geo_location_service_registry.rb +1 -1
  73. data/lib/adwords_api/v201402/location_criterion_service.rb +1 -1
  74. data/lib/adwords_api/v201402/location_criterion_service_registry.rb +1 -1
  75. data/lib/adwords_api/v201402/managed_customer_service.rb +1 -1
  76. data/lib/adwords_api/v201402/managed_customer_service_registry.rb +1 -1
  77. data/lib/adwords_api/v201402/media_service.rb +1 -1
  78. data/lib/adwords_api/v201402/media_service_registry.rb +1 -1
  79. data/lib/adwords_api/v201402/mutate_job_service.rb +1 -1
  80. data/lib/adwords_api/v201402/mutate_job_service_registry.rb +2 -2
  81. data/lib/adwords_api/v201402/offline_conversion_feed_service.rb +1 -1
  82. data/lib/adwords_api/v201402/offline_conversion_feed_service_registry.rb +1 -1
  83. data/lib/adwords_api/v201402/report_definition_service.rb +1 -1
  84. data/lib/adwords_api/v201402/report_definition_service_registry.rb +1 -1
  85. data/lib/adwords_api/v201402/shared_criterion_service.rb +1 -1
  86. data/lib/adwords_api/v201402/shared_criterion_service_registry.rb +1 -1
  87. data/lib/adwords_api/v201402/shared_set_service.rb +1 -1
  88. data/lib/adwords_api/v201402/shared_set_service_registry.rb +1 -1
  89. data/lib/adwords_api/v201402/targeting_idea_service.rb +1 -1
  90. data/lib/adwords_api/v201402/targeting_idea_service_registry.rb +2 -2
  91. data/lib/adwords_api/v201402/traffic_estimator_service.rb +1 -1
  92. data/lib/adwords_api/v201402/traffic_estimator_service_registry.rb +2 -2
  93. data/lib/adwords_api/v201406/ad_group_ad_service.rb +1 -1
  94. data/lib/adwords_api/v201406/ad_group_ad_service_registry.rb +1 -1
  95. data/lib/adwords_api/v201406/ad_group_bid_modifier_service.rb +1 -1
  96. data/lib/adwords_api/v201406/ad_group_bid_modifier_service_registry.rb +1 -1
  97. data/lib/adwords_api/v201406/ad_group_criterion_service.rb +1 -1
  98. data/lib/adwords_api/v201406/ad_group_criterion_service_registry.rb +1 -1
  99. data/lib/adwords_api/v201406/ad_group_feed_service.rb +1 -1
  100. data/lib/adwords_api/v201406/ad_group_feed_service_registry.rb +1 -1
  101. data/lib/adwords_api/v201406/ad_group_service.rb +1 -1
  102. data/lib/adwords_api/v201406/ad_group_service_registry.rb +1 -1
  103. data/lib/adwords_api/v201406/ad_param_service.rb +1 -1
  104. data/lib/adwords_api/v201406/ad_param_service_registry.rb +1 -1
  105. data/lib/adwords_api/v201406/adwords_user_list_service.rb +1 -1
  106. data/lib/adwords_api/v201406/adwords_user_list_service_registry.rb +1 -1
  107. data/lib/adwords_api/v201406/alert_service.rb +1 -1
  108. data/lib/adwords_api/v201406/alert_service_registry.rb +1 -1
  109. data/lib/adwords_api/v201406/bidding_strategy_service.rb +1 -1
  110. data/lib/adwords_api/v201406/bidding_strategy_service_registry.rb +1 -1
  111. data/lib/adwords_api/v201406/budget_order_service.rb +1 -1
  112. data/lib/adwords_api/v201406/budget_order_service_registry.rb +1 -1
  113. data/lib/adwords_api/v201406/budget_service.rb +1 -1
  114. data/lib/adwords_api/v201406/budget_service_registry.rb +1 -1
  115. data/lib/adwords_api/v201406/campaign_ad_extension_service.rb +1 -1
  116. data/lib/adwords_api/v201406/campaign_ad_extension_service_registry.rb +1 -1
  117. data/lib/adwords_api/v201406/campaign_criterion_service.rb +1 -1
  118. data/lib/adwords_api/v201406/campaign_criterion_service_registry.rb +1 -1
  119. data/lib/adwords_api/v201406/campaign_feed_service.rb +1 -1
  120. data/lib/adwords_api/v201406/campaign_feed_service_registry.rb +1 -1
  121. data/lib/adwords_api/v201406/campaign_service.rb +1 -1
  122. data/lib/adwords_api/v201406/campaign_service_registry.rb +2 -2
  123. data/lib/adwords_api/v201406/campaign_shared_set_service.rb +1 -1
  124. data/lib/adwords_api/v201406/campaign_shared_set_service_registry.rb +1 -1
  125. data/lib/adwords_api/v201406/constant_data_service.rb +1 -1
  126. data/lib/adwords_api/v201406/constant_data_service_registry.rb +1 -1
  127. data/lib/adwords_api/v201406/conversion_tracker_service.rb +1 -1
  128. data/lib/adwords_api/v201406/conversion_tracker_service_registry.rb +1 -1
  129. data/lib/adwords_api/v201406/customer_feed_service.rb +1 -1
  130. data/lib/adwords_api/v201406/customer_feed_service_registry.rb +1 -1
  131. data/lib/adwords_api/v201406/customer_service.rb +1 -1
  132. data/lib/adwords_api/v201406/customer_service_registry.rb +1 -1
  133. data/lib/adwords_api/v201406/customer_sync_service.rb +1 -1
  134. data/lib/adwords_api/v201406/customer_sync_service_registry.rb +1 -1
  135. data/lib/adwords_api/v201406/data_service.rb +1 -1
  136. data/lib/adwords_api/v201406/data_service_registry.rb +1 -1
  137. data/lib/adwords_api/v201406/experiment_service.rb +1 -1
  138. data/lib/adwords_api/v201406/experiment_service_registry.rb +1 -1
  139. data/lib/adwords_api/v201406/feed_item_service.rb +1 -1
  140. data/lib/adwords_api/v201406/feed_item_service_registry.rb +1 -1
  141. data/lib/adwords_api/v201406/feed_mapping_service.rb +1 -1
  142. data/lib/adwords_api/v201406/feed_mapping_service_registry.rb +1 -1
  143. data/lib/adwords_api/v201406/feed_service.rb +1 -1
  144. data/lib/adwords_api/v201406/feed_service_registry.rb +1 -1
  145. data/lib/adwords_api/v201406/geo_location_service.rb +1 -1
  146. data/lib/adwords_api/v201406/geo_location_service_registry.rb +1 -1
  147. data/lib/adwords_api/v201406/label_service.rb +1 -1
  148. data/lib/adwords_api/v201406/label_service_registry.rb +1 -1
  149. data/lib/adwords_api/v201406/location_criterion_service.rb +1 -1
  150. data/lib/adwords_api/v201406/location_criterion_service_registry.rb +1 -1
  151. data/lib/adwords_api/v201406/managed_customer_service.rb +1 -1
  152. data/lib/adwords_api/v201406/managed_customer_service_registry.rb +1 -1
  153. data/lib/adwords_api/v201406/media_service.rb +1 -1
  154. data/lib/adwords_api/v201406/media_service_registry.rb +1 -1
  155. data/lib/adwords_api/v201406/mutate_job_service.rb +1 -1
  156. data/lib/adwords_api/v201406/mutate_job_service_registry.rb +1 -1
  157. data/lib/adwords_api/v201406/offline_conversion_feed_service.rb +1 -1
  158. data/lib/adwords_api/v201406/offline_conversion_feed_service_registry.rb +1 -1
  159. data/lib/adwords_api/v201406/report_definition_service.rb +1 -1
  160. data/lib/adwords_api/v201406/report_definition_service_registry.rb +1 -1
  161. data/lib/adwords_api/v201406/shared_criterion_service.rb +1 -1
  162. data/lib/adwords_api/v201406/shared_criterion_service_registry.rb +1 -1
  163. data/lib/adwords_api/v201406/shared_set_service.rb +1 -1
  164. data/lib/adwords_api/v201406/shared_set_service_registry.rb +1 -1
  165. data/lib/adwords_api/v201406/targeting_idea_service.rb +1 -1
  166. data/lib/adwords_api/v201406/targeting_idea_service_registry.rb +1 -1
  167. data/lib/adwords_api/v201406/traffic_estimator_service.rb +1 -1
  168. data/lib/adwords_api/v201406/traffic_estimator_service_registry.rb +1 -1
  169. data/lib/adwords_api/version.rb +1 -1
  170. metadata +167 -171
  171. checksums.yaml +0 -15
  172. data/examples/v201402/basic_operations/delete_ad_group.rb~ +0 -104
  173. data/examples/v201402/basic_operations/delete_campaign.rb~ +0 -91
  174. data/examples/v201406/basic_operations/remove_ad_group.rb~ +0 -90
  175. data/examples/v201406/basic_operations/remove_campaign.rb~ +0 -111
  176. data/lib/adwords_api/client_login_header_handler.rb +0 -37
  177. data/lib/adwords_api/report_utils.rb~ +0 -283
  178. data/lib/adwords_api/version.rb~ +0 -26
  179. data/test/adwords_api/test_adwords_api.rb~ +0 -114
  180. 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