google-adwords-api 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. data/ChangeLog +4 -0
  2. data/README.md +5 -5
  3. data/adwords_api.yml +1 -9
  4. data/examples/v201402/advanced_operations/add_places_location_extensions.rb +0 -0
  5. data/examples/v201406/advanced_operations/add_ad_customizer.rb +277 -0
  6. data/examples/v201406/advanced_operations/add_places_location_extensions.rb +0 -0
  7. data/examples/v201406/advanced_operations/add_text_ad_with_upgraded_urls.rb +0 -0
  8. data/examples/v201406/campaign_management/add_campaign_labels.rb +0 -0
  9. data/examples/v201406/campaign_management/get_campaigns_by_label.rb +0 -0
  10. data/examples/v201406/misc/create_ad_words_session_without_properties_file.rb +0 -0
  11. data/examples/v201406/shopping_campaigns/add_product_partition_tree.rb +0 -0
  12. data/examples/v201406/shopping_campaigns/add_product_scope.rb +0 -0
  13. data/examples/v201406/shopping_campaigns/add_shopping_campaign.rb +0 -0
  14. data/examples/v201406/shopping_campaigns/get_product_category_taxonomy.rb +0 -0
  15. data/examples/v201406/shopping_campaigns/set_product_sales_channel.rb +0 -0
  16. data/lib/adwords_api.rb +0 -7
  17. data/lib/adwords_api/api_config.rb +5 -7
  18. data/lib/adwords_api/credential_handler.rb +0 -5
  19. data/lib/adwords_api/v201402/ad_group_ad_service.rb +1 -1
  20. data/lib/adwords_api/v201402/ad_group_ad_service_registry.rb +1 -1
  21. data/lib/adwords_api/v201402/ad_group_bid_modifier_service.rb +1 -1
  22. data/lib/adwords_api/v201402/ad_group_bid_modifier_service_registry.rb +1 -1
  23. data/lib/adwords_api/v201402/ad_group_criterion_service.rb +1 -1
  24. data/lib/adwords_api/v201402/ad_group_criterion_service_registry.rb +2 -2
  25. data/lib/adwords_api/v201402/ad_group_feed_service.rb +1 -1
  26. data/lib/adwords_api/v201402/ad_group_feed_service_registry.rb +1 -1
  27. data/lib/adwords_api/v201402/ad_group_service.rb +1 -1
  28. data/lib/adwords_api/v201402/ad_group_service_registry.rb +1 -1
  29. data/lib/adwords_api/v201402/ad_param_service.rb +1 -1
  30. data/lib/adwords_api/v201402/ad_param_service_registry.rb +1 -1
  31. data/lib/adwords_api/v201402/adwords_user_list_service.rb +1 -1
  32. data/lib/adwords_api/v201402/adwords_user_list_service_registry.rb +2 -2
  33. data/lib/adwords_api/v201402/alert_service.rb +1 -1
  34. data/lib/adwords_api/v201402/alert_service_registry.rb +1 -1
  35. data/lib/adwords_api/v201402/bidding_strategy_service.rb +1 -1
  36. data/lib/adwords_api/v201402/bidding_strategy_service_registry.rb +1 -1
  37. data/lib/adwords_api/v201402/budget_order_service.rb +1 -1
  38. data/lib/adwords_api/v201402/budget_order_service_registry.rb +2 -2
  39. data/lib/adwords_api/v201402/budget_service.rb +1 -1
  40. data/lib/adwords_api/v201402/budget_service_registry.rb +1 -1
  41. data/lib/adwords_api/v201402/campaign_ad_extension_service.rb +1 -1
  42. data/lib/adwords_api/v201402/campaign_ad_extension_service_registry.rb +1 -1
  43. data/lib/adwords_api/v201402/campaign_criterion_service.rb +1 -1
  44. data/lib/adwords_api/v201402/campaign_criterion_service_registry.rb +1 -1
  45. data/lib/adwords_api/v201402/campaign_feed_service.rb +1 -1
  46. data/lib/adwords_api/v201402/campaign_feed_service_registry.rb +1 -1
  47. data/lib/adwords_api/v201402/campaign_service.rb +1 -1
  48. data/lib/adwords_api/v201402/campaign_service_registry.rb +2 -2
  49. data/lib/adwords_api/v201402/campaign_shared_set_service.rb +1 -1
  50. data/lib/adwords_api/v201402/campaign_shared_set_service_registry.rb +1 -1
  51. data/lib/adwords_api/v201402/constant_data_service.rb +1 -1
  52. data/lib/adwords_api/v201402/constant_data_service_registry.rb +1 -1
  53. data/lib/adwords_api/v201402/conversion_tracker_service.rb +1 -1
  54. data/lib/adwords_api/v201402/conversion_tracker_service_registry.rb +1 -1
  55. data/lib/adwords_api/v201402/customer_feed_service.rb +1 -1
  56. data/lib/adwords_api/v201402/customer_feed_service_registry.rb +1 -1
  57. data/lib/adwords_api/v201402/customer_service.rb +1 -1
  58. data/lib/adwords_api/v201402/customer_service_registry.rb +1 -1
  59. data/lib/adwords_api/v201402/customer_sync_service.rb +1 -1
  60. data/lib/adwords_api/v201402/customer_sync_service_registry.rb +1 -1
  61. data/lib/adwords_api/v201402/data_service.rb +1 -1
  62. data/lib/adwords_api/v201402/data_service_registry.rb +1 -1
  63. data/lib/adwords_api/v201402/experiment_service.rb +1 -1
  64. data/lib/adwords_api/v201402/experiment_service_registry.rb +1 -1
  65. data/lib/adwords_api/v201402/feed_item_service.rb +1 -1
  66. data/lib/adwords_api/v201402/feed_item_service_registry.rb +2 -2
  67. data/lib/adwords_api/v201402/feed_mapping_service.rb +1 -1
  68. data/lib/adwords_api/v201402/feed_mapping_service_registry.rb +1 -1
  69. data/lib/adwords_api/v201402/feed_service.rb +1 -1
  70. data/lib/adwords_api/v201402/feed_service_registry.rb +1 -1
  71. data/lib/adwords_api/v201402/geo_location_service.rb +1 -1
  72. data/lib/adwords_api/v201402/geo_location_service_registry.rb +1 -1
  73. data/lib/adwords_api/v201402/location_criterion_service.rb +1 -1
  74. data/lib/adwords_api/v201402/location_criterion_service_registry.rb +1 -1
  75. data/lib/adwords_api/v201402/managed_customer_service.rb +1 -1
  76. data/lib/adwords_api/v201402/managed_customer_service_registry.rb +1 -1
  77. data/lib/adwords_api/v201402/media_service.rb +1 -1
  78. data/lib/adwords_api/v201402/media_service_registry.rb +1 -1
  79. data/lib/adwords_api/v201402/mutate_job_service.rb +1 -1
  80. data/lib/adwords_api/v201402/mutate_job_service_registry.rb +2 -2
  81. data/lib/adwords_api/v201402/offline_conversion_feed_service.rb +1 -1
  82. data/lib/adwords_api/v201402/offline_conversion_feed_service_registry.rb +1 -1
  83. data/lib/adwords_api/v201402/report_definition_service.rb +1 -1
  84. data/lib/adwords_api/v201402/report_definition_service_registry.rb +1 -1
  85. data/lib/adwords_api/v201402/shared_criterion_service.rb +1 -1
  86. data/lib/adwords_api/v201402/shared_criterion_service_registry.rb +1 -1
  87. data/lib/adwords_api/v201402/shared_set_service.rb +1 -1
  88. data/lib/adwords_api/v201402/shared_set_service_registry.rb +1 -1
  89. data/lib/adwords_api/v201402/targeting_idea_service.rb +1 -1
  90. data/lib/adwords_api/v201402/targeting_idea_service_registry.rb +2 -2
  91. data/lib/adwords_api/v201402/traffic_estimator_service.rb +1 -1
  92. data/lib/adwords_api/v201402/traffic_estimator_service_registry.rb +2 -2
  93. data/lib/adwords_api/v201406/ad_group_ad_service.rb +1 -1
  94. data/lib/adwords_api/v201406/ad_group_ad_service_registry.rb +1 -1
  95. data/lib/adwords_api/v201406/ad_group_bid_modifier_service.rb +1 -1
  96. data/lib/adwords_api/v201406/ad_group_bid_modifier_service_registry.rb +1 -1
  97. data/lib/adwords_api/v201406/ad_group_criterion_service.rb +1 -1
  98. data/lib/adwords_api/v201406/ad_group_criterion_service_registry.rb +1 -1
  99. data/lib/adwords_api/v201406/ad_group_feed_service.rb +1 -1
  100. data/lib/adwords_api/v201406/ad_group_feed_service_registry.rb +1 -1
  101. data/lib/adwords_api/v201406/ad_group_service.rb +1 -1
  102. data/lib/adwords_api/v201406/ad_group_service_registry.rb +1 -1
  103. data/lib/adwords_api/v201406/ad_param_service.rb +1 -1
  104. data/lib/adwords_api/v201406/ad_param_service_registry.rb +1 -1
  105. data/lib/adwords_api/v201406/adwords_user_list_service.rb +1 -1
  106. data/lib/adwords_api/v201406/adwords_user_list_service_registry.rb +1 -1
  107. data/lib/adwords_api/v201406/alert_service.rb +1 -1
  108. data/lib/adwords_api/v201406/alert_service_registry.rb +1 -1
  109. data/lib/adwords_api/v201406/bidding_strategy_service.rb +1 -1
  110. data/lib/adwords_api/v201406/bidding_strategy_service_registry.rb +1 -1
  111. data/lib/adwords_api/v201406/budget_order_service.rb +1 -1
  112. data/lib/adwords_api/v201406/budget_order_service_registry.rb +1 -1
  113. data/lib/adwords_api/v201406/budget_service.rb +1 -1
  114. data/lib/adwords_api/v201406/budget_service_registry.rb +1 -1
  115. data/lib/adwords_api/v201406/campaign_ad_extension_service.rb +1 -1
  116. data/lib/adwords_api/v201406/campaign_ad_extension_service_registry.rb +1 -1
  117. data/lib/adwords_api/v201406/campaign_criterion_service.rb +1 -1
  118. data/lib/adwords_api/v201406/campaign_criterion_service_registry.rb +1 -1
  119. data/lib/adwords_api/v201406/campaign_feed_service.rb +1 -1
  120. data/lib/adwords_api/v201406/campaign_feed_service_registry.rb +1 -1
  121. data/lib/adwords_api/v201406/campaign_service.rb +1 -1
  122. data/lib/adwords_api/v201406/campaign_service_registry.rb +2 -2
  123. data/lib/adwords_api/v201406/campaign_shared_set_service.rb +1 -1
  124. data/lib/adwords_api/v201406/campaign_shared_set_service_registry.rb +1 -1
  125. data/lib/adwords_api/v201406/constant_data_service.rb +1 -1
  126. data/lib/adwords_api/v201406/constant_data_service_registry.rb +1 -1
  127. data/lib/adwords_api/v201406/conversion_tracker_service.rb +1 -1
  128. data/lib/adwords_api/v201406/conversion_tracker_service_registry.rb +1 -1
  129. data/lib/adwords_api/v201406/customer_feed_service.rb +1 -1
  130. data/lib/adwords_api/v201406/customer_feed_service_registry.rb +1 -1
  131. data/lib/adwords_api/v201406/customer_service.rb +1 -1
  132. data/lib/adwords_api/v201406/customer_service_registry.rb +1 -1
  133. data/lib/adwords_api/v201406/customer_sync_service.rb +1 -1
  134. data/lib/adwords_api/v201406/customer_sync_service_registry.rb +1 -1
  135. data/lib/adwords_api/v201406/data_service.rb +1 -1
  136. data/lib/adwords_api/v201406/data_service_registry.rb +1 -1
  137. data/lib/adwords_api/v201406/experiment_service.rb +1 -1
  138. data/lib/adwords_api/v201406/experiment_service_registry.rb +1 -1
  139. data/lib/adwords_api/v201406/feed_item_service.rb +1 -1
  140. data/lib/adwords_api/v201406/feed_item_service_registry.rb +1 -1
  141. data/lib/adwords_api/v201406/feed_mapping_service.rb +1 -1
  142. data/lib/adwords_api/v201406/feed_mapping_service_registry.rb +1 -1
  143. data/lib/adwords_api/v201406/feed_service.rb +1 -1
  144. data/lib/adwords_api/v201406/feed_service_registry.rb +1 -1
  145. data/lib/adwords_api/v201406/geo_location_service.rb +1 -1
  146. data/lib/adwords_api/v201406/geo_location_service_registry.rb +1 -1
  147. data/lib/adwords_api/v201406/label_service.rb +1 -1
  148. data/lib/adwords_api/v201406/label_service_registry.rb +1 -1
  149. data/lib/adwords_api/v201406/location_criterion_service.rb +1 -1
  150. data/lib/adwords_api/v201406/location_criterion_service_registry.rb +1 -1
  151. data/lib/adwords_api/v201406/managed_customer_service.rb +1 -1
  152. data/lib/adwords_api/v201406/managed_customer_service_registry.rb +1 -1
  153. data/lib/adwords_api/v201406/media_service.rb +1 -1
  154. data/lib/adwords_api/v201406/media_service_registry.rb +1 -1
  155. data/lib/adwords_api/v201406/mutate_job_service.rb +1 -1
  156. data/lib/adwords_api/v201406/mutate_job_service_registry.rb +1 -1
  157. data/lib/adwords_api/v201406/offline_conversion_feed_service.rb +1 -1
  158. data/lib/adwords_api/v201406/offline_conversion_feed_service_registry.rb +1 -1
  159. data/lib/adwords_api/v201406/report_definition_service.rb +1 -1
  160. data/lib/adwords_api/v201406/report_definition_service_registry.rb +1 -1
  161. data/lib/adwords_api/v201406/shared_criterion_service.rb +1 -1
  162. data/lib/adwords_api/v201406/shared_criterion_service_registry.rb +1 -1
  163. data/lib/adwords_api/v201406/shared_set_service.rb +1 -1
  164. data/lib/adwords_api/v201406/shared_set_service_registry.rb +1 -1
  165. data/lib/adwords_api/v201406/targeting_idea_service.rb +1 -1
  166. data/lib/adwords_api/v201406/targeting_idea_service_registry.rb +1 -1
  167. data/lib/adwords_api/v201406/traffic_estimator_service.rb +1 -1
  168. data/lib/adwords_api/v201406/traffic_estimator_service_registry.rb +1 -1
  169. data/lib/adwords_api/version.rb +1 -1
  170. metadata +167 -171
  171. checksums.yaml +0 -15
  172. data/examples/v201402/basic_operations/delete_ad_group.rb~ +0 -104
  173. data/examples/v201402/basic_operations/delete_campaign.rb~ +0 -91
  174. data/examples/v201406/basic_operations/remove_ad_group.rb~ +0 -90
  175. data/examples/v201406/basic_operations/remove_campaign.rb~ +0 -111
  176. data/lib/adwords_api/client_login_header_handler.rb +0 -37
  177. data/lib/adwords_api/report_utils.rb~ +0 -283
  178. data/lib/adwords_api/version.rb~ +0 -26
  179. data/test/adwords_api/test_adwords_api.rb~ +0 -114
  180. data/test/adwords_api/test_report_utils.rb~ +0 -216
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ 0.13.1:
2
+ - Added example for Ad Customizers.
3
+ - Removed support for ClientLogin (no longer supported by the API).
4
+
1
5
  0.13.0:
