google-adwords-api 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/ChangeLog +3 -0
  2. data/examples/v201206/campaign_management/add_keywords_in_bulk.rb +1 -1
  3. data/examples/v201209/campaign_management/add_keywords_in_bulk.rb +1 -1
  4. data/examples/v201302/account_management/create_account.rb +87 -0
  5. data/examples/v201302/account_management/get_account_alerts.rb +114 -0
  6. data/examples/v201302/account_management/get_account_changes.rb +137 -0
  7. data/examples/v201302/account_management/get_account_hierarchy.rb +95 -0
  8. data/examples/v201302/advanced_operations/add_click_to_download_ad.rb +129 -0
  9. data/examples/v201302/advanced_operations/add_site_links.rb +213 -0
  10. data/examples/v201302/basic_operations/add_ad_groups.rb +135 -0
  11. data/examples/v201302/basic_operations/add_campaigns.rb +154 -0
  12. data/examples/v201302/basic_operations/add_keywords.rb +108 -0
  13. data/examples/v201302/basic_operations/add_text_ads.rb +105 -0
  14. data/examples/v201302/basic_operations/delete_ad.rb +85 -0
  15. data/examples/v201302/basic_operations/delete_ad_group.rb +102 -0
  16. data/examples/v201302/basic_operations/delete_campaign.rb +103 -0
  17. data/examples/v201302/basic_operations/delete_keyword.rb +90 -0
  18. data/examples/v201302/basic_operations/get_ad_groups.rb +98 -0
  19. data/examples/v201302/basic_operations/get_campaigns.rb +93 -0
  20. data/examples/v201302/basic_operations/get_campaigns_with_awql.rb +85 -0
  21. data/examples/v201302/basic_operations/get_keywords.rb +104 -0
  22. data/examples/v201302/basic_operations/get_text_ads.rb +106 -0
  23. data/examples/v201302/basic_operations/pause_ad.rb +84 -0
  24. data/examples/v201302/basic_operations/update_ad_group.rb +81 -0
  25. data/examples/v201302/basic_operations/update_campaign.rb +82 -0
  26. data/examples/v201302/basic_operations/update_keyword.rb +102 -0
  27. data/examples/v201302/campaign_management/add_experiment.rb +158 -0
  28. data/examples/v201302/campaign_management/add_keywords_in_bulk.rb +150 -0
  29. data/examples/v201302/campaign_management/add_location_extension.rb +117 -0
  30. data/examples/v201302/campaign_management/add_location_extension_override.rb +83 -0
  31. data/examples/v201302/campaign_management/get_all_disapproved_ads.rb +93 -0
  32. data/examples/v201302/campaign_management/get_all_disapproved_ads_with_awql.rb +84 -0
  33. data/examples/v201302/campaign_management/promote_experiment.rb +77 -0
  34. data/examples/v201302/campaign_management/set_ad_parameters.rb +114 -0
  35. data/examples/v201302/campaign_management/set_campaign_enhanced.rb +83 -0
  36. data/examples/v201302/campaign_management/set_criterion_bid_modifier.rb +102 -0
  37. data/examples/v201302/campaign_management/validate_text_ad.rb +106 -0
  38. data/examples/v201302/error_handling/handle_captcha_challenge.rb +93 -0
  39. data/examples/v201302/error_handling/handle_partial_failures.rb +126 -0
  40. data/examples/v201302/error_handling/handle_policy_violation_error.rb +137 -0
  41. data/examples/v201302/error_handling/handle_two_factor_authorization_error.rb +88 -0
  42. data/examples/v201302/misc/get_all_images_and_videos.rb +100 -0
  43. data/examples/v201302/misc/upload_image.rb +89 -0
  44. data/examples/v201302/misc/use_oauth2.rb +97 -0
  45. data/examples/v201302/misc/use_oauth2_jwt.rb +93 -0
  46. data/examples/v201302/optimization/estimate_keyword_traffic.rb +129 -0
  47. data/examples/v201302/optimization/get_keyword_bid_simulations.rb +92 -0
  48. data/examples/v201302/optimization/get_keyword_ideas.rb +122 -0
  49. data/examples/v201302/optimization/get_placement_ideas.rb +104 -0
  50. data/examples/v201302/remarketing/add_audience.rb +115 -0
  51. data/examples/v201302/remarketing/add_conversion_tracker.rb +96 -0
  52. data/examples/v201302/reporting/download_criteria_report.rb +79 -0
  53. data/examples/v201302/reporting/download_criteria_report_with_awql.rb +78 -0
  54. data/examples/v201302/reporting/get_campaign_stats.rb +105 -0
  55. data/examples/v201302/reporting/get_report_fields.rb +71 -0
  56. data/examples/v201302/reporting/parallel_report_download.rb +163 -0
  57. data/examples/v201302/targeting/add_campaign_targeting_criteria.rb +115 -0
  58. data/examples/v201302/targeting/add_demographic_targeting_criteria.rb +108 -0
  59. data/examples/v201302/targeting/get_campaign_targeting_criteria.rb +102 -0
  60. data/examples/v201302/targeting/get_targetable_languages_and_carriers.rb +86 -0
  61. data/examples/v201302/targeting/lookup_location.rb +104 -0
  62. data/lib/adwords_api/api_config.rb +74 -4
  63. data/lib/adwords_api/v201302/ad_extension_override_service.rb +38 -0
  64. data/lib/adwords_api/v201302/ad_extension_override_service_registry.rb +46 -0
  65. data/lib/adwords_api/v201302/ad_group_ad_service.rb +42 -0
  66. data/lib/adwords_api/v201302/ad_group_ad_service_registry.rb +46 -0
  67. data/lib/adwords_api/v201302/ad_group_criterion_service.rb +42 -0
  68. data/lib/adwords_api/v201302/ad_group_criterion_service_registry.rb +46 -0
  69. data/lib/adwords_api/v201302/ad_group_feed_service.rb +38 -0
  70. data/lib/adwords_api/v201302/ad_group_feed_service_registry.rb +47 -0
  71. data/lib/adwords_api/v201302/ad_group_service.rb +42 -0
  72. data/lib/adwords_api/v201302/ad_group_service_registry.rb +46 -0
  73. data/lib/adwords_api/v201302/ad_param_service.rb +38 -0
  74. data/lib/adwords_api/v201302/ad_param_service_registry.rb +46 -0
  75. data/lib/adwords_api/v201302/alert_service.rb +34 -0
  76. data/lib/adwords_api/v201302/alert_service_registry.rb +46 -0
  77. data/lib/adwords_api/v201302/budget_order_service.rb +42 -0
  78. data/lib/adwords_api/v201302/budget_order_service_registry.rb +46 -0
  79. data/lib/adwords_api/v201302/budget_service.rb +38 -0
  80. data/lib/adwords_api/v201302/budget_service_registry.rb +46 -0
  81. data/lib/adwords_api/v201302/campaign_ad_extension_service.rb +38 -0
  82. data/lib/adwords_api/v201302/campaign_ad_extension_service_registry.rb +46 -0
  83. data/lib/adwords_api/v201302/campaign_criterion_service.rb +42 -0
  84. data/lib/adwords_api/v201302/campaign_criterion_service_registry.rb +46 -0
  85. data/lib/adwords_api/v201302/campaign_feed_service.rb +38 -0
  86. data/lib/adwords_api/v201302/campaign_feed_service_registry.rb +46 -0
  87. data/lib/adwords_api/v201302/campaign_service.rb +42 -0
  88. data/lib/adwords_api/v201302/campaign_service_registry.rb +46 -0
  89. data/lib/adwords_api/v201302/campaign_shared_set_service.rb +38 -0
  90. data/lib/adwords_api/v201302/campaign_shared_set_service_registry.rb +47 -0
  91. data/lib/adwords_api/v201302/constant_data_service.rb +62 -0
  92. data/lib/adwords_api/v201302/constant_data_service_registry.rb +46 -0
  93. data/lib/adwords_api/v201302/conversion_tracker_service.rb +38 -0
  94. data/lib/adwords_api/v201302/conversion_tracker_service_registry.rb +46 -0
  95. data/lib/adwords_api/v201302/customer_service.rb +34 -0
  96. data/lib/adwords_api/v201302/customer_service_registry.rb +46 -0
  97. data/lib/adwords_api/v201302/customer_sync_service.rb +34 -0
  98. data/lib/adwords_api/v201302/customer_sync_service_registry.rb +47 -0
  99. data/lib/adwords_api/v201302/data_service.rb +38 -0
  100. data/lib/adwords_api/v201302/data_service_registry.rb +46 -0
  101. data/lib/adwords_api/v201302/experiment_service.rb +38 -0
  102. data/lib/adwords_api/v201302/experiment_service_registry.rb +46 -0
  103. data/lib/adwords_api/v201302/feed_item_service.rb +38 -0
  104. data/lib/adwords_api/v201302/feed_item_service_registry.rb +47 -0
  105. data/lib/adwords_api/v201302/feed_mapping_service.rb +38 -0
  106. data/lib/adwords_api/v201302/feed_mapping_service_registry.rb +46 -0
  107. data/lib/adwords_api/v201302/feed_service.rb +38 -0
  108. data/lib/adwords_api/v201302/feed_service_registry.rb +47 -0
  109. data/lib/adwords_api/v201302/geo_location_service.rb +34 -0
  110. data/lib/adwords_api/v201302/geo_location_service_registry.rb +46 -0
  111. data/lib/adwords_api/v201302/location_criterion_service.rb +34 -0
  112. data/lib/adwords_api/v201302/location_criterion_service_registry.rb +46 -0
  113. data/lib/adwords_api/v201302/managed_customer_service.rb +50 -0
  114. data/lib/adwords_api/v201302/managed_customer_service_registry.rb +46 -0
  115. data/lib/adwords_api/v201302/media_service.rb +38 -0
  116. data/lib/adwords_api/v201302/media_service_registry.rb +46 -0
  117. data/lib/adwords_api/v201302/mutate_job_service.rb +42 -0
  118. data/lib/adwords_api/v201302/mutate_job_service_registry.rb +46 -0
  119. data/lib/adwords_api/v201302/report_definition_service.rb +34 -0
  120. data/lib/adwords_api/v201302/report_definition_service_registry.rb +46 -0
  121. data/lib/adwords_api/v201302/shared_criterion_service.rb +38 -0
  122. data/lib/adwords_api/v201302/shared_criterion_service_registry.rb +47 -0
  123. data/lib/adwords_api/v201302/targeting_idea_service.rb +38 -0
  124. data/lib/adwords_api/v201302/targeting_idea_service_registry.rb +46 -0
  125. data/lib/adwords_api/v201302/traffic_estimator_service.rb +34 -0
  126. data/lib/adwords_api/v201302/traffic_estimator_service_registry.rb +46 -0
  127. data/lib/adwords_api/v201302/user_list_service.rb +38 -0
  128. data/lib/adwords_api/v201302/user_list_service_registry.rb +46 -0
  129. data/lib/adwords_api/version.rb +1 -1
  130. data/test/adwords_api/test_adwords_api.rb +1 -1
  131. data/test/adwords_api/test_api_config.rb +8 -8
  132. data/test/adwords_api/test_report_utils.rb +1 -1
  133. data/test/bugs/test_issue_00000031.rb +2 -2
  134. data/test/bugs/test_issue_00000063.rb +6 -6
  135. data/test/examples/v201302/test_account_management.rb +50 -0
  136. data/test/examples/v201302/test_advanced_operations.rb +54 -0
  137. data/test/examples/v201302/test_basic_operations.rb +177 -0
  138. data/test/examples/v201302/test_campaign_management.rb +140 -0
  139. data/test/examples/v201302/test_error_handling.rb +63 -0
  140. data/test/examples/v201302/test_misc.rb +39 -0
  141. data/test/examples/v201302/test_optimization.rb +63 -0
  142. data/test/examples/v201302/test_remarketing.rb +39 -0
  143. data/test/examples/v201302/test_reporting.rb +84 -0
  144. data/test/examples/v201302/test_targeting.rb +68 -0
  145. data/test/examples/v201302/utils.rb +267 -0
  146. data/test/suite_exampletests_v201302.rb +37 -0
  147. data/test/templates/v201209/basic_operations_get_campaigns.def +1 -1
  148. data/test/templates/v201302/basic_operations_get_campaigns.def +114 -0
  149. metadata +139 -2
