google-adwords-api 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/README +12 -9
- data/adwords_api.yml +3 -17
- data/examples/v201206/account_management/create_account.rb +3 -0
- data/examples/v201206/account_management/get_account_alerts.rb +3 -0
- data/examples/v201206/account_management/get_account_hierarchy.rb +3 -0
- data/examples/v201206/account_management/get_client_customer_id.rb +3 -0
- data/examples/v201206/account_management/get_client_unit_usage.rb +3 -0
- data/examples/v201206/reporting/parallel_report_download.rb +3 -0
- data/examples/v201209/account_management/create_account.rb +3 -0
- data/examples/v201209/account_management/get_account_alerts.rb +3 -0
- data/examples/v201209/account_management/get_account_hierarchy.rb +3 -0
- data/examples/v201209/account_management/get_client_customer_id.rb +3 -0
- data/examples/v201209/account_management/get_client_unit_usage.rb +3 -0
- data/examples/{v201109/misc/use_oauth2.rb → v201209/misc/use_oauth2_jwt.rb} +19 -23
- data/examples/v201209/reporting/parallel_report_download.rb +3 -0
- data/lib/adwords_api.rb +8 -3
- data/lib/adwords_api/api_config.rb +0 -132
- data/lib/adwords_api/credential_handler.rb +3 -17
- data/lib/adwords_api/report_header_handler.rb +1 -2
- data/lib/adwords_api/report_utils.rb +1 -8
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_adwords_api.rb +23 -9
- data/test/adwords_api/test_api_config.rb +0 -8
- data/test/adwords_api/test_credential_handler.rb +45 -9
- data/test/adwords_api/test_report_utils.rb +3 -2
- data/test/{suite_exampletests_v201109.rb → suite_integration.rb} +14 -11
- data/test/templates/v201209/basic_operations_get_campaigns.def +114 -0
- data/test/test_utils.rb +105 -0
- metadata +8 -250
- data/examples/v201109/account_management/create_account.rb +0 -80
- data/examples/v201109/account_management/get_account_alerts.rb +0 -111
- data/examples/v201109/account_management/get_account_changes.rb +0 -137
- data/examples/v201109/account_management/get_account_hierarchy.rb +0 -93
- data/examples/v201109/account_management/get_client_customer_id.rb +0 -85
- data/examples/v201109/account_management/get_client_unit_usage.rb +0 -87
- data/examples/v201109/basic_operations/add_ad_groups.rb +0 -111
- data/examples/v201109/basic_operations/add_campaigns.rb +0 -125
- data/examples/v201109/basic_operations/add_keywords.rb +0 -108
- data/examples/v201109/basic_operations/add_text_ads.rb +0 -105
- data/examples/v201109/basic_operations/delete_ad.rb +0 -85
- data/examples/v201109/basic_operations/delete_ad_group.rb +0 -102
- data/examples/v201109/basic_operations/delete_campaign.rb +0 -103
- data/examples/v201109/basic_operations/delete_keyword.rb +0 -90
- data/examples/v201109/basic_operations/get_ad_groups.rb +0 -98
- data/examples/v201109/basic_operations/get_campaigns.rb +0 -93
- data/examples/v201109/basic_operations/get_keywords.rb +0 -104
- data/examples/v201109/basic_operations/get_text_ads.rb +0 -106
- data/examples/v201109/basic_operations/pause_ad.rb +0 -84
- data/examples/v201109/basic_operations/update_ad_group.rb +0 -81
- data/examples/v201109/basic_operations/update_campaign.rb +0 -84
- data/examples/v201109/basic_operations/update_keyword.rb +0 -99
- data/examples/v201109/campaign_management/add_experiment.rb +0 -158
- data/examples/v201109/campaign_management/add_keywords_in_bulk.rb +0 -150
- data/examples/v201109/campaign_management/add_location_extension.rb +0 -117
- data/examples/v201109/campaign_management/add_location_extension_override.rb +0 -83
- data/examples/v201109/campaign_management/get_all_disapproved_ads.rb +0 -93
- data/examples/v201109/campaign_management/promote_experiment.rb +0 -77
- data/examples/v201109/campaign_management/set_ad_parameters.rb +0 -114
- data/examples/v201109/campaign_management/validate_text_ad.rb +0 -106
- data/examples/v201109/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201109/error_handling/handle_partial_failures.rb +0 -126
- data/examples/v201109/error_handling/handle_policy_violation_error.rb +0 -137
- data/examples/v201109/error_handling/handle_two_factor_authorization_error.rb +0 -87
- data/examples/v201109/misc/get_all_images_and_videos.rb +0 -100
- data/examples/v201109/misc/upload_image.rb +0 -89
- data/examples/v201109/misc/use_oauth.rb +0 -100
- data/examples/v201109/optimization/estimate_keyword_traffic.rb +0 -129
- data/examples/v201109/optimization/get_keyword_bid_simulations.rb +0 -92
- data/examples/v201109/optimization/get_keyword_ideas.rb +0 -106
- data/examples/v201109/optimization/get_placement_ideas.rb +0 -104
- data/examples/v201109/remarketing/add_audience.rb +0 -115
- data/examples/v201109/remarketing/add_conversion_tracker.rb +0 -97
- data/examples/v201109/reporting/download_criteria_report.rb +0 -79
- data/examples/v201109/reporting/get_campaign_stats.rb +0 -105
- data/examples/v201109/reporting/get_defined_reports.rb +0 -75
- data/examples/v201109/reporting/get_report_fields.rb +0 -71
- data/examples/v201109/reporting/parallel_report_download.rb +0 -159
- data/examples/v201109/targeting/add_campaign_targeting_criteria.rb +0 -118
- data/examples/v201109/targeting/get_campaign_targeting_criteria.rb +0 -102
- data/examples/v201109/targeting/get_targetable_languages_and_carriers.rb +0 -86
- data/examples/v201109/targeting/lookup_location.rb +0 -103
- data/examples/v201109_1/account_management/create_account.rb +0 -80
- data/examples/v201109_1/account_management/get_account_alerts.rb +0 -111
- data/examples/v201109_1/account_management/get_account_changes.rb +0 -137
- data/examples/v201109_1/account_management/get_account_hierarchy.rb +0 -93
- data/examples/v201109_1/account_management/get_client_customer_id.rb +0 -85
- data/examples/v201109_1/account_management/get_client_unit_usage.rb +0 -87
- data/examples/v201109_1/basic_operations/add_ad_groups.rb +0 -111
- data/examples/v201109_1/basic_operations/add_campaigns.rb +0 -140
- data/examples/v201109_1/basic_operations/add_keywords.rb +0 -108
- data/examples/v201109_1/basic_operations/add_text_ads.rb +0 -105
- data/examples/v201109_1/basic_operations/delete_ad.rb +0 -85
- data/examples/v201109_1/basic_operations/delete_ad_group.rb +0 -102
- data/examples/v201109_1/basic_operations/delete_campaign.rb +0 -103
- data/examples/v201109_1/basic_operations/delete_keyword.rb +0 -90
- data/examples/v201109_1/basic_operations/get_ad_groups.rb +0 -98
- data/examples/v201109_1/basic_operations/get_campaigns.rb +0 -93
- data/examples/v201109_1/basic_operations/get_keywords.rb +0 -104
- data/examples/v201109_1/basic_operations/get_text_ads.rb +0 -106
- data/examples/v201109_1/basic_operations/pause_ad.rb +0 -84
- data/examples/v201109_1/basic_operations/update_ad_group.rb +0 -81
- data/examples/v201109_1/basic_operations/update_campaign.rb +0 -84
- data/examples/v201109_1/basic_operations/update_keyword.rb +0 -99
- data/examples/v201109_1/campaign_management/add_experiment.rb +0 -158
- data/examples/v201109_1/campaign_management/add_keywords_in_bulk.rb +0 -150
- data/examples/v201109_1/campaign_management/add_location_extension.rb +0 -117
- data/examples/v201109_1/campaign_management/add_location_extension_override.rb +0 -83
- data/examples/v201109_1/campaign_management/get_all_disapproved_ads.rb +0 -93
- data/examples/v201109_1/campaign_management/promote_experiment.rb +0 -77
- data/examples/v201109_1/campaign_management/set_ad_parameters.rb +0 -114
- data/examples/v201109_1/campaign_management/validate_text_ad.rb +0 -106
- data/examples/v201109_1/error_handling/handle_captcha_challenge.rb +0 -93
- data/examples/v201109_1/error_handling/handle_partial_failures.rb +0 -126
- data/examples/v201109_1/error_handling/handle_policy_violation_error.rb +0 -137
- data/examples/v201109_1/error_handling/handle_two_factor_authorization_error.rb +0 -87
- data/examples/v201109_1/misc/get_all_images_and_videos.rb +0 -100
- data/examples/v201109_1/misc/upload_image.rb +0 -89
- data/examples/v201109_1/misc/use_oauth.rb +0 -100
- data/examples/v201109_1/misc/use_oauth2.rb +0 -97
- data/examples/v201109_1/optimization/estimate_keyword_traffic.rb +0 -129
- data/examples/v201109_1/optimization/get_keyword_bid_simulations.rb +0 -92
- data/examples/v201109_1/optimization/get_keyword_ideas.rb +0 -112
- data/examples/v201109_1/optimization/get_placement_ideas.rb +0 -104
- data/examples/v201109_1/remarketing/add_audience.rb +0 -115
- data/examples/v201109_1/remarketing/add_conversion_tracker.rb +0 -97
- data/examples/v201109_1/reporting/download_criteria_report.rb +0 -79
- data/examples/v201109_1/reporting/get_campaign_stats.rb +0 -105
- data/examples/v201109_1/reporting/get_defined_reports.rb +0 -75
- data/examples/v201109_1/reporting/get_report_fields.rb +0 -71
- data/examples/v201109_1/reporting/parallel_report_download.rb +0 -159
- data/examples/v201109_1/targeting/add_campaign_targeting_criteria.rb +0 -118
- data/examples/v201109_1/targeting/get_campaign_targeting_criteria.rb +0 -102
- data/examples/v201109_1/targeting/get_targetable_languages_and_carriers.rb +0 -86
- data/examples/v201109_1/targeting/lookup_location.rb +0 -103
- data/examples/v201206/misc/use_oauth.rb +0 -100
- data/examples/v201209/misc/use_oauth.rb +0 -100
- data/lib/adwords_api/v201109/ad_extension_override_service.rb +0 -38
- data/lib/adwords_api/v201109/ad_extension_override_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/ad_group_ad_service.rb +0 -38
- data/lib/adwords_api/v201109/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/ad_group_criterion_service.rb +0 -38
- data/lib/adwords_api/v201109/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/ad_group_service.rb +0 -38
- data/lib/adwords_api/v201109/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/ad_param_service.rb +0 -38
- data/lib/adwords_api/v201109/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/alert_service.rb +0 -34
- data/lib/adwords_api/v201109/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/budget_order_service.rb +0 -42
- data/lib/adwords_api/v201109/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/bulk_mutate_job_service.rb +0 -38
- data/lib/adwords_api/v201109/bulk_mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/campaign_ad_extension_service.rb +0 -38
- data/lib/adwords_api/v201109/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/campaign_criterion_service.rb +0 -38
- data/lib/adwords_api/v201109/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/campaign_service.rb +0 -38
- data/lib/adwords_api/v201109/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/campaign_target_service.rb +0 -38
- data/lib/adwords_api/v201109/campaign_target_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/constant_data_service.rb +0 -38
- data/lib/adwords_api/v201109/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/conversion_tracker_service.rb +0 -38
- data/lib/adwords_api/v201109/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/create_account_service.rb +0 -34
- data/lib/adwords_api/v201109/create_account_service_registry.rb +0 -47
- data/lib/adwords_api/v201109/customer_sync_service.rb +0 -34
- data/lib/adwords_api/v201109/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201109/data_service.rb +0 -38
- data/lib/adwords_api/v201109/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/experiment_service.rb +0 -38
- data/lib/adwords_api/v201109/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/geo_location_service.rb +0 -34
- data/lib/adwords_api/v201109/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/info_service.rb +0 -34
- data/lib/adwords_api/v201109/info_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/location_criterion_service.rb +0 -34
- data/lib/adwords_api/v201109/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/media_service.rb +0 -38
- data/lib/adwords_api/v201109/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/mutate_job_service.rb +0 -42
- data/lib/adwords_api/v201109/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/report_definition_service.rb +0 -38
- data/lib/adwords_api/v201109/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/serviced_account_service.rb +0 -34
- data/lib/adwords_api/v201109/serviced_account_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201109/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/traffic_estimator_service.rb +0 -34
- data/lib/adwords_api/v201109/traffic_estimator_service_registry.rb +0 -46
- data/lib/adwords_api/v201109/user_list_service.rb +0 -38
- data/lib/adwords_api/v201109/user_list_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/ad_extension_override_service.rb +0 -38
- data/lib/adwords_api/v201109_1/ad_extension_override_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/ad_group_ad_service.rb +0 -38
- data/lib/adwords_api/v201109_1/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/ad_group_criterion_service.rb +0 -38
- data/lib/adwords_api/v201109_1/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/ad_group_service.rb +0 -38
- data/lib/adwords_api/v201109_1/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/ad_param_service.rb +0 -38
- data/lib/adwords_api/v201109_1/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/alert_service.rb +0 -34
- data/lib/adwords_api/v201109_1/alert_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/budget_order_service.rb +0 -42
- data/lib/adwords_api/v201109_1/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/bulk_mutate_job_service.rb +0 -38
- data/lib/adwords_api/v201109_1/bulk_mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/campaign_ad_extension_service.rb +0 -38
- data/lib/adwords_api/v201109_1/campaign_ad_extension_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/campaign_criterion_service.rb +0 -38
- data/lib/adwords_api/v201109_1/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/campaign_service.rb +0 -38
- data/lib/adwords_api/v201109_1/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/campaign_target_service.rb +0 -38
- data/lib/adwords_api/v201109_1/campaign_target_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/constant_data_service.rb +0 -38
- data/lib/adwords_api/v201109_1/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/conversion_tracker_service.rb +0 -38
- data/lib/adwords_api/v201109_1/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/create_account_service.rb +0 -34
- data/lib/adwords_api/v201109_1/create_account_service_registry.rb +0 -47
- data/lib/adwords_api/v201109_1/customer_service.rb +0 -34
- data/lib/adwords_api/v201109_1/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/customer_sync_service.rb +0 -34
- data/lib/adwords_api/v201109_1/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201109_1/data_service.rb +0 -38
- data/lib/adwords_api/v201109_1/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/experiment_service.rb +0 -38
- data/lib/adwords_api/v201109_1/experiment_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/geo_location_service.rb +0 -34
- data/lib/adwords_api/v201109_1/geo_location_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/info_service.rb +0 -34
- data/lib/adwords_api/v201109_1/info_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/location_criterion_service.rb +0 -34
- data/lib/adwords_api/v201109_1/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/managed_customer_service.rb +0 -38
- data/lib/adwords_api/v201109_1/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/media_service.rb +0 -38
- data/lib/adwords_api/v201109_1/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/mutate_job_service.rb +0 -42
- data/lib/adwords_api/v201109_1/mutate_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/report_definition_service.rb +0 -38
- data/lib/adwords_api/v201109_1/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/serviced_account_service.rb +0 -34
- data/lib/adwords_api/v201109_1/serviced_account_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201109_1/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/traffic_estimator_service.rb +0 -34
- data/lib/adwords_api/v201109_1/traffic_estimator_service_registry.rb +0 -46
- data/lib/adwords_api/v201109_1/user_list_service.rb +0 -38
- data/lib/adwords_api/v201109_1/user_list_service_registry.rb +0 -46
- data/test/examples/v201109/test_account_management.rb +0 -60
- data/test/examples/v201109/test_basic_operations.rb +0 -172
- data/test/examples/v201109/test_campaign_management.rb +0 -116
- data/test/examples/v201109/test_error_handling.rb +0 -63
- data/test/examples/v201109/test_misc.rb +0 -45
- data/test/examples/v201109/test_optimization.rb +0 -63
- data/test/examples/v201109/test_remarketing.rb +0 -39
- data/test/examples/v201109/test_reporting.rb +0 -72
- data/test/examples/v201109/test_targeting.rb +0 -60
- data/test/examples/v201109/utils.rb +0 -238
- data/test/examples/v201109_1/test_account_management.rb +0 -60
- data/test/examples/v201109_1/test_basic_operations.rb +0 -172
- data/test/examples/v201109_1/test_campaign_management.rb +0 -116
- data/test/examples/v201109_1/test_error_handling.rb +0 -63
- data/test/examples/v201109_1/test_misc.rb +0 -45
- data/test/examples/v201109_1/test_optimization.rb +0 -63
- data/test/examples/v201109_1/test_remarketing.rb +0 -39
- data/test/examples/v201109_1/test_reporting.rb +0 -72
- data/test/examples/v201109_1/test_targeting.rb +0 -60
- data/test/examples/v201109_1/utils.rb +0 -238
- data/test/suite_exampletests_v201109_1.rb +0 -37
@@ -1,75 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.sgomes@gmail.com (Sérgio Gomes)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example gets all report definitions. Adding new definitions is
|
22
|
-
# deprecated, please use AdHoc reporting.
|
23
|
-
#
|
24
|
-
# Tags: ReportDefinitionService.get
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def get_defined_reports()
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
report_def_srv = adwords.service(:ReportDefinitionService, API_VERSION)
|
38
|
-
|
39
|
-
# Get all the report definitions.
|
40
|
-
selector = {}
|
41
|
-
response = report_def_srv.get(selector)
|
42
|
-
if response and response[:entries]
|
43
|
-
entries = response[:entries]
|
44
|
-
puts "#{entries.length} report definition(s) found."
|
45
|
-
entries.each do |entry|
|
46
|
-
puts " Report definition id is #{entry[:id]} and name is " +
|
47
|
-
"\"#{entry[:report_name]}\"."
|
48
|
-
end
|
49
|
-
else
|
50
|
-
puts 'No report definitions found.'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if __FILE__ == $0
|
55
|
-
API_VERSION = :v201109
|
56
|
-
|
57
|
-
begin
|
58
|
-
get_defined_reports()
|
59
|
-
|
60
|
-
# HTTP errors.
|
61
|
-
rescue AdsCommon::Errors::HttpError => e
|
62
|
-
puts "HTTP Error: %s" % e
|
63
|
-
|
64
|
-
# API errors.
|
65
|
-
rescue AdwordsApi::Errors::ApiException => e
|
66
|
-
puts "Message: %s" % e.message
|
67
|
-
puts 'Errors:'
|
68
|
-
e.errors.each_with_index do |error, index|
|
69
|
-
puts "\tError [%d]:" % (index + 1)
|
70
|
-
error.each do |field, value|
|
71
|
-
puts "\t\t%s: %s" % [field, value]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.sgomes@gmail.com (Sérgio Gomes)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example gets the list of possible report fields for a report type.
|
22
|
-
#
|
23
|
-
# Tags: ReportDefinitionService.getReportFields
|
24
|
-
|
25
|
-
require 'adwords_api'
|
26
|
-
|
27
|
-
def get_report_fields(report_type)
|
28
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
29
|
-
# when called without parameters.
|
30
|
-
adwords = AdwordsApi::Api.new
|
31
|
-
|
32
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
33
|
-
# the configuration file or provide your own logger:
|
34
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
35
|
-
|
36
|
-
report_def_srv = adwords.service(:ReportDefinitionService, API_VERSION)
|
37
|
-
|
38
|
-
# Get report fields.
|
39
|
-
fields = report_def_srv.get_report_fields(report_type)
|
40
|
-
if fields
|
41
|
-
puts "Report type '%s' contains the following fields:" % report_type
|
42
|
-
fields.each do |field|
|
43
|
-
puts ' - %s (%s)' % [field[:field_name], field[:field_type]]
|
44
|
-
puts ' := [%s]' % field[:enum_values].join(', ') if field[:enum_values]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
if __FILE__ == $0
|
50
|
-
API_VERSION = :v201109
|
51
|
-
|
52
|
-
begin
|
53
|
-
report_type = 'INSERT_REPORT_TYPE_HERE'
|
54
|
-
get_report_fields(report_type)
|
55
|
-
|
56
|
-
# HTTP errors.
|
57
|
-
rescue AdsCommon::Errors::HttpError => e
|
58
|
-
puts "HTTP Error: %s" % e
|
59
|
-
|
60
|
-
# API errors.
|
61
|
-
rescue AdwordsApi::Errors::ApiException => e
|
62
|
-
puts "Message: %s" % e.message
|
63
|
-
puts 'Errors:'
|
64
|
-
e.errors.each_with_index do |error, index|
|
65
|
-
puts "\tError [%d]:" % (index + 1)
|
66
|
-
error.each do |field, value|
|
67
|
-
puts "\t\t%s: %s" % [field, value]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,159 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example gets and downloads an Ad Hoc report from a XML report definition.
|
22
|
-
|
23
|
-
require 'thread'
|
24
|
-
|
25
|
-
require 'adwords_api'
|
26
|
-
require 'adwords_api/utils'
|
27
|
-
|
28
|
-
def parallel_report_download()
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
# Determine list of customer IDs to retrieve report for. For this example we
|
38
|
-
# will use ServicedAccountService to get all IDs in hierarchy.
|
39
|
-
|
40
|
-
serviced_account_srv = adwords.service(:ServicedAccountService, API_VERSION)
|
41
|
-
|
42
|
-
# Get the account hierarchy for this account.
|
43
|
-
selector = {:enable_paging => false}
|
44
|
-
|
45
|
-
# Run the request at the MCC level.
|
46
|
-
graph = adwords.use_mcc() {serviced_account_srv.get(selector)}
|
47
|
-
|
48
|
-
# Using queue to balance load between threads.
|
49
|
-
queue = Queue.new()
|
50
|
-
|
51
|
-
if graph and graph[:accounts] and !graph[:accounts].empty?
|
52
|
-
graph[:accounts].each {|account| queue << account[:customer_id]}
|
53
|
-
else
|
54
|
-
raise StandardError, 'Can not retrieve any customer ID'
|
55
|
-
end
|
56
|
-
|
57
|
-
# Get report utilities for the version.
|
58
|
-
report_utils = adwords.report_utils(API_VERSION)
|
59
|
-
|
60
|
-
# Define report definition. You can also pass your own XML text as a string.
|
61
|
-
report_definition = {
|
62
|
-
:selector => {
|
63
|
-
:fields => ['CampaignId', 'Id', 'Impressions', 'Clicks', 'Cost'],
|
64
|
-
# Predicates are optional.
|
65
|
-
:predicates => {
|
66
|
-
:field => 'Status',
|
67
|
-
:operator => 'IN',
|
68
|
-
:values => ['ENABLED', 'PAUSED']
|
69
|
-
}
|
70
|
-
},
|
71
|
-
:report_name => 'Custom ADGROUP_PERFORMANCE_REPORT',
|
72
|
-
:report_type => 'ADGROUP_PERFORMANCE_REPORT',
|
73
|
-
:download_format => 'CSV',
|
74
|
-
:date_range_type => 'LAST_7_DAYS',
|
75
|
-
# Enable to get rows with zero impressions.
|
76
|
-
:include_zero_impressions => false
|
77
|
-
}
|
78
|
-
|
79
|
-
puts "Retrieving %d reports with %d threads:" % [queue.size, THREADS]
|
80
|
-
|
81
|
-
reports_succeeded = Queue.new()
|
82
|
-
reports_failed = Queue.new()
|
83
|
-
|
84
|
-
# Creating a mutex to control access to the queue.
|
85
|
-
queue_mutex = Mutex.new
|
86
|
-
|
87
|
-
# Start all the threads.
|
88
|
-
threads = (1..THREADS).map do |thread_id|
|
89
|
-
Thread.new(report_definition) do |local_def|
|
90
|
-
cid = nil
|
91
|
-
begin
|
92
|
-
cid = queue_mutex.synchronize {(queue.empty?) ? nil : queue.pop(true)}
|
93
|
-
if cid
|
94
|
-
retry_count = 0
|
95
|
-
file_name = "adgroup_%010d.csv" % cid
|
96
|
-
puts "[%2d/%d] Loading report for customer ID %s into '%s'..." %
|
97
|
-
[thread_id, retry_count,
|
98
|
-
AdwordsApi::Utils.format_id(cid), file_name]
|
99
|
-
begin
|
100
|
-
report_utils.download_report_as_file(local_def, file_name, cid)
|
101
|
-
reports_succeeded << {:cid => cid, :file_name => file_name}
|
102
|
-
rescue AdwordsApi::Errors::ReportError => e
|
103
|
-
if e.http_code == 500 && retry_count < MAX_RETRIES
|
104
|
-
retry_count += 1
|
105
|
-
sleep(retry_count * BACKOFF_FACTOR)
|
106
|
-
retry
|
107
|
-
else
|
108
|
-
puts(("Report failed for customer ID %s with code %d after %d " +
|
109
|
-
"retries.") % [cid, e.http_code, retry_count + 1])
|
110
|
-
reports_failed <<
|
111
|
-
{:cid => cid, :http_code => e.http_code, :message => e.message}
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end while (cid != nil)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# Wait for all threads to finish.
|
120
|
-
threads.each { |aThread| aThread.join }
|
121
|
-
|
122
|
-
puts 'Download completed, results:'
|
123
|
-
puts 'Successful reports:'
|
124
|
-
while !reports_succeeded.empty? do
|
125
|
-
result = reports_succeeded.pop()
|
126
|
-
puts "\tClient ID %s => '%s'" %
|
127
|
-
[AdwordsApi::Utils.format_id(result[:cid]), result[:file_name]]
|
128
|
-
end
|
129
|
-
puts 'Failed reports:'
|
130
|
-
while !reports_failed.empty? do
|
131
|
-
result = reports_failed.pop()
|
132
|
-
puts "\tClient ID %s => Code: %d, Message: '%s'" %
|
133
|
-
[AdwordsApi::Utils.format_id(result[:cid]),
|
134
|
-
result[:http_code], result[:message]]
|
135
|
-
end
|
136
|
-
puts 'End of results.'
|
137
|
-
end
|
138
|
-
|
139
|
-
if __FILE__ == $0
|
140
|
-
API_VERSION = :v201109
|
141
|
-
# Number of parallel threads to spawn.
|
142
|
-
THREADS = 10
|
143
|
-
# Maximum number of retries for 500 errors.
|
144
|
-
MAX_RETRIES = 5
|
145
|
-
# Timeout between retries in seconds.
|
146
|
-
BACKOFF_FACTOR = 5
|
147
|
-
|
148
|
-
begin
|
149
|
-
parallel_report_download()
|
150
|
-
|
151
|
-
# HTTP errors.
|
152
|
-
rescue AdsCommon::Errors::HttpError => e
|
153
|
-
puts "HTTP Error: %s" % e
|
154
|
-
|
155
|
-
# API errors.
|
156
|
-
rescue AdwordsApi::Errors::ReportError => e
|
157
|
-
puts "Reporting Error: %s" % e.message
|
158
|
-
end
|
159
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example adds various types of targeting criteria to a campaign. To get
|
22
|
-
# campaigns list, run get_campaigns.rb.
|
23
|
-
#
|
24
|
-
# Tags: CampaignCriterionService.mutate
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def add_campaign_targeting_criteria(campaign_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
campaign_criterion_srv =
|
38
|
-
adwords.service(:CampaignCriterionService, API_VERSION)
|
39
|
-
|
40
|
-
# Create campaign criteria.
|
41
|
-
campaign_criteria = [
|
42
|
-
# Location criteria. The IDs can be found in the documentation or retrieved
|
43
|
-
# with the LocationCriterionService.
|
44
|
-
{:xsi_type => 'Location', :id => 21137}, # California, USA
|
45
|
-
{:xsi_type => 'Location', :id => 2484}, # Mexico
|
46
|
-
# Language criteria. The IDs can be found in the documentation or retrieved
|
47
|
-
# with the ConstantDataService.
|
48
|
-
{:xsi_type => 'Language', :id => 1000}, # English
|
49
|
-
{:xsi_type => 'Language', :id => 1003}, # Spanish
|
50
|
-
# Platform criteria. The IDs can be found in the documentation.
|
51
|
-
{:xsi_type => 'Platform', :id => 30001}, # Mobile
|
52
|
-
{:xsi_type => 'Platform', :id => 30002} # Tablets
|
53
|
-
]
|
54
|
-
|
55
|
-
# Create operations.
|
56
|
-
operations = campaign_criteria.map do |criterion|
|
57
|
-
{:operator => 'ADD',
|
58
|
-
:operand => {
|
59
|
-
:campaign_id => campaign_id,
|
60
|
-
:criterion => criterion}
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
# Add negative campaign criterion.
|
65
|
-
operations << {
|
66
|
-
:operator => 'ADD',
|
67
|
-
:operand => {
|
68
|
-
# The 'xsi_type' field allows you to specify the xsi:type of the object
|
69
|
-
# being created. It's only necessary when you must provide an explicit
|
70
|
-
# type that the client library can't infer.
|
71
|
-
:xsi_type => 'NegativeCampaignCriterion',
|
72
|
-
:campaign_id => campaign_id,
|
73
|
-
:criterion => {
|
74
|
-
:xsi_type => 'Keyword',
|
75
|
-
:text => 'jupiter cruise',
|
76
|
-
:match_type => 'BROAD'
|
77
|
-
}
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
response = campaign_criterion_srv.mutate(operations)
|
82
|
-
|
83
|
-
if response and response[:value]
|
84
|
-
criteria = response[:value]
|
85
|
-
criteria.each do |campaign_criterion|
|
86
|
-
criterion = campaign_criterion[:criterion]
|
87
|
-
puts ("Campaign criterion with campaign ID %d, criterion ID %d and " +
|
88
|
-
"type '%s' was added.") % [campaign_criterion[:campaign_id],
|
89
|
-
criterion[:id], criterion[:criterion_type]]
|
90
|
-
end
|
91
|
-
else
|
92
|
-
puts 'No criteria were returned.'
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
if __FILE__ == $0
|
97
|
-
API_VERSION = :v201109
|
98
|
-
|
99
|
-
begin
|
100
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'
|
101
|
-
add_campaign_targeting_criteria(campaign_id)
|
102
|
-
|
103
|
-
# HTTP errors.
|
104
|
-
rescue AdsCommon::Errors::HttpError => e
|
105
|
-
puts "HTTP Error: %s" % e
|
106
|
-
|
107
|
-
# API errors.
|
108
|
-
rescue AdwordsApi::Errors::ApiException => e
|
109
|
-
puts "Message: %s" % e.message
|
110
|
-
puts 'Errors:'
|
111
|
-
e.errors.each_with_index do |error, index|
|
112
|
-
puts "\tError [%d]:" % (index + 1)
|
113
|
-
error.each do |field, value|
|
114
|
-
puts "\t\t%s: %s" % [field, value]
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Encoding: utf-8
|
3
|
-
#
|
4
|
-
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
-
#
|
6
|
-
# Copyright:: Copyright 2011, Google Inc. All Rights Reserved.
|
7
|
-
#
|
8
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
-
# you may not use this file except in compliance with the License.
|
10
|
-
# You may obtain a copy of the License at
|
11
|
-
#
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
-
#
|
14
|
-
# Unless required by applicable law or agreed to in writing, software
|
15
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
17
|
-
# implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
# This example illustrates how to retrieve all the campaign targets. To set
|
22
|
-
# campaign targets, run add_campaign_targeting_criteria.rb.
|
23
|
-
#
|
24
|
-
# Tags: CampaignCriterionService.get
|
25
|
-
|
26
|
-
require 'adwords_api'
|
27
|
-
|
28
|
-
def get_campaign_targeting_criteria(campaign_id)
|
29
|
-
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
30
|
-
# when called without parameters.
|
31
|
-
adwords = AdwordsApi::Api.new
|
32
|
-
|
33
|
-
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
34
|
-
# the configuration file or provide your own logger:
|
35
|
-
# adwords.logger = Logger.new('adwords_xml.log')
|
36
|
-
|
37
|
-
campaign_criterion_srv =
|
38
|
-
adwords.service(:CampaignCriterionService, API_VERSION)
|
39
|
-
|
40
|
-
# Selector to get all the targeting for this campaign.
|
41
|
-
selector = {
|
42
|
-
:fields => ['Id', 'CriteriaType', 'KeywordText'],
|
43
|
-
:predicates => [
|
44
|
-
{:field => 'CampaignId', :operator => 'EQUALS', :values => [campaign_id]}
|
45
|
-
],
|
46
|
-
:paging => {
|
47
|
-
:start_index => 0,
|
48
|
-
:number_results => PAGE_SIZE
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
# Set initial values.
|
53
|
-
offset, page = 0, {}
|
54
|
-
|
55
|
-
begin
|
56
|
-
page = campaign_criterion_srv.get(selector)
|
57
|
-
if page[:entries]
|
58
|
-
page[:entries].each do |typed_criterion|
|
59
|
-
negative = typed_criterion[:xsi_type] == 'NegativeCampaignCriterion' ?
|
60
|
-
' (negative)' : ''
|
61
|
-
criterion = typed_criterion[:criterion]
|
62
|
-
puts ("Campaign criterion%s with ID %d, type '%s' and text '%s'" +
|
63
|
-
" was found.") %
|
64
|
-
[negative, criterion[:id], criterion[:type], criterion[:text]]
|
65
|
-
end
|
66
|
-
# Increment values to request the next page.
|
67
|
-
offset += PAGE_SIZE
|
68
|
-
selector[:paging][:start_index] = offset
|
69
|
-
end
|
70
|
-
end while page[:total_num_entries] > offset
|
71
|
-
|
72
|
-
if page.include?(:total_num_entries)
|
73
|
-
puts "\tCampaign ID %d has %d criteria." %
|
74
|
-
[campaign_id, page[:total_num_entries]]
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
if __FILE__ == $0
|
79
|
-
API_VERSION = :v201109
|
80
|
-
PAGE_SIZE = 500
|
81
|
-
|
82
|
-
begin
|
83
|
-
# Specify campaign ID to get targeting for.
|
84
|
-
campaign_id = 'INSERT_CAMPAIGN_ID_HERE'.to_i
|
85
|
-
get_campaign_targeting_criteria(campaign_id)
|
86
|
-
|
87
|
-
# HTTP errors.
|
88
|
-
rescue AdsCommon::Errors::HttpError => e
|
89
|
-
puts "HTTP Error: %s" % e
|
90
|
-
|
91
|
-
# API errors.
|
92
|
-
rescue AdwordsApi::Errors::ApiException => e
|
93
|
-
puts "Message: %s" % e.message
|
94
|
-
puts 'Errors:'
|
95
|
-
e.errors.each_with_index do |error, index|
|
96
|
-
puts "\tError [%d]:" % (index + 1)
|
97
|
-
error.each do |field, value|
|
98
|
-
puts "\t\t%s: %s" % [field, value]
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|