google-adwords-api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (334) hide show
  1. data/COPYING +201 -0
  2. data/ChangeLog +14 -0
  3. data/README +44 -14
  4. data/Rakefile +1 -1
  5. data/adwords_api.yml +0 -1
  6. data/examples/v200909/add_ad_group_criteria.rb +1 -1
  7. data/examples/v200909/perform_bulk_mutate_job.rb +1 -1
  8. data/examples/v201003/get_related_placements.rb +6 -9
  9. data/examples/v201003/perform_bulk_mutate_job.rb +1 -1
  10. data/examples/v201008/get_bulk_mutate_job.rb +1 -1
  11. data/examples/v201008/perform_bulk_mutate_job.rb +1 -1
  12. data/examples/v201101/add_mcc_report_definition.rb +4 -8
  13. data/examples/v201101/download_mcc_report.rb +47 -23
  14. data/examples/v201101/download_mcc_report_as_file.rb +118 -0
  15. data/examples/v201101/get_bulk_mutate_job.rb +1 -1
  16. data/examples/v201101/get_keyword_opportunities.rb +0 -0
  17. data/examples/v201101/perform_bulk_mutate_job.rb +1 -1
  18. data/lib/adwords_api.rb +4 -8
  19. data/lib/adwords_api/api_config.rb +1 -1
  20. data/lib/adwords_api/auth/v13_login_handler.rb +3 -6
  21. data/lib/adwords_api/extensions.rb +156 -25
  22. data/lib/adwords_api/v13/AccountService.rb +0 -0
  23. data/lib/adwords_api/v13/AccountServiceDriver.rb +6 -6
  24. data/lib/adwords_api/v13/AccountServiceMappingRegistry.rb +0 -0
  25. data/lib/adwords_api/v13/AccountServiceWrapper.rb +2 -2
  26. data/lib/adwords_api/v13/ReportService.rb +0 -0
  27. data/lib/adwords_api/v13/ReportServiceDriver.rb +8 -8
  28. data/lib/adwords_api/v13/ReportServiceMappingRegistry.rb +0 -0
  29. data/lib/adwords_api/v13/ReportServiceWrapper.rb +2 -2
  30. data/lib/adwords_api/v13/TrafficEstimatorService.rb +0 -0
  31. data/lib/adwords_api/v13/TrafficEstimatorServiceDriver.rb +5 -5
  32. data/lib/adwords_api/v13/TrafficEstimatorServiceMappingRegistry.rb +0 -0
  33. data/lib/adwords_api/v13/TrafficEstimatorServiceWrapper.rb +2 -2
  34. data/lib/adwords_api/v200909/AdExtensionOverrideService.rb +0 -0
  35. data/lib/adwords_api/v200909/AdExtensionOverrideServiceDriver.rb +3 -3
  36. data/lib/adwords_api/v200909/AdExtensionOverrideServiceMappingRegistry.rb +0 -0
  37. data/lib/adwords_api/v200909/AdExtensionOverrideServiceWrapper.rb +2 -2
  38. data/lib/adwords_api/v200909/AdGroupAdService.rb +239 -239
  39. data/lib/adwords_api/v200909/AdGroupAdServiceDriver.rb +3 -3
  40. data/lib/adwords_api/v200909/AdGroupAdServiceMappingRegistry.rb +120 -120
  41. data/lib/adwords_api/v200909/AdGroupAdServiceWrapper.rb +2 -2
  42. data/lib/adwords_api/v200909/AdGroupCriterionService.rb +0 -0
  43. data/lib/adwords_api/v200909/AdGroupCriterionServiceDriver.rb +3 -3
  44. data/lib/adwords_api/v200909/AdGroupCriterionServiceMappingRegistry.rb +0 -0
  45. data/lib/adwords_api/v200909/AdGroupCriterionServiceWrapper.rb +2 -2
  46. data/lib/adwords_api/v200909/AdGroupService.rb +0 -0
  47. data/lib/adwords_api/v200909/AdGroupServiceDriver.rb +3 -3
  48. data/lib/adwords_api/v200909/AdGroupServiceMappingRegistry.rb +0 -0
  49. data/lib/adwords_api/v200909/AdGroupServiceWrapper.rb +2 -2
  50. data/lib/adwords_api/v200909/AdParamService.rb +0 -0
  51. data/lib/adwords_api/v200909/AdParamServiceDriver.rb +3 -3
  52. data/lib/adwords_api/v200909/AdParamServiceMappingRegistry.rb +0 -0
  53. data/lib/adwords_api/v200909/AdParamServiceWrapper.rb +2 -2
  54. data/lib/adwords_api/v200909/BulkMutateJobService.rb +0 -0
  55. data/lib/adwords_api/v200909/BulkMutateJobServiceDriver.rb +3 -3
  56. data/lib/adwords_api/v200909/BulkMutateJobServiceMappingRegistry.rb +0 -0
  57. data/lib/adwords_api/v200909/BulkMutateJobServiceWrapper.rb +2 -2
  58. data/lib/adwords_api/v200909/CampaignAdExtensionService.rb +0 -0
  59. data/lib/adwords_api/v200909/CampaignAdExtensionServiceDriver.rb +3 -3
  60. data/lib/adwords_api/v200909/CampaignAdExtensionServiceMappingRegistry.rb +0 -0
  61. data/lib/adwords_api/v200909/CampaignAdExtensionServiceWrapper.rb +2 -2
  62. data/lib/adwords_api/v200909/CampaignCriterionService.rb +0 -0
  63. data/lib/adwords_api/v200909/CampaignCriterionServiceDriver.rb +3 -3
  64. data/lib/adwords_api/v200909/CampaignCriterionServiceMappingRegistry.rb +0 -0
  65. data/lib/adwords_api/v200909/CampaignCriterionServiceWrapper.rb +2 -2
  66. data/lib/adwords_api/v200909/CampaignService.rb +0 -0
  67. data/lib/adwords_api/v200909/CampaignServiceDriver.rb +3 -3
  68. data/lib/adwords_api/v200909/CampaignServiceMappingRegistry.rb +0 -0
  69. data/lib/adwords_api/v200909/CampaignServiceWrapper.rb +2 -2
  70. data/lib/adwords_api/v200909/CampaignTargetService.rb +0 -0
  71. data/lib/adwords_api/v200909/CampaignTargetServiceDriver.rb +3 -3
  72. data/lib/adwords_api/v200909/CampaignTargetServiceMappingRegistry.rb +0 -0
  73. data/lib/adwords_api/v200909/CampaignTargetServiceWrapper.rb +2 -2
  74. data/lib/adwords_api/v200909/GeoLocationService.rb +0 -0
  75. data/lib/adwords_api/v200909/GeoLocationServiceDriver.rb +2 -2
  76. data/lib/adwords_api/v200909/GeoLocationServiceMappingRegistry.rb +0 -0
  77. data/lib/adwords_api/v200909/GeoLocationServiceWrapper.rb +2 -2
  78. data/lib/adwords_api/v200909/InfoService.rb +0 -0
  79. data/lib/adwords_api/v200909/InfoServiceDriver.rb +2 -2
  80. data/lib/adwords_api/v200909/InfoServiceMappingRegistry.rb +0 -0
  81. data/lib/adwords_api/v200909/InfoServiceWrapper.rb +2 -2
  82. data/lib/adwords_api/v200909/TargetingIdeaService.rb +0 -0
  83. data/lib/adwords_api/v200909/TargetingIdeaServiceDriver.rb +3 -3
  84. data/lib/adwords_api/v200909/TargetingIdeaServiceMappingRegistry.rb +0 -0
  85. data/lib/adwords_api/v200909/TargetingIdeaServiceWrapper.rb +2 -2
  86. data/lib/adwords_api/v201003/AdExtensionOverrideService.rb +0 -0
  87. data/lib/adwords_api/v201003/AdExtensionOverrideServiceDriver.rb +3 -3
  88. data/lib/adwords_api/v201003/AdExtensionOverrideServiceMappingRegistry.rb +0 -0
  89. data/lib/adwords_api/v201003/AdExtensionOverrideServiceWrapper.rb +2 -2
  90. data/lib/adwords_api/v201003/AdGroupAdService.rb +293 -293
  91. data/lib/adwords_api/v201003/AdGroupAdServiceDriver.rb +3 -3
  92. data/lib/adwords_api/v201003/AdGroupAdServiceMappingRegistry.rb +124 -124
  93. data/lib/adwords_api/v201003/AdGroupAdServiceWrapper.rb +2 -2
  94. data/lib/adwords_api/v201003/AdGroupCriterionService.rb +0 -0
  95. data/lib/adwords_api/v201003/AdGroupCriterionServiceDriver.rb +3 -3
  96. data/lib/adwords_api/v201003/AdGroupCriterionServiceMappingRegistry.rb +0 -0
  97. data/lib/adwords_api/v201003/AdGroupCriterionServiceWrapper.rb +2 -2
  98. data/lib/adwords_api/v201003/AdGroupService.rb +0 -0
  99. data/lib/adwords_api/v201003/AdGroupServiceDriver.rb +3 -3
  100. data/lib/adwords_api/v201003/AdGroupServiceMappingRegistry.rb +0 -0
  101. data/lib/adwords_api/v201003/AdGroupServiceWrapper.rb +2 -2
  102. data/lib/adwords_api/v201003/AdParamService.rb +0 -0
  103. data/lib/adwords_api/v201003/AdParamServiceDriver.rb +3 -3
  104. data/lib/adwords_api/v201003/AdParamServiceMappingRegistry.rb +0 -0
  105. data/lib/adwords_api/v201003/AdParamServiceWrapper.rb +2 -2
  106. data/lib/adwords_api/v201003/BidLandscapeService.rb +0 -0
  107. data/lib/adwords_api/v201003/BidLandscapeServiceDriver.rb +2 -2
  108. data/lib/adwords_api/v201003/BidLandscapeServiceMappingRegistry.rb +0 -0
  109. data/lib/adwords_api/v201003/BidLandscapeServiceWrapper.rb +2 -2
  110. data/lib/adwords_api/v201003/BulkMutateJobService.rb +0 -0
  111. data/lib/adwords_api/v201003/BulkMutateJobServiceDriver.rb +3 -3
  112. data/lib/adwords_api/v201003/BulkMutateJobServiceMappingRegistry.rb +0 -0
  113. data/lib/adwords_api/v201003/BulkMutateJobServiceWrapper.rb +2 -2
  114. data/lib/adwords_api/v201003/CampaignAdExtensionService.rb +0 -0
  115. data/lib/adwords_api/v201003/CampaignAdExtensionServiceDriver.rb +3 -3
  116. data/lib/adwords_api/v201003/CampaignAdExtensionServiceMappingRegistry.rb +0 -0
  117. data/lib/adwords_api/v201003/CampaignAdExtensionServiceWrapper.rb +2 -2
  118. data/lib/adwords_api/v201003/CampaignCriterionService.rb +0 -0
  119. data/lib/adwords_api/v201003/CampaignCriterionServiceDriver.rb +3 -3
  120. data/lib/adwords_api/v201003/CampaignCriterionServiceMappingRegistry.rb +0 -0
  121. data/lib/adwords_api/v201003/CampaignCriterionServiceWrapper.rb +2 -2
  122. data/lib/adwords_api/v201003/CampaignService.rb +0 -0
  123. data/lib/adwords_api/v201003/CampaignServiceDriver.rb +3 -3
  124. data/lib/adwords_api/v201003/CampaignServiceMappingRegistry.rb +0 -0
  125. data/lib/adwords_api/v201003/CampaignServiceWrapper.rb +2 -2
  126. data/lib/adwords_api/v201003/CampaignTargetService.rb +0 -0
  127. data/lib/adwords_api/v201003/CampaignTargetServiceDriver.rb +3 -3
  128. data/lib/adwords_api/v201003/CampaignTargetServiceMappingRegistry.rb +0 -0
  129. data/lib/adwords_api/v201003/CampaignTargetServiceWrapper.rb +2 -2
  130. data/lib/adwords_api/v201003/GeoLocationService.rb +0 -0
  131. data/lib/adwords_api/v201003/GeoLocationServiceDriver.rb +2 -2
  132. data/lib/adwords_api/v201003/GeoLocationServiceMappingRegistry.rb +0 -0
  133. data/lib/adwords_api/v201003/GeoLocationServiceWrapper.rb +2 -2
  134. data/lib/adwords_api/v201003/InfoService.rb +0 -0
  135. data/lib/adwords_api/v201003/InfoServiceDriver.rb +2 -2
  136. data/lib/adwords_api/v201003/InfoServiceMappingRegistry.rb +0 -0
  137. data/lib/adwords_api/v201003/InfoServiceWrapper.rb +2 -2
  138. data/lib/adwords_api/v201003/MediaService.rb +224 -224
  139. data/lib/adwords_api/v201003/MediaServiceDriver.rb +3 -3
  140. data/lib/adwords_api/v201003/MediaServiceMappingRegistry.rb +58 -58
  141. data/lib/adwords_api/v201003/MediaServiceWrapper.rb +2 -2
  142. data/lib/adwords_api/v201003/ReportDefinitionService.rb +0 -0
  143. data/lib/adwords_api/v201003/ReportDefinitionServiceDriver.rb +4 -4
  144. data/lib/adwords_api/v201003/ReportDefinitionServiceMappingRegistry.rb +0 -0
  145. data/lib/adwords_api/v201003/ReportDefinitionServiceWrapper.rb +2 -2
  146. data/lib/adwords_api/v201003/TargetingIdeaService.rb +0 -0
  147. data/lib/adwords_api/v201003/TargetingIdeaServiceDriver.rb +3 -3
  148. data/lib/adwords_api/v201003/TargetingIdeaServiceMappingRegistry.rb +0 -0
  149. data/lib/adwords_api/v201003/TargetingIdeaServiceWrapper.rb +2 -2
  150. data/lib/adwords_api/v201008/AdExtensionOverrideService.rb +0 -0
  151. data/lib/adwords_api/v201008/AdExtensionOverrideServiceDriver.rb +3 -3
  152. data/lib/adwords_api/v201008/AdExtensionOverrideServiceMappingRegistry.rb +0 -0
  153. data/lib/adwords_api/v201008/AdExtensionOverrideServiceWrapper.rb +2 -2
  154. data/lib/adwords_api/v201008/AdGroupAdService.rb +255 -255
  155. data/lib/adwords_api/v201008/AdGroupAdServiceDriver.rb +3 -3
  156. data/lib/adwords_api/v201008/AdGroupAdServiceMappingRegistry.rb +120 -120
  157. data/lib/adwords_api/v201008/AdGroupAdServiceWrapper.rb +2 -2
  158. data/lib/adwords_api/v201008/AdGroupCriterionService.rb +0 -0
  159. data/lib/adwords_api/v201008/AdGroupCriterionServiceDriver.rb +3 -3
  160. data/lib/adwords_api/v201008/AdGroupCriterionServiceMappingRegistry.rb +0 -0
  161. data/lib/adwords_api/v201008/AdGroupCriterionServiceWrapper.rb +2 -2
  162. data/lib/adwords_api/v201008/AdGroupService.rb +0 -0
  163. data/lib/adwords_api/v201008/AdGroupServiceDriver.rb +3 -3
  164. data/lib/adwords_api/v201008/AdGroupServiceMappingRegistry.rb +0 -0
  165. data/lib/adwords_api/v201008/AdGroupServiceWrapper.rb +2 -2
  166. data/lib/adwords_api/v201008/AdParamService.rb +0 -0
  167. data/lib/adwords_api/v201008/AdParamServiceDriver.rb +3 -3
  168. data/lib/adwords_api/v201008/AdParamServiceMappingRegistry.rb +0 -0
  169. data/lib/adwords_api/v201008/AdParamServiceWrapper.rb +2 -2
  170. data/lib/adwords_api/v201008/AlertService.rb +0 -0
  171. data/lib/adwords_api/v201008/AlertServiceDriver.rb +2 -2
  172. data/lib/adwords_api/v201008/AlertServiceMappingRegistry.rb +0 -0
  173. data/lib/adwords_api/v201008/AlertServiceWrapper.rb +2 -2
  174. data/lib/adwords_api/v201008/BidLandscapeService.rb +0 -0
  175. data/lib/adwords_api/v201008/BidLandscapeServiceDriver.rb +2 -2
  176. data/lib/adwords_api/v201008/BidLandscapeServiceMappingRegistry.rb +0 -0
  177. data/lib/adwords_api/v201008/BidLandscapeServiceWrapper.rb +2 -2
  178. data/lib/adwords_api/v201008/BulkMutateJobService.rb +0 -0
  179. data/lib/adwords_api/v201008/BulkMutateJobServiceDriver.rb +3 -3
  180. data/lib/adwords_api/v201008/BulkMutateJobServiceMappingRegistry.rb +0 -0
  181. data/lib/adwords_api/v201008/BulkMutateJobServiceWrapper.rb +2 -2
  182. data/lib/adwords_api/v201008/CampaignAdExtensionService.rb +0 -0
  183. data/lib/adwords_api/v201008/CampaignAdExtensionServiceDriver.rb +3 -3
  184. data/lib/adwords_api/v201008/CampaignAdExtensionServiceMappingRegistry.rb +0 -0
  185. data/lib/adwords_api/v201008/CampaignAdExtensionServiceWrapper.rb +2 -2
  186. data/lib/adwords_api/v201008/CampaignCriterionService.rb +0 -0
  187. data/lib/adwords_api/v201008/CampaignCriterionServiceDriver.rb +3 -3
  188. data/lib/adwords_api/v201008/CampaignCriterionServiceMappingRegistry.rb +0 -0
  189. data/lib/adwords_api/v201008/CampaignCriterionServiceWrapper.rb +2 -2
  190. data/lib/adwords_api/v201008/CampaignService.rb +0 -0
  191. data/lib/adwords_api/v201008/CampaignServiceDriver.rb +3 -3
  192. data/lib/adwords_api/v201008/CampaignServiceMappingRegistry.rb +0 -0
  193. data/lib/adwords_api/v201008/CampaignServiceWrapper.rb +2 -2
  194. data/lib/adwords_api/v201008/CampaignTargetService.rb +0 -0
  195. data/lib/adwords_api/v201008/CampaignTargetServiceDriver.rb +3 -3
  196. data/lib/adwords_api/v201008/CampaignTargetServiceMappingRegistry.rb +0 -0
  197. data/lib/adwords_api/v201008/CampaignTargetServiceWrapper.rb +2 -2
  198. data/lib/adwords_api/v201008/CustomerSyncService.rb +0 -0
  199. data/lib/adwords_api/v201008/CustomerSyncServiceDriver.rb +2 -2
  200. data/lib/adwords_api/v201008/CustomerSyncServiceMappingRegistry.rb +0 -0
  201. data/lib/adwords_api/v201008/CustomerSyncServiceWrapper.rb +2 -2
  202. data/lib/adwords_api/v201008/ExperimentService.rb +0 -0
  203. data/lib/adwords_api/v201008/ExperimentServiceDriver.rb +3 -3
  204. data/lib/adwords_api/v201008/ExperimentServiceMappingRegistry.rb +0 -0
  205. data/lib/adwords_api/v201008/ExperimentServiceWrapper.rb +2 -2
  206. data/lib/adwords_api/v201008/GeoLocationService.rb +0 -0
  207. data/lib/adwords_api/v201008/GeoLocationServiceDriver.rb +2 -2
  208. data/lib/adwords_api/v201008/GeoLocationServiceMappingRegistry.rb +0 -0
  209. data/lib/adwords_api/v201008/GeoLocationServiceWrapper.rb +2 -2
  210. data/lib/adwords_api/v201008/InfoService.rb +0 -0
  211. data/lib/adwords_api/v201008/InfoServiceDriver.rb +2 -2
  212. data/lib/adwords_api/v201008/InfoServiceMappingRegistry.rb +0 -0
  213. data/lib/adwords_api/v201008/InfoServiceWrapper.rb +2 -2
  214. data/lib/adwords_api/v201008/MediaService.rb +203 -203
  215. data/lib/adwords_api/v201008/MediaServiceDriver.rb +3 -3
  216. data/lib/adwords_api/v201008/MediaServiceMappingRegistry.rb +54 -54
  217. data/lib/adwords_api/v201008/MediaServiceWrapper.rb +2 -2
  218. data/lib/adwords_api/v201008/ReportDefinitionService.rb +0 -0
  219. data/lib/adwords_api/v201008/ReportDefinitionServiceDriver.rb +4 -4
  220. data/lib/adwords_api/v201008/ReportDefinitionServiceMappingRegistry.rb +0 -0
  221. data/lib/adwords_api/v201008/ReportDefinitionServiceWrapper.rb +2 -2
  222. data/lib/adwords_api/v201008/ServicedAccountService.rb +0 -0
  223. data/lib/adwords_api/v201008/ServicedAccountServiceDriver.rb +2 -2
  224. data/lib/adwords_api/v201008/ServicedAccountServiceMappingRegistry.rb +0 -0
  225. data/lib/adwords_api/v201008/ServicedAccountServiceWrapper.rb +2 -2
  226. data/lib/adwords_api/v201008/TargetingIdeaService.rb +0 -0
  227. data/lib/adwords_api/v201008/TargetingIdeaServiceDriver.rb +3 -3
  228. data/lib/adwords_api/v201008/TargetingIdeaServiceMappingRegistry.rb +0 -0
  229. data/lib/adwords_api/v201008/TargetingIdeaServiceWrapper.rb +2 -2
  230. data/lib/adwords_api/v201008/TrafficEstimatorService.rb +0 -0
  231. data/lib/adwords_api/v201008/TrafficEstimatorServiceDriver.rb +2 -2
  232. data/lib/adwords_api/v201008/TrafficEstimatorServiceMappingRegistry.rb +0 -0
  233. data/lib/adwords_api/v201008/TrafficEstimatorServiceWrapper.rb +2 -2
  234. data/lib/adwords_api/v201008/UserListService.rb +0 -0
  235. data/lib/adwords_api/v201008/UserListServiceDriver.rb +3 -3
  236. data/lib/adwords_api/v201008/UserListServiceMappingRegistry.rb +0 -0
  237. data/lib/adwords_api/v201008/UserListServiceWrapper.rb +2 -2
  238. data/lib/adwords_api/v201101/AdExtensionOverrideService.rb +0 -0
  239. data/lib/adwords_api/v201101/AdExtensionOverrideServiceDriver.rb +3 -3
  240. data/lib/adwords_api/v201101/AdExtensionOverrideServiceMappingRegistry.rb +0 -0
  241. data/lib/adwords_api/v201101/AdExtensionOverrideServiceWrapper.rb +2 -2
  242. data/lib/adwords_api/v201101/AdGroupAdService.rb +246 -246
  243. data/lib/adwords_api/v201101/AdGroupAdServiceDriver.rb +3 -3
  244. data/lib/adwords_api/v201101/AdGroupAdServiceMappingRegistry.rb +94 -94
  245. data/lib/adwords_api/v201101/AdGroupAdServiceWrapper.rb +2 -2
  246. data/lib/adwords_api/v201101/AdGroupCriterionService.rb +0 -0
  247. data/lib/adwords_api/v201101/AdGroupCriterionServiceDriver.rb +3 -3
  248. data/lib/adwords_api/v201101/AdGroupCriterionServiceMappingRegistry.rb +0 -0
  249. data/lib/adwords_api/v201101/AdGroupCriterionServiceWrapper.rb +2 -2
  250. data/lib/adwords_api/v201101/AdGroupService.rb +0 -0
  251. data/lib/adwords_api/v201101/AdGroupServiceDriver.rb +3 -3
  252. data/lib/adwords_api/v201101/AdGroupServiceMappingRegistry.rb +0 -0
  253. data/lib/adwords_api/v201101/AdGroupServiceWrapper.rb +2 -2
  254. data/lib/adwords_api/v201101/AdParamService.rb +0 -0
  255. data/lib/adwords_api/v201101/AdParamServiceDriver.rb +3 -3
  256. data/lib/adwords_api/v201101/AdParamServiceMappingRegistry.rb +0 -0
  257. data/lib/adwords_api/v201101/AdParamServiceWrapper.rb +2 -2
  258. data/lib/adwords_api/v201101/AlertService.rb +0 -0
  259. data/lib/adwords_api/v201101/AlertServiceDriver.rb +2 -2
  260. data/lib/adwords_api/v201101/AlertServiceMappingRegistry.rb +0 -0
  261. data/lib/adwords_api/v201101/AlertServiceWrapper.rb +2 -2
  262. data/lib/adwords_api/v201101/BulkMutateJobService.rb +0 -13
  263. data/lib/adwords_api/v201101/BulkMutateJobServiceDriver.rb +3 -3
  264. data/lib/adwords_api/v201101/BulkMutateJobServiceMappingRegistry.rb +0 -20
  265. data/lib/adwords_api/v201101/BulkMutateJobServiceWrapper.rb +2 -2
  266. data/lib/adwords_api/v201101/BulkOpportunityService.rb +0 -0
  267. data/lib/adwords_api/v201101/BulkOpportunityServiceDriver.rb +2 -2
  268. data/lib/adwords_api/v201101/BulkOpportunityServiceMappingRegistry.rb +0 -0
  269. data/lib/adwords_api/v201101/BulkOpportunityServiceWrapper.rb +2 -2
  270. data/lib/adwords_api/v201101/CampaignAdExtensionService.rb +0 -0
  271. data/lib/adwords_api/v201101/CampaignAdExtensionServiceDriver.rb +3 -3
  272. data/lib/adwords_api/v201101/CampaignAdExtensionServiceMappingRegistry.rb +0 -0
  273. data/lib/adwords_api/v201101/CampaignAdExtensionServiceWrapper.rb +2 -2
  274. data/lib/adwords_api/v201101/CampaignCriterionService.rb +0 -0
  275. data/lib/adwords_api/v201101/CampaignCriterionServiceDriver.rb +3 -3
  276. data/lib/adwords_api/v201101/CampaignCriterionServiceMappingRegistry.rb +0 -0
  277. data/lib/adwords_api/v201101/CampaignCriterionServiceWrapper.rb +2 -2
  278. data/lib/adwords_api/v201101/CampaignService.rb +0 -0
  279. data/lib/adwords_api/v201101/CampaignServiceDriver.rb +3 -3
  280. data/lib/adwords_api/v201101/CampaignServiceMappingRegistry.rb +0 -0
  281. data/lib/adwords_api/v201101/CampaignServiceWrapper.rb +2 -2
  282. data/lib/adwords_api/v201101/CampaignTargetService.rb +0 -13
  283. data/lib/adwords_api/v201101/CampaignTargetServiceDriver.rb +3 -3
  284. data/lib/adwords_api/v201101/CampaignTargetServiceMappingRegistry.rb +0 -20
  285. data/lib/adwords_api/v201101/CampaignTargetServiceWrapper.rb +2 -2
  286. data/lib/adwords_api/v201101/ConversionTrackerService.rb +27 -0
  287. data/lib/adwords_api/v201101/ConversionTrackerServiceDriver.rb +3 -3
  288. data/lib/adwords_api/v201101/ConversionTrackerServiceMappingRegistry.rb +36 -0
  289. data/lib/adwords_api/v201101/ConversionTrackerServiceWrapper.rb +2 -2
  290. data/lib/adwords_api/v201101/CustomerSyncService.rb +0 -0
  291. data/lib/adwords_api/v201101/CustomerSyncServiceDriver.rb +2 -2
  292. data/lib/adwords_api/v201101/CustomerSyncServiceMappingRegistry.rb +0 -0
  293. data/lib/adwords_api/v201101/CustomerSyncServiceWrapper.rb +2 -2
  294. data/lib/adwords_api/v201101/DataService.rb +0 -0
  295. data/lib/adwords_api/v201101/DataServiceDriver.rb +3 -3
  296. data/lib/adwords_api/v201101/DataServiceMappingRegistry.rb +0 -0
  297. data/lib/adwords_api/v201101/DataServiceWrapper.rb +2 -2
  298. data/lib/adwords_api/v201101/ExperimentService.rb +0 -0
  299. data/lib/adwords_api/v201101/ExperimentServiceDriver.rb +3 -3
  300. data/lib/adwords_api/v201101/ExperimentServiceMappingRegistry.rb +0 -0
  301. data/lib/adwords_api/v201101/ExperimentServiceWrapper.rb +2 -2
  302. data/lib/adwords_api/v201101/GeoLocationService.rb +0 -0
  303. data/lib/adwords_api/v201101/GeoLocationServiceDriver.rb +2 -2
  304. data/lib/adwords_api/v201101/GeoLocationServiceMappingRegistry.rb +0 -0
  305. data/lib/adwords_api/v201101/GeoLocationServiceWrapper.rb +2 -2
  306. data/lib/adwords_api/v201101/InfoService.rb +0 -0
  307. data/lib/adwords_api/v201101/InfoServiceDriver.rb +2 -2
  308. data/lib/adwords_api/v201101/InfoServiceMappingRegistry.rb +0 -0
  309. data/lib/adwords_api/v201101/InfoServiceWrapper.rb +2 -2
  310. data/lib/adwords_api/v201101/MediaService.rb +203 -203
  311. data/lib/adwords_api/v201101/MediaServiceDriver.rb +3 -3
  312. data/lib/adwords_api/v201101/MediaServiceMappingRegistry.rb +54 -54
  313. data/lib/adwords_api/v201101/MediaServiceWrapper.rb +2 -2
  314. data/lib/adwords_api/v201101/ReportDefinitionService.rb +0 -0
  315. data/lib/adwords_api/v201101/ReportDefinitionServiceDriver.rb +4 -4
  316. data/lib/adwords_api/v201101/ReportDefinitionServiceMappingRegistry.rb +0 -0
  317. data/lib/adwords_api/v201101/ReportDefinitionServiceWrapper.rb +16 -2
  318. data/lib/adwords_api/v201101/ServicedAccountService.rb +0 -0
  319. data/lib/adwords_api/v201101/ServicedAccountServiceDriver.rb +2 -2
  320. data/lib/adwords_api/v201101/ServicedAccountServiceMappingRegistry.rb +0 -0
  321. data/lib/adwords_api/v201101/ServicedAccountServiceWrapper.rb +2 -2
  322. data/lib/adwords_api/v201101/TargetingIdeaService.rb +0 -0
  323. data/lib/adwords_api/v201101/TargetingIdeaServiceDriver.rb +3 -3
  324. data/lib/adwords_api/v201101/TargetingIdeaServiceMappingRegistry.rb +0 -0
  325. data/lib/adwords_api/v201101/TargetingIdeaServiceWrapper.rb +2 -2
  326. data/lib/adwords_api/v201101/TrafficEstimatorService.rb +0 -0
  327. data/lib/adwords_api/v201101/TrafficEstimatorServiceDriver.rb +2 -2
  328. data/lib/adwords_api/v201101/TrafficEstimatorServiceMappingRegistry.rb +0 -0
  329. data/lib/adwords_api/v201101/TrafficEstimatorServiceWrapper.rb +2 -2
  330. data/lib/adwords_api/v201101/UserListService.rb +0 -0
  331. data/lib/adwords_api/v201101/UserListServiceDriver.rb +3 -3
  332. data/lib/adwords_api/v201101/UserListServiceMappingRegistry.rb +0 -0
  333. data/lib/adwords_api/v201101/UserListServiceWrapper.rb +2 -2
  334. metadata +205 -211
