google-adwords-api 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (324) hide show
  1. data/ChangeLog +9 -0
  2. data/README +26 -10
  3. data/Rakefile +1 -1
  4. data/examples/v200909/add_ad_group.rb +2 -2
  5. data/examples/v200909/add_ads.rb +4 -4
  6. data/examples/v200909/add_campaign.rb +2 -2
  7. data/examples/v200909/check_campaigns.rb +4 -4
  8. data/examples/v201003/add_ad_group.rb +2 -2
  9. data/examples/v201003/add_ads.rb +6 -6
  10. data/examples/v201003/add_campaign.rb +2 -2
  11. data/examples/v201003/add_keywords_performance_report_definition.rb +2 -2
  12. data/examples/v201003/check_campaigns.rb +4 -4
  13. data/examples/v201008/add_ad_group.rb +2 -2
  14. data/examples/v201008/add_ads.rb +7 -7
  15. data/examples/v201008/add_campaign.rb +2 -2
  16. data/examples/v201008/add_experiment.rb +5 -5
  17. data/examples/v201008/add_keywords_performance_report_definition.rb +2 -2
  18. data/examples/v201008/add_user_list.rb +2 -2
  19. data/examples/v201008/check_campaigns.rb +4 -4
  20. data/examples/v201008/get_account_hierarchy.rb +8 -11
  21. data/examples/v201101/add_ad_group.rb +2 -2
  22. data/examples/v201101/add_ads.rb +6 -6
  23. data/examples/v201101/add_campaign.rb +2 -2
  24. data/examples/v201101/add_conversion.rb +4 -4
  25. data/examples/v201101/add_experiment.rb +5 -5
  26. data/examples/v201101/add_keywords_performance_report_definition.rb +2 -2
  27. data/examples/v201101/add_user_list.rb +3 -3
  28. data/examples/v201101/check_campaigns.rb +4 -4
  29. data/examples/v201101/get_account_hierarchy.rb +7 -9
  30. data/examples/v201109/add_ad_extension_override.rb +82 -0
  31. data/examples/v201109/add_ad_group.rb +89 -0
  32. data/examples/v201109/add_ad_group_criteria.rb +109 -0
  33. data/examples/v201109/add_ads.rb +174 -0
  34. data/examples/v201109/add_campaign.rb +99 -0
  35. data/examples/v201109/add_campaign_ad_extension.rb +121 -0
  36. data/examples/v201109/add_campaign_targeting_criteria.rb +102 -0
  37. data/examples/{v201101/add_mcc_report_definition.rb → v201109/add_conversion.rb} +26 -28
  38. data/examples/v201109/add_experiment.rb +153 -0
  39. data/examples/v201109/add_negative_campaign_criterion.rb +87 -0
  40. data/examples/v201109/add_user_list.rb +113 -0
  41. data/examples/v201109/check_campaigns.rb +123 -0
  42. data/examples/v201109/delete_ad.rb +85 -0
  43. data/examples/v201109/delete_ad_group.rb +77 -0
  44. data/examples/v201109/delete_ad_group_criterion.rb +86 -0
  45. data/examples/v201109/delete_bulk_mutate_job.rb +87 -0
  46. data/examples/v201109/delete_campaign.rb +78 -0
  47. data/examples/v201109/delete_experiment.rb +78 -0
  48. data/examples/v201109/delete_user_list.rb +78 -0
  49. data/examples/v201109/download_adhoc_report.rb +79 -0
  50. data/examples/v201109/download_report.rb +67 -0
  51. data/examples/v201109/get_account_hierarchy.rb +93 -0
  52. data/examples/v201109/get_ad_group_bid_landscape.rb +94 -0
  53. data/examples/v201109/get_all_account_changes.rb +137 -0
  54. data/examples/v201109/get_all_active_ad_group_criteria.rb +98 -0
  55. data/examples/v201109/get_all_ad_extension_overrides.rb +82 -0
  56. data/examples/v201109/get_all_ad_group_criteria.rb +90 -0
  57. data/examples/v201109/get_all_ad_groups.rb +85 -0
  58. data/examples/v201109/get_all_ad_params.rb +86 -0
  59. data/examples/v201109/get_all_ads.rb +90 -0
  60. data/examples/v201109/get_all_campaign_ad_extensions.rb +87 -0
  61. data/examples/v201109/get_all_campaign_targets.rb +74 -0
  62. data/examples/v201109/get_all_campaigns.rb +77 -0
  63. data/examples/v201109/get_all_carriers.rb +72 -0
  64. data/examples/v201109/get_all_conversions.rb +79 -0
  65. data/examples/v201109/get_all_disapproved_ads.rb +93 -0
  66. data/examples/v201109/get_all_experiments.rb +89 -0
  67. data/examples/v201109/get_all_images.rb +82 -0
  68. data/examples/v201109/get_all_languages.rb +73 -0
  69. data/examples/v201109/get_all_paused_campaigns.rb +83 -0
  70. data/examples/v201109/get_all_report_definitions.rb +75 -0
  71. data/examples/v201109/get_all_user_lists.rb +78 -0
  72. data/examples/v201109/get_all_videos.rb +78 -0
  73. data/examples/v201109/get_bulk_mutate_job.rb +97 -0
  74. data/examples/v201109/get_campaign_alerts.rb +95 -0
  75. data/examples/v201109/get_client_customer_id.rb +87 -0
  76. data/examples/v201109/get_conversion_optimizer_eligibility.rb +93 -0
  77. data/examples/v201109/get_criterion_bid_landscape.rb +93 -0
  78. data/examples/v201109/get_geo_location_info.rb +99 -0
  79. data/examples/v201109/get_keyword_opportunities.rb +95 -0
  80. data/examples/v201109/get_location_criteria.rb +103 -0
  81. data/examples/v201109/get_method_cost.rb +87 -0
  82. data/examples/v201109/get_operation_count.rb +79 -0
  83. data/examples/v201109/get_related_keywords.rb +108 -0
  84. data/examples/v201109/get_related_placements.rb +107 -0
  85. data/examples/v201109/get_report_fields.rb +72 -0
  86. data/examples/v201109/get_total_usage_units_per_month.rb +74 -0
  87. data/examples/v201109/get_traffic_estimates.rb +129 -0
  88. data/examples/v201109/get_unit_count.rb +81 -0
  89. data/examples/v201109/handle_partial_failures.rb +127 -0
  90. data/examples/v201109/handle_policy_violation_error.rb +138 -0
  91. data/examples/v201109/handle_second_factor.rb +87 -0
  92. data/examples/v201109/oauth_handling.rb +95 -0
  93. data/examples/v201109/perform_bulk_mutate_job.rb +212 -0
  94. data/examples/v201109/perform_mutate_job.rb +177 -0
  95. data/examples/v201109/promote_experiment.rb +79 -0
  96. data/examples/v201109/set_ad_params.rb +115 -0
  97. data/examples/v201109/update_ad.rb +86 -0
  98. data/examples/v201109/update_ad_group.rb +81 -0
  99. data/examples/v201109/update_ad_group_criterion.rb +99 -0
  100. data/examples/v201109/update_campaign.rb +84 -0
  101. data/examples/v201109/update_conversion.rb +87 -0
  102. data/examples/v201109/update_user_list.rb +82 -0
  103. data/examples/v201109/upload_image.rb +90 -0
  104. data/lib/adwords_api.rb +54 -50
  105. data/lib/adwords_api/api_config.rb +70 -14
  106. data/lib/adwords_api/credential_handler.rb +32 -13
  107. data/lib/adwords_api/errors.rb +12 -0
  108. data/lib/adwords_api/extensions.rb +8 -118
  109. data/lib/adwords_api/report_utils.rb +198 -0
  110. data/lib/adwords_api/utils.rb +5 -2
  111. data/lib/adwords_api/v13/account_service.rb +11 -11
  112. data/lib/adwords_api/v13/account_service_registry.rb +5 -3
  113. data/lib/adwords_api/v13/report_service.rb +15 -15
  114. data/lib/adwords_api/v13/report_service_registry.rb +5 -3
  115. data/lib/adwords_api/v200909/ad_extension_override_service.rb +5 -5
  116. data/lib/adwords_api/v200909/ad_extension_override_service_registry.rb +5 -3
  117. data/lib/adwords_api/v200909/ad_group_ad_service.rb +5 -5
  118. data/lib/adwords_api/v200909/ad_group_ad_service_registry.rb +5 -3
  119. data/lib/adwords_api/v200909/ad_group_criterion_service.rb +5 -5
  120. data/lib/adwords_api/v200909/ad_group_criterion_service_registry.rb +5 -3
  121. data/lib/adwords_api/v200909/ad_group_service.rb +5 -5
  122. data/lib/adwords_api/v200909/ad_group_service_registry.rb +5 -3
  123. data/lib/adwords_api/v200909/ad_param_service.rb +5 -5
  124. data/lib/adwords_api/v200909/ad_param_service_registry.rb +5 -3
  125. data/lib/adwords_api/v200909/bulk_mutate_job_service.rb +5 -5
  126. data/lib/adwords_api/v200909/bulk_mutate_job_service_registry.rb +5 -3
  127. data/lib/adwords_api/v200909/campaign_ad_extension_service.rb +5 -5
  128. data/lib/adwords_api/v200909/campaign_ad_extension_service_registry.rb +5 -3
  129. data/lib/adwords_api/v200909/campaign_criterion_service.rb +5 -5
  130. data/lib/adwords_api/v200909/campaign_criterion_service_registry.rb +5 -3
  131. data/lib/adwords_api/v200909/campaign_service.rb +5 -5
  132. data/lib/adwords_api/v200909/campaign_service_registry.rb +5 -3
  133. data/lib/adwords_api/v200909/campaign_target_service.rb +5 -5
  134. data/lib/adwords_api/v200909/campaign_target_service_registry.rb +5 -3
  135. data/lib/adwords_api/v200909/geo_location_service.rb +3 -3
  136. data/lib/adwords_api/v200909/geo_location_service_registry.rb +5 -3
  137. data/lib/adwords_api/v200909/info_service.rb +3 -3
  138. data/lib/adwords_api/v200909/info_service_registry.rb +5 -3
  139. data/lib/adwords_api/v200909/targeting_idea_service.rb +5 -5
  140. data/lib/adwords_api/v200909/targeting_idea_service_registry.rb +5 -3
  141. data/lib/adwords_api/v201003/ad_extension_override_service.rb +5 -5
  142. data/lib/adwords_api/v201003/ad_extension_override_service_registry.rb +5 -3
  143. data/lib/adwords_api/v201003/ad_group_ad_service.rb +5 -5
  144. data/lib/adwords_api/v201003/ad_group_ad_service_registry.rb +5 -3
  145. data/lib/adwords_api/v201003/ad_group_criterion_service.rb +5 -5
  146. data/lib/adwords_api/v201003/ad_group_criterion_service_registry.rb +5 -3
  147. data/lib/adwords_api/v201003/ad_group_service.rb +5 -5
  148. data/lib/adwords_api/v201003/ad_group_service_registry.rb +5 -3
  149. data/lib/adwords_api/v201003/ad_param_service.rb +5 -5
  150. data/lib/adwords_api/v201003/ad_param_service_registry.rb +5 -3
  151. data/lib/adwords_api/v201003/bid_landscape_service.rb +3 -3
  152. data/lib/adwords_api/v201003/bid_landscape_service_registry.rb +5 -3
  153. data/lib/adwords_api/v201003/bulk_mutate_job_service.rb +5 -5
  154. data/lib/adwords_api/v201003/bulk_mutate_job_service_registry.rb +5 -3
  155. data/lib/adwords_api/v201003/campaign_ad_extension_service.rb +5 -5
  156. data/lib/adwords_api/v201003/campaign_ad_extension_service_registry.rb +5 -3
  157. data/lib/adwords_api/v201003/campaign_criterion_service.rb +5 -5
  158. data/lib/adwords_api/v201003/campaign_criterion_service_registry.rb +5 -3
  159. data/lib/adwords_api/v201003/campaign_service.rb +5 -5
  160. data/lib/adwords_api/v201003/campaign_service_registry.rb +5 -3
  161. data/lib/adwords_api/v201003/campaign_target_service.rb +5 -5
  162. data/lib/adwords_api/v201003/campaign_target_service_registry.rb +5 -3
  163. data/lib/adwords_api/v201003/geo_location_service.rb +3 -3
  164. data/lib/adwords_api/v201003/geo_location_service_registry.rb +5 -3
  165. data/lib/adwords_api/v201003/info_service.rb +3 -3
  166. data/lib/adwords_api/v201003/info_service_registry.rb +5 -3
  167. data/lib/adwords_api/v201003/media_service.rb +5 -5
  168. data/lib/adwords_api/v201003/media_service_registry.rb +5 -3
  169. data/lib/adwords_api/v201003/report_definition_service.rb +7 -7
  170. data/lib/adwords_api/v201003/report_definition_service_registry.rb +5 -3
  171. data/lib/adwords_api/v201003/targeting_idea_service.rb +5 -5
  172. data/lib/adwords_api/v201003/targeting_idea_service_registry.rb +5 -3
  173. data/lib/adwords_api/v201008/ad_extension_override_service.rb +5 -5
  174. data/lib/adwords_api/v201008/ad_extension_override_service_registry.rb +5 -3
  175. data/lib/adwords_api/v201008/ad_group_ad_service.rb +5 -5
  176. data/lib/adwords_api/v201008/ad_group_ad_service_registry.rb +5 -3
  177. data/lib/adwords_api/v201008/ad_group_criterion_service.rb +5 -5
  178. data/lib/adwords_api/v201008/ad_group_criterion_service_registry.rb +5 -3
  179. data/lib/adwords_api/v201008/ad_group_service.rb +5 -5
  180. data/lib/adwords_api/v201008/ad_group_service_registry.rb +5 -3
  181. data/lib/adwords_api/v201008/ad_param_service.rb +5 -5
  182. data/lib/adwords_api/v201008/ad_param_service_registry.rb +5 -3
  183. data/lib/adwords_api/v201008/alert_service.rb +3 -3
  184. data/lib/adwords_api/v201008/alert_service_registry.rb +5 -3
  185. data/lib/adwords_api/v201008/bid_landscape_service.rb +3 -3
  186. data/lib/adwords_api/v201008/bid_landscape_service_registry.rb +5 -3
  187. data/lib/adwords_api/v201008/bulk_mutate_job_service.rb +5 -5
  188. data/lib/adwords_api/v201008/bulk_mutate_job_service_registry.rb +5 -3
  189. data/lib/adwords_api/v201008/campaign_ad_extension_service.rb +5 -5
  190. data/lib/adwords_api/v201008/campaign_ad_extension_service_registry.rb +5 -3
  191. data/lib/adwords_api/v201008/campaign_criterion_service.rb +5 -5
  192. data/lib/adwords_api/v201008/campaign_criterion_service_registry.rb +5 -3
  193. data/lib/adwords_api/v201008/campaign_service.rb +5 -5
  194. data/lib/adwords_api/v201008/campaign_service_registry.rb +5 -3
  195. data/lib/adwords_api/v201008/campaign_target_service.rb +5 -5
  196. data/lib/adwords_api/v201008/campaign_target_service_registry.rb +5 -3
  197. data/lib/adwords_api/v201008/customer_sync_service.rb +3 -3
  198. data/lib/adwords_api/v201008/customer_sync_service_registry.rb +5 -3
  199. data/lib/adwords_api/v201008/experiment_service.rb +5 -5
  200. data/lib/adwords_api/v201008/experiment_service_registry.rb +5 -3
  201. data/lib/adwords_api/v201008/geo_location_service.rb +3 -3
  202. data/lib/adwords_api/v201008/geo_location_service_registry.rb +5 -3
  203. data/lib/adwords_api/v201008/info_service.rb +3 -3
  204. data/lib/adwords_api/v201008/info_service_registry.rb +5 -3
  205. data/lib/adwords_api/v201008/media_service.rb +5 -5
  206. data/lib/adwords_api/v201008/media_service_registry.rb +5 -3
  207. data/lib/adwords_api/v201008/report_definition_service.rb +7 -7
  208. data/lib/adwords_api/v201008/report_definition_service_registry.rb +5 -3
  209. data/lib/adwords_api/v201008/serviced_account_service.rb +3 -3
  210. data/lib/adwords_api/v201008/serviced_account_service_registry.rb +5 -3
  211. data/lib/adwords_api/v201008/targeting_idea_service.rb +5 -5
  212. data/lib/adwords_api/v201008/targeting_idea_service_registry.rb +5 -3
  213. data/lib/adwords_api/v201008/traffic_estimator_service.rb +3 -3
  214. data/lib/adwords_api/v201008/traffic_estimator_service_registry.rb +5 -3
  215. data/lib/adwords_api/v201008/user_list_service.rb +5 -5
  216. data/lib/adwords_api/v201008/user_list_service_registry.rb +5 -3
  217. data/lib/adwords_api/v201101/ad_extension_override_service.rb +5 -5
  218. data/lib/adwords_api/v201101/ad_extension_override_service_registry.rb +5 -3
  219. data/lib/adwords_api/v201101/ad_group_ad_service.rb +5 -5
  220. data/lib/adwords_api/v201101/ad_group_ad_service_registry.rb +5 -3
  221. data/lib/adwords_api/v201101/ad_group_criterion_service.rb +5 -5
  222. data/lib/adwords_api/v201101/ad_group_criterion_service_registry.rb +5 -3
  223. data/lib/adwords_api/v201101/ad_group_service.rb +5 -5
  224. data/lib/adwords_api/v201101/ad_group_service_registry.rb +5 -3
  225. data/lib/adwords_api/v201101/ad_param_service.rb +5 -5
  226. data/lib/adwords_api/v201101/ad_param_service_registry.rb +5 -3
  227. data/lib/adwords_api/v201101/alert_service.rb +3 -3
  228. data/lib/adwords_api/v201101/alert_service_registry.rb +5 -3
  229. data/lib/adwords_api/v201101/bulk_mutate_job_service.rb +5 -5
  230. data/lib/adwords_api/v201101/bulk_mutate_job_service_registry.rb +5 -3
  231. data/lib/adwords_api/v201101/bulk_opportunity_service.rb +3 -3
  232. data/lib/adwords_api/v201101/bulk_opportunity_service_registry.rb +5 -3
  233. data/lib/adwords_api/v201101/campaign_ad_extension_service.rb +5 -5
  234. data/lib/adwords_api/v201101/campaign_ad_extension_service_registry.rb +5 -3
  235. data/lib/adwords_api/v201101/campaign_criterion_service.rb +5 -5
  236. data/lib/adwords_api/v201101/campaign_criterion_service_registry.rb +5 -3
  237. data/lib/adwords_api/v201101/campaign_service.rb +5 -5
  238. data/lib/adwords_api/v201101/campaign_service_registry.rb +5 -3
  239. data/lib/adwords_api/v201101/campaign_target_service.rb +5 -5
  240. data/lib/adwords_api/v201101/campaign_target_service_registry.rb +5 -3
  241. data/lib/adwords_api/v201101/conversion_tracker_service.rb +5 -5
  242. data/lib/adwords_api/v201101/conversion_tracker_service_registry.rb +5 -3
  243. data/lib/adwords_api/v201101/customer_sync_service.rb +3 -3
  244. data/lib/adwords_api/v201101/customer_sync_service_registry.rb +5 -3
  245. data/lib/adwords_api/v201101/data_service.rb +5 -5
  246. data/lib/adwords_api/v201101/data_service_registry.rb +5 -3
  247. data/lib/adwords_api/v201101/experiment_service.rb +5 -5
  248. data/lib/adwords_api/v201101/experiment_service_registry.rb +5 -3
  249. data/lib/adwords_api/v201101/geo_location_service.rb +3 -3
  250. data/lib/adwords_api/v201101/geo_location_service_registry.rb +5 -3
  251. data/lib/adwords_api/v201101/info_service.rb +3 -3
  252. data/lib/adwords_api/v201101/info_service_registry.rb +5 -3
  253. data/lib/adwords_api/v201101/media_service.rb +5 -5
  254. data/lib/adwords_api/v201101/media_service_registry.rb +5 -3
  255. data/lib/adwords_api/v201101/report_definition_service.rb +7 -15
  256. data/lib/adwords_api/v201101/report_definition_service_registry.rb +5 -3
  257. data/lib/adwords_api/v201101/serviced_account_service.rb +3 -3
  258. data/lib/adwords_api/v201101/serviced_account_service_registry.rb +5 -3
  259. data/lib/adwords_api/v201101/targeting_idea_service.rb +5 -5
  260. data/lib/adwords_api/v201101/targeting_idea_service_registry.rb +5 -3
  261. data/lib/adwords_api/v201101/traffic_estimator_service.rb +3 -3
  262. data/lib/adwords_api/v201101/traffic_estimator_service_registry.rb +5 -3
  263. data/lib/adwords_api/v201101/user_list_service.rb +5 -5
  264. data/lib/adwords_api/v201101/user_list_service_registry.rb +5 -3
  265. data/lib/adwords_api/v201109/ad_extension_override_service.rb +36 -0
  266. data/lib/adwords_api/v201109/ad_extension_override_service_registry.rb +44 -0
  267. data/lib/adwords_api/v201109/ad_group_ad_service.rb +36 -0
  268. data/lib/adwords_api/v201109/ad_group_ad_service_registry.rb +44 -0
  269. data/lib/adwords_api/v201109/ad_group_criterion_service.rb +36 -0
  270. data/lib/adwords_api/v201109/ad_group_criterion_service_registry.rb +44 -0
  271. data/lib/adwords_api/v201109/ad_group_service.rb +36 -0
  272. data/lib/adwords_api/v201109/ad_group_service_registry.rb +44 -0
  273. data/lib/adwords_api/v201109/ad_param_service.rb +36 -0
  274. data/lib/adwords_api/v201109/ad_param_service_registry.rb +44 -0
  275. data/lib/adwords_api/v201109/alert_service.rb +32 -0
  276. data/lib/adwords_api/v201109/alert_service_registry.rb +44 -0
  277. data/lib/adwords_api/v201109/bulk_mutate_job_service.rb +36 -0
  278. data/lib/adwords_api/v201109/bulk_mutate_job_service_registry.rb +44 -0
  279. data/lib/adwords_api/v201109/bulk_opportunity_service.rb +32 -0
  280. data/lib/adwords_api/v201109/bulk_opportunity_service_registry.rb +44 -0
  281. data/lib/adwords_api/v201109/campaign_ad_extension_service.rb +36 -0
  282. data/lib/adwords_api/v201109/campaign_ad_extension_service_registry.rb +44 -0
  283. data/lib/adwords_api/v201109/campaign_criterion_service.rb +36 -0
  284. data/lib/adwords_api/v201109/campaign_criterion_service_registry.rb +44 -0
  285. data/lib/adwords_api/v201109/campaign_service.rb +36 -0
  286. data/lib/adwords_api/v201109/campaign_service_registry.rb +44 -0
  287. data/lib/adwords_api/v201109/campaign_target_service.rb +36 -0
  288. data/lib/adwords_api/v201109/campaign_target_service_registry.rb +44 -0
  289. data/lib/adwords_api/v201109/constant_data_service.rb +36 -0
  290. data/lib/adwords_api/v201109/constant_data_service_registry.rb +44 -0
  291. data/lib/adwords_api/v201109/conversion_tracker_service.rb +36 -0
  292. data/lib/adwords_api/v201109/conversion_tracker_service_registry.rb +44 -0
  293. data/lib/adwords_api/v201109/customer_sync_service.rb +32 -0
  294. data/lib/adwords_api/v201109/customer_sync_service_registry.rb +45 -0
  295. data/lib/adwords_api/v201109/data_service.rb +36 -0
  296. data/lib/adwords_api/v201109/data_service_registry.rb +44 -0
  297. data/lib/adwords_api/v201109/experiment_service.rb +36 -0
  298. data/lib/adwords_api/v201109/experiment_service_registry.rb +44 -0
  299. data/lib/adwords_api/v201109/geo_location_service.rb +32 -0
  300. data/lib/adwords_api/v201109/geo_location_service_registry.rb +44 -0
  301. data/lib/adwords_api/v201109/info_service.rb +32 -0
  302. data/lib/adwords_api/v201109/info_service_registry.rb +44 -0
  303. data/lib/adwords_api/v201109/location_criterion_service.rb +32 -0
  304. data/lib/adwords_api/v201109/location_criterion_service_registry.rb +44 -0
  305. data/lib/adwords_api/v201109/media_service.rb +36 -0
  306. data/lib/adwords_api/v201109/media_service_registry.rb +44 -0
  307. data/lib/adwords_api/v201109/mutate_job_service.rb +40 -0
  308. data/lib/adwords_api/v201109/mutate_job_service_registry.rb +44 -0
  309. data/lib/adwords_api/v201109/report_definition_service.rb +45 -0
  310. data/lib/adwords_api/v201109/report_definition_service_registry.rb +44 -0
  311. data/lib/adwords_api/v201109/serviced_account_service.rb +32 -0
  312. data/lib/adwords_api/v201109/serviced_account_service_registry.rb +44 -0
  313. data/lib/adwords_api/v201109/targeting_idea_service.rb +36 -0
  314. data/lib/adwords_api/v201109/targeting_idea_service_registry.rb +44 -0
  315. data/lib/adwords_api/v201109/traffic_estimator_service.rb +32 -0
  316. data/lib/adwords_api/v201109/traffic_estimator_service_registry.rb +44 -0
  317. data/lib/adwords_api/v201109/user_list_service.rb +36 -0
  318. data/lib/adwords_api/v201109/user_list_service_registry.rb +44 -0
  319. data/test/bugs/test_issue_00000031.rb +78 -0
  320. metadata +467 -342
  321. data/examples/v201101/download_mcc_report.rb +0 -113
  322. data/examples/v201101/download_mcc_report_as_file.rb +0 -114
  323. data/lib/adwords_api/v13/traffic_estimator_service.rb +0 -44
  324. data/lib/adwords_api/v13/traffic_estimator_service_registry.rb +0 -39