2
6
  - Removed deprecated API version v201309.
3
7
 
data/README.md CHANGED
@@ -74,7 +74,7 @@ The basics of making a request are:
74
74
 
75
75
  3. Specify which service you're looking to use, and which version:
76
76
 
77
- campaign_srv = adwords.service(:CampaignService, :v201402)
77
+ campaign_srv = adwords.service(:CampaignService, :v201406)
78
78
 
79
79
  4. You should now be able to just use the API methods in the returned object:
80
80
 
@@ -211,7 +211,7 @@ To target a specific version:
211
211
 
212
212
  For example:
213
213
 
214
- $ rake generate[v201402]
214
+ $ rake generate[v201406]
215
215
 
216
216
  To target a specific service in a specific version:
217
217
 
@@ -219,7 +219,7 @@ To target a specific service in a specific version:
219
219
 
220
220
  For example:
221
221
 
222
- $ rake generate[v201402,CampaignService]
222
+ $ rake generate[v201406,CampaignService]
223
223
 
224
224
  To build the gems:
225
225
 
@@ -247,7 +247,7 @@ announcements and other news.
247
247
 
248
248
  ## Licence
249
249
 
250
- Copyright 2010-2013, Google Inc. All Rights Reserved.
250
+ Copyright 2010-2014, Google Inc. All Rights Reserved.
251
251
 