@@ -17,12 +17,19 @@
17
17
  # See the License for the specific language governing permissions and
18
18
  # limitations under the License.
19
19
  #
20
- # This example gets and downloads a report from a report definition. To get a
21
- # report definition, run add_keywords_performance_report_definition.rb.
20
+ # This example gets and downloads a report from a report definition using MCC
21
+ # (cross-client) feature. To create a report definition, run
22
+ # add_mcc_report_definition.rb.
23
+ #
24
+ # Please note: This feature is still under development and may change before it
25
+ # is released.
26
+ #
27
+ # Tags: ReportDefinitionService
22
28
 
23
29
  require 'rubygems'
24
30
  gem 'google-adwords-api'
25
31
  require 'adwords_api'
32
+ require 'pp'
26
33
 
27
34
  API_VERSION = :v201101
28
35
  MAX_RETRIES = 10
@@ -36,31 +43,48 @@ def download_mcc_report()
36
43
 
37
44
  report_definition_id = 'INSERT_REPORT_ID_HERE'.to_i
38
45
 
39
- # Initially run with qt = 'new'
40
- qt = 'new'
41
- retries_count = 0
46
+ # Poll for the report.
47
+ report_data = poll_for_report(report_def_srv, report_definition_id)
42
48
 
43
- begin
49
+ # Check the response code.
50
+ case report_data[:code]
51
+ when 301
52
+ puts "Acquired report data of size: %d" % report_data[:report_data].size
53
+ when 500
54
+ puts "Received a failure: %s" % report_data[:body]['failureReason']
55
+ if report_data[:body]['failures']
56
+ puts "Failures info:"
57
+ pp report_data[:body]['failures']
58
+ end
59
+ else
60
+ puts "Report returned with unexpected code %d and body: %s" % [
61
+ report_data[:code], report_data[:body]]
62
+ end
63
+ end
64
+
65
+ def poll_for_report(report_def_srv, report_definition_id)
66
+ # Initially run with query_token = 'new'.
67
+ query_token = 'new'
68
+
69
+ MAX_RETRIES.times do |retry_count|
44
70
  # Acquire report or report status with "download_mcc_report" extension