data/lib/adwords_api.rb CHANGED
@@ -20,18 +20,18 @@
20
20
  #
21
21
  # Contains the main classes for the client library.
22
22
 
23
- gem 'google-ads-common', '~>0.5.0'
24
-
25
- require 'savon'
23
+ gem 'google-ads-common', '~>0.5.2'
26
24
 
27
25
  require 'ads_common/api'
28
26
  require 'ads_common/auth/oauth_handler'
27
+ require 'ads_common/savon_service'
29
28
  require 'ads_common/savon_headers/oauth_header_handler'
30
29
  require 'ads_common/savon_headers/simple_header_handler'
31
30
  require 'adwords_api/api_config'
32
31
  require 'adwords_api/client_login_header_handler'
33
32
  require 'adwords_api/credential_handler'
34
33
  require 'adwords_api/errors'
34
+ require 'adwords_api/report_utils'
35
35
  require 'adwords_api/v13_login_handler'
36
36
 
37
37
  # Main namespace for all the client library's modules and classes.
@@ -56,10 +56,7 @@ module AdwordsApi
56
56
  # Sets the logger to use.
57
57
  def logger=(logger)
58
58
  super(logger)
59
- Savon.configure do |config|
60
- config.log_level = :debug
61
- config.logger = logger
62
- end
59
+ AdsCommon::SavonService.logger = logger
63
60
  end