252
252
  Licensed under the Apache License, Version 2.0 (the "License");
253
253
  you may not use this file except in compliance with the License.
@@ -265,7 +265,7 @@ limitations under the License.
265
265
 
266
266
  Authors:
267
267
 
268
- - api.sgomes (Sérgio Gomes)
268
+ - api.sgomes@gmail.com (Sérgio Gomes)
269
269
  - api.dklimkin@gmail.com (Danial Klimkin)
270
270
  - api.mcloonan@gmail.com (Michael Cloonan)
271
271
 
data/adwords_api.yml CHANGED
@@ -2,8 +2,7 @@
2
2
  # This is an example configuration file for the AdWords API client library.
3
3
  # Please fill in the required fields, and copy it over to your home directory.
4
4
  :authentication:
5
- # Authentication method, methods currently supported: OAUTH2, OAUTH2_JWT,
6
- # ClientLogin.
5
+ # Authentication method, methods currently supported: OAUTH2, OAUTH2_JWT.
7
6
  :method: OAuth2
8
7
 
9
8
  # Auth parameters for OAUTH2 method.
@@ -28,13 +27,6 @@
28
27
  # To impersonate a user set prn to an email address.
29
28
  #:oauth2_prn: INSERT_OAUTH2_PRN_HERE
30
29
 