45
71
  # method.
46
- report_data = report_def_srv.download_mcc_report(report_definition_id, qt)
47
- # Saving query id for following queries.
48
- qt = report_data[:body]['qt']
49
- # Checking the response code.
50
- case report_data[:code]
51
- when 200
52
- puts "Acquired report of size: %d" % report_data[:body].size
53
- break
54
- when 206
55
- puts "Received a status update: %s" % report_data[:body]['stateName']
56
- puts "Waiting for %d seconds to retry..." % RETRY_INTERVAL
57
- when 500
58
- puts "Received a failure: %s" % report_data[:body]['stateName']
59
- break
72
+ report_data = report_def_srv.download_mcc_report(report_definition_id,
73
+ query_token)
74
+ if report_data[:body]
75
+ # Save query id for following queries.
76
+ query_token = report_data[:body]['queryToken']
77
+ # Print current query status.
78
+ puts "Received a status update: %s" % report_data[:body]['state']
60
79
  end
61
- sleep(RETRY_INTERVAL)
62
- retries_count += 1
63
- end while retries_count < MAX_RETRIES
80
+ if report_data[:code] == 200
81
+ puts "Try %d/%d: still processing, retry in %d seconds..." % [
82
+ retry_count + 1, MAX_RETRIES, RETRY_INTERVAL]
83
+ sleep(RETRY_INTERVAL)
84
+ else
85
+ return report_data
86
+ end
87
+ end
64
88
  end