64
61
 
65
62
  # Retrieve single NestedHeaderHandler for v20xx and one SingleHeaderHandler
@@ -76,8 +73,7 @@ module AdwordsApi
76
73
  # - a list of SOAP header handlers; one per provided header
77
74
  #
78
75
  def soap_header_handlers(auth_handler, header_list, version, namespace)
79
- auth_method = @config.read('authentication.method',
80
- 'ClientLogin').to_s.upcase.to_sym
76
+ auth_method = @config.read('authentication.method', :CLIENTLOGIN)
81
77
 
82
78
  handlers = []
83
79
 
@@ -113,8 +109,7 @@ module AdwordsApi
113
109
  # support is available.
114
110
  def client_login_handler()
115
111
  if @client_login_handler.nil?
116
- auth_method_str = @config.read('authentication.method', 'ClientLogin')
117
- auth_method = auth_method_str.to_s.upcase.to_sym
112
+ auth_method = @config.read('authentication.method', :CLIENTLOGIN)
118
113
  environment = @config.read('service.environment')
119
114
  if auth_method == :CLIENTLOGIN
120
115
  # We use client login, so we can reuse general AuthHandler.
@@ -138,20 +133,14 @@ module AdwordsApi
138
133
  # - accepts a block, which it will execute as an MCC-level operation
