google-adwords-api 0.9.3 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,88 +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 illustrates how to find a client customer ID for a client email.
22
- # We recommend to use this script as a one off to convert your identifiers to
23
- # IDs and store them for future use.
24
- #
25
- # Note: This code example uses MCC-level calls and won't work with Test
26
- # Accounts, see: https://developers.google.com/adwords/api/docs/test-accounts
27
- #
28
- # Tags: InfoService.get
29
-
30
- require 'adwords_api'
31
- require 'adwords_api/utils'
32
-
33
- def get_client_customer_id(client_email)
34
- # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
35
- # when called without parameters.
36
- adwords = AdwordsApi::Api.new
37
-
38
- # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
39
- # the configuration file or provide your own logger:
40
- # adwords.logger = Logger.new('adwords_xml.log')
41
-
42
- info_srv = adwords.service(:InfoService, API_VERSION)
43
-
44
- today = Time.new.strftime('%Y%m%d')
45
- selector = {
46
- :client_emails => [client_email],
47
- :api_usage_type => 'UNIT_COUNT_FOR_CLIENTS',
48
- :include_sub_accounts => true,
49
- :date_range => {:min => today, :max => today}
50
- }
51
-
52
- # Get the information for client email address.
53
- info = adwords.use_mcc() {info_srv.get(selector)}
54
-
55
- if info and info[:api_usage_records]
56
- api_usage_records = info[:api_usage_records]
57
- api_usage_records.each do |record|
58
- puts "Found record with client email '%s' and ID %s." %
59
- [record[:client_email],
60
- AdwordsApi::Utils.format_id(record[:client_customer_id])]
61
- end
62
- end
63
- end
64
-
65
- if __FILE__ == $0
66
- API_VERSION = :v201209
67
-
68
- begin
69
- # Email address to find ID for.
70
- client_email = 'INSERT_EMAIL_ADDRESS_HERE'
71
- get_client_customer_id(client_email)
72
-
73
- # HTTP errors.
74
- rescue AdsCommon::Errors::HttpError => e
75
- puts "HTTP Error: %s" % e
76
-
77
- # API errors.
78
- rescue AdwordsApi::Errors::ApiException => e
79
- puts "Message: %s" % e.message
80
- puts 'Errors:'
81
- e.errors.each_with_index do |error, index|
82
- puts "\tError [%d]:" % (index + 1)
83
- error.each do |field, value|
84
- puts "\t\t%s: %s" % [field, value]
85
- end
86
- end
87
- end
88
- 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 illustrates how to retrieve the number of API units usage for a
22
- # client account for the current month.
23
- #
24
- # Note: This code example uses MCC-level calls and won't work with Test
25
- # Accounts, see: https://developers.google.com/adwords/api/docs/test-accounts
26
- #
27
- # Tags: InfoService.get
28
-
29
- require 'adwords_api'
30
-
31
- def get_client_unit_usage(client_customer_id)
32
- # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
33
- # when called without parameters.
34
- adwords = AdwordsApi::Api.new
35
-
36
- # To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
37
- # the configuration file or provide your own logger:
38
- # adwords.logger = Logger.new('adwords_xml.log')
39
-
40
- info_srv = adwords.service(:InfoService, API_VERSION)
41
-
42
- start_date = Time.now.strftime('%Y%m01')
43
- end_date = Time.now.strftime('%Y%m%d')
44
-
45
- selector = {
46
- :api_usage_type => 'UNIT_COUNT_FOR_CLIENTS',
47
- :client_customer_ids => [client_customer_id],
48
- # Set to true to navigate your entire accounts tree.
49
- :include_sub_accounts => 1,
50
- :date_range => {
51
- :min => start_date,
52
- :max => end_date
53
- }
54
- }
55
-
56
- # Force to use the MCC credentials.
57
- adwords.use_mcc do
58
- # Get the unit info.
59
- info_srv.get(selector) do |header, response|
60
- puts "Total number of units consumed from %s to %s is %d." %
61
- [start_date, end_date, response[:cost]]
62
- puts "Number of units consumed by this request is %d" % header[:units]
63
- end
64
- end
65
- end
66
-
67
- if __FILE__ == $0
68
- API_VERSION = :v201209
69
-
70
- begin
71
- # Specify client customer ID for the account to get usage for.
72
- client_customer_id = 'INSERT_CLIENT_CUSTOMER_ID_HERE'.to_i
73
- get_client_unit_usage(client_customer_id)
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,103 +0,0 @@
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 illustrates how to create a video campaign.
22
- #
23
- # Note: AdWords for Video API is a Beta feature.
24
- #
25
- # Tags: VideoCampaignService.mutate, BudgetService.mutate
26
-
27
- require 'adwords_api'
28
- require 'date'
29
-
30
- def add_video_campaign()
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
- video_campaign_srv = adwords.service(:VideoCampaignService, API_VERSION)
41
-
42
- # Create a budget, which can be shared by multiple campaigns.
43
- budget = {
44
- :name => 'Video budget #%d' % (Time.new.to_f * 1000).to_i,
45
- :amount => {:micro_amount => 50000000},
46
- :delivery_method => 'STANDARD',
47
- :period => 'DAILY'
48
- }
49
- budget_operation = {:operator => 'ADD', :operand => budget}
50
-
51
- # Add budget.
52
- return_budget = budget_srv.mutate([budget_operation])
53
- budget_id = return_budget[:value].first[:budget_id]
54
-
55
- # Create video campaign.
56
- campaigns = [{
57
- :name => "Interplanetary Video #%d" % (Time.new.to_f * 1000).to_i,
58
- :status => 'PAUSED',
59
- :budget_id => budget_id,
60
- # Optional fields:
61
- :start_date =>
62
- DateTime.parse((Date.today + 1).to_s).strftime('%Y%m%d'),
63
- }]
64
-
65
- # Prepare for adding campaign.
66
- operations = campaigns.map do |campaign|
67
- {:operator => 'ADD', :operand => campaign}
68
- end
69
-
70
- # Add video campaign.
71
- response = video_campaign_srv.mutate(operations)
72
- if response and response[:value]
73
- response[:value].each do |campaign|
74
- puts "Campaign with name '%s' and ID %d was added." %
75
- [campaign[:name], campaign[:id]]
76
- end
77
- else
78
- raise new StandardError, 'No campaigns were added.'
79
- end
80
- end
81
-
82
- if __FILE__ == $0
83
- API_VERSION = :v201209
84
-
85
- begin
86
- add_video_campaign()
87
-
88
- # HTTP errors.
89
- rescue AdsCommon::Errors::HttpError => e
90
- puts "HTTP Error: %s" % e
91
-
92
- # API errors.
93
- rescue AdwordsApi::Errors::ApiException => e
94
- puts "Message: %s" % e.message
95
- puts 'Errors:'
96
- e.errors.each_with_index do |error, index|
97
- puts "\tError [%d]:" % (index + 1)
98
- error.each do |field, value|
99
- puts "\t\t%s: %s" % [field, value]
100
- end
101
- end
102
- end
103
- end
@@ -1,92 +0,0 @@
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 illustrates how to find YouTube videos by a search string. It
22
- # retrieve details for the first 100 matching videos.
23
- #
24
- # Note: AdWords for Video API is a Beta feature.
25
- #
26
- # Tags: VideoService.search
27
-
28
- require 'adwords_api'
29
-
30
- def find_videos()
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
- video_srv = adwords.service(:VideoService, API_VERSION)
40
-
41
- # Search string to use.
42
- query_str = 'AdWords API with Ruby'
43
-
44
- # Create a selector.
45
- selector = {
46
- :search_type => 'VIDEO',
47
- :query => query_str,
48
- :paging => {
49
- :start_index => 0,
50
- :number_results => PAGE_SIZE
51
- }
52
- }
53
-
54
- # Run the query.
55
- page = video_srv.search(selector)
56
-
57
- if page[:entries]
58
- page[:entries].each do |video|
59
- puts "YouTube video ID '%s' with title '%s' found." %
60
- [video[:id], video[:title]]
61
- end
62
- if page.include?(:total_num_entries)
63
- puts "\tTotal number of matching videos: %d." % [page[:total_num_entries]]
64
- end
65
- else
66
- puts "No videos matching '%s' were found." % query_str
67
- end
68
- end
69
-
70
- if __FILE__ == $0
71
- API_VERSION = :v201209
72
- PAGE_SIZE = 100
73
-
74
- begin
75
- find_videos()
76
-
77
- # HTTP errors.
78
- rescue AdsCommon::Errors::HttpError => e
79
- puts "HTTP Error: %s" % e
80
-
81
- # API errors.
82
- rescue AdwordsApi::Errors::ApiException => e
83
- puts "Message: %s" % e.message
84
- puts 'Errors:'
85
- e.errors.each_with_index do |error, index|
86
- puts "\tError [%d]:" % (index + 1)
87
- error.each do |field, value|
88
- puts "\t\t%s: %s" % [field, value]
89
- end
90
- end
91
- end
92
- end
@@ -1,101 +0,0 @@
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 show how to retrieve all keywords for a video campaign. To get
22
- # a list with all campaigns, run get_video_campaigns.rb.
23
- #
24
- # Note: AdWords for Video API is a Beta feature.
25
- #
26
- # Tags: VideoTargetingGroupCriterionService.get
27
-
28
- require 'adwords_api'
29
-
30
- def get_keyword_criteria(campaign_id)
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
- vtgc_srv =
40
- adwords.service(:VideoTargetingGroupCriterionService, API_VERSION)
41
-
42
- # Get all the keywords for the campaign.
43
- selector = {
44
- :campaign_ids => [campaign_id],
45
- :criterion_types => ['SEARCH_KEYWORD'],
46
- :paging => {
47
- :start_index => 0,
48
- :number_results => PAGE_SIZE
49
- }
50
- }
51
-
52
- # Set initial values.
53
- offset, page = 0, {}
54
-
55
- begin
56
- page = vtgc_srv.get(selector)
57
- if page[:entries]
58
- page[:entries].each do |keyword|
59
- negative_string =
60
- ('NegativeTargetingGroupCriterion'.eql?(keyword[:xsi_type])) ?
61
- ' (negative)' : ''
62
- puts "Criterion%s ID %d, targeting group ID %d and text '%s'" %
63
- [negative_string, keyword[:criterion][:id],
64
- keyword[:targeting_group_id], keyword[:criterion][:text]]
65
- end
66
- # Increment values to request the next page.
67
- offset += PAGE_SIZE
68
- selector[:paging][:start_index] = offset
69
- end
70
- end while page[:total_num_entries] > offset
71
-
72
- if page.include?(:total_num_entries)
73
- puts "\tTotal number of keywords found: %d." % [page[:total_num_entries]]
74
- end
75
- end
76
-
77
- if __FILE__ == $0
78
- API_VERSION = :v201209
79
- PAGE_SIZE = 500
80
-
81
- begin
82
- # Campaign ID to get criteria for.
83
- campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
84
- get_keyword_criteria(campaign_id)
85
-
86
- # HTTP errors.
87
- rescue AdsCommon::Errors::HttpError => e
88
- puts "HTTP Error: %s" % e
89
-
90
- # API errors.
91
- rescue AdwordsApi::Errors::ApiException => e
92
- puts "Message: %s" % e.message
93
- puts 'Errors:'
94
- e.errors.each_with_index do |error, index|
95
- puts "\tError [%d]:" % (index + 1)
96
- error.each do |field, value|
97
- puts "\t\t%s: %s" % [field, value]
98
- end
99
- end
100
- end
101
- end