google-adwords-api 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. data/ChangeLog +3 -0
  2. data/README +4 -7
  3. data/examples/v201206/account_management/create_account.rb +84 -0
  4. data/examples/v201206/account_management/get_account_alerts.rb +111 -0
  5. data/examples/v201206/account_management/get_account_changes.rb +137 -0
  6. data/examples/v201206/account_management/get_account_hierarchy.rb +92 -0
  7. data/examples/v201206/account_management/get_client_customer_id.rb +85 -0
  8. data/examples/v201206/account_management/get_client_unit_usage.rb +87 -0
  9. data/examples/v201206/basic_operations/add_ad_groups.rb +136 -0
  10. data/examples/v201206/basic_operations/add_campaigns.rb +146 -0
  11. data/examples/v201206/basic_operations/add_keywords.rb +108 -0
  12. data/examples/v201206/basic_operations/add_text_ads.rb +105 -0
  13. data/examples/v201206/basic_operations/delete_ad.rb +85 -0
  14. data/examples/v201206/basic_operations/delete_ad_group.rb +102 -0
  15. data/examples/v201206/basic_operations/delete_campaign.rb +103 -0
  16. data/examples/v201206/basic_operations/delete_keyword.rb +90 -0
  17. data/examples/v201206/basic_operations/get_ad_groups.rb +98 -0
  18. data/examples/v201206/basic_operations/get_campaigns.rb +93 -0
  19. data/examples/v201206/basic_operations/get_campaigns_with_awql.rb +85 -0
  20. data/examples/v201206/basic_operations/get_keywords.rb +104 -0
  21. data/examples/v201206/basic_operations/get_text_ads.rb +106 -0
  22. data/examples/v201206/basic_operations/pause_ad.rb +84 -0
  23. data/examples/v201206/basic_operations/update_ad_group.rb +81 -0
  24. data/examples/v201206/basic_operations/update_campaign.rb +84 -0
  25. data/examples/v201206/basic_operations/update_keyword.rb +99 -0
  26. data/examples/v201206/campaign_management/add_experiment.rb +158 -0
  27. data/examples/v201206/campaign_management/add_keywords_in_bulk.rb +150 -0
  28. data/examples/v201206/campaign_management/add_location_extension.rb +117 -0
  29. data/examples/v201206/campaign_management/add_location_extension_override.rb +83 -0
  30. data/examples/v201206/campaign_management/get_all_disapproved_ads.rb +93 -0
  31. data/examples/v201206/campaign_management/get_all_disapproved_ads_with_awql.rb +84 -0
  32. data/examples/v201206/campaign_management/promote_experiment.rb +77 -0
  33. data/examples/v201206/campaign_management/set_ad_parameters.rb +114 -0
  34. data/examples/v201206/campaign_management/validate_text_ad.rb +106 -0
  35. data/examples/v201206/error_handling/handle_captcha_challenge.rb +93 -0
  36. data/examples/v201206/error_handling/handle_partial_failures.rb +126 -0
  37. data/examples/v201206/error_handling/handle_policy_violation_error.rb +137 -0
  38. data/examples/v201206/error_handling/handle_two_factor_authorization_error.rb +87 -0
  39. data/examples/v201206/misc/get_all_images_and_videos.rb +101 -0
  40. data/examples/v201206/misc/upload_image.rb +90 -0
  41. data/examples/v201206/misc/use_oauth.rb +100 -0
  42. data/examples/v201206/misc/use_oauth2.rb +97 -0
  43. data/examples/v201206/optimization/estimate_keyword_traffic.rb +129 -0
  44. data/examples/v201206/optimization/get_keyword_bid_simulations.rb +92 -0
  45. data/examples/v201206/optimization/get_keyword_ideas.rb +115 -0
  46. data/examples/v201206/optimization/get_placement_ideas.rb +106 -0
  47. data/examples/v201206/remarketing/add_audience.rb +115 -0
  48. data/examples/v201206/remarketing/add_conversion_tracker.rb +97 -0
  49. data/examples/v201206/reporting/download_criteria_report.rb +79 -0
  50. data/examples/v201206/reporting/download_criteria_report_with_awql.rb +78 -0
  51. data/examples/v201206/reporting/get_campaign_stats.rb +105 -0
  52. data/examples/v201206/reporting/get_defined_reports.rb +75 -0
  53. data/examples/v201206/reporting/get_report_fields.rb +71 -0
  54. data/examples/v201206/reporting/parallel_report_download.rb +159 -0
  55. data/examples/v201206/targeting/add_campaign_targeting_criteria.rb +118 -0
  56. data/examples/v201206/targeting/get_campaign_targeting_criteria.rb +102 -0
  57. data/examples/v201206/targeting/get_targetable_languages_and_carriers.rb +86 -0
  58. data/examples/v201206/targeting/lookup_location.rb +104 -0
  59. data/lib/adwords_api/api_config.rb +69 -5
  60. data/lib/adwords_api/report_utils.rb +50 -1
  61. data/lib/adwords_api/v201109/ad_extension_override_service.rb +1 -1
  62. data/lib/adwords_api/v201109/ad_extension_override_service_registry.rb +1 -1
  63. data/lib/adwords_api/v201109/ad_group_ad_service.rb +1 -1
  64. data/lib/adwords_api/v201109/ad_group_ad_service_registry.rb +1 -1
  65. data/lib/adwords_api/v201109/ad_group_criterion_service.rb +1 -1
  66. data/lib/adwords_api/v201109/ad_group_criterion_service_registry.rb +1 -1
  67. data/lib/adwords_api/v201109/ad_group_service.rb +1 -1
  68. data/lib/adwords_api/v201109/ad_group_service_registry.rb +1 -1
  69. data/lib/adwords_api/v201109/ad_param_service.rb +1 -1
  70. data/lib/adwords_api/v201109/ad_param_service_registry.rb +1 -1
  71. data/lib/adwords_api/v201109/alert_service.rb +1 -1
  72. data/lib/adwords_api/v201109/alert_service_registry.rb +1 -1
  73. data/lib/adwords_api/v201109/budget_order_service.rb +1 -1
  74. data/lib/adwords_api/v201109/budget_order_service_registry.rb +1 -1
  75. data/lib/adwords_api/v201109/bulk_mutate_job_service.rb +1 -1
  76. data/lib/adwords_api/v201109/bulk_mutate_job_service_registry.rb +1 -1
  77. data/lib/adwords_api/v201109/campaign_ad_extension_service.rb +1 -1
  78. data/lib/adwords_api/v201109/campaign_ad_extension_service_registry.rb +1 -1
  79. data/lib/adwords_api/v201109/campaign_criterion_service.rb +1 -1
  80. data/lib/adwords_api/v201109/campaign_criterion_service_registry.rb +1 -1
  81. data/lib/adwords_api/v201109/campaign_service.rb +1 -1
  82. data/lib/adwords_api/v201109/campaign_service_registry.rb +1 -1
  83. data/lib/adwords_api/v201109/campaign_target_service.rb +1 -1
  84. data/lib/adwords_api/v201109/campaign_target_service_registry.rb +1 -1
  85. data/lib/adwords_api/v201109/constant_data_service.rb +1 -1
  86. data/lib/adwords_api/v201109/constant_data_service_registry.rb +1 -1
  87. data/lib/adwords_api/v201109/conversion_tracker_service.rb +1 -1
  88. data/lib/adwords_api/v201109/conversion_tracker_service_registry.rb +1 -1
  89. data/lib/adwords_api/v201109/create_account_service.rb +1 -1
  90. data/lib/adwords_api/v201109/create_account_service_registry.rb +1 -1
  91. data/lib/adwords_api/v201109/customer_sync_service.rb +1 -1
  92. data/lib/adwords_api/v201109/customer_sync_service_registry.rb +1 -1
  93. data/lib/adwords_api/v201109/data_service.rb +1 -1
  94. data/lib/adwords_api/v201109/data_service_registry.rb +1 -1
  95. data/lib/adwords_api/v201109/experiment_service.rb +1 -1
  96. data/lib/adwords_api/v201109/experiment_service_registry.rb +1 -1
  97. data/lib/adwords_api/v201109/geo_location_service.rb +1 -1
  98. data/lib/adwords_api/v201109/geo_location_service_registry.rb +1 -1
  99. data/lib/adwords_api/v201109/info_service.rb +1 -1
  100. data/lib/adwords_api/v201109/info_service_registry.rb +1 -1
  101. data/lib/adwords_api/v201109/location_criterion_service.rb +1 -1
  102. data/lib/adwords_api/v201109/location_criterion_service_registry.rb +1 -1
  103. data/lib/adwords_api/v201109/media_service.rb +1 -1
  104. data/lib/adwords_api/v201109/media_service_registry.rb +1 -1
  105. data/lib/adwords_api/v201109/mutate_job_service.rb +1 -1
  106. data/lib/adwords_api/v201109/mutate_job_service_registry.rb +1 -1
  107. data/lib/adwords_api/v201109/report_definition_service.rb +1 -1
  108. data/lib/adwords_api/v201109/report_definition_service_registry.rb +1 -1
  109. data/lib/adwords_api/v201109/serviced_account_service.rb +1 -1
  110. data/lib/adwords_api/v201109/serviced_account_service_registry.rb +1 -1
  111. data/lib/adwords_api/v201109/targeting_idea_service.rb +1 -1
  112. data/lib/adwords_api/v201109/targeting_idea_service_registry.rb +2 -2
  113. data/lib/adwords_api/v201109/traffic_estimator_service.rb +1 -1
  114. data/lib/adwords_api/v201109/traffic_estimator_service_registry.rb +1 -1
  115. data/lib/adwords_api/v201109/user_list_service.rb +1 -1
  116. data/lib/adwords_api/v201109/user_list_service_registry.rb +1 -1
  117. data/lib/adwords_api/v201109_1/ad_extension_override_service.rb +1 -1
  118. data/lib/adwords_api/v201109_1/ad_extension_override_service_registry.rb +1 -1
  119. data/lib/adwords_api/v201109_1/ad_group_ad_service.rb +1 -1
  120. data/lib/adwords_api/v201109_1/ad_group_ad_service_registry.rb +1 -1
  121. data/lib/adwords_api/v201109_1/ad_group_criterion_service.rb +1 -1
  122. data/lib/adwords_api/v201109_1/ad_group_criterion_service_registry.rb +1 -1
  123. data/lib/adwords_api/v201109_1/ad_group_service.rb +1 -1
  124. data/lib/adwords_api/v201109_1/ad_group_service_registry.rb +1 -1
  125. data/lib/adwords_api/v201109_1/ad_param_service.rb +1 -1
  126. data/lib/adwords_api/v201109_1/ad_param_service_registry.rb +1 -1
  127. data/lib/adwords_api/v201109_1/alert_service.rb +1 -1
  128. data/lib/adwords_api/v201109_1/alert_service_registry.rb +1 -1
  129. data/lib/adwords_api/v201109_1/budget_order_service.rb +1 -1
  130. data/lib/adwords_api/v201109_1/budget_order_service_registry.rb +1 -1
  131. data/lib/adwords_api/v201109_1/bulk_mutate_job_service.rb +1 -1
  132. data/lib/adwords_api/v201109_1/bulk_mutate_job_service_registry.rb +1 -1
  133. data/lib/adwords_api/v201109_1/campaign_ad_extension_service.rb +1 -1
  134. data/lib/adwords_api/v201109_1/campaign_ad_extension_service_registry.rb +1 -1
  135. data/lib/adwords_api/v201109_1/campaign_criterion_service.rb +1 -1
  136. data/lib/adwords_api/v201109_1/campaign_criterion_service_registry.rb +1 -1
  137. data/lib/adwords_api/v201109_1/campaign_service.rb +1 -1
  138. data/lib/adwords_api/v201109_1/campaign_service_registry.rb +1 -1
  139. data/lib/adwords_api/v201109_1/campaign_target_service.rb +1 -1
  140. data/lib/adwords_api/v201109_1/campaign_target_service_registry.rb +1 -1
  141. data/lib/adwords_api/v201109_1/constant_data_service.rb +1 -1
  142. data/lib/adwords_api/v201109_1/constant_data_service_registry.rb +1 -1
  143. data/lib/adwords_api/v201109_1/conversion_tracker_service.rb +1 -1
  144. data/lib/adwords_api/v201109_1/conversion_tracker_service_registry.rb +1 -1
  145. data/lib/adwords_api/v201109_1/create_account_service.rb +1 -1
  146. data/lib/adwords_api/v201109_1/create_account_service_registry.rb +1 -1
  147. data/lib/adwords_api/v201109_1/customer_service.rb +34 -0
  148. data/lib/adwords_api/v201109_1/customer_service_registry.rb +46 -0
  149. data/lib/adwords_api/v201109_1/customer_sync_service.rb +1 -1
  150. data/lib/adwords_api/v201109_1/customer_sync_service_registry.rb +1 -1
  151. data/lib/adwords_api/v201109_1/data_service.rb +1 -1
  152. data/lib/adwords_api/v201109_1/data_service_registry.rb +1 -1
  153. data/lib/adwords_api/v201109_1/experiment_service.rb +1 -1
  154. data/lib/adwords_api/v201109_1/experiment_service_registry.rb +1 -1
  155. data/lib/adwords_api/v201109_1/geo_location_service.rb +1 -1
  156. data/lib/adwords_api/v201109_1/geo_location_service_registry.rb +1 -1
  157. data/lib/adwords_api/v201109_1/info_service.rb +1 -1
  158. data/lib/adwords_api/v201109_1/info_service_registry.rb +1 -1
  159. data/lib/adwords_api/v201109_1/location_criterion_service.rb +1 -1
  160. data/lib/adwords_api/v201109_1/location_criterion_service_registry.rb +1 -1
  161. data/lib/adwords_api/v201109_1/managed_customer_service.rb +38 -0
  162. data/lib/adwords_api/v201109_1/managed_customer_service_registry.rb +46 -0
  163. data/lib/adwords_api/v201109_1/media_service.rb +1 -1
  164. data/lib/adwords_api/v201109_1/media_service_registry.rb +1 -1
  165. data/lib/adwords_api/v201109_1/mutate_job_service.rb +1 -1
  166. data/lib/adwords_api/v201109_1/mutate_job_service_registry.rb +1 -1
  167. data/lib/adwords_api/v201109_1/report_definition_service.rb +1 -1
  168. data/lib/adwords_api/v201109_1/report_definition_service_registry.rb +1 -1
  169. data/lib/adwords_api/v201109_1/serviced_account_service.rb +1 -1
  170. data/lib/adwords_api/v201109_1/serviced_account_service_registry.rb +1 -1
  171. data/lib/adwords_api/v201109_1/targeting_idea_service.rb +1 -1
  172. data/lib/adwords_api/v201109_1/targeting_idea_service_registry.rb +2 -2
  173. data/lib/adwords_api/v201109_1/traffic_estimator_service.rb +1 -1
  174. data/lib/adwords_api/v201109_1/traffic_estimator_service_registry.rb +1 -1
  175. data/lib/adwords_api/v201109_1/user_list_service.rb +1 -1
  176. data/lib/adwords_api/v201109_1/user_list_service_registry.rb +1 -1
  177. data/lib/adwords_api/v201206/ad_extension_override_service.rb +38 -0
  178. data/lib/adwords_api/v201206/ad_extension_override_service_registry.rb +46 -0
  179. data/lib/adwords_api/v201206/ad_group_ad_service.rb +42 -0
  180. data/lib/adwords_api/v201206/ad_group_ad_service_registry.rb +46 -0
  181. data/lib/adwords_api/v201206/ad_group_criterion_service.rb +42 -0
  182. data/lib/adwords_api/v201206/ad_group_criterion_service_registry.rb +46 -0
  183. data/lib/adwords_api/v201206/ad_group_service.rb +42 -0
  184. data/lib/adwords_api/v201206/ad_group_service_registry.rb +46 -0
  185. data/lib/adwords_api/v201206/ad_param_service.rb +38 -0
  186. data/lib/adwords_api/v201206/ad_param_service_registry.rb +46 -0
  187. data/lib/adwords_api/v201206/alert_service.rb +34 -0
  188. data/lib/adwords_api/v201206/alert_service_registry.rb +46 -0
  189. data/lib/adwords_api/v201206/budget_order_service.rb +42 -0
  190. data/lib/adwords_api/v201206/budget_order_service_registry.rb +46 -0
  191. data/lib/adwords_api/v201206/bulk_mutate_job_service.rb +38 -0
  192. data/lib/adwords_api/v201206/bulk_mutate_job_service_registry.rb +46 -0
  193. data/lib/adwords_api/v201206/campaign_ad_extension_service.rb +38 -0
  194. data/lib/adwords_api/v201206/campaign_ad_extension_service_registry.rb +46 -0
  195. data/lib/adwords_api/v201206/campaign_criterion_service.rb +42 -0
  196. data/lib/adwords_api/v201206/campaign_criterion_service_registry.rb +46 -0
  197. data/lib/adwords_api/v201206/campaign_service.rb +42 -0
  198. data/lib/adwords_api/v201206/campaign_service_registry.rb +46 -0
  199. data/lib/adwords_api/v201206/constant_data_service.rb +62 -0
  200. data/lib/adwords_api/v201206/constant_data_service_registry.rb +46 -0
  201. data/lib/adwords_api/v201206/conversion_tracker_service.rb +38 -0
  202. data/lib/adwords_api/v201206/conversion_tracker_service_registry.rb +46 -0
  203. data/lib/adwords_api/v201206/customer_service.rb +34 -0
  204. data/lib/adwords_api/v201206/customer_service_registry.rb +46 -0
  205. data/lib/adwords_api/v201206/customer_sync_service.rb +34 -0
  206. data/lib/adwords_api/v201206/customer_sync_service_registry.rb +47 -0
  207. data/lib/adwords_api/v201206/data_service.rb +38 -0
  208. data/lib/adwords_api/v201206/data_service_registry.rb +46 -0
  209. data/lib/adwords_api/v201206/experiment_service.rb +38 -0
  210. data/lib/adwords_api/v201206/experiment_service_registry.rb +46 -0
  211. data/lib/adwords_api/v201206/geo_location_service.rb +34 -0
  212. data/lib/adwords_api/v201206/geo_location_service_registry.rb +46 -0
  213. data/lib/adwords_api/v201206/info_service.rb +34 -0
  214. data/lib/adwords_api/v201206/info_service_registry.rb +46 -0
  215. data/lib/adwords_api/v201206/location_criterion_service.rb +34 -0
  216. data/lib/adwords_api/v201206/location_criterion_service_registry.rb +46 -0
  217. data/lib/adwords_api/v201206/managed_customer_service.rb +38 -0
  218. data/lib/adwords_api/v201206/managed_customer_service_registry.rb +46 -0
  219. data/lib/adwords_api/v201206/media_service.rb +38 -0
  220. data/lib/adwords_api/v201206/media_service_registry.rb +46 -0
  221. data/lib/adwords_api/v201206/mutate_job_service.rb +42 -0
  222. data/lib/adwords_api/v201206/mutate_job_service_registry.rb +46 -0
  223. data/lib/adwords_api/v201206/report_definition_service.rb +34 -0
  224. data/lib/adwords_api/v201206/report_definition_service_registry.rb +46 -0
  225. data/lib/adwords_api/v201206/targeting_idea_service.rb +38 -0
  226. data/lib/adwords_api/v201206/targeting_idea_service_registry.rb +46 -0
  227. data/lib/adwords_api/v201206/traffic_estimator_service.rb +34 -0
  228. data/lib/adwords_api/v201206/traffic_estimator_service_registry.rb +46 -0
  229. data/lib/adwords_api/v201206/user_list_service.rb +38 -0
  230. data/lib/adwords_api/v201206/user_list_service_registry.rb +46 -0
  231. data/lib/adwords_api/version.rb +1 -1
  232. data/test/adwords_api/test_api_config.rb +10 -10
  233. data/test/adwords_api/test_report_utils.rb +1 -1
  234. data/test/bugs/test_issue_00000031.rb +14 -14
  235. data/test/bugs/test_issue_00000063.rb +6 -6
  236. data/test/examples/v201206/test_account_management.rb +60 -0
  237. data/test/examples/v201206/test_basic_operations.rb +177 -0
  238. data/test/examples/v201206/test_campaign_management.rb +124 -0
  239. data/test/examples/v201206/test_error_handling.rb +63 -0
  240. data/test/examples/v201206/test_misc.rb +45 -0
  241. data/test/examples/v201206/test_optimization.rb +63 -0
  242. data/test/examples/v201206/test_remarketing.rb +39 -0
  243. data/test/examples/v201206/test_reporting.rb +89 -0
  244. data/test/examples/v201206/test_targeting.rb +60 -0
  245. data/test/examples/v201206/utils.rb +239 -0
  246. data/test/suite_exampletests_v201206.rb +37 -0
  247. metadata +155 -50
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
+ #
6
+ # Copyright:: Copyright 2012, 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
+ # Tests the error handling examples.
22
+
23
+ require 'test/unit'
24
+
25
+ require 'error_handling/handle_captcha_challenge'
26
+ require 'error_handling/handle_partial_failures'
27
+ require 'error_handling/handle_policy_violation_error'
28
+ require 'error_handling/handle_two_factor_authorization_error'
29
+
30
+ MAX_RETRIES = 50
31
+
32
+ class TestErrorHandlingV201206 < Test::Unit::TestCase
33
+ def setup
34
+ @logger = Logger.new(STDOUT)
35
+ @logger.level = Logger::ERROR
36
+ @adwords = AdwordsApi::Api.new
37
+ @adwords.logger = @logger
38
+ @utils = UtilsV201206.new(@adwords)
39
+ end
40
+
41
+ # This test is disabled as it requires user input.
42
+ def disabled_test_handle_captcha_challenge
43
+ handle_captcha_challenge()
44
+ end
45
+
46
+ def test_handle_partial_failures
47
+ ad_group = @utils.get_ad_group()
48
+ assert_not_nil(ad_group)
49
+ assert_not_nil(ad_group[:id])
50
+ handle_partial_failures(ad_group[:id])
51
+ end
52
+
53
+ def test_handle_policy_violation_error
54
+ ad_group = @utils.get_ad_group()
55
+ assert_not_nil(ad_group)
56
+ assert_not_nil(ad_group[:id])
57
+ handle_policy_violation_error(ad_group[:id])
58
+ end
59
+
60
+ def test_handle_two_factor_authorization_error
61
+ handle_two_factor_authorization_error()
62
+ end
63
+ end
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
+ #
6
+ # Copyright:: Copyright 2012, 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
+ # Tests the misc examples.
22
+
23
+ require 'test/unit'
24
+
25
+ require 'misc/get_all_images_and_videos'
26
+ require 'misc/upload_image'
27
+ require 'misc/use_oauth'
28
+
29
+ class TestMiscV201206 < Test::Unit::TestCase
30
+ def setup
31
+ end
32
+
33
+ def test_get_all_images_and_videos
34
+ get_all_images_and_videos()
35
+ end
36
+
37
+ def test_upload_image
38
+ upload_image()
39
+ end
40
+
41
+ # This test is disabled as it requires user input.
42
+ def disabled_test_use_oauth
43
+ use_oauth()
44
+ end
45
+ end
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
+ #
6
+ # Copyright:: Copyright 2012, 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
+ # Tests the optimization examples.
22
+
23
+ require 'test/unit'
24
+
25
+ require 'optimization/estimate_keyword_traffic'
26
+ require 'optimization/get_keyword_bid_simulations'
27
+ require 'optimization/get_keyword_ideas'
28
+ require 'optimization/get_placement_ideas'
29
+
30
+ class TestOptimizationV201206 < Test::Unit::TestCase
31
+ def setup
32
+ @logger = Logger.new(STDOUT)
33
+ @logger.level = Logger::ERROR
34
+ @adwords = AdwordsApi::Api.new
35
+ @adwords.logger = @logger
36
+ @utils = UtilsV201206.new(@adwords)
37
+ end
38
+
39
+ def test_estimate_keyword_traffic
40
+ estimate_keyword_traffic()
41
+ end
42
+
43
+ def test_get_keyword_bid_simulations
44
+ ad_group = @utils.get_ad_group()
45
+ assert_not_nil(ad_group)
46
+ assert_not_nil(ad_group[:id])
47
+ keyword = @utils.get_keyword()
48
+ assert_not_nil(keyword)
49
+ assert_not_nil(keyword[:criterion])
50
+ assert_not_nil(keyword[:criterion][:id])
51
+ get_criterion_bid_landscapes(ad_group[:id], keyword[:criterion][:id])
52
+ end
53
+
54
+ def test_get_keyword_ideas
55
+ keyword_text = 'orion tours'
56
+ get_keyword_ideas(keyword_text)
57
+ end
58
+
59
+ def test_get_placement_ideas
60
+ url = 'http://example.google.com'
61
+ get_placement_ideas(url)
62
+ end
63
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
+ #
6
+ # Copyright:: Copyright 2012, 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
+ # Tests the remarketing examples.
22
+
23
+ require 'test/unit'
24
+
25
+ require 'remarketing/add_audience'
26
+ require 'remarketing/add_conversion_tracker'
27
+
28
+ class TestRemarketingV201206 < Test::Unit::TestCase
29
+ def setup
30
+ end
31
+
32
+ def test_add_audience
33
+ add_audience()
34
+ end
35
+
36
+ def test_add_conversion_tracker
37
+ add_conversion_tracker()
38
+ end
39
+ end
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
+ #
6
+ # Copyright:: Copyright 2012, 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
+ # Tests the reporting examples.
22
+
23
+ require 'test/unit'
24
+ require 'tempfile'
25
+
26
+ require 'reporting/download_criteria_report'
27
+ require 'reporting/download_criteria_report_with_awql'
28
+ require 'reporting/get_campaign_stats'
29
+ require 'reporting/get_defined_reports'
30
+ require 'reporting/get_report_fields'
31
+ require 'reporting/parallel_report_download'
32
+
33
+ THREADS = 3
34
+ MAX_RETRIES = 3
35
+ BACKOFF_FACTOR = 3
36
+
37
+ class TestReportingV201206 < Test::Unit::TestCase
38
+ def setup()
39
+ @logger = Logger.new(STDOUT)
40
+ @logger.level = Logger::ERROR
41
+ @adwords = AdwordsApi::Api.new()
42
+ @adwords.logger = @logger
43
+ @utils = UtilsV201206.new(@adwords)
44
+ end
45
+
46
+ def test_download_criteria_report()
47
+ file = Tempfile.new('ruby-examples')
48
+ begin
49
+ file.close()
50
+ download_criteria_report(file.path)
51
+ ensure
52
+ file.unlink()
53
+ end
54
+ end
55
+
56
+ def test_download_criteria_report_with_awql()
57
+ file = Tempfile.new('ruby-examples')
58
+ begin
59
+ file.close()
60
+ download_criteria_report_with_awql(file.path, 'CSV')
61
+ ensure
62
+ file.unlink()
63
+ end
64
+ end
65
+
66
+ def test_get_campaign_stats()
67
+ get_campaign_stats()
68
+ end
69
+
70
+ def test_get_defined_reports()
71
+ get_defined_reports()
72
+ end
73
+
74
+ def test_get_report_fields()
75
+ report_type = 'ACCOUNT_PERFORMANCE_REPORT'
76
+ get_report_fields(report_type)
77
+ end
78
+
79
+ def test_parallel_report_download()
80
+ old_dir = Dir.pwd
81
+ Dir.chdir('/tmp')
82
+ begin
83
+ parallel_report_download()
84
+ ensure
85
+ Dir.chdir(old_dir)
86
+ end
87
+ end
88
+ end
89
+
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
5
+ #
6
+ # Copyright:: Copyright 2012, 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
+ # Tests the targeting examples.
22
+
23
+ require 'test/unit'
24
+
25
+ require 'targeting/add_campaign_targeting_criteria'
26
+ require 'targeting/get_campaign_targeting_criteria'
27
+ require 'targeting/get_targetable_languages_and_carriers'
28
+ require 'targeting/lookup_location'
29
+
30
+ class TestTargetingV201206 < Test::Unit::TestCase
31
+ def setup
32
+ @logger = Logger.new(STDOUT)
33
+ @logger.level = Logger::ERROR
34
+ @adwords = AdwordsApi::Api.new
35
+ @adwords.logger = @logger
36
+ @utils = UtilsV201206.new(@adwords)
37
+ end
38
+
39
+ def test_add_campaign_targeting_criteria
40
+ campaign = @utils.get_campaign()
41
+ assert_not_nil(campaign)
42
+ assert_not_nil(campaign[:id])
43
+ add_campaign_targeting_criteria(campaign[:id])
44
+ end
45
+
46
+ def test_get_campaign_targeting_criteria
47
+ campaign = @utils.get_campaign()
48
+ assert_not_nil(campaign)
49
+ assert_not_nil(campaign[:id])
50
+ get_campaign_targeting_criteria(campaign[:id])
51
+ end
52
+
53
+ def test_get_targetable_languages_and_carriers
54
+ get_targetable_languages_and_carriers()
55
+ end
56
+
57
+ def test_lookup_location
58
+ lookup_location()
59
+ end
60
+ end
@@ -0,0 +1,239 @@
1
+ # Encoding: utf-8
2
+ #
3
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
4
+ #
5
+ # Copyright:: Copyright 2012, 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
+ # Utilities and constants for example tests.
21
+
22
+ API_VERSION = :v201206
23
+ PAGE_SIZE = 500
24
+
25
+ class UtilsV201206
26
+ def initialize(adwords)
27
+ @adwords = adwords
28
+ end
29
+
30
+ def get_campaign
31
+ @campaign ||= create_campaign()
32
+ return @campaign
33
+ end
34
+
35
+ def get_ad_group
36
+ @ad_group ||= create_ad_group()
37
+ return @ad_group
38
+ end
39
+
40
+ def get_ad
41
+ @ad ||= create_ad(get_ad_group()[:id])
42
+ return @ad
43
+ end
44
+
45
+ def get_keyword
46
+ @keyword ||= create_keyword(get_ad_group()[:id])
47
+ return @keyword
48
+ end
49
+
50
+ def get_location_extension
51
+ @location_extension ||= create_location_extension(get_campaign()[:id])
52
+ return @location_extension
53
+ end
54
+
55
+ def get_experiment
56
+ @experiment ||= create_experiment(
57
+ get_campaign()[:id], get_ad_group()[:id], get_keyword[:criterion][:id])
58
+ return @experiment
59
+ end
60
+
61
+ private
62
+
63
+ def create_campaign
64
+ campaign_srv = @adwords.service(:CampaignService, API_VERSION)
65
+ campaign = {
66
+ :name => "Example tests campaign #%d" % (Time.new.to_f * 1000).to_i,
67
+ :status => 'PAUSED',
68
+ :bidding_strategy => {:xsi_type => 'ManualCPC'},
69
+ :budget => {
70
+ :period => 'DAILY',
71
+ :amount => {:micro_amount => 50000000},
72
+ :delivery_method => 'STANDARD'
73
+ },
74
+ :network_setting => {
75
+ :target_google_search => true,
76
+ :target_search_network => true,
77
+ :target_content_network => false,
78
+ :target_content_contextual => false
79
+ }
80
+ }
81
+ operation = {:operator => 'ADD', :operand => campaign}
82
+ response = campaign_srv.mutate([operation])
83
+ return response[:value].first
84
+ end
85
+
86
+ def create_ad_group
87
+ campaign = get_campaign()
88
+ ad_group_srv = @adwords.service(:AdGroupService, API_VERSION)
89
+ ad_group = {
90
+ :name => "Example tests ad group #%d" % (Time.new.to_f * 1000).to_i,
91
+ :status => 'ENABLED',
92
+ :campaign_id => campaign[:id],
93
+ :bids => {
94
+ :xsi_type => 'ManualCPCAdGroupBids',
95
+ :keyword_max_cpc => {:amount => {:micro_amount => 10000000}},
96
+ }
97
+ }
98
+ operation = {:operator => 'ADD', :operand => ad_group}
99
+ response = ad_group_srv.mutate([operation])
100
+ return response[:value].first
101
+ end
102
+
103
+ def create_ad(ad_group_id)
104
+ ad_group_ad_srv = @adwords.service(:AdGroupAdService, API_VERSION)
105
+ text_ad = {
106
+ :xsi_type => 'TextAd',
107
+ :headline => 'Examples test ad %d' % (Time.new.to_f * 1000).to_i,
108
+ :description1 => 'testing ruby examples',
109
+ :description2 => 'all your base are belong to us',
110
+ :url => 'http://www.example.com',
111
+ :display_url => 'www.example.com'
112
+ }
113
+ operation = {:operator => 'ADD',
114
+ :operand => {:ad_group_id => ad_group_id, :ad => text_ad}}
115
+ response = ad_group_ad_srv.mutate([operation])
116
+ return response[:value].first
117
+ end
118
+
119
+ def create_keyword(ad_group_id)
120
+ ad_group_criterion_srv =
121
+ @adwords.service(:AdGroupCriterionService, API_VERSION)
122
+ keyword = {
123
+ :xsi_type => 'BiddableAdGroupCriterion',
124
+ :ad_group_id => ad_group_id,
125
+ :criterion => {
126
+ :xsi_type => 'Keyword',
127
+ :text => 'mars cruise',
128
+ :match_type => 'BROAD'
129
+ }
130
+ }
131
+ operation = {:operator => 'ADD', :operand => keyword}
132
+ response = ad_group_criterion_srv.mutate([operation])
133
+ return response[:value].first
134
+ end
135
+
136
+ def create_location_extension(campaign_id)
137
+ campaign_ad_ext_srv =
138
+ @adwords.service(:CampaignAdExtensionService, API_VERSION)
139
+ geo_location_srv = @adwords.service(:GeoLocationService, API_VERSION)
140
+
141
+ selector = {
142
+ :addresses => [
143
+ {
144
+ :street_address => '1600 Amphitheatre Parkway',
145
+ :city_name => 'Mountain View',
146
+ :province_code => 'CA',
147
+ :postal_code => '94043',
148
+ :country_code => 'US'
149
+ }
150
+ ]
151
+ }
152
+
153
+ locations = geo_location_srv.get(selector)
154
+ raise StandardError, 'Unable to retrieve geo locations.' if locations.nil?
155
+
156
+ operations = locations.map do |location|
157
+ {
158
+ :operator => 'ADD',
159
+ :operand => {
160
+ :campaign_id => campaign_id,
161
+ :status => 'ACTIVE',
162
+ :ad_extension => {
163
+ :xsi_type => 'LocationExtension',
164
+ :address => location[:address],
165
+ :geo_point => location[:geo_point],
166
+ :encoded_location => location[:encoded_location],
167
+ :source => 'ADWORDS_FRONTEND'
168
+ }
169
+ }
170
+ }
171
+ end
172
+
173
+ response = campaign_ad_ext_srv.mutate(operations)
174
+ extension = response[:value].first
175
+ return extension
176
+ end
177
+
178
+ def create_experiment(campaign_id, ad_group_id, criterion_id)
179
+ experiment_srv = @adwords.service(:ExperimentService, API_VERSION)
180
+ ad_group_srv = @adwords.service(:AdGroupService, API_VERSION)
181
+ ad_group_criterion_srv =
182
+ @adwords.service(:AdGroupCriterionService, API_VERSION)
183
+
184
+ operation = {
185
+ :operator => 'ADD',
186
+ :operand => {
187
+ :campaign_id => campaign_id,
188
+ :name => "Examples test experiment #%d" % (Time.new.to_f * 1000).to_i,
189
+ :query_percentage => 10,
190
+ :start_date_time => Time.now.strftime('%Y%m%d %H%M%S'),
191
+ }
192
+ }
193
+ response = experiment_srv.mutate([operation])
194
+ experiment = response[:value].first
195
+
196
+ raise StandardError, 'Failed to create experiment' if experiment.nil?
197
+
198
+ ad_group = {
199
+ :id => ad_group_id,
200
+ :experiment_data => {
201
+ :experiment_id => experiment[:id],
202
+ :experiment_delta_status => 'MODIFIED',
203
+ :experiment_bid_multipliers => {
204
+ :xsi_type => 'ManualCPCAdGroupExperimentBidMultipliers',
205
+ :max_cpc_multiplier => {:multiplier => 1.5}
206
+ }
207
+ }
208
+ }
209
+
210
+ operation = {:operator => 'SET', :operand => ad_group}
211
+ response = ad_group_srv.mutate([operation])
212
+ ad_group = response[:value].first
213
+
214
+ raise StandardError, 'Failed to assign experiment' if ad_group.nil?
215
+
216
+ ad_group_criterion = {
217
+ :xsi_type => 'BiddableAdGroupCriterion',
218
+ :ad_group_id => ad_group_id,
219
+ :criterion => {:id => criterion_id},
220
+ :experiment_data => {
221
+ :xsi_type => 'BiddableAdGroupCriterionExperimentData',
222
+ :experiment_id => experiment[:id],
223
+ :experiment_delta_status => 'MODIFIED',
224
+ :experiment_bid_multiplier => {
225
+ :xsi_type => 'ManualCPCAdGroupCriterionExperimentBidMultiplier',
226
+ :max_cpc_multiplier => {:multiplier => 1.5}
227
+ }
228
+ }
229
+ }
230
+
231
+ operation = {:operator => 'SET', :operand => ad_group_criterion}
232
+ response = ad_group_criterion_srv.mutate([operation])
233
+ criterion = response[:value].first
234
+
235
+ raise StandardError, 'Failed to assign criterion' if criterion.nil?
236
+
237
+ return experiment
238
+ end
239
+ end