139
134
  #
140
135
  # Returns:
141
- # - Boolean indicating whether MCC-level operations are currently enabled or
142
- # disabled
136
+ # - block execution result, if block given
137
+ # - boolean indicating whether MCC-level operations are currently
138
+ # enabled or disabled, if no block provided
143
139
  #
144
- def use_mcc
145
- if block_given?
146
- previous = @credential_handler.use_mcc
147
- begin
148
- @credential_handler.use_mcc = true
149
- yield
150
- ensure
151
- @credential_handler.use_mcc = previous
152
- end
153
- end
154
- return @credential_handler.use_mcc
140
+ def use_mcc(&block)
141
+ return (block_given?) ?
142
+ run_with_temporary_flag(:@use_mcc, true, block) :
143
+ @credential_handler.use_mcc
155
144
  end
156
145
 
157
146
  # Helper method to provide a simple way of doing an MCC-level operation
@@ -173,20 +162,14 @@ module AdwordsApi
173
162
  # - accepts a block, which it will execute as a validate-only operation
174
163
  #
175
164
  # Returns:
176
- # - Boolean indicating whether validate-only operations are currently
177
- # enabled or disabled
165
+ # - block execution result, if block given
166
+ # - boolean indicating whether validate-only operations are currently
167
+ # enabled or disabled, if no block provided
178
168
  #
