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.
- data/COPYING +201 -0
- data/ChangeLog +14 -0
- data/README +44 -14
- data/Rakefile +1 -1
- data/adwords_api.yml +0 -1
- data/examples/v200909/add_ad_group_criteria.rb +1 -1
- data/examples/v200909/perform_bulk_mutate_job.rb +1 -1
- data/examples/v201003/get_related_placements.rb +6 -9
- data/examples/v201003/perform_bulk_mutate_job.rb +1 -1
- data/examples/v201008/get_bulk_mutate_job.rb +1 -1
- data/examples/v201008/perform_bulk_mutate_job.rb +1 -1
- data/examples/v201101/add_mcc_report_definition.rb +4 -8
- data/examples/v201101/download_mcc_report.rb +47 -23
- data/examples/v201101/download_mcc_report_as_file.rb +118 -0
- data/examples/v201101/get_bulk_mutate_job.rb +1 -1
- data/examples/v201101/get_keyword_opportunities.rb +0 -0
- data/examples/v201101/perform_bulk_mutate_job.rb +1 -1
- data/lib/adwords_api.rb +4 -8
- data/lib/adwords_api/api_config.rb +1 -1
- data/lib/adwords_api/auth/v13_login_handler.rb +3 -6
- data/lib/adwords_api/extensions.rb +156 -25
- data/lib/adwords_api/v13/AccountService.rb +0 -0
- data/lib/adwords_api/v13/AccountServiceDriver.rb +6 -6
- data/lib/adwords_api/v13/AccountServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v13/AccountServiceWrapper.rb +2 -2
- data/lib/adwords_api/v13/ReportService.rb +0 -0
- data/lib/adwords_api/v13/ReportServiceDriver.rb +8 -8
- data/lib/adwords_api/v13/ReportServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v13/ReportServiceWrapper.rb +2 -2
- data/lib/adwords_api/v13/TrafficEstimatorService.rb +0 -0
- data/lib/adwords_api/v13/TrafficEstimatorServiceDriver.rb +5 -5
- data/lib/adwords_api/v13/TrafficEstimatorServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v13/TrafficEstimatorServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/AdExtensionOverrideService.rb +0 -0
- data/lib/adwords_api/v200909/AdExtensionOverrideServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/AdExtensionOverrideServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/AdExtensionOverrideServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/AdGroupAdService.rb +239 -239
- data/lib/adwords_api/v200909/AdGroupAdServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/AdGroupAdServiceMappingRegistry.rb +120 -120
- data/lib/adwords_api/v200909/AdGroupAdServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/AdGroupCriterionService.rb +0 -0
- data/lib/adwords_api/v200909/AdGroupCriterionServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/AdGroupCriterionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/AdGroupCriterionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/AdGroupService.rb +0 -0
- data/lib/adwords_api/v200909/AdGroupServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/AdGroupServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/AdGroupServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/AdParamService.rb +0 -0
- data/lib/adwords_api/v200909/AdParamServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/AdParamServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/AdParamServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/BulkMutateJobService.rb +0 -0
- data/lib/adwords_api/v200909/BulkMutateJobServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/BulkMutateJobServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/BulkMutateJobServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/CampaignAdExtensionService.rb +0 -0
- data/lib/adwords_api/v200909/CampaignAdExtensionServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/CampaignAdExtensionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/CampaignAdExtensionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/CampaignCriterionService.rb +0 -0
- data/lib/adwords_api/v200909/CampaignCriterionServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/CampaignCriterionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/CampaignCriterionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/CampaignService.rb +0 -0
- data/lib/adwords_api/v200909/CampaignServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/CampaignServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/CampaignServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/CampaignTargetService.rb +0 -0
- data/lib/adwords_api/v200909/CampaignTargetServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/CampaignTargetServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/CampaignTargetServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/GeoLocationService.rb +0 -0
- data/lib/adwords_api/v200909/GeoLocationServiceDriver.rb +2 -2
- data/lib/adwords_api/v200909/GeoLocationServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/GeoLocationServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/InfoService.rb +0 -0
- data/lib/adwords_api/v200909/InfoServiceDriver.rb +2 -2
- data/lib/adwords_api/v200909/InfoServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/InfoServiceWrapper.rb +2 -2
- data/lib/adwords_api/v200909/TargetingIdeaService.rb +0 -0
- data/lib/adwords_api/v200909/TargetingIdeaServiceDriver.rb +3 -3
- data/lib/adwords_api/v200909/TargetingIdeaServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v200909/TargetingIdeaServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/AdExtensionOverrideService.rb +0 -0
- data/lib/adwords_api/v201003/AdExtensionOverrideServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/AdExtensionOverrideServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/AdExtensionOverrideServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/AdGroupAdService.rb +293 -293
- data/lib/adwords_api/v201003/AdGroupAdServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/AdGroupAdServiceMappingRegistry.rb +124 -124
- data/lib/adwords_api/v201003/AdGroupAdServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/AdGroupCriterionService.rb +0 -0
- data/lib/adwords_api/v201003/AdGroupCriterionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/AdGroupCriterionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/AdGroupCriterionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/AdGroupService.rb +0 -0
- data/lib/adwords_api/v201003/AdGroupServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/AdGroupServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/AdGroupServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/AdParamService.rb +0 -0
- data/lib/adwords_api/v201003/AdParamServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/AdParamServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/AdParamServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/BidLandscapeService.rb +0 -0
- data/lib/adwords_api/v201003/BidLandscapeServiceDriver.rb +2 -2
- data/lib/adwords_api/v201003/BidLandscapeServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/BidLandscapeServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/BulkMutateJobService.rb +0 -0
- data/lib/adwords_api/v201003/BulkMutateJobServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/BulkMutateJobServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/BulkMutateJobServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/CampaignAdExtensionService.rb +0 -0
- data/lib/adwords_api/v201003/CampaignAdExtensionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/CampaignAdExtensionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/CampaignAdExtensionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/CampaignCriterionService.rb +0 -0
- data/lib/adwords_api/v201003/CampaignCriterionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/CampaignCriterionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/CampaignCriterionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/CampaignService.rb +0 -0
- data/lib/adwords_api/v201003/CampaignServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/CampaignServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/CampaignServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/CampaignTargetService.rb +0 -0
- data/lib/adwords_api/v201003/CampaignTargetServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/CampaignTargetServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/CampaignTargetServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/GeoLocationService.rb +0 -0
- data/lib/adwords_api/v201003/GeoLocationServiceDriver.rb +2 -2
- data/lib/adwords_api/v201003/GeoLocationServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/GeoLocationServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/InfoService.rb +0 -0
- data/lib/adwords_api/v201003/InfoServiceDriver.rb +2 -2
- data/lib/adwords_api/v201003/InfoServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/InfoServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/MediaService.rb +224 -224
- data/lib/adwords_api/v201003/MediaServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/MediaServiceMappingRegistry.rb +58 -58
- data/lib/adwords_api/v201003/MediaServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/ReportDefinitionService.rb +0 -0
- data/lib/adwords_api/v201003/ReportDefinitionServiceDriver.rb +4 -4
- data/lib/adwords_api/v201003/ReportDefinitionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/ReportDefinitionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201003/TargetingIdeaService.rb +0 -0
- data/lib/adwords_api/v201003/TargetingIdeaServiceDriver.rb +3 -3
- data/lib/adwords_api/v201003/TargetingIdeaServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201003/TargetingIdeaServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/AdExtensionOverrideService.rb +0 -0
- data/lib/adwords_api/v201008/AdExtensionOverrideServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/AdExtensionOverrideServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/AdExtensionOverrideServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/AdGroupAdService.rb +255 -255
- data/lib/adwords_api/v201008/AdGroupAdServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/AdGroupAdServiceMappingRegistry.rb +120 -120
- data/lib/adwords_api/v201008/AdGroupAdServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/AdGroupCriterionService.rb +0 -0
- data/lib/adwords_api/v201008/AdGroupCriterionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/AdGroupCriterionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/AdGroupCriterionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/AdGroupService.rb +0 -0
- data/lib/adwords_api/v201008/AdGroupServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/AdGroupServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/AdGroupServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/AdParamService.rb +0 -0
- data/lib/adwords_api/v201008/AdParamServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/AdParamServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/AdParamServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/AlertService.rb +0 -0
- data/lib/adwords_api/v201008/AlertServiceDriver.rb +2 -2
- data/lib/adwords_api/v201008/AlertServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/AlertServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/BidLandscapeService.rb +0 -0
- data/lib/adwords_api/v201008/BidLandscapeServiceDriver.rb +2 -2
- data/lib/adwords_api/v201008/BidLandscapeServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/BidLandscapeServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/BulkMutateJobService.rb +0 -0
- data/lib/adwords_api/v201008/BulkMutateJobServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/BulkMutateJobServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/BulkMutateJobServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/CampaignAdExtensionService.rb +0 -0
- data/lib/adwords_api/v201008/CampaignAdExtensionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/CampaignAdExtensionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/CampaignAdExtensionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/CampaignCriterionService.rb +0 -0
- data/lib/adwords_api/v201008/CampaignCriterionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/CampaignCriterionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/CampaignCriterionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/CampaignService.rb +0 -0
- data/lib/adwords_api/v201008/CampaignServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/CampaignServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/CampaignServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/CampaignTargetService.rb +0 -0
- data/lib/adwords_api/v201008/CampaignTargetServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/CampaignTargetServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/CampaignTargetServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/CustomerSyncService.rb +0 -0
- data/lib/adwords_api/v201008/CustomerSyncServiceDriver.rb +2 -2
- data/lib/adwords_api/v201008/CustomerSyncServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/CustomerSyncServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/ExperimentService.rb +0 -0
- data/lib/adwords_api/v201008/ExperimentServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/ExperimentServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/ExperimentServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/GeoLocationService.rb +0 -0
- data/lib/adwords_api/v201008/GeoLocationServiceDriver.rb +2 -2
- data/lib/adwords_api/v201008/GeoLocationServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/GeoLocationServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/InfoService.rb +0 -0
- data/lib/adwords_api/v201008/InfoServiceDriver.rb +2 -2
- data/lib/adwords_api/v201008/InfoServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/InfoServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/MediaService.rb +203 -203
- data/lib/adwords_api/v201008/MediaServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/MediaServiceMappingRegistry.rb +54 -54
- data/lib/adwords_api/v201008/MediaServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/ReportDefinitionService.rb +0 -0
- data/lib/adwords_api/v201008/ReportDefinitionServiceDriver.rb +4 -4
- data/lib/adwords_api/v201008/ReportDefinitionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/ReportDefinitionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/ServicedAccountService.rb +0 -0
- data/lib/adwords_api/v201008/ServicedAccountServiceDriver.rb +2 -2
- data/lib/adwords_api/v201008/ServicedAccountServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/ServicedAccountServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/TargetingIdeaService.rb +0 -0
- data/lib/adwords_api/v201008/TargetingIdeaServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/TargetingIdeaServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/TargetingIdeaServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/TrafficEstimatorService.rb +0 -0
- data/lib/adwords_api/v201008/TrafficEstimatorServiceDriver.rb +2 -2
- data/lib/adwords_api/v201008/TrafficEstimatorServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/TrafficEstimatorServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201008/UserListService.rb +0 -0
- data/lib/adwords_api/v201008/UserListServiceDriver.rb +3 -3
- data/lib/adwords_api/v201008/UserListServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201008/UserListServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/AdExtensionOverrideService.rb +0 -0
- data/lib/adwords_api/v201101/AdExtensionOverrideServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/AdExtensionOverrideServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/AdExtensionOverrideServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/AdGroupAdService.rb +246 -246
- data/lib/adwords_api/v201101/AdGroupAdServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/AdGroupAdServiceMappingRegistry.rb +94 -94
- data/lib/adwords_api/v201101/AdGroupAdServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/AdGroupCriterionService.rb +0 -0
- data/lib/adwords_api/v201101/AdGroupCriterionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/AdGroupCriterionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/AdGroupCriterionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/AdGroupService.rb +0 -0
- data/lib/adwords_api/v201101/AdGroupServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/AdGroupServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/AdGroupServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/AdParamService.rb +0 -0
- data/lib/adwords_api/v201101/AdParamServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/AdParamServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/AdParamServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/AlertService.rb +0 -0
- data/lib/adwords_api/v201101/AlertServiceDriver.rb +2 -2
- data/lib/adwords_api/v201101/AlertServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/AlertServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/BulkMutateJobService.rb +0 -13
- data/lib/adwords_api/v201101/BulkMutateJobServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/BulkMutateJobServiceMappingRegistry.rb +0 -20
- data/lib/adwords_api/v201101/BulkMutateJobServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/BulkOpportunityService.rb +0 -0
- data/lib/adwords_api/v201101/BulkOpportunityServiceDriver.rb +2 -2
- data/lib/adwords_api/v201101/BulkOpportunityServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/BulkOpportunityServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/CampaignAdExtensionService.rb +0 -0
- data/lib/adwords_api/v201101/CampaignAdExtensionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/CampaignAdExtensionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/CampaignAdExtensionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/CampaignCriterionService.rb +0 -0
- data/lib/adwords_api/v201101/CampaignCriterionServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/CampaignCriterionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/CampaignCriterionServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/CampaignService.rb +0 -0
- data/lib/adwords_api/v201101/CampaignServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/CampaignServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/CampaignServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/CampaignTargetService.rb +0 -13
- data/lib/adwords_api/v201101/CampaignTargetServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/CampaignTargetServiceMappingRegistry.rb +0 -20
- data/lib/adwords_api/v201101/CampaignTargetServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/ConversionTrackerService.rb +27 -0
- data/lib/adwords_api/v201101/ConversionTrackerServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/ConversionTrackerServiceMappingRegistry.rb +36 -0
- data/lib/adwords_api/v201101/ConversionTrackerServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/CustomerSyncService.rb +0 -0
- data/lib/adwords_api/v201101/CustomerSyncServiceDriver.rb +2 -2
- data/lib/adwords_api/v201101/CustomerSyncServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/CustomerSyncServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/DataService.rb +0 -0
- data/lib/adwords_api/v201101/DataServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/DataServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/DataServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/ExperimentService.rb +0 -0
- data/lib/adwords_api/v201101/ExperimentServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/ExperimentServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/ExperimentServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/GeoLocationService.rb +0 -0
- data/lib/adwords_api/v201101/GeoLocationServiceDriver.rb +2 -2
- data/lib/adwords_api/v201101/GeoLocationServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/GeoLocationServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/InfoService.rb +0 -0
- data/lib/adwords_api/v201101/InfoServiceDriver.rb +2 -2
- data/lib/adwords_api/v201101/InfoServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/InfoServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/MediaService.rb +203 -203
- data/lib/adwords_api/v201101/MediaServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/MediaServiceMappingRegistry.rb +54 -54
- data/lib/adwords_api/v201101/MediaServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/ReportDefinitionService.rb +0 -0
- data/lib/adwords_api/v201101/ReportDefinitionServiceDriver.rb +4 -4
- data/lib/adwords_api/v201101/ReportDefinitionServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/ReportDefinitionServiceWrapper.rb +16 -2
- data/lib/adwords_api/v201101/ServicedAccountService.rb +0 -0
- data/lib/adwords_api/v201101/ServicedAccountServiceDriver.rb +2 -2
- data/lib/adwords_api/v201101/ServicedAccountServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/ServicedAccountServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/TargetingIdeaService.rb +0 -0
- data/lib/adwords_api/v201101/TargetingIdeaServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/TargetingIdeaServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/TargetingIdeaServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/TrafficEstimatorService.rb +0 -0
- data/lib/adwords_api/v201101/TrafficEstimatorServiceDriver.rb +2 -2
- data/lib/adwords_api/v201101/TrafficEstimatorServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/TrafficEstimatorServiceWrapper.rb +2 -2
- data/lib/adwords_api/v201101/UserListService.rb +0 -0
- data/lib/adwords_api/v201101/UserListServiceDriver.rb +3 -3
- data/lib/adwords_api/v201101/UserListServiceMappingRegistry.rb +0 -0
- data/lib/adwords_api/v201101/UserListServiceWrapper.rb +2 -2
- 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
|
21
|
-
# report definition, run
|
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
|
-
#
|
40
|
-
|
41
|
-
retries_count = 0
|
46
|
+
# Poll for the report.
|
47
|
+
report_data = poll_for_report(report_def_srv, report_definition_id)
|
42
48
|
|
43
|
-
|
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,
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
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'] = '
|
78
|
+
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
79
79
|
|
80
80
|
begin
|
81
81
|
get_all_bulk_mutate_jobs()
|
File without changes
|
@@ -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'] = '
|
193
|
+
ENV['ADWORDSAPI_DEBUG'] = 'false'
|
194
194
|
|
195
195
|
begin
|
196
196
|
perform_bulk_mutate_job()
|
data/lib/adwords_api.rb
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
require 'rubygems'
|
24
24
|
gem 'soap4r', '=1.5.8'
|
25
|
-
gem 'google-ads-common', '~>0.2.
|
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 =
|
265
|
-
|
266
|
-
|
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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
#
|
3
|
-
# Authors:: api.
|
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
|
-
|
31
|
-
|
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::
|
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::
|
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
|
-
|
214
|
-
|
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
|
-
#
|
221
|
-
def self.
|
222
|
-
|
223
|
-
|
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
|
-
|
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
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
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
|