31
- # Auth parameters for ClientLogin method.
32
- # NOTE: ClientLogin method is deprecated, use OAuth2.0 instead.
33
- #:password: INSERT_YOUR_PASSWORD_HERE
34
- #:email: INSERT_YOUR_LOGIN_EMAIL_HERE
35
- # To manage your auth tokens manually, use the 'auth_token' property.
36
- #:auth_token: INSERT_AUTH_TOKEN_HERE
37
-
38
30
  # Other parameters.
39
31
  :developer_token: INSERT_YOUR_DEVELOPER_TOKEN_HERE
40
32
  :client_customer_id: INSERT_YOUR_CLIENT_CUSTOMER_ID_HERE
@@ -0,0 +1,277 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #
4
+ # Author:: api.mcloonan@gmail.com (Michael Cloonan)
5
+ #
6
+ # Copyright:: Copyright 2014, Google Inc. All Rights Reserved.
7
+ #
8
+ # License:: Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17
+ # implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+ # This example adds an ad customizer feed and associates it with the customer.
22
+ # Then it adds an ad that uses the feed to populate dynamic data.
23
+ #
24
+ # Tags: CustomerFeedService.mutate, FeedItemService.mutate
25
+ # Tags: FeedMappingService.mutate, FeedService.mutate
26
+ # Tags: AdGroupAdService.mutate
27
+
28
+ require 'adwords_api'
29
+
30
+ def add_ad_customizer(ad_group_ids)
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
+ feed_srv = adwords.service(:FeedService, API_VERSION)
40
+ feed_item_srv = adwords.service(:FeedItemService, API_VERSION)
41
+ feed_mapping_srv = adwords.service(:FeedMappingService, API_VERSION)
42
+ customer_feed_srv = adwords.service(:CustomerFeedService, API_VERSION)
43
+ ad_group_ad_srv = adwords.service(:AdGroupAdService, API_VERSION)
44
+
45
+ # First, create a customizer feed. One feed per account can be used for
46
+ # all ads.
47
+ customizer_feed = {
48
+ :name => 'CustomizerFeed',
49
+ :attributes => [
50
+ {:type => 'STRING', :name => 'Name'},
51
+ {:type => 'STRING', :name => 'Price'},
52
+ {:type => 'DATE_TIME', :name => 'Date'}
53
+ ]
54
+ }
55
+
56
+ response = feed_srv.mutate([
57
+ {:operator => 'ADD', :operand => customizer_feed}
58
+ ])
59
+
60
+ feed_data = {}
61
+ if response and response[:value]
62
+ feed = response[:value].first
63
+ feed_data = {
64
+ :feed_id => feed[:id],
65
+ :name_id => feed[:attributes][0][:id],
66
+ :price_id => feed[:attributes][1][:id],
67
+ :date_id => feed[:attributes][2][:id]
68
+ }
69
+ puts "Feed with name '%s' and ID %d was added with:" %
70
+ [feed[:name], feed[:id]]
71
+ puts ("\tName attribute ID %d and price attribute ID %d " +
72
+ "and date attribute ID %d.") % [
73
+ feed_data[:name_id],
74
+ feed_data[:price_id],
75
+ feed_data[:date_id]
76
+ ]
77
+ else
78
+ raise new StandardError, 'No feeds were added.'
79
+ end
80
+
81
+ # Creating feed mapping to map the fields with customizer IDs.
82
+ feed_mapping = {
83
+ :placeholder_type => PLACEHOLDER_AD_CUSTOMIZER,
84
+ :feed_id => feed_data[:feed_id],
85
+ :attribute_field_mappings => [
86
+ {
87
+ :feed_attribute_id => feed_data[:name_id],
88
+ :field_id => PLACEHOLDER_FIELD_STRING
89
+ },
90
+ {
91
+ :feed_attribute_id => feed_data[:price_id],
92
+ :field_id => PLACEHOLDER_FIELD_PRICE
93
+ },
94
+ {
95
+ :feed_attribute_id => feed_data[:date_id],
96
+ :field_id => PLACEHOLDER_FIELD_DATE
97
+ }
98
+ ]
99
+ }
100
+
101
+ response = feed_mapping_srv.mutate([
102
+ {:operator => 'ADD', :operand => feed_mapping}
103
+ ])
104
+ if response and response[:value]
105
+ feed_mapping = response[:value].first
106
+ puts ('Feed mapping with ID %d and placeholder type %d was saved for feed' +
107
+ ' with ID %d.') % [
108
+ feed_mapping[:feed_mapping_id],
109
+ feed_mapping[:placeholder_type],
110
+ feed_mapping[:feed_id]
111
+ ]
112
+ else
113
+ raise new StandardError, 'No feed mappings were added.'
114
+ end
115
+
116
+ # Now adding feed items -- the values we'd like to place.
117
+ items_data = [
118
+ {
119
+ :name => 'Mars',
120
+ :price => '$1234.56',
121
+ :date => '20140601 000000',
122
+ :ad_group_id => ad_group_ids[0]
123
+ },
124
+ {
125
+ :name => 'Venus',
126
+ :price => '$1450.00',
127
+ :date => '20140615 120000',
128
+ :ad_group_id => ad_group_ids[1]
129
+ }
130
+ ]
131
+
132
+ feed_items = items_data.map do |item|
133
+ {
134
+ :feed_id => feed_data[:feed_id],
135
+ :attribute_values => [
136
+ {
137
+ :feed_attribute_id => feed_data[:name_id],
138
+ :string_value => item[:name]
139
+ },
140
+ {
141
+ :feed_attribute_id => feed_data[:price_id],
142
+ :string_value => item[:price]
143
+ },
144
+ {
145
+ :feed_attribute_id => feed_data[:date_id],
146
+ :string_value => item[:date]
147
+ }
148
+ ],
149
+ :ad_group_targeting => {
150
+ :targeting_ad_group_id => item[:ad_group_id]
151
+ }
152
+ }
153
+ end
154
+
155
+ feed_items_operations = feed_items.map do |item|
156
+ {:operator => 'ADD', :operand => item}
157
+ end
158
+
159
+ response = feed_item_srv.mutate(feed_items_operations)
160
+ if response and response[:value]
161
+ response[:value].each do |feed_item|
162
+ puts 'Feed item with ID %d was added.' % feed_item[:feed_item_id]
163
+ end
164
+ else
165
+ raise new StandardError, 'No feed items were added.'
166
+ end
167
+
168
+ # Finally, creating a customer (account-level) feed with a matching function
169
+ # that determines when to use this feed. For this case we use the "IDENTITY"
170
+ # matching function that is always 'true' just to associate this feed with
171
+ # the customer. The targeting is done within the feed items using the
172
+ # :campaign_targeting, :ad_group_targeting, or :keyword_targeting attributes.
173
+ matching_function = {
174
+ :operator => 'IDENTITY',
175
+ :lhs_operand => [
176
+ {
177
+ :xsi_type => 'ConstantOperand',
178
+ :type => 'BOOLEAN',
179
+ :boolean_value => true
180
+ }
181
+ ]
182
+ }
183
+
184
+ customer_feed = {
185
+ :feed_id => feed_data[:feed_id],
186
+ :matching_function => matching_function,
187
+ :placeholder_types => [PLACEHOLDER_AD_CUSTOMIZER]
188
+ }
189
+
190
+ response = customer_feed_srv.mutate([
191
+ {:operator => 'ADD', :operand => customer_feed}
192
+ ])
193
+ if response and response[:value]
194
+ feed = response[:value].first
195
+ puts 'Customer feed with ID %d was added.' % [feed[:feed_id]]
196
+ else
197
+ raise new StandardError, 'No customer feeds were added.'
198
+ end
199
+
200
+ # All set! We can now create ads with customizations.
201
+ text_ad = {
202
+ :xsi_type => 'TextAd',
203
+ :headline => 'Luxury Cruise to {=CustomizerFeed.Name}',
204
+ :description1 => 'Only {=CustomizerFeed.Price}',
205
+ :description2 => 'Offer ends in {=countdown(CustomizerFeed.Date)}!',
206
+ :url => 'http://www.example.com',
207
+ :display_url => 'www.example.com'
208
+ }
209
+
210
+ # We add the same ad to both ad groups. When they serve, they will show
211
+ # different values, since they match different feed items.
212
+ operations = ad_group_ids.map do |ad_group_id|
213
+ {
214
+ :operator => 'ADD',
215
+ :operand => {
216
+ :ad_group_id => ad_group_id,
217
+ :ad => text_ad
218
+ }
219
+ }
220
+ end
221
+
222
+ response = ad_group_ad_srv.mutate(operations)
223
+ if response and response[:value]
224
+ ads = response[:value]
225
+ ads.each do |ad|
226
+ puts "\tCreated an ad with ID %d, type '%s' and status '%s'" %
227
+ [ad[:ad][:id], ad[:ad][:ad_type], ad[:status]]
228
+ end
229
+ else
230
+ raise StandardError, 'No ads were added.'
231
+ end
232
+ end
233
+
234
+ if __FILE__ == $0
235
+ API_VERSION = :v201406
236
+
237
+ # See the Placeholder reference page for a list of all the placeholder types
238
+ # and fields:
239
+ # https://developers.google.com/adwords/api/docs/appendix/placeholders
240
+ PLACEHOLDER_AD_CUSTOMIZER = 10
241
+ PLACEHOLDER_FIELD_INTEGER = 1
242
+ PLACEHOLDER_FIELD_FLOAT = 2
243
+ PLACEHOLDER_FIELD_PRICE = 3
244
+ PLACEHOLDER_FIELD_DATE = 4
245
+ PLACEHOLDER_FIELD_STRING = 5
246
+
247
+ begin
248
+ ad_group_ids = [
249
+ 'INSERT_AD_GROUP_ID_HERE'.to_i,
250
+ 'INSERT_AD_GROUP_ID_HERE'.to_i
251
+ ]
252
+ add_ad_customizer(ad_group_ids)
253
+
254
+ # Authorization error.
255
+ rescue AdsCommon::Errors::OAuth2VerificationRequired => e
256
+ puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
257
+ "OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
258
+ "to retrieve and store OAuth2 tokens."
259
+ puts "See this wiki page for more details:\n\n " +
260
+ 'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
261
+
262
+ # HTTP errors.
263
+ rescue AdsCommon::Errors::HttpError => e
264
+ puts "HTTP Error: %s" % e
265
+
266
+ # API errors.
267
+ rescue AdwordsApi::Errors::ApiException => e
268
+ puts "Message: %s" % e.message
269
+ puts 'Errors:'
270
+ e.errors.each_with_index do |error, index|
271
+ puts "\tError [%d]:" % (index + 1)
272
+ error.each do |field, value|
273
+ puts "\t\t%s: %s" % [field, value]
274
+ end
275
+ end
276
+ end
277
+ end
data/lib/adwords_api.rb CHANGED
@@ -23,7 +23,6 @@
23
23
  require 'ads_common/api'