179
- def validate_only
180
- if block_given?
181
- previous = @credential_handler.validate_only
182
- begin
183
- @credential_handler.validate_only = true
184
- yield
185
- ensure
186
- @credential_handler.validate_only = previous
187
- end
188
- end
189
- return @credential_handler.validate_only
169
+ def validate_only(&block)
170
+ return (block_given?) ?
171
+ run_with_temporary_flag(:@validate_only, true, block) :
172
+ @credential_handler.validate_only
190
173
  end
191
174
 
192
175
  # Helper method to provide a simple way of performing validate-only
@@ -208,20 +191,14 @@ module AdwordsApi
208
191
  # - accepts a block, which it will execute as a partial failure operation
209
192
  #
210
193
  # Returns:
211
- # - Boolean indicating whether partial failure operations are currently
212
- # enabled or disabled
194
+ # - block execution result, if block given
195
+ # - boolean indicating whether partial failure operations are currently
196
+ # enabled or disabled, if no block provided
213
197
  #
214
- def partial_failure
215
- if block_given?
216
- previous = @credential_handler.partial_failure
217
- begin
218
- @credential_handler.partial_failure = true
219
- yield
220
- ensure
221
- @credential_handler.partial_failure = previous
222
- end
223
- end
224
- return @credential_handler.partial_failure
198
+ def partial_failure(&block)
199
+ return (block_given?) ?
200
+ run_with_temporary_flag(:partial_failure, true, block) :
201
+ @credential_handler.partial_failure
225
202
  end
226
203
 
227
204
  # Helper method to provide a simple way of performing requests with support
@@ -234,6 +211,21 @@ module AdwordsApi
234
211
  @credential_handler.partial_failure = value
235
212
  end
236
213
 
214
+ # Returns an instance of ReportUtils object with all utilities relevant to
215
+ # the reporting.
216
+ #
217
+ # Args:
218
+ # - version: version of the API to use (optional).
219
+ #
220
+ def report_utils(version = nil)
221
+ version = api_config.default_version if version.nil?
222
+ # Check if version exists.
223
+ if !api_config.versions.include?(version)
224
+ raise AdsCommon::Errors::Error, "Unknown version '%s'" % version
225
+ end
226
+ return AdwordsApi::ReportUtils.new(self, version)
227
+ end
228
+
237
229
  private
238
230
 
239
231
  # Overrides AdsCommon::Api.get_auth_handler to allow version-specific
@@ -259,5 +251,17 @@ module AdwordsApi
259
251
  return (version == :v13) ?
260
252
  AdwordsApi::V13LoginHandler.new : super(environment)
261
253
  end
254
+
255
+ # Executes block with a temporary flag set to a given value. Returns block
256
+ # result.
257
+ def run_with_temporary_flag(flag_name, flag_value, block)
258
+ previous = @credential_handler.instance_variable_get(flag_name)
259
+ @credential_handler.instance_variable_set(flag_name, flag_value)
260
+ begin
261
+ return block.call
262
+ ensure
263
+ @credential_handler.instance_variable_set(flag_name, previous)
264
+ end
265
+ end
262
266
  end