65
89
 
66
90
  if __FILE__ == $0
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # Author:: api.dklimkin@gmail.com (Danial Klimkin)
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
+ # This example gets and saves a report from a report definition using MCC
21
+ # (cross-client) feature to a given path. To create a report definition, run
22
+ # add_mcc_report_definition.rb.
23
+ #
24
+ # Please note: This feature is still under development and may change before it
25
+ # is released.
26
+ #
27
+ # Tags: ReportDefinitionService
28
+
29
+ require 'rubygems'
30
+ gem 'google-adwords-api'
31
+ require 'adwords_api'
32
+ require 'pp'
33
+
34
+ API_VERSION = :v201101
35
+ MAX_RETRIES = 10
36
+ RETRY_INTERVAL = 30
37
+
38
+ def download_mcc_report_as_file()
39
+ # AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
40
+ # when called without parameters.
41
+ adwords = AdwordsApi::Api.new
42
+ report_def_srv = adwords.service(:ReportDefinitionService, API_VERSION)
43
+
44
+ report_definition_id = 'INSERT_REPORT_ID_HERE'.to_i
45
+ file_name = 'INSERT_OUTPUT_FILE_NAME_HERE'
46
+
47
+ # Poll for the report.
48
+ report_data = poll_for_report(report_def_srv, report_definition_id, file_name)
49
+
50
+ # Check the response code.
51
+ case report_data[:code]
52
+ when 301
53
+ puts "Saved report into a file: %s" % file_name
54
+ when 500
55
+ puts "Received a failure: %s" % report_data[:body]['failureReason']
56
+ if report_data[:body]['failures']
57
+ puts "Failures info:"
58
+ pp report_data[:body]['failures']
59
+ end
60
+ else
61
+ puts "Report returned with unexpected code %d and body: %s" % [
62
+ report_data[:code], report_data[:body]]
63
+ end
64
+ end
65
+
66
+ def poll_for_report(report_def_srv, report_definition_id, file_name)
67
+ # Initially run with query_token = 'new'.
68
+ query_token = 'new'
69
+
70
+ MAX_RETRIES.times do |retry_count|
71
+ # Acquire report or report status with "download_mcc_report_as_file"
72
+ # extension method.
73
+ report_data = report_def_srv.download_mcc_report_as_file(
74
+ report_definition_id, query_token, file_name)
75
+ if report_data[:body]
76
+ # Save query id for following queries.
77
+ query_token = report_data[:body]['queryToken']
78
+ # Print current query status.
79
+ puts "Received a status update: %s" % report_data[:body]['state']
80
+ end
81
+ if report_data[:code] == 200
82
+ puts "Try %d/%d: still processing, retry in %d seconds..." % [
83
+ retry_count + 1, MAX_RETRIES, RETRY_INTERVAL]
84
+ sleep(RETRY_INTERVAL)
85
+ else
86
+ return report_data
87
+ end
88
+ end
89
+ end
90
+
91
+ if __FILE__ == $0
92
+ begin
93
+ download_mcc_report_as_file()
94
+
95
+ # Connection error. Likely transitory.
96
+ rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
97
+ puts 'Connection Error: %s' % e
98
+ puts 'Source: %s' % e.backtrace.first
99
+
100
+ # API Error.
101
+ rescue AdwordsApi::Errors::ApiException => e
102
+ puts 'API Exception caught.'
103
+ puts 'Message: %s' % e.message
104
+ puts 'Code: %d' % e.code if e.code
105
+ puts 'Trigger: %s' % e.trigger if e.trigger
106
+ puts 'Errors:'
107
+ if e.errors
108
+ e.errors.each_with_index do |error, index|
109
+ puts ' %d. Error type is %s. Fields:' % [index + 1, error[:xsi_type]]
110
+ error.each_pair do |field, value|
111
+ if field != :xsi_type
112
+ puts ' %s: %s' % [field, value]
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -75,7 +75,7 @@ if __FILE__ == $0
75
75
  # To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