24
24
  require 'ads_common/savon_headers/oauth_header_handler'
25
25
  require 'adwords_api/api_config'
26
- require 'adwords_api/client_login_header_handler'
27
26
  require 'adwords_api/credential_handler'
28
27
  require 'adwords_api/errors'
29
28
  require 'adwords_api/report_utils'
@@ -63,12 +62,6 @@ module AdwordsApi
63
62
  def soap_header_handler(auth_handler, version, header_ns, default_ns)
64
63
  auth_method = @config.read('authentication.method', :OAUTH2)
65
64
  handler_class = case auth_method
66
- when :CLIENTLOGIN
67
- raise AdsCommon::Errors::AuthError,
68
- "ClientLogin is not supported. " +
69
- "Please use OAuth2 instead. See here for details:\n\t\t" +
70
- "https://developers.google.com/adwords/api/" +
71
- "docs/guides/authentication"
72
65
  when :OAUTH2, :OAUTH2_JWT
73
66
  AdsCommon::SavonHeaders::OAuthHeaderHandler
74
67
  else
@@ -218,12 +218,6 @@ module AdwordsApi
218
218
  [:v201406, :LabelService] => 'cm/'
219
219
  }
220
220
 
221
- # Auth constants for ClientLogin method.
222
- @@client_login_config = {
223
- :AUTH_SERVER => 'https://www.google.com',
224
- :LOGIN_SERVICE_NAME => 'adwords'
225
- }
226
-
227
221
  public