263
267
  end
@@ -35,19 +35,19 @@ module AdwordsApi
35
35
  end
36
36
 
37
37
  # Set defaults
38
- DEFAULT_VERSION = :v201101
38
+ DEFAULT_VERSION = :v201109
39
39
  DEFAULT_ENVIRONMENT = :PRODUCTION
40
- LATEST_VERSION = :v201101
40
+ LATEST_VERSION = :v201109
41
41
 
42
42
  # Set other constants
43
43
  API_NAME = 'AdwordsApi'
44
44
  API_PATH = 'adwords_api'
45
- CLIENT_LIB_VERSION = '0.4.0'
45
+ CLIENT_LIB_VERSION = '0.4.1'
46
46
  DEFAULT_CONFIG_FILENAME = 'adwords_api.yml'
47
47
 
48
48
  # Configure the services available to each version
49
49
  @@service_config = {
50
- :v13 => [:AccountService, :ReportService, :TrafficEstimatorService],
50
+ :v13 => [:AccountService, :ReportService],
51
51
  :v200909 => [:AdExtensionOverrideService, :AdGroupAdService,
52
52
  :AdGroupCriterionService, :AdGroupService, :AdParamService,
53
53
  :BulkMutateJobService, :CampaignAdExtensionService,
@@ -81,7 +81,19 @@ module AdwordsApi
81
81
  :GeoLocationService, :InfoService, :MediaService,
82
82
  :ReportDefinitionService, :ServicedAccountService,
83
83
  :TargetingIdeaService, :TrafficEstimatorService,
84
- :UserListService]
84
+ :UserListService],
85
+ :v201109 => [:AdExtensionOverrideService, :AdGroupAdService,
86
+ :AdGroupCriterionService, :AdGroupService, :AdParamService,
87
+ :AlertService, :BulkMutateJobService,
88
+ :BulkOpportunityService, :CampaignAdExtensionService,
89
+ :CampaignCriterionService, :CampaignService,
90
+ :CampaignTargetService, :ConversionTrackerService,
91
+ :CustomerSyncService, :DataService, :ExperimentService,
92
+ :GeoLocationService, :InfoService, :MediaService,
93
+ :ReportDefinitionService, :ServicedAccountService,
94
+ :TargetingIdeaService, :TrafficEstimatorService,
95
+ :UserListService, :ConstantDataService,
96
+ :LocationCriterionService, :MutateJobService]
85
97
  }
86
98
 
87
99
  # Configure the different environments, with the base URL for each one
@@ -92,7 +104,8 @@ module AdwordsApi
92
104
  :v200909 => 'https://adwords.google.com/api/adwords/',
93
105
  :v201003 => 'https://adwords.google.com/api/adwords/',
94
106
  :v201008 => 'https://adwords.google.com/api/adwords/',
95
- :v201101 => 'https://adwords.google.com/api/adwords/'
107
+ :v201101 => 'https://adwords.google.com/api/adwords/',
108
+ :v201109 => 'https://adwords.google.com/api/adwords/'
96
109
  },
97
110
  :SANDBOX => {
98
111
  :oauth_scope => 'https://adwords-sandbox.google.com/api/adwords/',
@@ -100,7 +113,8 @@ module AdwordsApi
100
113
  :v200909 => 'https://adwords-sandbox.google.com/api/adwords/',
101
114
  :v201003 => 'https://adwords-sandbox.google.com/api/adwords/',
102
115
  :v201008 => 'https://adwords-sandbox.google.com/api/adwords/',
103
- :v201101 => 'https://adwords-sandbox.google.com/api/adwords/'
116
+ :v201101 => 'https://adwords-sandbox.google.com/api/adwords/',
117
+ :v201109 => 'https://adwords-sandbox.google.com/api/adwords/'
104
118
  }
105
119
  }
106
120
 
@@ -110,7 +124,6 @@ module AdwordsApi
110
124
  # v13
111
125
  [:v13, :AccountService] => '',
112
126
  [:v13, :ReportService] => '',
113
- [:v13, :TrafficEstimatorService] => '',
114
127
  # v200909
115
128
  [:v200909, :AdExtensionOverrideService] => 'cm/',
116
129
  [:v200909, :AdGroupAdService] => 'cm/',
@@ -189,7 +202,35 @@ module AdwordsApi
189
202
  [:v201101, :ServicedAccountService] => 'mcm/',
190
203
  [:v201101, :TargetingIdeaService] => 'o/',
191
204
  [:v201101, :TrafficEstimatorService] => 'o/',
192
- [:v201101, :UserListService] => 'cm/'
205
+ [:v201101, :UserListService] => 'cm/',
206
+ # v201109
207
+ [:v201109, :AdExtensionOverrideService] => 'cm/',
208
+ [:v201109, :AdGroupAdService] => 'cm/',
209
+ [:v201109, :AdGroupCriterionService] => 'cm/',
210
+ [:v201109, :AdGroupService] => 'cm/',
211
+ [:v201109, :AdParamService] => 'cm/',
212
+ [:v201109, :AlertService] => 'mcm/',
213
+ [:v201109, :BulkMutateJobService] => 'job/',
214
+ [:v201109, :BulkOpportunityService] => 'o/',
215
+ [:v201109, :CampaignAdExtensionService] => 'cm/',
216
+ [:v201109, :CampaignCriterionService] => 'cm/',
217
+ [:v201109, :CampaignService] => 'cm/',
218
+ [:v201109, :CampaignTargetService] => 'cm/',
219
+ [:v201109, :ConversionTrackerService] => 'cm/',
220
+ [:v201109, :CustomerSyncService] => 'ch/',
221
+ [:v201109, :DataService] => 'cm/',
222
+ [:v201109, :ExperimentService] => 'cm/',
223
+ [:v201109, :GeoLocationService] => 'cm/',
224
+ [:v201109, :InfoService] => 'info/',
225
+ [:v201109, :MediaService] => 'cm/',
226
+ [:v201109, :ReportDefinitionService] => 'cm/',
227
+ [:v201109, :ServicedAccountService] => 'mcm/',
228
+ [:v201109, :TargetingIdeaService] => 'o/',
229
+ [:v201109, :TrafficEstimatorService] => 'o/',
230
+ [:v201109, :UserListService] => 'cm/',
231
+ [:v201109, :ConstantDataService] => 'cm/',
232
+ [:v201109, :LocationCriterionService] => 'cm/',
233
+ [:v201109, :MutateJobService] => 'cm/'
193
234
  }
