google-adwords-api 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/ChangeLog +7 -0
  2. data/README +4 -4
  3. data/examples/v201109_1/account_management/create_account.rb +80 -0
  4. data/examples/v201109_1/account_management/get_account_alerts.rb +111 -0
  5. data/examples/v201109_1/account_management/get_account_changes.rb +137 -0
  6. data/examples/v201109_1/account_management/get_account_hierarchy.rb +93 -0
  7. data/examples/v201109_1/account_management/get_client_customer_id.rb +85 -0
  8. data/examples/v201109_1/account_management/get_client_unit_usage.rb +87 -0
  9. data/examples/v201109_1/basic_operations/add_ad_groups.rb +111 -0
  10. data/examples/v201109_1/basic_operations/add_campaigns.rb +140 -0
  11. data/examples/v201109_1/basic_operations/add_keywords.rb +108 -0
  12. data/examples/v201109_1/basic_operations/add_text_ads.rb +105 -0
  13. data/examples/v201109_1/basic_operations/delete_ad.rb +85 -0
  14. data/examples/v201109_1/basic_operations/delete_ad_group.rb +102 -0
  15. data/examples/v201109_1/basic_operations/delete_campaign.rb +103 -0
  16. data/examples/v201109_1/basic_operations/delete_keyword.rb +90 -0
  17. data/examples/v201109_1/basic_operations/get_ad_groups.rb +98 -0
  18. data/examples/v201109_1/basic_operations/get_campaigns.rb +93 -0
  19. data/examples/v201109_1/basic_operations/get_keywords.rb +104 -0
  20. data/examples/v201109_1/basic_operations/get_text_ads.rb +106 -0
  21. data/examples/v201109_1/basic_operations/pause_ad.rb +84 -0
  22. data/examples/v201109_1/basic_operations/update_ad_group.rb +81 -0
  23. data/examples/v201109_1/basic_operations/update_campaign.rb +84 -0
  24. data/examples/v201109_1/basic_operations/update_keyword.rb +99 -0
  25. data/examples/v201109_1/campaign_management/add_experiment.rb +158 -0
  26. data/examples/v201109_1/campaign_management/add_keywords_in_bulk.rb +150 -0
  27. data/examples/v201109_1/campaign_management/add_location_extension.rb +117 -0
  28. data/examples/v201109_1/campaign_management/add_location_extension_override.rb +83 -0
  29. data/examples/v201109_1/campaign_management/get_all_disapproved_ads.rb +93 -0
  30. data/examples/v201109_1/campaign_management/promote_experiment.rb +77 -0
  31. data/examples/v201109_1/campaign_management/set_ad_parameters.rb +114 -0
  32. data/examples/v201109_1/campaign_management/validate_text_ad.rb +106 -0
  33. data/examples/v201109_1/error_handling/handle_captcha_challenge.rb +93 -0
  34. data/examples/v201109_1/error_handling/handle_partial_failures.rb +126 -0
  35. data/examples/v201109_1/error_handling/handle_policy_violation_error.rb +137 -0
  36. data/examples/v201109_1/error_handling/handle_two_factor_authorization_error.rb +87 -0
  37. data/examples/v201109_1/misc/get_all_images_and_videos.rb +101 -0
  38. data/examples/v201109_1/misc/upload_image.rb +90 -0
  39. data/examples/v201109_1/misc/use_oauth.rb +97 -0
  40. data/examples/v201109_1/optimization/estimate_keyword_traffic.rb +129 -0
  41. data/examples/v201109_1/optimization/get_keyword_bid_simulations.rb +92 -0
  42. data/examples/v201109_1/optimization/get_keyword_ideas.rb +113 -0
  43. data/examples/v201109_1/optimization/get_placement_ideas.rb +106 -0
  44. data/examples/v201109_1/remarketing/add_audience.rb +115 -0
  45. data/examples/v201109_1/remarketing/add_conversion_tracker.rb +97 -0
  46. data/examples/v201109_1/reporting/download_criteria_report.rb +79 -0
  47. data/examples/v201109_1/reporting/get_campaign_stats.rb +105 -0
  48. data/examples/v201109_1/reporting/get_defined_reports.rb +75 -0
  49. data/examples/{v201109/reporting/download_defined_report.rb → v201109_1/reporting/get_report_fields.rb} +15 -11
  50. data/examples/v201109_1/reporting/parallel_report_download.rb +159 -0
  51. data/examples/v201109_1/targeting/add_campaign_targeting_criteria.rb +118 -0
  52. data/examples/v201109_1/targeting/get_campaign_targeting_criteria.rb +102 -0
  53. data/examples/v201109_1/targeting/get_targetable_languages_and_carriers.rb +86 -0
  54. data/examples/v201109_1/targeting/lookup_location.rb +103 -0
  55. data/lib/adwords_api.rb +15 -88
  56. data/lib/adwords_api/api_config.rb +75 -33
  57. data/lib/adwords_api/client_login_header_handler.rb +17 -26
  58. data/lib/adwords_api/credential_handler.rb +29 -65
  59. data/lib/adwords_api/report_header_handler.rb +65 -0
  60. data/lib/adwords_api/report_utils.rb +12 -36
  61. data/lib/adwords_api/v201109/ad_extension_override_service.rb +3 -3
  62. data/lib/adwords_api/v201109/ad_extension_override_service_registry.rb +2 -2
  63. data/lib/adwords_api/v201109/ad_group_ad_service.rb +3 -3
  64. data/lib/adwords_api/v201109/ad_group_ad_service_registry.rb +1 -1
  65. data/lib/adwords_api/v201109/ad_group_criterion_service.rb +3 -3
  66. data/lib/adwords_api/v201109/ad_group_criterion_service_registry.rb +1 -1
  67. data/lib/adwords_api/v201109/ad_group_service.rb +3 -3
  68. data/lib/adwords_api/v201109/ad_group_service_registry.rb +1 -1
  69. data/lib/adwords_api/v201109/ad_param_service.rb +3 -3
  70. data/lib/adwords_api/v201109/ad_param_service_registry.rb +1 -1
  71. data/lib/adwords_api/v201109/alert_service.rb +3 -3
  72. data/lib/adwords_api/v201109/alert_service_registry.rb +1 -1
  73. data/lib/adwords_api/v201109/budget_order_service.rb +42 -0
  74. data/lib/adwords_api/v201109/budget_order_service_registry.rb +46 -0
  75. data/lib/adwords_api/v201109/bulk_mutate_job_service.rb +3 -3
  76. data/lib/adwords_api/v201109/bulk_mutate_job_service_registry.rb +1 -1
  77. data/lib/adwords_api/v201109/campaign_ad_extension_service.rb +3 -3
  78. data/lib/adwords_api/v201109/campaign_ad_extension_service_registry.rb +2 -2
  79. data/lib/adwords_api/v201109/campaign_criterion_service.rb +3 -3
  80. data/lib/adwords_api/v201109/campaign_criterion_service_registry.rb +1 -1
  81. data/lib/adwords_api/v201109/campaign_service.rb +3 -3
  82. data/lib/adwords_api/v201109/campaign_service_registry.rb +1 -1
  83. data/lib/adwords_api/v201109/campaign_target_service.rb +3 -3
  84. data/lib/adwords_api/v201109/campaign_target_service_registry.rb +1 -1
  85. data/lib/adwords_api/v201109/constant_data_service.rb +3 -3
  86. data/lib/adwords_api/v201109/constant_data_service_registry.rb +1 -1
  87. data/lib/adwords_api/v201109/conversion_tracker_service.rb +3 -3
  88. data/lib/adwords_api/v201109/conversion_tracker_service_registry.rb +1 -1
  89. data/lib/adwords_api/v201109/create_account_service.rb +3 -3
  90. data/lib/adwords_api/v201109/create_account_service_registry.rb +1 -1
  91. data/lib/adwords_api/v201109/customer_sync_service.rb +3 -3
  92. data/lib/adwords_api/v201109/customer_sync_service_registry.rb +1 -1
  93. data/lib/adwords_api/v201109/data_service.rb +3 -3
  94. data/lib/adwords_api/v201109/data_service_registry.rb +1 -1
  95. data/lib/adwords_api/v201109/experiment_service.rb +3 -3
  96. data/lib/adwords_api/v201109/experiment_service_registry.rb +1 -1
  97. data/lib/adwords_api/v201109/geo_location_service.rb +3 -3
  98. data/lib/adwords_api/v201109/geo_location_service_registry.rb +1 -1
  99. data/lib/adwords_api/v201109/info_service.rb +3 -3
  100. data/lib/adwords_api/v201109/info_service_registry.rb +1 -1
  101. data/lib/adwords_api/v201109/location_criterion_service.rb +3 -3
  102. data/lib/adwords_api/v201109/location_criterion_service_registry.rb +1 -1
  103. data/lib/adwords_api/v201109/media_service.rb +3 -3
  104. data/lib/adwords_api/v201109/media_service_registry.rb +1 -1
  105. data/lib/adwords_api/v201109/mutate_job_service.rb +3 -3
  106. data/lib/adwords_api/v201109/mutate_job_service_registry.rb +1 -1
  107. data/lib/adwords_api/v201109/report_definition_service.rb +3 -12
  108. data/lib/adwords_api/v201109/report_definition_service_registry.rb +1 -1
  109. data/lib/adwords_api/v201109/serviced_account_service.rb +3 -3
  110. data/lib/adwords_api/v201109/serviced_account_service_registry.rb +1 -1
  111. data/lib/adwords_api/v201109/targeting_idea_service.rb +3 -3
  112. data/lib/adwords_api/v201109/targeting_idea_service_registry.rb +1 -1
  113. data/lib/adwords_api/v201109/traffic_estimator_service.rb +3 -3
  114. data/lib/adwords_api/v201109/traffic_estimator_service_registry.rb +1 -1
  115. data/lib/adwords_api/v201109/user_list_service.rb +3 -3
  116. data/lib/adwords_api/v201109/user_list_service_registry.rb +1 -1
  117. data/lib/adwords_api/v201109_1/ad_extension_override_service.rb +38 -0
  118. data/lib/adwords_api/v201109_1/ad_extension_override_service_registry.rb +46 -0
  119. data/lib/adwords_api/v201109_1/ad_group_ad_service.rb +38 -0
  120. data/lib/adwords_api/v201109_1/ad_group_ad_service_registry.rb +46 -0
  121. data/lib/adwords_api/v201109_1/ad_group_criterion_service.rb +38 -0
  122. data/lib/adwords_api/v201109_1/ad_group_criterion_service_registry.rb +46 -0
  123. data/lib/adwords_api/v201109_1/ad_group_service.rb +38 -0
  124. data/lib/adwords_api/v201109_1/ad_group_service_registry.rb +46 -0
  125. data/lib/adwords_api/v201109_1/ad_param_service.rb +38 -0
  126. data/lib/adwords_api/v201109_1/ad_param_service_registry.rb +46 -0
  127. data/lib/adwords_api/v201109_1/alert_service.rb +34 -0
  128. data/lib/adwords_api/v201109_1/alert_service_registry.rb +46 -0
  129. data/lib/adwords_api/v201109_1/budget_order_service.rb +42 -0
  130. data/lib/adwords_api/v201109_1/budget_order_service_registry.rb +46 -0
  131. data/lib/adwords_api/v201109_1/bulk_mutate_job_service.rb +38 -0
  132. data/lib/adwords_api/v201109_1/bulk_mutate_job_service_registry.rb +46 -0
  133. data/lib/adwords_api/v201109_1/campaign_ad_extension_service.rb +38 -0
  134. data/lib/adwords_api/v201109_1/campaign_ad_extension_service_registry.rb +46 -0
  135. data/lib/adwords_api/v201109_1/campaign_criterion_service.rb +38 -0
  136. data/lib/adwords_api/v201109_1/campaign_criterion_service_registry.rb +46 -0
  137. data/lib/adwords_api/v201109_1/campaign_service.rb +38 -0
  138. data/lib/adwords_api/v201109_1/campaign_service_registry.rb +46 -0
  139. data/lib/adwords_api/v201109_1/campaign_target_service.rb +38 -0
  140. data/lib/adwords_api/v201109_1/campaign_target_service_registry.rb +46 -0
  141. data/lib/adwords_api/v201109_1/constant_data_service.rb +38 -0
  142. data/lib/adwords_api/v201109_1/constant_data_service_registry.rb +46 -0
  143. data/lib/adwords_api/v201109_1/conversion_tracker_service.rb +38 -0
  144. data/lib/adwords_api/v201109_1/conversion_tracker_service_registry.rb +46 -0
  145. data/lib/adwords_api/v201109_1/create_account_service.rb +34 -0
  146. data/lib/adwords_api/v201109_1/create_account_service_registry.rb +47 -0
  147. data/lib/adwords_api/v201109_1/customer_sync_service.rb +34 -0
  148. data/lib/adwords_api/v201109_1/customer_sync_service_registry.rb +47 -0
  149. data/lib/adwords_api/v201109_1/data_service.rb +38 -0
  150. data/lib/adwords_api/v201109_1/data_service_registry.rb +46 -0
  151. data/lib/adwords_api/v201109_1/experiment_service.rb +38 -0
  152. data/lib/adwords_api/v201109_1/experiment_service_registry.rb +46 -0
  153. data/lib/adwords_api/v201109_1/geo_location_service.rb +34 -0
  154. data/lib/adwords_api/v201109_1/geo_location_service_registry.rb +46 -0
  155. data/lib/adwords_api/v201109_1/info_service.rb +34 -0
  156. data/lib/adwords_api/v201109_1/info_service_registry.rb +46 -0
  157. data/lib/adwords_api/v201109_1/location_criterion_service.rb +34 -0
  158. data/lib/adwords_api/v201109_1/location_criterion_service_registry.rb +46 -0
  159. data/lib/adwords_api/v201109_1/media_service.rb +38 -0
  160. data/lib/adwords_api/v201109_1/media_service_registry.rb +46 -0
  161. data/lib/adwords_api/v201109_1/mutate_job_service.rb +42 -0
  162. data/lib/adwords_api/v201109_1/mutate_job_service_registry.rb +46 -0
  163. data/lib/adwords_api/v201109_1/report_definition_service.rb +38 -0
  164. data/lib/adwords_api/v201109_1/report_definition_service_registry.rb +46 -0
  165. data/lib/adwords_api/v201109_1/serviced_account_service.rb +34 -0
  166. data/lib/adwords_api/v201109_1/serviced_account_service_registry.rb +46 -0
  167. data/lib/adwords_api/v201109_1/targeting_idea_service.rb +38 -0
  168. data/lib/adwords_api/v201109_1/targeting_idea_service_registry.rb +46 -0
  169. data/lib/adwords_api/v201109_1/traffic_estimator_service.rb +34 -0
  170. data/lib/adwords_api/v201109_1/traffic_estimator_service_registry.rb +46 -0
  171. data/lib/adwords_api/v201109_1/user_list_service.rb +38 -0
  172. data/lib/adwords_api/v201109_1/user_list_service_registry.rb +46 -0
  173. data/lib/adwords_api/version.rb +1 -1
  174. data/test/adwords_api/test_api_config.rb +24 -8
  175. data/test/adwords_api/test_credential_handler.rb +32 -52
  176. data/test/coverage.rb +38 -0
  177. data/test/examples/v201109/test_reporting.rb +0 -12
  178. data/test/examples/v201109_1/test_account_management.rb +60 -0
  179. data/test/examples/v201109_1/test_basic_operations.rb +172 -0
  180. data/test/examples/v201109_1/test_campaign_management.rb +116 -0
  181. data/test/examples/v201109_1/test_error_handling.rb +63 -0
  182. data/{lib/adwords_api/v13_login_handler.rb → test/examples/v201109_1/test_misc.rb} +24 -10
  183. data/test/examples/v201109_1/test_optimization.rb +63 -0
  184. data/test/{suite_exampletests.rb → examples/v201109_1/test_remarketing.rb} +16 -8
  185. data/test/examples/v201109_1/test_reporting.rb +77 -0
  186. data/test/examples/v201109_1/test_targeting.rb +60 -0
  187. data/test/examples/v201109_1/utils.rb +239 -0
  188. data/test/suite_exampletests_v201109.rb +37 -0
  189. data/test/suite_exampletests_v201109_1.rb +37 -0
  190. data/test/suite_unittests.rb +7 -5
  191. metadata +136 -11
  192. data/lib/adwords_api/extensions.rb +0 -269
