google-adwords-api 0.9.3 → 0.10.0

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 (213) hide show
  1. data/ChangeLog +4 -0
  2. data/README +4 -4
  3. data/examples/{v201209 → v201309}/account_management/create_account.rb +9 -1
  4. data/examples/{v201209 → v201309}/account_management/get_account_alerts.rb +9 -1
  5. data/examples/{v201209 → v201309}/account_management/get_account_changes.rb +9 -1
  6. data/examples/{v201209 → v201309}/account_management/get_account_hierarchy.rb +9 -1
  7. data/examples/v201309/advanced_operations/add_ad_group_bid_modifier.rb +105 -0
  8. data/examples/v201309/advanced_operations/add_click_to_download_ad.rb +137 -0
  9. data/examples/v201309/advanced_operations/add_site_links.rb +244 -0
  10. data/examples/v201309/advanced_operations/create_and_attach_shared_keyword_set.rb +147 -0
  11. data/examples/v201309/advanced_operations/find_and_remove_criteria_from_shared_set.rb +181 -0
  12. data/examples/{v201209/adwords_for_video/get_video_campaign_criteria.rb → v201309/advanced_operations/get_ad_group_bid_modifiers.rb} +30 -23
  13. data/examples/v201309/advanced_operations/upload_offline_conversions.rb +117 -0
  14. data/examples/v201309/advanced_operations/use_shared_bidding_strategy.rb +163 -0
  15. data/examples/{v201209 → v201309}/basic_operations/add_ad_groups.rb +28 -21
  16. data/examples/{v201209 → v201309}/basic_operations/add_campaigns.rb +18 -15
  17. data/examples/{v201209 → v201309}/basic_operations/add_keywords.rb +9 -1
  18. data/examples/{v201209 → v201309}/basic_operations/add_text_ads.rb +9 -1
  19. data/examples/{v201209 → v201309}/basic_operations/delete_ad.rb +9 -1
  20. data/examples/{v201209 → v201309}/basic_operations/delete_ad_group.rb +9 -1
  21. data/examples/{v201209 → v201309}/basic_operations/delete_campaign.rb +9 -1
  22. data/examples/{v201209 → v201309}/basic_operations/delete_keyword.rb +9 -1
  23. data/examples/{v201209 → v201309}/basic_operations/get_ad_groups.rb +9 -1
  24. data/examples/{v201209 → v201309}/basic_operations/get_campaigns.rb +9 -1
  25. data/examples/{v201209 → v201309}/basic_operations/get_campaigns_with_awql.rb +9 -1
  26. data/examples/{v201209 → v201309}/basic_operations/get_keywords.rb +9 -1
  27. data/examples/{v201209 → v201309}/basic_operations/get_text_ads.rb +9 -1
  28. data/examples/{v201209 → v201309}/basic_operations/pause_ad.rb +9 -1
  29. data/examples/{v201209 → v201309}/basic_operations/update_ad_group.rb +9 -1
  30. data/examples/{v201209 → v201309}/basic_operations/update_campaign.rb +9 -1
  31. data/examples/{v201209 → v201309}/basic_operations/update_keyword.rb +21 -10
  32. data/examples/{v201209 → v201309}/campaign_management/add_experiment.rb +9 -1
  33. data/examples/{v201209 → v201309}/campaign_management/add_keywords_in_bulk.rb +10 -2
  34. data/examples/{v201209 → v201309}/campaign_management/add_location_extension.rb +9 -1
  35. data/examples/{v201209 → v201309}/campaign_management/add_location_extension_override.rb +9 -1
  36. data/examples/{v201209 → v201309}/campaign_management/get_all_disapproved_ads.rb +21 -13
  37. data/examples/{v201209 → v201309}/campaign_management/get_all_disapproved_ads_with_awql.rb +17 -8
  38. data/examples/{v201209 → v201309}/campaign_management/promote_experiment.rb +9 -1
  39. data/examples/{v201209 → v201309}/campaign_management/set_ad_parameters.rb +9 -1
  40. data/examples/{v201209 → v201309}/campaign_management/set_criterion_bid_modifier.rb +11 -5
  41. data/examples/{v201209 → v201309}/campaign_management/validate_text_ad.rb +9 -1
  42. data/examples/{v201209 → v201309}/error_handling/handle_captcha_challenge.rb +1 -1
  43. data/examples/{v201209 → v201309}/error_handling/handle_partial_failures.rb +9 -1
  44. data/examples/{v201209 → v201309}/error_handling/handle_policy_violation_error.rb +9 -1
  45. data/examples/{v201209 → v201309}/error_handling/handle_two_factor_authorization_error.rb +1 -1
  46. data/examples/{v201209 → v201309}/misc/get_all_images_and_videos.rb +9 -1
  47. data/examples/{v201209/misc/use_oauth2.rb → v201309/misc/setup_oauth2.rb} +17 -26
  48. data/examples/{v201209 → v201309}/misc/upload_image.rb +9 -1
  49. data/examples/{v201209 → v201309}/misc/use_oauth2_jwt.rb +1 -1
  50. data/examples/{v201209 → v201309}/optimization/estimate_keyword_traffic.rb +9 -1
  51. data/examples/{v201209 → v201309}/optimization/get_keyword_bid_simulations.rb +9 -1
  52. data/examples/{v201209 → v201309}/optimization/get_keyword_ideas.rb +17 -1
  53. data/examples/{v201209 → v201309}/optimization/get_placement_ideas.rb +9 -1
  54. data/examples/{v201209 → v201309}/remarketing/add_audience.rb +11 -3
  55. data/examples/{v201209 → v201309}/remarketing/add_conversion_tracker.rb +9 -2
  56. data/examples/{v201209 → v201309}/reporting/download_criteria_report.rb +9 -1
  57. data/examples/{v201209 → v201309}/reporting/download_criteria_report_with_awql.rb +9 -1
  58. data/examples/{v201209 → v201309}/reporting/get_campaign_stats.rb +9 -1
  59. data/examples/{v201209 → v201309}/reporting/get_report_fields.rb +9 -1
  60. data/examples/{v201209 → v201309}/reporting/parallel_report_download.rb +9 -1
  61. data/examples/{v201209 → v201309}/targeting/add_campaign_targeting_criteria.rb +10 -5
  62. data/examples/{v201209 → v201309}/targeting/add_demographic_targeting_criteria.rb +9 -1
  63. data/examples/{v201209 → v201309}/targeting/get_campaign_targeting_criteria.rb +9 -1
  64. data/examples/{v201209 → v201309}/targeting/get_targetable_languages_and_carriers.rb +9 -1
  65. data/examples/{v201209 → v201309}/targeting/lookup_location.rb +9 -1
  66. data/lib/adwords_api/api_config.rb +57 -55
  67. data/lib/adwords_api/{v201209 → v201309}/ad_group_ad_service.rb +7 -7
  68. data/lib/adwords_api/v201309/ad_group_ad_service_registry.rb +46 -0
  69. data/lib/adwords_api/{v201209 → v201309}/ad_group_bid_modifier_service.rb +6 -6
  70. data/lib/adwords_api/v201309/ad_group_bid_modifier_service_registry.rb +46 -0
  71. data/lib/adwords_api/{v201209 → v201309}/ad_group_criterion_service.rb +7 -7
  72. data/lib/adwords_api/v201309/ad_group_criterion_service_registry.rb +46 -0
  73. data/lib/adwords_api/v201309/ad_group_feed_service.rb +38 -0
  74. data/lib/adwords_api/v201309/ad_group_feed_service_registry.rb +46 -0
  75. data/lib/adwords_api/{v201209 → v201309}/ad_group_service.rb +7 -7
  76. data/lib/adwords_api/v201309/ad_group_service_registry.rb +46 -0
  77. data/lib/adwords_api/{v201209 → v201309}/ad_param_service.rb +7 -7
  78. data/lib/adwords_api/v201309/ad_param_service_registry.rb +46 -0
  79. data/lib/adwords_api/v201309/adwords_user_list_service.rb +38 -0
  80. data/lib/adwords_api/v201309/adwords_user_list_service_registry.rb +46 -0
  81. data/lib/adwords_api/{v201209 → v201309}/alert_service.rb +7 -7
  82. data/lib/adwords_api/v201309/alert_service_registry.rb +46 -0
  83. data/lib/adwords_api/{v201209/managed_customer_service.rb → v201309/bidding_strategy_service.rb} +9 -9
  84. data/lib/adwords_api/v201309/bidding_strategy_service_registry.rb +46 -0
  85. data/lib/adwords_api/{v201209 → v201309}/budget_order_service.rb +7 -7
  86. data/lib/adwords_api/v201309/budget_order_service_registry.rb +46 -0
  87. data/lib/adwords_api/{v201209 → v201309}/budget_service.rb +7 -7
  88. data/lib/adwords_api/v201309/budget_service_registry.rb +46 -0
  89. data/lib/adwords_api/{v201209 → v201309}/campaign_ad_extension_service.rb +7 -7
  90. data/lib/adwords_api/v201309/campaign_ad_extension_service_registry.rb +46 -0
  91. data/lib/adwords_api/{v201209 → v201309}/campaign_criterion_service.rb +7 -7
  92. data/lib/adwords_api/v201309/campaign_criterion_service_registry.rb +46 -0
  93. data/lib/adwords_api/v201309/campaign_feed_service.rb +38 -0
  94. data/lib/adwords_api/v201309/campaign_feed_service_registry.rb +46 -0
  95. data/lib/adwords_api/{v201209 → v201309}/campaign_service.rb +7 -7
  96. data/lib/adwords_api/v201309/campaign_service_registry.rb +46 -0
  97. data/lib/adwords_api/v201309/campaign_shared_set_service.rb +38 -0
  98. data/lib/adwords_api/v201309/campaign_shared_set_service_registry.rb +47 -0
  99. data/lib/adwords_api/{v201209 → v201309}/constant_data_service.rb +7 -7
  100. data/lib/adwords_api/v201309/constant_data_service_registry.rb +46 -0
  101. data/lib/adwords_api/{v201209 → v201309}/conversion_tracker_service.rb +7 -7
  102. data/lib/adwords_api/v201309/conversion_tracker_service_registry.rb +46 -0
  103. data/lib/adwords_api/{v201209 → v201309}/customer_service.rb +7 -7
  104. data/lib/adwords_api/v201309/customer_service_registry.rb +46 -0
  105. data/lib/adwords_api/{v201209 → v201309}/customer_sync_service.rb +7 -7
  106. data/lib/adwords_api/v201309/customer_sync_service_registry.rb +47 -0
  107. data/lib/adwords_api/{v201209 → v201309}/data_service.rb +7 -7
  108. data/lib/adwords_api/v201309/data_service_registry.rb +46 -0
  109. data/lib/adwords_api/{v201209 → v201309}/experiment_service.rb +7 -7
  110. data/lib/adwords_api/v201309/experiment_service_registry.rb +46 -0
  111. data/lib/adwords_api/{v201209/user_list_service.rb → v201309/feed_item_service.rb} +9 -9
  112. data/lib/adwords_api/v201309/feed_item_service_registry.rb +46 -0
  113. data/lib/adwords_api/v201309/feed_mapping_service.rb +38 -0
  114. data/lib/adwords_api/v201309/feed_mapping_service_registry.rb +46 -0
  115. data/lib/adwords_api/v201309/feed_service.rb +38 -0
  116. data/lib/adwords_api/v201309/feed_service_registry.rb +46 -0
  117. data/lib/adwords_api/{v201209 → v201309}/geo_location_service.rb +7 -7
  118. data/lib/adwords_api/v201309/geo_location_service_registry.rb +46 -0
  119. data/lib/adwords_api/{v201209 → v201309}/location_criterion_service.rb +7 -7
  120. data/lib/adwords_api/v201309/location_criterion_service_registry.rb +46 -0
  121. data/lib/adwords_api/v201309/managed_customer_service.rb +50 -0
  122. data/lib/adwords_api/v201309/managed_customer_service_registry.rb +46 -0
  123. data/lib/adwords_api/{v201209 → v201309}/media_service.rb +7 -7
  124. data/lib/adwords_api/v201309/media_service_registry.rb +46 -0
  125. data/lib/adwords_api/{v201209 → v201309}/mutate_job_service.rb +7 -7
  126. data/lib/adwords_api/v201309/mutate_job_service_registry.rb +46 -0
  127. data/lib/adwords_api/v201309/offline_conversion_feed_service.rb +34 -0
  128. data/lib/adwords_api/v201309/offline_conversion_feed_service_registry.rb +46 -0
  129. data/lib/adwords_api/{v201209 → v201309}/report_definition_service.rb +7 -7
  130. data/lib/adwords_api/v201309/report_definition_service_registry.rb +46 -0
  131. data/lib/adwords_api/v201309/shared_criterion_service.rb +38 -0
  132. data/lib/adwords_api/v201309/shared_criterion_service_registry.rb +47 -0
  133. data/lib/adwords_api/v201309/shared_set_service.rb +38 -0
  134. data/lib/adwords_api/v201309/shared_set_service_registry.rb +47 -0
  135. data/lib/adwords_api/{v201209 → v201309}/targeting_idea_service.rb +7 -7
  136. data/lib/adwords_api/v201309/targeting_idea_service_registry.rb +46 -0
  137. data/lib/adwords_api/{v201209 → v201309}/traffic_estimator_service.rb +7 -7
  138. data/lib/adwords_api/{v201209 → v201309}/traffic_estimator_service_registry.rb +5 -5
  139. data/lib/adwords_api/version.rb +1 -1
  140. data/test/adwords_api/test_adwords_api.rb +1 -1
  141. data/test/adwords_api/test_api_config.rb +8 -8
  142. data/test/adwords_api/test_report_utils.rb +1 -1
  143. data/test/bugs/test_issue_00000031.rb +2 -2
  144. data/test/bugs/test_issue_00000063.rb +6 -6
  145. data/test/templates/v201302/basic_operations_get_campaigns.def +1 -1
  146. data/test/templates/v201302/misc_use_oauth2_jwt.def +1 -1
  147. data/test/templates/v201306/basic_operations_get_campaigns.def +1 -1
  148. data/test/templates/v201306/misc_use_oauth2_jwt.def +1 -1
  149. data/test/templates/{v201209 → v201309}/basic_operations_get_campaigns.def +7 -7
  150. data/test/templates/v201309/misc_use_oauth2_jwt.def +131 -0
  151. metadata +416 -430
  152. data/examples/v201209/account_management/get_client_customer_id.rb +0 -88
  153. data/examples/v201209/account_management/get_client_unit_usage.rb +0 -90
  154. data/examples/v201209/adwords_for_video/add_video_campaign.rb +0 -103
  155. data/examples/v201209/adwords_for_video/find_videos.rb +0 -92
  156. data/examples/v201209/adwords_for_video/get_keyword_criteria.rb +0 -101
  157. data/examples/v201209/adwords_for_video/get_targeting_groups.rb +0 -93
  158. data/examples/v201209/adwords_for_video/get_video_campaign_stats.rb +0 -126
  159. data/examples/v201209/adwords_for_video/get_video_campaigns.rb +0 -94
  160. data/examples/v201209/campaign_management/set_campaign_enhanced.rb +0 -89
  161. data/lib/adwords_api/v201209/ad_extension_override_service.rb +0 -38
  162. data/lib/adwords_api/v201209/ad_extension_override_service_registry.rb +0 -46
  163. data/lib/adwords_api/v201209/ad_group_ad_service_registry.rb +0 -46
  164. data/lib/adwords_api/v201209/ad_group_bid_modifier_service_registry.rb +0 -46
  165. data/lib/adwords_api/v201209/ad_group_criterion_service_registry.rb +0 -46
  166. data/lib/adwords_api/v201209/ad_group_service_registry.rb +0 -46
  167. data/lib/adwords_api/v201209/ad_param_service_registry.rb +0 -46
  168. data/lib/adwords_api/v201209/alert_service_registry.rb +0 -46
  169. data/lib/adwords_api/v201209/budget_order_service_registry.rb +0 -46
  170. data/lib/adwords_api/v201209/budget_service_registry.rb +0 -46
  171. data/lib/adwords_api/v201209/campaign_ad_extension_service_registry.rb +0 -46
  172. data/lib/adwords_api/v201209/campaign_criterion_service_registry.rb +0 -46
  173. data/lib/adwords_api/v201209/campaign_service_registry.rb +0 -46
  174. data/lib/adwords_api/v201209/constant_data_service_registry.rb +0 -46
  175. data/lib/adwords_api/v201209/conversion_tracker_service_registry.rb +0 -46
  176. data/lib/adwords_api/v201209/customer_service_registry.rb +0 -46
  177. data/lib/adwords_api/v201209/customer_sync_service_registry.rb +0 -47
  178. data/lib/adwords_api/v201209/data_service_registry.rb +0 -46
  179. data/lib/adwords_api/v201209/experiment_service_registry.rb +0 -46
  180. data/lib/adwords_api/v201209/geo_location_service_registry.rb +0 -46
  181. data/lib/adwords_api/v201209/info_service.rb +0 -34
  182. data/lib/adwords_api/v201209/info_service_registry.rb +0 -46
  183. data/lib/adwords_api/v201209/location_criterion_service_registry.rb +0 -46
  184. data/lib/adwords_api/v201209/managed_customer_service_registry.rb +0 -46
  185. data/lib/adwords_api/v201209/media_service_registry.rb +0 -46
  186. data/lib/adwords_api/v201209/mutate_job_service_registry.rb +0 -46
  187. data/lib/adwords_api/v201209/report_definition_service_registry.rb +0 -46
  188. data/lib/adwords_api/v201209/targeting_idea_service_registry.rb +0 -46
  189. data/lib/adwords_api/v201209/user_list_service_registry.rb +0 -46
  190. data/lib/adwords_api/v201209/video_ad_service.rb +0 -38
  191. data/lib/adwords_api/v201209/video_ad_service_registry.rb +0 -46
  192. data/lib/adwords_api/v201209/video_campaign_criterion_service.rb +0 -38
  193. data/lib/adwords_api/v201209/video_campaign_criterion_service_registry.rb +0 -47
  194. data/lib/adwords_api/v201209/video_campaign_service.rb +0 -38
  195. data/lib/adwords_api/v201209/video_campaign_service_registry.rb +0 -46
  196. data/lib/adwords_api/v201209/video_service.rb +0 -42
  197. data/lib/adwords_api/v201209/video_service_registry.rb +0 -46
  198. data/lib/adwords_api/v201209/video_targeting_group_criterion_service.rb +0 -38
  199. data/lib/adwords_api/v201209/video_targeting_group_criterion_service_registry.rb +0 -46
  200. data/lib/adwords_api/v201209/video_targeting_group_service.rb +0 -38
  201. data/lib/adwords_api/v201209/video_targeting_group_service_registry.rb +0 -46
  202. data/test/examples/v201209/test_account_management.rb +0 -60
  203. data/test/examples/v201209/test_basic_operations.rb +0 -177
  204. data/test/examples/v201209/test_campaign_management.rb +0 -124
  205. data/test/examples/v201209/test_error_handling.rb +0 -63
  206. data/test/examples/v201209/test_misc.rb +0 -39
  207. data/test/examples/v201209/test_optimization.rb +0 -63
  208. data/test/examples/v201209/test_remarketing.rb +0 -39
  209. data/test/examples/v201209/test_reporting.rb +0 -84
  210. data/test/examples/v201209/test_targeting.rb +0 -60
  211. data/test/examples/v201209/utils.rb +0 -261
  212. data/test/suite_exampletests_v201209.rb +0 -37
  213. data/test/suite_exampletests_v201306.rb +0 -37
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
+ #
6
+ # Copyright:: Copyright 2013, 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 adds a Shared Bidding Strategy and uses it to construct a
22
+ # campaign.
23
+ #
24
+ # Tags: BiddingStrategyService.mutate, CampaignService.mutate
25
+ # Tags: BudgetService.mutate
26
+
27
+ require 'adwords_api'
28
+ require 'date'
29
+
30
+ def use_shared_bidding_strategy()
31
+ # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
32
+ # when called without parameters.
33
+ adwords = AdwordsApi::Api.new
34
+
35
+ # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
36
+ # the configuration file or provide your own logger:
37
+ # adwords.logger = Logger.new('adwords_xml.log')
38
+
39
+ budget_srv = adwords.service(:BudgetService, API_VERSION)
40
+ bidding_srv = adwords.service(:BiddingStrategyService, API_VERSION)
41
+ campaign_srv = adwords.service(:CampaignService, API_VERSION)
42
+
43
+ # Create a budget, which can be shared by multiple campaigns.
44
+ budget = {
45
+ :name => 'Interplanetary budget #%d' % (Time.new.to_f * 1000).to_i,
46
+ :amount => {:micro_amount => 50000000},
47
+ :delivery_method => 'STANDARD',
48
+ :period => 'DAILY',
49
+ :is_explicitly_shared => true
50
+ }
51
+ return_budget = budget_srv.mutate([
52
+ {:operator => 'ADD', :operand => budget}])
53
+ budget_id = return_budget[:value].first[:budget_id]
54
+
55
+ # Create a shared bidding strategy.
56
+ shared_bidding_strategy = {
57
+ :name => 'Maximize Clicks #%d' % (Time.new.to_f * 1000).to_i,
58
+ :bidding_scheme => {
59
+ :xsi_type => 'TargetSpendBiddingScheme',
60
+ # Optionally set additional bidding scheme parameters.
61
+ :bid_ceiling => {:micro_amount => 20000000},
62
+ :spend_target => {:micro_amount => 40000000}
63
+ }
64
+ }
65
+ return_strategy = bidding_srv.mutate([
66
+ {:operator => 'ADD', :operand => shared_bidding_strategy}])
67
+
68
+ bidding_strategy = return_strategy[:value].first
69
+ puts ("Shared bidding strategy with name '%s' and ID %d of type '%s' was " +
70
+ 'created') %
71
+ [bidding_strategy[:name], bidding_strategy[:id], bidding_strategy[:type]]
72
+
73
+ # Create campaigns.
74
+ campaigns = [
75
+ {
76
+ :name => "Interplanetary Cruise #%d" % (Time.new.to_f * 1000).to_i,
77
+ :status => 'PAUSED',
78
+ :bidding_strategy_configuration => {
79
+ :bidding_strategy_id => bidding_strategy[:id]
80
+ },
81
+ # Budget (required) - note only the budget ID is required.
82
+ :budget => {:budget_id => budget_id},
83
+ # Set the campaign network options to Search, Content and Search Network.
84
+ :network_setting => {
85
+ :target_google_search => true,
86
+ :target_search_network => true,
87
+ :target_content_network => true
88
+ },
89
+ :settings => [
90
+ {
91
+ :xsi_type => 'KeywordMatchSetting',
92
+ :opt_in => true
93
+ }
94
+ ]
95
+ },
96
+ {
97
+ :name => "Interplanetary Cruise banner #%d" % (Time.new.to_f * 1000).to_i,
98
+ :status => 'PAUSED',
99
+ :bidding_strategy_configuration => {
100
+ :bidding_strategy_id => bidding_strategy[:id]
101
+ },
102
+ :budget => {:budget_id => budget_id},
103
+ :settings => [
104
+ {
105
+ :xsi_type => 'KeywordMatchSetting',
106
+ :opt_in => true
107
+ }
108
+ ],
109
+ :network_setting => {
110
+ :target_google_search => false,
111
+ :target_search_network => false,
112
+ :target_content_network => true
113
+ }
114
+ }
115
+ ]
116
+
117
+ # Prepare for adding campaign.
118
+ operations = campaigns.map do |campaign|
119
+ {:operator => 'ADD', :operand => campaign}
120
+ end
121
+
122
+ # Add campaign.
123
+ response = campaign_srv.mutate(operations)
124
+ if response and response[:value]
125
+ response[:value].each do |campaign|
126
+ puts "Campaign with name '%s' and ID %d was added." %
127
+ [campaign[:name], campaign[:id]]
128
+ end
129
+ else
130
+ raise new StandardError, 'No campaigns were added.'
131
+ end
132
+ end
133
+
134
+ if __FILE__ == $0
135
+ API_VERSION = :v201309
136
+
137
+ begin
138
+ use_shared_bidding_strategy()
139
+
140
+ # Authorization error.
141
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
142
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
143
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
144
+ "to retrieve and store OAuth2 tokens."
145
+ puts "See this wiki page for more details:\n\n " +
146
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
147
+
148
+ # HTTP errors.
149
+ rescue AdsCommon::Errors::HttpError => e
150
+ puts "HTTP Error: %s" % e
151
+
152
+ # API errors.
153
+ rescue AdwordsApi::Errors::ApiException => e
154
+ puts "Message: %s" % e.message
155
+ puts 'Errors:'
156
+ e.errors.each_with_index do |error, index|
157
+ puts "\tError [%d]:" % (index + 1)
158
+ error.each do |field, value|
159
+ puts "\t\t%s: %s" % [field, value]
160
+ end
161
+ end
162
+ end
163
+ end
@@ -41,18 +41,17 @@ def add_ad_groups(campaign_id)
41
41
  :name => "Earth to Mars Cruises #%d" % (Time.new.to_f * 1000).to_i,