@@ -0,0 +1,267 @@
1
+ # Encoding: utf-8
2
+ #
3
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
4
+ #
5
+ # Copyright:: Copyright 2013, 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 = :v201302
23
+ PAGE_SIZE = 500
24
+
25
+ class UtilsV201302
26
+ def initialize(adwords)
27
+ @adwords = adwords
28
+ end
29
+
30
+ def get_budget
31
+ @budget ||= create_budget()
32
+ return @budget
33
+ end
34
+
35
+ def get_campaign
36
+ @campaign ||= create_campaign()
37
+ return @campaign
38
+ end
39
+
40
+ def get_ad_group
41
+ @ad_group ||= create_ad_group()
42
+ return @ad_group
43
+ end
44
+
45
+ def get_ad
46
+ @ad ||= create_ad(get_ad_group()[:id])
47
+ return @ad
48
+ end
49
+
50
+ def get_keyword
51
+ @keyword ||= create_keyword(get_ad_group()[:id])
52
+ return @keyword
53
+ end
54
+
55
+ def get_location_extension
56
+ @location_extension ||= create_location_extension(get_campaign()[:id])
57
+ return @location_extension
58
+ end
59
+
60
+ def get_experiment
61
+ @experiment ||= create_experiment(
62
+ get_campaign()[:id], get_ad_group()[:id], get_keyword[:criterion][:id])
63
+ return @experiment
64
+ end
65
+
66
+ private
67
+
68
+ def create_campaign()
69
+ budget = get_budget()
70
+ budget_id = budget[:budget_id]
71
+
72
+ campaign_srv = @adwords.service(:CampaignService, API_VERSION)
73
+ campaign = {
74
+ :name => "Example tests campaign #%d" % (Time.new.to_f * 1000).to_i,
75
+ :status => 'PAUSED',
76
+ :bidding_strategy_configuration => {
77
+ :bidding_strategy_type => 'MANUAL_CPC'
78
+ },
79
+ :budget => {:budget_id => budget_id},
80
+ :network_setting => {
81
+ :target_google_search => true,
82
+ :target_search_network => true,
83
+ :target_content_network => true
84
+ },
85
+ :settings => [
86
+ {
87
+ :xsi_type => 'KeywordMatchSetting',
88
+ :opt_in => true
89
+ }
90
+ ]
91
+ }
92
+ operation = {:operator => 'ADD', :operand => campaign}
93
+ response = campaign_srv.mutate([operation])
94
+ return response[:value].first
95
+ end
96
+
97
+ def create_budget()
98
+ budget_srv = @adwords.service(:BudgetService, API_VERSION)
99
+ budget = {
100
+ :name => 'Example tests budget #%d' % (Time.new.to_f * 1000).to_i,
101
+ :amount => {:micro_amount => 50000000},
102
+ :delivery_method => 'STANDARD',
103
+ :period => 'DAILY'
104
+ }
105
+ operation = {:operator => 'ADD', :operand => budget}
106
+ response = budget_srv.mutate([operation])
107
+ return response[:value].first
108
+ end
109
+
110
+ def create_ad_group()
111
+ campaign = get_campaign()
112
+ ad_group_srv = @adwords.service(:AdGroupService, API_VERSION)
113
+ ad_group = {
114
+ :name => "Example tests ad group #%d" % (Time.new.to_f * 1000).to_i,
115
+ :status => 'ENABLED',
116
+ :campaign_id => campaign[:id],
117
+ :bidding_strategy_configuration => {
118
+ :bids => [
119
+ {
120
+ :xsi_type => 'CpcBid',
121
+ :bid => {:micro_amount => 10000000}
122
+ }
123
+ ]
124
+ }
125
+ }
126
+ operation = {:operator => 'ADD', :operand => ad_group}
127
+ response = ad_group_srv.mutate([operation])
128
+ return response[:value].first
129
+ end
130
+
131
+ def create_ad(ad_group_id)
132
+ ad_group_ad_srv = @adwords.service(:AdGroupAdService, API_VERSION)
133
+ text_ad = {
134
+ :xsi_type => 'TextAd',
135
+ :headline => 'Examples test ad %d' % (Time.new.to_f * 1000).to_i,
136
+ :description1 => 'testing ruby examples',
137
+ :description2 => 'all your base are belong to us',
138
+ :url => 'http://www.example.com',
139
+ :display_url => 'www.example.com'
140
+ }
141
+ operation = {:operator => 'ADD',
142
+ :operand => {:ad_group_id => ad_group_id, :ad => text_ad}}
143
+ response = ad_group_ad_srv.mutate([operation])
144
+ return response[:value].first
145
+ end
146
+
147
+ def create_keyword(ad_group_id)
148
+ ad_group_criterion_srv =
149
+ @adwords.service(:AdGroupCriterionService, API_VERSION)
150
+ keyword = {
151
+ :xsi_type => 'BiddableAdGroupCriterion',
152
+ :ad_group_id => ad_group_id,
153
+ :criterion => {
154
+ :xsi_type => 'Keyword',
155
+ :text => 'mars cruise',
156
+ :match_type => 'BROAD'
157
+ }
158
+ }
159
+ operation = {:operator => 'ADD', :operand => keyword}
160
+ response = ad_group_criterion_srv.mutate([operation])
161
+ return response[:value].first
162
+ end
163
+
164
+ def create_location_extension(campaign_id)
165
+ campaign_ad_ext_srv =
166
+ @adwords.service(:CampaignAdExtensionService, API_VERSION)
167
+ geo_location_srv = @adwords.service(:GeoLocationService, API_VERSION)
168
+
169
+ selector = {
170
+ :addresses => [
171
+ {
172
+ :street_address => '1600 Amphitheatre Parkway',
173
+ :city_name => 'Mountain View',
174
+ :province_code => 'CA',
175
+ :postal_code => '94043',
176
+ :country_code => 'US'
177
+ }
178
+ ]
179
+ }
180
+
181
+ locations = geo_location_srv.get(selector)
182
+ raise StandardError, 'Unable to retrieve geo locations.' if locations.nil?
183
+
184
+ operations = locations.map do |location|
185
+ {
186
+ :operator => 'ADD',
187
+ :operand => {
188
+ :campaign_id => campaign_id,
189
+ :status => 'ACTIVE',
190
+ :ad_extension => {
191
+ :xsi_type => 'LocationExtension',
192
+ :address => location[:address],
193
+ :geo_point => location[:geo_point],
194
+ :encoded_location => location[:encoded_location],
195
+ :source => 'ADWORDS_FRONTEND'
196
+ }
197
+ }
198
+ }
199
+ end
200
+
201
+ response = campaign_ad_ext_srv.mutate(operations)
202
+ extension = response[:value].first
203
+ return extension
204
+ end
205
+
206
+ def create_experiment(campaign_id, ad_group_id, criterion_id)
207
+ experiment_srv = @adwords.service(:ExperimentService, API_VERSION)
208
+ ad_group_srv = @adwords.service(:AdGroupService, API_VERSION)
209
+ ad_group_criterion_srv =
210
+ @adwords.service(:AdGroupCriterionService, API_VERSION)
211
+
212
+ operation = {
213
+ :operator => 'ADD',
214
+ :operand => {
215
+ :campaign_id => campaign_id,
216
+ :name => "Examples test experiment #%d" % (Time.new.to_f * 1000).to_i,
217
+ :query_percentage => 10,
218
+ :start_date_time => Time.now.strftime('%Y%m%d %H%M%S'),
219
+ }
220
+ }
221
+ response = experiment_srv.mutate([operation])
222
+ experiment = response[:value].first
223
+
224
+ raise StandardError, 'Failed to create experiment' if experiment.nil?
225
+
226
+ ad_group = {
227
+ :id => ad_group_id,
228
+ :experiment_data => {
229
+ :experiment_id => experiment[:id],
230
+ :experiment_delta_status => 'MODIFIED',
231
+ :experiment_bid_multipliers => {
232
+ :xsi_type => 'ManualCPCAdGroupExperimentBidMultipliers',
233
+ :max_cpc_multiplier => {:multiplier => 1.5}
234
+ }
235
+ }
236
+ }
237
+
238
+ operation = {:operator => 'SET', :operand => ad_group}
239
+ response = ad_group_srv.mutate([operation])
240
+ ad_group = response[:value].first
241
+
242
+ raise StandardError, 'Failed to assign experiment' if ad_group.nil?
243
+
244
+ ad_group_criterion = {
245
+ :xsi_type => 'BiddableAdGroupCriterion',
246
+ :ad_group_id => ad_group_id,
247
+ :criterion => {:id => criterion_id},
248
+ :experiment_data => {
249
+ :xsi_type => 'BiddableAdGroupCriterionExperimentData',
250
+ :experiment_id => experiment[:id],
251
+ :experiment_delta_status => 'MODIFIED',
252
+ :experiment_bid_multiplier => {
253
+ :xsi_type => 'ManualCPCAdGroupCriterionExperimentBidMultiplier',
254
+ :max_cpc_multiplier => {:multiplier => 1.5}
255
+ }
256
+ }
257
+ }
258
+
259
+ operation = {:operator => 'SET', :operand => ad_group_criterion}
260
+ response = ad_group_criterion_srv.mutate([operation])
261
+ criterion = response[:value].first
262
+
263
+ raise StandardError, 'Failed to assign criterion' if criterion.nil?
264
+
265
+ return experiment
266
+ end
267
+ end
@@ -0,0 +1,37 @@
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
+ # Test suite for v201209 example tests.
22
+
23
+ require 'test/unit'
24
+
25
+ $:.unshift File.expand_path('../../lib/', __FILE__)
26
+ $:.unshift File.expand_path('../../', __FILE__)
27
+
28
+ version = 'v201302'
29
+
30
+ examples_path =
31
+ File.expand_path(File.join('..', '..', 'examples', version), __FILE__)
32
+ $:.unshift(examples_path)
33
+
34
+ tests_path = File.join(File.dirname(__FILE__), 'examples', version)
35
+ require File.join(tests_path, 'utils.rb')
36
+ tests_mask = File.join(tests_path, 'test_*.rb')
37
+ Dir.glob(tests_mask).each {|file| require file}
@@ -22,7 +22,7 @@ def setup_mocks()
22
22
  {"env:Envelope"=>
23
23
  {"env:Header"=>
24
24
  {"wsdl:RequestHeader"=>
25
- {"userAgent"=>"ruby-tests (AwApi-Ruby/0.8.1, Common-Ruby/0.9.2, Savon/1.2.0, ruby/1.9.3, HTTPI/1.1.1, net_http)",
25
+ {"userAgent"=>"ruby-tests (AwApi-Ruby/0.8.2, Common-Ruby/0.9.3, Savon/1.2.0, ruby/1.9.3, HTTPI/1.1.1, net_http)",
26
26
  "developerToken"=>"dev_token123",
27
27
  "clientCustomerId"=>"123-456-7890",
28
28
  "authToken"=>"abcAuthbcd",
@@ -0,0 +1,114 @@
1
+ def setup_mocks()
2
+ $api_config = {
3
+ :service => {:environment => 'PRODUCTION'},
4
+ :authentication => {
5
+ :method => 'ClientLogin',
6
+ :email => 'noreply@google.com',
7
+ :password => 'noreply_password',
8
+ :developer_token => 'dev_token123',
9
+ :client_customer_id => '123-456-7890',
10
+ :user_agent => 'ruby-tests'
11
+ }
12
+ }
13
+
14
+ stub_request(:post, "https://www.google.com/accounts/ClientLogin").
15
+ with(:body => {"Email"=>"noreply@google.com", "Passwd"=>"noreply_password", "accountType"=>"GOOGLE", "service"=>"adwords"}).
16
+ to_return(:status => 200, :body => "SID=abcSIDbcd\nLSID=abcLSIDbcd\nAuth=abcAuthbcd\n", :headers => {})
17
+
18
+ stub_request(:post, "https://adwords.google.com/api/adwords/cm/v201302/CampaignService").
19
+ with(
20
+ :body =>
21
+ # autogenerated code
22
+ {"env:Envelope"=>
23
+ {"env:Header"=>
24
+ {"wsdl:RequestHeader"=>
25
+ {"userAgent"=>"ruby-tests (AwApi-Ruby/0.8.2, Common-Ruby/0.9.3, Savon/1.2.0, ruby/1.9.3, HTTPI/1.1.1, net_http)",
26
+ "developerToken"=>"dev_token123",
27
+ "clientCustomerId"=>"123-456-7890",
28
+ "authToken"=>"abcAuthbcd",
29
+ "xmlns"=>"https://adwords.google.com/api/adwords/cm/v201302"}},
30
+ "env:Body"=>
31
+ {"get"=>
32
+ {"serviceSelector"=>
33
+ {"fields"=>["Id", "Name", "Status"],
34
+ "ordering"=>{"field"=>"Name", "sortOrder"=>"ASCENDING"},
35
+ "paging"=>{"startIndex"=>"0", "numberResults"=>"5"}},
36
+ "xmlns"=>"https://adwords.google.com/api/adwords/cm/v201302"}},
37
+ "xmlns:xsd"=>"http://www.w3.org/2001/XMLSchema",
38
+ "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
39
+ "xmlns:wsdl"=>"https://adwords.google.com/api/adwords/cm/v201302",
40
+ "xmlns:env"=>"http://schemas.xmlsoap.org/soap/envelope/"}},
41
+ # end of auto-generated code.
42
+ :headers => {
43
+ 'SOAPAction' => '"get"',
44
+ 'Content-Type' => 'text/xml;charset=UTF-8'
45
+ }
46
+ ).
47
+ to_return(
48
+ :status => 200,
49
+ :body => '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
50
+ <soap:Header>
51
+ <ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201302">
52
+ <requestId>0004c</requestId>
53
+ <serviceName>CampaignService</serviceName>
54
+ <methodName>get</methodName>
55
+ <operations>42</operations>
56
+ <responseTime>84</responseTime>
57
+ <units>42</units>
58
+ </ResponseHeader>
59
+ </soap:Header>
60
+ <soap:Body>
61
+ <getResponse xmlns="https://adwords.google.com/api/adwords/cm/v201302">
62
+ <rval>
63
+ <totalNumEntries>2</totalNumEntries>
64
+ <Page.Type>CampaignPage</Page.Type>
65
+ <totalBudget>
66
+ <period>DAILY</period><amount><ComparableValue.Type>Money</ComparableValue.Type>
67
+ <microAmount>0</microAmount></amount>
68
+ </totalBudget>
69
+ <entries>
70
+ <id>15</id><name>Campaign name 1</name><status>PAUSED</status><campaignStats><network>ALL</network>
71
+ <Stats.Type>CampaignStats</Stats.Type></campaignStats><frequencyCap><impressions>0</impressions></frequencyCap>
72
+ </entries>
73
+ <entries>
74
+ <id>16</id><name>Campaign name 2</name><status>ACTIVE</status><campaignStats><network>ALL</network>
75
+ <Stats.Type>CampaignStats</Stats.Type></campaignStats><frequencyCap><impressions>150</impressions></frequencyCap>
76
+ </entries>
77
+ </rval>
78
+ </getResponse>
79
+ </soap:Body>
80
+ </soap:Envelope>',
81
+ :headers => {'content-type' => 'text/xml;'}
82
+ )
83
+ end
84
+
85
+ def run_asserts()
86
+ assert_equal(2, $latest_result[:total_num_entries])
87
+ assert_equal('CampaignPage', $latest_result[:page_type])
88
+ entries = $latest_result[:entries]
89
+ assert_equal(2, entries.size)
90
+
91
+ if entries[0][:id] == 15
92
+ assert_campaign_15(entries[0])
93
+ assert_campaign_16(entries[1])
94
+ else
95
+ assert_campaign_15(entries[1])
96
+ assert_campaign_16(entries[0])
97
+ end
98
+ end
99
+
100
+ def assert_campaign_15(entry)
101
+ assert_equal(15, entry[:id])
102
+ assert_equal('Campaign name 1', entry[:name])
103
+ assert_equal('PAUSED', entry[:status])
104
+ assert_equal({:network=>"ALL", :stats_type=>"CampaignStats"}, entry[:campaign_stats])
105
+ assert_equal({:impressions=>0}, entry[:frequency_cap])
106
+ end
107
+
108
+ def assert_campaign_16(entry)
109
+ assert_equal(16, entry[:id])
110
+ assert_equal('Campaign name 2', entry[:name])
111
+ assert_equal('ACTIVE', entry[:status])
112
+ assert_equal({:network=>"ALL", :stats_type=>"CampaignStats"}, entry[:campaign_stats])
113
+ assert_equal({:impressions=>150}, entry[:frequency_cap])
114
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-adwords-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-07 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-ads-common
@@ -38,6 +38,72 @@ files:
38
38
  - lib/adwords_api/version.rb
39
39
  - lib/adwords_api/report_utils.rb
40
40
  - lib/adwords_api/credential_handler.rb
41
+ - lib/adwords_api/v201302/campaign_feed_service_registry.rb
42
+ - lib/adwords_api/v201302/mutate_job_service.rb
43
+ - lib/adwords_api/v201302/conversion_tracker_service_registry.rb
44
+ - lib/adwords_api/v201302/budget_service.rb
45
+ - lib/adwords_api/v201302/ad_extension_override_service_registry.rb
46
+ - lib/adwords_api/v201302/feed_mapping_service.rb
47
+ - lib/adwords_api/v201302/customer_service.rb
48
+ - lib/adwords_api/v201302/experiment_service_registry.rb
49
+ - lib/adwords_api/v201302/alert_service_registry.rb
50
+ - lib/adwords_api/v201302/campaign_shared_set_service.rb
51
+ - lib/adwords_api/v201302/campaign_criterion_service.rb
52
+ - lib/adwords_api/v201302/budget_order_service.rb
53
+ - lib/adwords_api/v201302/feed_service.rb
54
+ - lib/adwords_api/v201302/ad_group_ad_service_registry.rb
55
+ - lib/adwords_api/v201302/customer_sync_service_registry.rb
56
+ - lib/adwords_api/v201302/shared_criterion_service.rb
57
+ - lib/adwords_api/v201302/feed_mapping_service_registry.rb
58
+ - lib/adwords_api/v201302/budget_order_service_registry.rb
59
+ - lib/adwords_api/v201302/experiment_service.rb
60
+ - lib/adwords_api/v201302/feed_item_service.rb
61
+ - lib/adwords_api/v201302/alert_service.rb
62
+ - lib/adwords_api/v201302/customer_sync_service.rb
63
+ - lib/adwords_api/v201302/ad_group_feed_service.rb
64
+ - lib/adwords_api/v201302/location_criterion_service_registry.rb
65
+ - lib/adwords_api/v201302/targeting_idea_service.rb
66
+ - lib/adwords_api/v201302/geo_location_service.rb
67
+ - lib/adwords_api/v201302/ad_group_criterion_service.rb
68
+ - lib/adwords_api/v201302/managed_customer_service.rb
69
+ - lib/adwords_api/v201302/user_list_service_registry.rb
70
+ - lib/adwords_api/v201302/constant_data_service_registry.rb
71
+ - lib/adwords_api/v201302/ad_group_ad_service.rb
72
+ - lib/adwords_api/v201302/traffic_estimator_service_registry.rb
73
+ - lib/adwords_api/v201302/shared_criterion_service_registry.rb
74
+ - lib/adwords_api/v201302/campaign_service.rb
75
+ - lib/adwords_api/v201302/conversion_tracker_service.rb
76
+ - lib/adwords_api/v201302/media_service_registry.rb
77
+ - lib/adwords_api/v201302/campaign_ad_extension_service_registry.rb
78
+ - lib/adwords_api/v201302/campaign_service_registry.rb
79
+ - lib/adwords_api/v201302/feed_item_service_registry.rb
80
+ - lib/adwords_api/v201302/user_list_service.rb
81
+ - lib/adwords_api/v201302/location_criterion_service.rb
82
+ - lib/adwords_api/v201302/ad_group_service.rb
83
+ - lib/adwords_api/v201302/ad_group_service_registry.rb
84
+ - lib/adwords_api/v201302/campaign_feed_service.rb
85
+ - lib/adwords_api/v201302/ad_param_service.rb
86
+ - lib/adwords_api/v201302/traffic_estimator_service.rb
87
+ - lib/adwords_api/v201302/data_service_registry.rb
88
+ - lib/adwords_api/v201302/ad_group_feed_service_registry.rb
89
+ - lib/adwords_api/v201302/campaign_shared_set_service_registry.rb
90
+ - lib/adwords_api/v201302/feed_service_registry.rb
91
+ - lib/adwords_api/v201302/ad_extension_override_service.rb
92
+ - lib/adwords_api/v201302/report_definition_service.rb
93
+ - lib/adwords_api/v201302/ad_param_service_registry.rb
94
+ - lib/adwords_api/v201302/budget_service_registry.rb
95
+ - lib/adwords_api/v201302/mutate_job_service_registry.rb
96
+ - lib/adwords_api/v201302/constant_data_service.rb
97
+ - lib/adwords_api/v201302/ad_group_criterion_service_registry.rb
98
+ - lib/adwords_api/v201302/customer_service_registry.rb
99
+ - lib/adwords_api/v201302/campaign_ad_extension_service.rb
100
+ - lib/adwords_api/v201302/campaign_criterion_service_registry.rb
101
+ - lib/adwords_api/v201302/managed_customer_service_registry.rb
102
+ - lib/adwords_api/v201302/report_definition_service_registry.rb
103
+ - lib/adwords_api/v201302/media_service.rb
104
+ - lib/adwords_api/v201302/geo_location_service_registry.rb
105
+ - lib/adwords_api/v201302/targeting_idea_service_registry.rb
106
+ - lib/adwords_api/v201302/data_service.rb
41
107
  - lib/adwords_api/report_header_handler.rb
42
108
  - lib/adwords_api/api_config.rb
43
109
  - lib/adwords_api/errors.rb
@@ -152,6 +218,17 @@ files:
152
218
  - lib/adwords_api/v201206/data_service.rb
153
219
  - lib/adwords_api.rb
154
220
  - test/suite_integration.rb
221
+ - test/examples/v201302/utils.rb
222
+ - test/examples/v201302/test_error_handling.rb
223
+ - test/examples/v201302/test_targeting.rb
224
+ - test/examples/v201302/test_misc.rb
225
+ - test/examples/v201302/test_remarketing.rb
226
+ - test/examples/v201302/test_account_management.rb
227
+ - test/examples/v201302/test_optimization.rb
228
+ - test/examples/v201302/test_reporting.rb
229
+ - test/examples/v201302/test_basic_operations.rb
230
+ - test/examples/v201302/test_campaign_management.rb
231
+ - test/examples/v201302/test_advanced_operations.rb
155
232
  - test/examples/v201209/utils.rb
156
233
  - test/examples/v201209/test_error_handling.rb
157
234
  - test/examples/v201209/test_targeting.rb
@@ -182,9 +259,69 @@ files:
182
259
  - test/adwords_api/test_credential_handler.rb
183
260
  - test/adwords_api/test_api_config.rb
184
261
  - test/adwords_api/test_utils.rb
262
+ - test/templates/v201302/basic_operations_get_campaigns.def
185
263
  - test/templates/v201209/basic_operations_get_campaigns.def
186
264
  - test/suite_exampletests_v201206.rb
265
+ - test/suite_exampletests_v201302.rb
187
266
  - test/test_utils.rb
267
+ - examples/v201302/reporting/download_criteria_report.rb
268
+ - examples/v201302/reporting/get_campaign_stats.rb
269
+ - examples/v201302/reporting/parallel_report_download.rb
270
+ - examples/v201302/reporting/get_report_fields.rb
271
+ - examples/v201302/reporting/download_criteria_report_with_awql.rb
272
+ - examples/v201302/error_handling/handle_policy_violation_error.rb
273
+ - examples/v201302/error_handling/handle_two_factor_authorization_error.rb
274
+ - examples/v201302/error_handling/handle_captcha_challenge.rb
275
+ - examples/v201302/error_handling/handle_partial_failures.rb
276
+ - examples/v201302/targeting/lookup_location.rb
277
+ - examples/v201302/targeting/get_targetable_languages_and_carriers.rb
278
+ - examples/v201302/targeting/add_campaign_targeting_criteria.rb
279
+ - examples/v201302/targeting/get_campaign_targeting_criteria.rb
280
+ - examples/v201302/targeting/add_demographic_targeting_criteria.rb
281
+ - examples/v201302/campaign_management/validate_text_ad.rb
282
+ - examples/v201302/campaign_management/add_experiment.rb
283
+ - examples/v201302/campaign_management/set_ad_parameters.rb
284
+ - examples/v201302/campaign_management/get_all_disapproved_ads_with_awql.rb
285
+ - examples/v201302/campaign_management/set_criterion_bid_modifier.rb
286
+ - examples/v201302/campaign_management/add_location_extension.rb
287
+ - examples/v201302/campaign_management/add_keywords_in_bulk.rb
288
+ - examples/v201302/campaign_management/promote_experiment.rb
289
+ - examples/v201302/campaign_management/get_all_disapproved_ads.rb
290
+ - examples/v201302/campaign_management/set_campaign_enhanced.rb
291
+ - examples/v201302/campaign_management/add_location_extension_override.rb
292
+ - examples/v201302/account_management/get_account_hierarchy.rb
293
+ - examples/v201302/account_management/get_account_changes.rb
294
+ - examples/v201302/account_management/get_account_alerts.rb
295
+ - examples/v201302/account_management/create_account.rb
296
+ - examples/v201302/optimization/estimate_keyword_traffic.rb
297
+ - examples/v201302/optimization/get_keyword_bid_simulations.rb
298
+ - examples/v201302/optimization/get_keyword_ideas.rb
299
+ - examples/v201302/optimization/get_placement_ideas.rb
300
+ - examples/v201302/basic_operations/update_campaign.rb
301
+ - examples/v201302/basic_operations/get_campaigns.rb
302
+ - examples/v201302/basic_operations/get_ad_groups.rb
303
+ - examples/v201302/basic_operations/add_campaigns.rb
304
+ - examples/v201302/basic_operations/delete_ad_group.rb
305
+ - examples/v201302/basic_operations/delete_keyword.rb
306
+ - examples/v201302/basic_operations/delete_ad.rb
307
+ - examples/v201302/basic_operations/add_ad_groups.rb
308
+ - examples/v201302/basic_operations/update_ad_group.rb
309
+ - examples/v201302/basic_operations/get_keywords.rb
310
+ - examples/v201302/basic_operations/delete_campaign.rb
311
+ - examples/v201302/basic_operations/get_text_ads.rb
312
+ - examples/v201302/basic_operations/add_keywords.rb
313
+ - examples/v201302/basic_operations/add_text_ads.rb
314
+ - examples/v201302/basic_operations/get_campaigns_with_awql.rb
315
+ - examples/v201302/basic_operations/pause_ad.rb
316
+ - examples/v201302/basic_operations/update_keyword.rb
317
+ - examples/v201302/misc/upload_image.rb
318
+ - examples/v201302/misc/use_oauth2_jwt.rb
319
+ - examples/v201302/misc/get_all_images_and_videos.rb
320
+ - examples/v201302/misc/use_oauth2.rb
321
+ - examples/v201302/remarketing/add_conversion_tracker.rb
322
+ - examples/v201302/remarketing/add_audience.rb
323
+ - examples/v201302/advanced_operations/add_site_links.rb
324
+ - examples/v201302/advanced_operations/add_click_to_download_ad.rb
188
325
  - examples/v201209/reporting/download_criteria_report.rb
189
326
  - examples/v201209/reporting/get_campaign_stats.rb
190
327
  - examples/v201209/reporting/parallel_report_download.rb