194
235
 
195
236
  # Configure the auth servers to use for each environment
@@ -278,17 +319,32 @@ module AdwordsApi
278
319
  #
279
320
  # Args:
280
321
  # - environment: the service environment to be used (as a string)
281
- # - version: the API version (as an integer)
322
+ # - version: the API version (as a symbol)
282
323
  #
283
324
  # Returns:
284
- # The endpoint URL (as a string)
325
+ # - The endpoint URL (as a string)
285
326
  #
286
327
  def self.report_download_url(environment, version)
328
+ base = get_wsdl_base(environment, version)
329
+ if base and service_config[version].include?(:ReportDefinitionService)
330
+ base += 'reportdownload'
331
+ end
332
+ return base
333
+ end
334
+
335
+ # Get the download URL for Ad Hoc reports.
336
+ #
337
+ # Args:
338
+ # - environment: the service environment to be used (as a string)
339
+ # - version: the API version (as a symbol)
340
+ #
341
+ # Returns:
342
+ # - The endpoint URL (as a string)
343
+ #
344
+ def self.adhoc_report_download_url(environment, version)
287
345
  base = get_wsdl_base(environment, version)
288
346
  if base
289
- path = service_config[version].include?(:ReportDefinitionService) ?
290
- 'reportdownload' : nil
291
- base += path.to_s
347
+ base += 'reportdownload/%s' % version.to_s
292
348
  end
293
349
  return base
294
350
  end
@@ -42,9 +42,8 @@ module AdwordsApi
42
42
  # Create the list of credentials to be used by the auth handler for header
43
43
  # generation.
44
44
  def credentials(version = nil)
45
- validate_headers_for_server
46
- method = @credentials[:method].to_s.upcase.to_sym
47
- result = case method
45
+ validate_headers_for_server(version)
46
+ result = case @credentials[:method]
48
47
  when :CLIENTLOGIN
49
48
  {:email => @credentials[:email],
50
49
  :password => @credentials[:password]}
@@ -55,19 +54,20 @@ module AdwordsApi
55
54
  :oauth_token => @credentials[:oauth_token],
56
55
  :oauth_token_secret => @credentials[:oauth_token_secret],
57
56
  :oauth_callback => @credentials[:oauth_callback],
58
- :oauth_method => @credentials[:oauth_method]}
57
+ :oauth_method => @credentials[:oauth_method],
58
+ :oauth_request_token => @credentials[:oauth_request_token]}
59
59
  end
60
- client_lib = 'Ruby-AwApi-%s|' % AdwordsApi::ApiConfig::CLIENT_LIB_VERSION
60
+ client_lib = 'AwApi-Ruby-%s|' % AdwordsApi::ApiConfig::CLIENT_LIB_VERSION
61
61
  user_agent = @credentials[:user_agent] || $0
62
62
  user_agent = client_lib + user_agent
63
63
  user_agent_symbol = (version == :v13) ? :useragent : :userAgent
64
64
  result[user_agent_symbol] = user_agent
65
65
  result[:developerToken] = @credentials[:developer_token]
66
66
  unless @use_mcc
67
- if @credentials[:client_email]
68
- result[:clientEmail] = @credentials[:client_email]
69
- elsif @credentials[:client_customer_id]
67
+ if @credentials[:client_customer_id]
70
68
  result[:clientCustomerId] = @credentials[:client_customer_id]
69
+ elsif @credentials[:client_email] and version != :v201109
70
+ result[:clientEmail] = @credentials[:client_email]
71
71
  end
72
72
  end
73
73
  if version != :v13
@@ -82,15 +82,33 @@ module AdwordsApi
82
82
  # Validates that the right credentials are being used for the chosen
83
83
  # environment.
84
84
  #
85
+ # Args:
86
+ # - version: API version to validate for
87
+ #
85
88
  # Raises:
86
- # Adwordsapi::Error::EnvironmentMismatchError if sandbox credentials are
89
+ # - AdsCommon::Error::EnvironmentMismatchError if sandbox credentials are
87
90
  # being used for production or vice-versa.
91
+ # - AdwordsApi::Errors:BadCredentialsError if supplied credentials are not
92
+ # valid.
88
93
  #
89
- def validate_headers_for_server
90
- method = @credentials[:method].to_s.upcase.to_sym
94
+ def validate_headers_for_server(version)
91
95
  token = @credentials[:developer_token]
92
96
  client_email = @credentials[:client_email]
93
- (sandbox_token, sandbox_client) = case method
97
+
98
+ if client_email and version == :v201109
99
+ raise AdwordsApi::Errors::BadCredentialsError, 'Deprecated header ' +
100
+ 'clientEmail is no longer supported, please use clientCustomerId'
101
+ end
102
+
103
+ client_customer_id = @credentials[:client_customer_id]
104
+ if client_customer_id and
105
+ !(client_customer_id.is_a?(Integer) or
106
+ (client_customer_id =~ /\d+-\d+-\d+/))
107
+ raise AdwordsApi::Errors::BadCredentialsError,
108
+ 'Invalid client customer ID: %s' % client_customer_id.to_s
109
+ end
110
+
111
+ (sandbox_token, sandbox_client) = case @credentials[:method]
94
112
  when :CLIENTLOGIN
95
113
  email = @credentials[:email]
96
114
  [(token =~ /#{Regexp.escape(email)}\+\+[a-zA-Z]{3}/),
@@ -113,7 +131,7 @@ module AdwordsApi
113
131
  when :SANDBOX
114
132
  # Check if either the token or client email do not follow the
115
133
  # correct format. Client email may not exist, though.
116
- if (!sandbox_token or (!client_email.empty? and !sandbox_client))
134
+ if (!sandbox_token or (client_email and !sandbox_client))
117
135
  raise AdsCommon::Errors::EnvironmentMismatchError,
118
136
  'Attempting to connect to the sandbox with malformatted ' +
119
137
  'credentials. Please check ' +
@@ -121,6 +139,7 @@ module AdwordsApi
121
139
  'adwords_api_sandbox.html#requestheaders for details.'
122
140
  end
123
141
  end
142
+ return nil
124
143
  end
125
144
  end
126
145
  end
@@ -55,5 +55,17 @@ module AdwordsApi
55
55
  return @array_fields.include?(field.to_s)
56
56
  end
57
57
  end
58
+
59
+ # Error for invalid credentials sush as malformed ID.
60
+ class BadCredentialsError < AdsCommon::Errors::ApiException
61
+ end
62
+
63
+ # Error for malformed report definition.
64
+ class InvalidReportDefinitionError < AdsCommon::Errors::ApiException
65
+ end
66
+
67
+ # Error for server-side report error.
68
+ class ReportError < AdsCommon::Errors::ApiException
69
+ end
58
70
  end
59
71
  end
@@ -37,8 +37,9 @@ module AdwordsApi
37
37
  [:v201008, :ReportDefinitionService] => [:download_report,
38
38
  :download_report_as_file],
39
39
  [:v201101, :ReportDefinitionService] => [:download_report,
40
- :download_report_as_file, :download_mcc_report,
41
- :download_mcc_report_as_file]
40
+ :download_report_as_file],
41
+ [:v201109, :ReportDefinitionService] => [:download_report,
42
+ :download_report_as_file]
42
43
  }