@@ -1,269 +0,0 @@
1
- # Encoding: utf-8
2
- #
3
- # Author:: api.sgomes@gmail.com (Sérgio Gomes)
4
- #
5
- # Copyright:: Copyright 2010, 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
- # Contains extensions to the API, that is, service helper methods provided in
21
- # client-side by the client library.
22
-
23
- require 'csv'
24
- require 'httpi/request'
25
- require 'rexml/document'
26
-
27
- require 'ads_common/http'
28
-
29
- module AdwordsApi
30
-
31
- module Extensions
32
-
33
- # Maintains a list of all extension methods, indexed by version and service.
34
- # Using camelCase to match API method names.
35
- @@extensions = {
36
- [:v13, :ReportService] => [:download_xml_report, :download_csv_report],
37
- [:v201003, :ReportDefinitionService] => [:download_report,
38
- :download_report_as_file],
39
- [:v201008, :ReportDefinitionService] => [:download_report,
40
- :download_report_as_file],
41
- [:v201101, :ReportDefinitionService] => [:download_report,
42
- :download_report_as_file],
43
- [:v201109, :ReportDefinitionService] => [:download_report,
44
- :download_report_as_file]
45
- }
46
-
47
- # Defines the parameter list for every extension method.
48
- @@methods = {
49
- :download_xml_report => [:job_id],
50
- :download_csv_report => [:job_id],
51
- :download_report => [:report_definition_id],
52
- :download_report_as_file => [:report_definition_id, :path]
53
- }
54
-
55
- # Return list of all extension methods, indexed by version and service.
56
- def self.extensions
57
- return @@extensions
58
- end
59
-
60
- # Return the parameter list for every extension method.
61
- def self.methods
62
- return @@methods
63
- end
64
-
65
- #########################################################################
66
- # NOTE: The following extension methods shouldn't be used directly; they
67
- # should instead be used from the services wrappers they get mapped to.
68
- # For example, you should use ReportServiceWrapper::downloadXmlReport
69
- # instead of Extensions::downloadXmlReport.
70
- #########################################################################
71
-
72
- # <i>Extension method</i> -- Download and return report data in XML format.
73
- #
74
- # *Warning*: this method is blocking for the calling thread.
75
- #
76
- # Args:
77
- # - wrapper: the service wrapper object for any API methods that need to be
78
- # called
79
- # - job_id: the job id for the report to be downloaded
80
- #
81
- # Returns:
82
- # The xml for the report (as a string)
83
- #
84
- def self.download_xml_report(wrapper, args)
85
- job_id = args.first
86
- sleep_interval = 30
87
-
88
- status_field = :get_report_job_status_return
89
- download_field = :get_report_download_url_return
90
-
91
- # Repeatedly check the report status until it is finished.
92
- # 'Pending' and 'InProgress' statuses indicate the job is still being run.
93
- status = wrapper.get_report_job_status(job_id)[status_field]
94
- while status != 'Completed' && status != 'Failed'
95
- sleep(sleep_interval)
96
- status = wrapper.get_report_job_status(job_id)[status_field]
97
- end
98
-
99
- if status == 'Completed'
100
- report_url = wrapper.get_report_download_url(job_id)[download_field]
101
-
102
- # Download the report and return its contents. The report is an XML
103
- # document; the actual element names vary depending on the type of
104
- # report run and columns requested.
105
- begin
106
- return AdsCommon::Http.get(report_url, wrapper.api.config)
107
- rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
108
- # This exception indicates a connection-level error.
109
- # In general, it is likely to be transitory.
110
- raise AdsCommon::Errors::HttpError, e.message, e.backtrace
111
- end
112
- else
113
- # Reports that pass validation will normally not fail, but if there is
114
- # an error in the report generation service it can sometimes happen.
115
- raise AdwordsApi::Errors::ApiException, 'Report generation failed.'
116
- end
117
- end
118
-
119
- # <i>Extension method</i> -- Download and return report data in CSV format.
120
- #
121
- # *Warning*: this method is blocking for the calling thread.
122
- #
123
- # Args:
124
- # - wrapper: the service wrapper object for any API methods that need to be
125
- # called
126
- # - job_id: the job id for the report to be downloaded
127
- # - xml: optional parameter used for testing and debugging
128
- #
129
- # Returns:
130
- # The CSV data for the report (as a string)
131
- #
132
- def self.download_csv_report(wrapper, args)
133
- (job_id, report_xml) = args
134
- # Get XML report data.
135
- report_xml = download_xml_report(wrapper, job_id) if report_xml.nil?
136
-
137
- begin
138
- # Construct DOM object.
139
- doc = REXML::Document.new(report_xml)
140
-
141
- # Get data columns.
142
- columns = []
143
- doc.elements.each('report/table/columns/column') do |column_elem|
144
- name = column_elem.attributes['name']
145
- columns << name unless name.nil?
146
- end
147
-
148
- # Get data rows.
149
- rows = []
150
- doc.elements.each('report/table/rows/row') do |row_elem|
151
- rows << row_elem.attributes unless row_elem.attributes.nil?
152
- end
153
-
154
- # Build CSV
155
- csv = ''
156
- CSV::Writer.generate(csv) do |writer|
157
- writer << columns
158
- rows.each do |row|
159
- row_values = []
160
- columns.each { |column| row_values << row[column] }
161
- writer << row_values
162
- end
163
- end
164
-
165
- return csv
166
- rescue REXML::ParseException => e
167
- # Error parsing XML
168
- raise AdwordsApi::Errors::ApiException,
169
- "Error parsing report XML: %s\nSource: %s" % [e, e.backtrace.first]
170
- end
171
- end
172
-
173
- # <i>Extension method</i> -- Download and return a v20xx report into a file.
174
- #
175
- # *Warning*: this method is blocking for the calling thread.
176
- #
177
- # Args:
178
- # - wrapper: the service wrapper object for any API methods that need to be
179
- # called
180
- # - report_definition_id: the id for the report definition
181
- # - path: the file where the data should be saved
182
- #
183
- # Returns:
184
- # nil
185
- #
186
- def self.download_report_as_file(wrapper, args)
187
- (report_definition_id, path) = args
188
- report_data = download_report(wrapper, [report_definition_id])
189
- save_to_file(report_data, path)
190
- return nil
191
- end
192
-
193
- # <i>Extension method</i> -- Download and return a v20xx report.
194
- #
195
- # *Warning*: this method is blocking for the calling thread.
196
- #
197
- # Args:
198
- # - wrapper: the service wrapper object for any API methods that need to be
199
- # called
200
- # - report_definition_id: the id for the report definition
201
- #
202
- # Returns:
203
- # The data for the report (as a string)
204
- #
205
- def self.download_report(wrapper, args)
206
- report_definition_id = args.first
207
- url = get_report_url(wrapper, "?__rd=%s" % report_definition_id)
208
- report_response = get_report_response(wrapper, url)
209
- return report_response.body
210
- end
211
-
212
- private
213
-
214
- # Saves raw data to a file.
215
- def self.save_to_file(data, path)
216
- open(path, 'wb') { |file| file.puts(data) } if path
217
- end
218
-
219
- # Generates default report URL with given parameters.
220
- def self.get_report_url(wrapper, parameters)
221
- return AdwordsApi::ApiConfig.report_download_url(
222
- wrapper.api.config.read('service.environment'),
223
- wrapper.version) + parameters
224
- end
225
-
226
- # Gets a report response for a given parameters.
227
- def self.get_report_response(wrapper, url)
228
- headers = get_report_request_headers(wrapper, url)
229
- report_response = AdsCommon::Http.get_response(url, wrapper.api.config,
230
- headers)
231
- return report_response
232
- end
233
-
234
- def self.get_report_request_headers(wrapper, url)
235
- headers = {}
236
- credentials = wrapper.api.credential_handler.credentials
237
- auth_handler = wrapper.api.get_auth_handler(
238
- wrapper.api.config.read('service.environment'), wrapper.version)
239
- headers['Authorization'] = auth_handler.auth_string(credentials,
240
- HTTPI::Request.new(url))
241
- headers['developerToken'] = credentials[:developerToken]
242
- if credentials[:clientCustomerId]
243
- headers['clientCustomerId'] = credentials[:clientCustomerId]
244
- elsif credentials[:clientEmail]
245
- headers['clientEmail'] = credentials[:clientEmail]
246
- elsif credentials[:email]
247
- headers['clientEmail'] = credentials[:email]
248
- end
249
- money_in_micros =
250
- wrapper.api.config.read('library.return_money_in_micros')
251
- unless money_in_micros.nil?
252
- headers['returnMoneyInMicros'] = money_in_micros
253
- end
254
- return headers
255
- end
256
-
257
- # Checks for old-style v13 reporting error.
258
- def self.check_old_error(response_text)
259
- error_message_regex = '^!!!(-?\d+)\|\|\|(-?\d+)\|\|\|(.*)\?\?\?'
260
- matches = response_text.match(error_message_regex)
261
- if matches
262
- message = (matches[3].nil?) ? response_text : matches[3]
263
- raise AdwordsApi::Errors::ApiException,
264
- "Report download error occured: %s" % message
265
- end
266
- return nil
267
- end
268
- end
269
- end