42
42
  :status => 'ENABLED',
43
43
  :campaign_id => campaign_id,
44
- :bids => {
45
- # The 'xsi_type' field allows you to specify the xsi:type of the object
46
- # being created. It's only necessary when you must provide an explicit
47
- # type that the client library can't infer.
48
- :xsi_type => 'ManualCPCAdGroupBids',
49
- :keyword_max_cpc => {
50
- :amount => {
51
- :micro_amount => 10000000
44
+ :bidding_strategy_configuration => {
45
+ :bids => [
46
+ {
47
+ # The 'xsi_type' field allows you to specify the xsi:type of the
48
+ # object being created. It's only necessary when you must provide
49
+ # an explicit type that the client library can't infer.
50
+ :xsi_type => 'CpcBid',
51
+ :bid => {:micro_amount => 10000000},
52
+ :content_bid => {:micro_amount => 2000000}
52
53
  }
53
- },
54
- # Optional field.
55
- :keyword_content_max_cpc => {:amount => {:micro_amount => 2000000}}
54
+ ]
56
55
  },
57
56
  :settings => [
58
57
  # Targetting restriction settings - these setting only affect serving
@@ -80,16 +79,16 @@ def add_ad_groups(campaign_id)
80
79
  :name => 'Earth to Pluto Cruises #%d' % (Time.new.to_f * 1000).to_i,
81
80
  :status => 'ENABLED',
82
81
  :campaign_id => campaign_id,
83
- :bids => {
84
- # The 'xsi_type' field allows you to specify the xsi:type of the object
85
- # being created. It's only necessary when you must provide an explicit
86
- # type that the client library can't infer.
87
- :xsi_type => 'ManualCPCAdGroupBids',
88
- :keyword_max_cpc => {
89
- :amount => {
90
- :micro_amount => 10000000
82
+ :bidding_strategy_configuration => {
83
+ :bids => [
84
+ {
85
+ # The 'xsi_type' field allows you to specify the xsi:type of the
86
+ # object being created. It's only necessary when you must provide
87
+ # an explicit type that the client library can't infer.
88
+ :xsi_type => 'CpcBid',
89
+ :bid => {:micro_amount => 10000000}
91
90
  }
92
- }
91
+ ]
93
92
  }
94
93
  }
95
94
  ]
@@ -111,13 +110,21 @@ def add_ad_groups(campaign_id)
111
110
  end
112
111
 
113
112
  if __FILE__ == $0
114
- API_VERSION = :v201209
113
+ API_VERSION = :v201309
115
114
 
116
115
  begin
117
116
  # Campaign ID to add ad group to.
118
117
  campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
119
118
  add_ad_groups(campaign_id)
120
119
 
120
+ # Authorization error.
121
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
122
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
123
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
124
+ "to retrieve and store OAuth2 tokens."
125
+ puts "See this wiki page for more details:\n\n " +
126
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
127
+
121
128
  # HTTP errors.
122
129
  rescue AdsCommon::Errors::HttpError => e
123
130
  puts "HTTP Error: %s" % e
@@ -55,11 +55,13 @@ def add_campaigns()
55
55
  {
56
56
  :name => "Interplanetary Cruise #%d" % (Time.new.to_f * 1000).to_i,
57
57
  :status => 'PAUSED',
58
- :bidding_strategy => {
59
- # The 'xsi_type' field allows you to specify the xsi:type of the object
60
- # being created. It's only necessary when you must provide an explicit
61
- # type that the client library can't infer.
62
- :xsi_type => 'ManualCPC'
58
+ :bidding_strategy_configuration => {
59
+ :bidding_strategy_type => 'MANUAL_CPC',
60
+ # Optional: provide BiddingScheme.
61
+ :bidding_scheme => {
62
+ :xsi_type => 'ManualCpcBiddingScheme',
63
+ :enhanced_cpc_enabled => false
64
+ }
63
65
  },
64
66
  # Budget (required) - note only the budget ID is required.
65
67
  :budget => {:budget_id => budget_id},
@@ -74,13 +76,6 @@ def add_campaigns()
74
76
  DateTime.parse((Date.today + 1).to_s).strftime('%Y%m%d'),
75
77
  :ad_serving_optimization_status => 'ROTATE',
76
78
  :settings => [
77
- # Display network targeting settings (optional).
78
- # It can only be enabled, shown only for demonstration purposes.
79
- # If not set this setting is enabled by default on ADD operations.
80
- {
81
- :xsi_type => 'TargetRestrictSetting',
82
- :use_ad_group => true
83
- },
84
79
  {
85
80
  :xsi_type => 'GeoTargetTypeSetting',
86
81
  :positive_geo_target_type => 'DONT_CARE',
@@ -100,8 +95,8 @@ def add_campaigns()
100
95
  {
101
96
  :name => "Interplanetary Cruise banner #%d" % (Time.new.to_f * 1000).to_i,
102
97
  :status => 'PAUSED',
103
- :bidding_strategy => {
104
- :xsi_type => 'ManualCPM'
98
+ :bidding_strategy_configuration => {
99
+ :bidding_strategy_type => 'MANUAL_CPC'
105
100
  },
106
101
  :budget => {:budget_id => budget_id},
107
102
  :settings => [
@@ -136,11 +131,19 @@ def add_campaigns()
136
131
  end
137
132
 
138
133
  if __FILE__ == $0
139
- API_VERSION = :v201209
134
+ API_VERSION = :v201309
140
135
 
141
136
  begin
142
137
  add_campaigns()
143
138
 
139
+ # Authorization error.
140
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
141
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
142
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
143
+ "to retrieve and store OAuth2 tokens."
144
+ puts "See this wiki page for more details:\n\n " +
145
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
146
+
144
147
  # HTTP errors.
145
148
  rescue AdsCommon::Errors::HttpError => e
146
149
  puts "HTTP Error: %s" % e
@@ -83,13 +83,21 @@ def add_keywords(ad_group_id)
83
83
  end
84
84
 
85
85
  if __FILE__ == $0
86
- API_VERSION = :v201209
86
+ API_VERSION = :v201309
87
87
 
88
88
  begin
89
89
  # Ad group ID to add keywords to.
90
90
  ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
91
91
  add_keywords(ad_group_id)
92
92
 
93
+ # Authorization error.
94
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
95
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
96
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
97
+ "to retrieve and store OAuth2 tokens."
98
+ puts "See this wiki page for more details:\n\n " +
99
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
100
+
93
101
  # HTTP errors.
94
102
  rescue AdsCommon::Errors::HttpError => e
95
103
  puts "HTTP Error: %s" % e
@@ -80,13 +80,21 @@ def add_text_ads(ad_group_id)
80
80
  end
81
81
 
82
82
  if __FILE__ == $0
83
- API_VERSION = :v201209
83
+ API_VERSION = :v201309
84
84
 
85
85
  begin
86
86
  # Ad group ID to add text ads to.
87
87
  ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
88
88
  add_text_ads(ad_group_id)
89
89
 
90
+ # Authorization error.
91
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
92
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
93
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
94
+ "to retrieve and store OAuth2 tokens."
95
+ puts "See this wiki page for more details:\n\n " +
96
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
97
+
90
98
  # HTTP errors.
91
99
  rescue AdsCommon::Errors::HttpError => e
92
100
  puts "HTTP Error: %s" % e
@@ -59,7 +59,7 @@ def delete_ad(ad_group_id, ad_id)
59
59
  end
60
60
 
61
61
  if __FILE__ == $0
62
- API_VERSION = :v201209
62
+ API_VERSION = :v201309
63
63
 
64
64
  begin
65
65
  # IDs of an ad to delete and its ad group.
@@ -67,6 +67,14 @@ if __FILE__ == $0
67
67
  ad_id = 'INSERT_AD_ID_HERE'.to_i
68
68
  delete_ad(ad_group_id, ad_id)
69
69
 
70
+ # Authorization error.
71
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
72
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
73
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
74
+ "to retrieve and store OAuth2 tokens."
75
+ puts "See this wiki page for more details:\n\n " +
76
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
77
+
70
78
  # HTTP errors.
71
79
  rescue AdsCommon::Errors::HttpError => e
72
80
  puts "HTTP Error: %s" % e
@@ -77,13 +77,21 @@ def delete_ad_group(ad_group_id)
77
77
  end
78
78
 
79
79
  if __FILE__ == $0
80
- API_VERSION = :v201209
80
+ API_VERSION = :v201309
81
81
 
82
82
  begin
83
83
  # ID of an ad group to delete.
84
84
  ad_group_id = 'INSERT_AD_GROUP_ID_HERE'.to_i
85
85
  delete_ad_group(ad_group_id)
86
86
 
87
+ # Authorization error.
88
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
89
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
90
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
91
+ "to retrieve and store OAuth2 tokens."
92
+ puts "See this wiki page for more details:\n\n " +
93
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
94
+
87
95
  # HTTP errors.
88
96
  rescue AdsCommon::Errors::HttpError => e
89
97
  puts "HTTP Error: %s" % e
@@ -78,13 +78,21 @@ def delete_campaign(campaign_id)
78
78
  end
79
79
 
80
80
  if __FILE__ == $0
81
- API_VERSION = :v201209
81
+ API_VERSION = :v201309
82
82
 
83
83
  begin
84
84
  # ID of a campaign to delete.
85
85
  campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
86
86
  delete_campaign(campaign_id)
87
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
+
88
96
  # HTTP errors.
89
97
  rescue AdsCommon::Errors::HttpError => e
90
98
  puts "HTTP Error: %s" % e
@@ -64,7 +64,7 @@ def delete_keyword(ad_group_id, criterion_id)
64
64
  end
65
65
 
66
66
  if __FILE__ == $0
67
- API_VERSION = :v201209
67
+ API_VERSION = :v201309
68
68
 
69
69
  begin
70
70
  # IDs of criterion to delete and its ad group.
@@ -72,6 +72,14 @@ if __FILE__ == $0
72
72
  criterion_id = 'INSERT_CRITERION_ID_HERE'.to_i
73
73
  delete_keyword(ad_group_id, criterion_id)
74
74
 
75
+ # Authorization error.
76
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
77
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
78
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
79
+ "to retrieve and store OAuth2 tokens."
80
+ puts "See this wiki page for more details:\n\n " +
81
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
82
+
75
83
  # HTTP errors.
76
84
  rescue AdsCommon::Errors::HttpError => e
77
85
  puts "HTTP Error: %s" % e