43
44
 
44
45
  # Defines the parameter list for every extension method.
@@ -46,10 +47,7 @@ module AdwordsApi
46
47
  :download_xml_report => [:job_id],
47
48
  :download_csv_report => [:job_id],
48
49
  :download_report => [:report_definition_id],
49
- :download_report_as_file => [:report_definition_id, :path],
50
- :download_mcc_report => [:report_definition_id, :query_token],
51
- :download_mcc_report_as_file =>
52
- [:report_definition_id, :query_token, :path]
50
+ :download_report_as_file => [:report_definition_id, :path]
53
51
  }
54
52
 
55
53
  # Return list of all extension methods, indexed by version and service.
@@ -209,78 +207,8 @@ module AdwordsApi
209
207
  return report_response.body
210
208
  end
211
209
 
212
- # <i>Extension method</i> -- Download and return a MCC report.
213
- #
214
- # *Warning*: this method is blocking for the calling thread.
215
- #
216
- # Args:
217
- # - wrapper: the service wrapper object for any API methods that need to be
218
- # called
219
- # - report_definition_id: the id for the report definition
220
- # - query_token: id from previous calls to the method
221
- #
222
- # Returns:
223
- # A hash with HTTP code and report service response
224
- #
225
- def self.download_mcc_report(wrapper, args)
226
- (report_definition_id, query_token) = args
227
- do_download_mcc_report(wrapper, report_definition_id, query_token, nil)
228
- end
229
-
230
- # <i>Extension method</i> -- Download and save a MCC report to file.
231
- #
232
- # *Warning*: this method is blocking for the calling thread.
233
- #
234
- # Args:
235
- # - wrapper: the service wrapper object for any API methods that need to be
236
- # called
237
- # - report_definition_id: the id for the report definition
238
- # - query_token: id from previous calls to the method
239
- # - path: filename to save downloaded report to
240
- #
241
- # Returns:
242
- # A hash with HTTP code and report service response
243
- #
244
- def self.download_mcc_report_as_file(wrapper, args)
245
- (report_definition_id, query_token, path) = args
246
- do_download_mcc_report(wrapper, report_definition_id, query_token, path)
247
- end
248
-
249
210
  private
250
211
 
251
- # Polls the service once and downloads report into a file or to a hash.
252
- def self.do_download_mcc_report(wrapper, report_definition_id, query_token,
253
- path = nil)
254
- query_token = 'new' if query_token.nil? or query_token.empty?
255
- url = get_report_url(wrapper,
256
- "?__rd=%s&qt=%s" % [report_definition_id, query_token])
257
- report_response = get_report_response(wrapper, url)
258
- check_old_error(report_response.body)
259
- mcc_response = report_response_to_hash(report_response)
260
- result = case report_response.code
261
- when 200, 500
262
- mcc_response
263
- when 301
264
- return_or_save_mcc_report_data(wrapper, mcc_response, path)
265
- else
266
- raise AdwordsApi::Errors::ApiException,
267
- "Unknown HTTP error code %d message: %s" %
268
- [report_response.code, report_response.body]
269
- end
270
- return result
271
- end
272
-
273
- # Downloads a report body into a hash or a file.
274
- def self.return_or_save_mcc_report_data(wrapper, mcc_response, path = nil)
275
- report_data = get_report_response(wrapper, mcc_response[:location]).body
276
- if path.nil?
277
- mcc_response[:report_data] = report_data
278
- else
279
- save_to_file(report_data, path)
280
- end
281
- return mcc_response
282
- end
283
-
284
212
  # Saves raw data to a file.
285
213
  def self.save_to_file(data, path)
286
214
  open(path, 'wb') { |file| file.puts(data) } if path
@@ -307,55 +235,17 @@ module AdwordsApi
307
235
  auth_handler = wrapper.api.client_login_handler
308
236
  headers['Authorization'] = "GoogleLogin auth=%s" %
309
237
  auth_handler.headers(credentials)[:authToken]
310
- if credentials[:clientEmail]
311
- headers['clientEmail'] = credentials[:clientEmail]
312
- elsif credentials[:clientCustomerId]
238
+ if credentials[:clientCustomerId]
313
239
  headers['clientCustomerId'] = credentials[:clientCustomerId]
240
+ elsif credentials[:clientEmail]
241
+ headers['clientEmail'] = credentials[:clientEmail]
314
242
  elsif credentials[:email]
315
243
  headers['clientEmail'] = credentials[:email]
316
244
  end
317
245
  return headers
318
246
  end
319
247
 
320
- # Converts report response data into a convenient hash.
321
- def self.report_response_to_hash(response)
322
- result = {}
323
- result[:code] = response.code
324
- xml = REXML::Document.new(response.body)
325
- result[:body] = xml_to_hash(xml.root) if xml and xml.root
326
- if !response.headers.nil? and !response.headers['Location'].nil?
327
- result[:location] = response.headers['Location']
328
- end
329
- # Special case for accounts list in failures.
330
- if result[:body] and result[:body][:failures]
331
- result[:body][:failures][:account] =
332
- arrayize(result[:body][:failures][:account])
333
- end
334
- return result
335
- end
336
-
337
- # Converts xml into a convenient hash.
338
- def self.xml_to_hash(xml)
339
- result = {}
340
- xml.elements.each do |item|
341
- value = (item.has_elements?) ? xml_to_hash(item) : item.get_text()
342
- if result[item.name].nil?
343
- result[item.name] = value
344
- else
345
- result[item.name] = arrayize(result[item.name])
346
- result[item.name] << value
347
- end
348
- end
349
- return result
350
- end
351
-
352
- # Makes sure object is an array.
353
- def self.arrayize(object)
354
- return [] if object.nil?
355
- return object.is_a?(Array) ? object : [object]
356
- end
357
-
358
- # Checks for old-style pre-MCC reporting error.
248
+ # Checks for old-style v13 reporting error.
359
249
  def self.check_old_error(response_text)
360
250
  error_message_regex = '^!!!(-?\d+)\|\|\|(-?\d+)\|\|\|(.*)\?\?\?'
361
251
  matches = response_text.match(error_message_regex)