228
222
 
229
223
  # Getters for constants and module variables.
@@ -257,7 +251,11 @@ module AdwordsApi
257
251
  end
258
252
 
259
253
  def self.client_login_config(key)
260
- return @@client_login_config[key]
254
+ raise AdsCommon::Errors::AuthError,
255
+ "ClientLogin is not supported. " +
256
+ "Please use OAuth2 instead. See here for details:\n\t\t" +
257
+ "https://developers.google.com/adwords/api/" +
258
+ "docs/guides/authentication"
261
259
  end
262
260
 
263
261
  def self.default_config_filename
@@ -74,11 +74,6 @@ module AdwordsApi
74
74
  # valid.
75
75
  #
76
76
  def validate_headers_for_server(credentials)
77
- if credentials[:client_email]
78
- raise AdwordsApi::Errors::BadCredentialsError, 'Deprecated header ' +
79
- 'clientEmail is no longer supported, please use clientCustomerId'
80
- end
81
-
82
77
  client_customer_id = credentials[:client_customer_id]
83
78
  if client_customer_id and
84
79
  !(client_customer_id.is_a?(Integer) or
@@ -5,7 +5,7 @@
5
5
  # Copyright:: Copyright 2013, Google Inc. All Rights Reserved.
6
6
  # License:: Licensed under the Apache License, Version 2.0.
7
7
  #
8
- # Code generated by AdsCommon library 0.9.5 on 2014-03-05 10:52:45.
8
+ # Code generated by AdsCommon library 0.9.5 on 2014-08-20 16:28:11.
9
9
 
10
10
  require 'ads_common/savon_service'
11
11
  require 'adwords_api/v201402/ad_group_ad_service_registry'