76
76
  # variable to 'true'. This can be done either from your operating system
77
77
  # environment or via code, as done below.
78
- ENV['ADWORDSAPI_DEBUG'] = 'true'
78
+ ENV['ADWORDSAPI_DEBUG'] = 'false'
79
79
 
80
80
  begin
81
81
  get_all_bulk_mutate_jobs()
@@ -190,7 +190,7 @@ if __FILE__ == $0
190
190
  # To enable logging of SOAP requests, set the ADWORDSAPI_DEBUG environment
191
191
  # variable to 'true'. This can be done either from your operating system
192
192
  # environment or via code, as done below.
193
- ENV['ADWORDSAPI_DEBUG'] = 'true'
193
+ ENV['ADWORDSAPI_DEBUG'] = 'false'
194
194
 
195
195
  begin
196
196
  perform_bulk_mutate_job()
@@ -22,7 +22,7 @@
22
22
 
23
23
  require 'rubygems'
24
24
  gem 'soap4r', '=1.5.8'
25
- gem 'google-ads-common', '~>0.2.0'
25
+ gem 'google-ads-common', '~>0.2.1'
26
26
  require 'thread'
27
27
  require 'uri'
28
28
  require 'ads_common/logger'
@@ -261,13 +261,9 @@ module AdwordsApi
261
261
  # configuration rather than use the default
262
262
  #
263
263
  def load_config(provided_config = nil)
264
- @config = AdsCommon::Config.new
265
- if !provided_config
266
- filename = File.join(ENV['HOME'], 'adwords_api.yml')
267
- @config.load(filename)
268
- else
269
- @config.set_all(provided_config)
270
- end
264
+ @config = (provided_config.nil?) ?
265
+ AdsCommon::Config.new(File.join(ENV['HOME'], 'adwords_api.yml')) :
266
+ AdsCommon::Config.new(provided_config)
271
267
  end
272
268
  end
273
269
  end
@@ -40,7 +40,7 @@ module AdwordsApi
40
40
  # Set other constants
41
41
  API_NAME = 'AdwordsApi'
42
42
  API_PATH = 'adwords_api'
43
- CLIENT_LIB_VERSION = '0.1.1'
43
+ CLIENT_LIB_VERSION = '0.1.2'
44
44
 
45
45
  # Configure the services available to each version
46
46
  @@service_config = {
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
  #
3
- # Authors:: api.sgomes@gmail.com (Sérgio Gomes)
3
+ # Authors:: api.dklimkin@gmail.com (Danial Klimkin)
4
4
  #
5
5
  # Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
6
6
  #
@@ -24,12 +24,9 @@ require 'ads_common/auth/base_handler'
24
24
  module AdwordsApi
25
25
  module Auth
26
26
  class V13LoginHandler < AdsCommon::Auth::BaseHandler
27
-
28
- # Ensure that clientEmail and clientCustomerId are always present
29
27
  def header_list(credentials)
30
- creds = credentials.keys.dup
31
- creds << :clientEmail unless creds.include? :clientEmail
32
- creds << :clientCustomerId unless creds.include? :clientCustomerId
28
+ # Ensure that clientEmail and clientCustomerId are always present.
29
+ return credentials.keys.dup() | [:clientEmail, :clientCustomerId]
33
30
  end
34
31
  end
35
32
  end
@@ -23,7 +23,6 @@
23
23
  require 'rexml/document'
24
24
  require 'csv'
25
25
  require 'ads_common/http'
26
- require 'json'
27
26
 
28
27
  module AdwordsApi
29
28
 
@@ -38,15 +37,19 @@ module AdwordsApi
38
37
  [:v201008, :ReportDefinitionService] => [:download_report,
39
38
  :download_report_as_file],
40
39
  [:v201101, :ReportDefinitionService] => [:download_report,
41
- :download_report_as_file]
40
+ :download_report_as_file, :download_mcc_report,
41
+ :download_mcc_report_as_file]
42
42
  }
43
43
 
44
- # Defines the parameter list for every extension method
44
+ # Defines the parameter list for every extension method.
45
45
  @@methods = {
46
46
  :download_xml_report => [:job_id],
47
47
  :download_csv_report => [:job_id],
48
48
  :download_report => [:report_definition_id],
49
- :download_report_as_file => [:report_definition_id, :path]
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
53
  }
51
54
 
52
55
  # Return list of all extension methods, indexed by version and service.
@@ -84,7 +87,7 @@ module AdwordsApi
84
87
  status_field = nil
85
88
  download_field = nil
86
89
 
87
- if wrapper.api.config.read('service.use_ruby_names')
90
+ if wrapper.api.config.read('service.use_ruby_names', true)
88
91
  status_field = :get_report_job_status_return
89
92
  download_field = :get_report_download_url_return
90
93
  else
@@ -116,7 +119,7 @@ module AdwordsApi
116
119
  else
117
120
  # Reports that pass validation will normally not fail, but if there is
118
121
  # an error in the report generation service it can sometimes happen.
119
- raise AdwordsApi::Error::Error, 'Report generation failed.'
122
+ raise AdwordsApi::Errors::ApiException, 'Report generation failed.'
120
123
  end
121
124
  end
122
125
 
@@ -168,7 +171,7 @@ module AdwordsApi
168
171
  return csv
169
172
  rescue REXML::ParseException => e
170
173
  # Error parsing XML
171
- raise AdwordsApi::Error::Error,
174
+ raise AdwordsApi::Errors::ApiException,
172
175
  "Error parsing report XML: %s\nSource: %s" % [e, e.backtrace.first]
173
176
  end
174
177
  end
@@ -188,12 +191,7 @@ module AdwordsApi
188
191
  #
189
192
  def self.download_report_as_file(wrapper, report_definition_id, path)
190
193
  report_data = download_report(wrapper, report_definition_id)
191
-
192
- # Write to file (if provided)
193
- if path
194
- open(path, 'w') { |file| file.puts(report_data) }
195
- end
196
-
194
+ save_to_file(report_data, path)
197
195
  return nil
198
196
  end
199
197
 
@@ -210,21 +208,103 @@ module AdwordsApi
210
208
  # The data for the report (as a string)
211
209
  #
212
210
  def self.download_report(wrapper, report_definition_id)
213
- report_response = get_report_response(wrapper, "?__rd=%s" %
214
- report_definition_id)
211
+ url = get_report_url(wrapper, "?__rd=%s" % report_definition_id)
212
+ report_response = get_report_response(wrapper, url)
215
213
  return report_response.body
216
214
  end
217
215
 
216
+ # <i>Extension method</i> -- Download and return a MCC report.
217
+ #
218
+ # *Warning*: this method is blocking for the calling thread.
219
+ #
220
+ # Args:
221
+ # - wrapper: the service wrapper object for any API methods that need to be
222
+ # called
223
+ # - report_definition_id: the id for the report definition
224
+ # - query_token: id from previous calls to the method
225
+ #
226
+ # Returns:
227
+ # A hash with HTTP code and report service response
228
+ #
229
+ def self.download_mcc_report(wrapper, report_definition_id, query_token)
230
+ do_download_mcc_report(wrapper, report_definition_id, query_token, nil)
231
+ end
232
+
233
+ # <i>Extension method</i> -- Download and save a MCC report to file.
234
+ #
235
+ # *Warning*: this method is blocking for the calling thread.
236
+ #
237
+ # Args:
238
+ # - wrapper: the service wrapper object for any API methods that need to be
239
+ # called
240
+ # - report_definition_id: the id for the report definition
241
+ # - query_token: id from previous calls to the method
242
+ # - path: filename to save downloaded report to
243
+ #
244
+ # Returns:
245
+ # A hash with HTTP code and report service response
246
+ #
247
+ def self.download_mcc_report_as_file(wrapper, report_definition_id,
248
+ query_token, path)
249
+ do_download_mcc_report(wrapper, report_definition_id, query_token, path)
250
+ end
251
+
218
252
  private
219
253
 
220
- # Gets a report response for a given parameters.
221
- def self.get_report_response(wrapper, parameters)
222
- # Get download URL.
223
- url = AdwordsApi::ApiConfig.report_download_url(
254
+ # Polls the service once and downloads report into a file or to a hash.
255
+ def self.do_download_mcc_report(wrapper, report_definition_id, query_token,
256
+ path = nil)
257
+ query_token = 'new' if query_token.nil? or query_token.empty?
258
+ url = get_report_url(wrapper,
259
+ "?__rd=%s&qt=%s" % [report_definition_id, query_token])
260
+ report_response = get_report_response(wrapper, url)
261
+ check_old_error(report_response.body)
262
+ mcc_response = report_response_to_hash(report_response)
263
+ result = case report_response.code
264
+ when 200, 500
265
+ mcc_response
266
+ when 301
267
+ return_or_save_mcc_report_data(wrapper, mcc_response, path)
268
+ else
269
+ raise AdwordsApi::Errors::ApiException,
270
+ "Unknown HTTP error code %d message: %s" %
271
+ [report_response.code, report_response.body]
272
+ end
273
+ return result
274
+ end
275
+
276
+ # Downloads a report body into a hash or a file.
277
+ def self.return_or_save_mcc_report_data(wrapper, mcc_response, path = nil)
278
+ report_data = get_report_response(wrapper, mcc_response[:location]).body
279
+ if path.nil?
280
+ mcc_response[:report_data] = report_data
281
+ else
282
+ save_to_file(report_data, path)
283
+ end
284
+ return mcc_response
285
+ end
286
+
287
+ # Saves raw data to a file.
288
+ def self.save_to_file(data, path)
289
+ open(path, 'w') { |file| file.puts(data) } if path
290
+ end
291
+
292
+ # Generates default report URL with given parameters.
293
+ def self.get_report_url(wrapper, parameters)
294
+ return AdwordsApi::ApiConfig.report_download_url(
224
295
  wrapper.api.config.read('service.environment'),
225
- wrapper.version)
296
+ wrapper.version) + parameters
297
+ end
226
298
 
227
- # Set HTTP headers.
299
+ # Gets a report response for a given parameters.
300
+ def self.get_report_response(wrapper, url)
301
+ headers = get_report_request_headers(wrapper)
302
+ report_response = AdsCommon::Http.get_response(url, wrapper.api.config,
303
+ headers)
304
+ return report_response
305
+ end
306
+
307
+ def self.get_report_request_headers(wrapper)
228
308
  headers = {}
229
309
  credentials = wrapper.api.credential_handler.credentials
230
310
  auth_handler = wrapper.api.client_login_handler
@@ -234,12 +314,63 @@ module AdwordsApi
234
314
  headers['clientEmail'] = credentials[:clientEmail]
235
315
  elsif credentials[:clientCustomerId]
236
316
  headers['clientCustomerId'] = credentials[:clientCustomerId]
317
+ elsif credentials[:email]
318
+ headers['clientEmail'] = credentials[:email]
319
+ end
320
+ return headers
321
+ end
322
+
323
+ # Converts report response data into a convenient hash.
324
+ def self.report_response_to_hash(response)
325
+ result = {}
326
+ result[:code] = response.code
327
+ xml = REXML::Document.new(response.body)
328
+ result[:body] = xml_to_hash(xml.root) if xml and xml.root
329
+ if !response.headers.nil? and !response.headers['Location'].nil?
330
+ result[:location] = response.headers['Location']
237
331
  end
332
+ # Special case for accounts list in failures.
333
+ if result[:body] and result[:body][:failures]
334
+ result[:body][:failures][:account] =
335
+ arrayize(result[:body][:failures][:account])
336
+ end
337
+ return result
338
+ end
238
339
 
239
- # Download report data.
240
- report_response = AdsCommon::Http.get_response(url + parameters,
241
- wrapper.api.config, headers)
242
- return report_response
340
+ # Converts xml into a convenient hash.
341
+ def self.xml_to_hash(xml)
342
+ result = {}
343
+ xml.elements.each do |item|
344
+ value = case item.has_elements?
345
+ when true: xml_to_hash(item)
346
+ else item.get_text()
347
+ end
348
+ if result[item.name].nil?
349
+ result[item.name] = value
350
+ else
351
+ result[item.name] = arrayize(result[item.name])
352
+ result[item.name] << value
353
+ end
354
+ end
355
+ return result
356
+ end
357
+
358
+ # Makes sure object is an array.
359
+ def self.arrayize(object)
360
+ return Array.new if object.nil?
361
+ return object.is_a?(Array) ? object : [object]
362
+ end
363
+
364
+ # Checks for old-style pre-MCC reporting error.
365
+ def self.check_old_error(response_text)
366
+ error_message_regex = '^!!!(-?\d+)\|\|\|(-?\d+)\|\|\|(.*)\?\?\?'
367
+ matches = response_text.match(error_message_regex)
368
+ if matches
369
+ message = (matches[3].nil?) ? response_text : matches[3]
370
+ raise AdwordsApi::Errors::ApiException,
371
+ "Report download error occured: %s" % message
372
+ end
373
+ return nil
243
374
  end
244
375
  end
245
376
  end