google-adwords-api 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/README +4 -4
- data/examples/v201109_1/account_management/create_account.rb +80 -0
- data/examples/v201109_1/account_management/get_account_alerts.rb +111 -0
- data/examples/v201109_1/account_management/get_account_changes.rb +137 -0
- data/examples/v201109_1/account_management/get_account_hierarchy.rb +93 -0
- data/examples/v201109_1/account_management/get_client_customer_id.rb +85 -0
- data/examples/v201109_1/account_management/get_client_unit_usage.rb +87 -0
- data/examples/v201109_1/basic_operations/add_ad_groups.rb +111 -0
- data/examples/v201109_1/basic_operations/add_campaigns.rb +140 -0
- data/examples/v201109_1/basic_operations/add_keywords.rb +108 -0
- data/examples/v201109_1/basic_operations/add_text_ads.rb +105 -0
- data/examples/v201109_1/basic_operations/delete_ad.rb +85 -0
- data/examples/v201109_1/basic_operations/delete_ad_group.rb +102 -0
- data/examples/v201109_1/basic_operations/delete_campaign.rb +103 -0
- data/examples/v201109_1/basic_operations/delete_keyword.rb +90 -0
- data/examples/v201109_1/basic_operations/get_ad_groups.rb +98 -0
- data/examples/v201109_1/basic_operations/get_campaigns.rb +93 -0
- data/examples/v201109_1/basic_operations/get_keywords.rb +104 -0
- data/examples/v201109_1/basic_operations/get_text_ads.rb +106 -0
- data/examples/v201109_1/basic_operations/pause_ad.rb +84 -0
- data/examples/v201109_1/basic_operations/update_ad_group.rb +81 -0
- data/examples/v201109_1/basic_operations/update_campaign.rb +84 -0
- data/examples/v201109_1/basic_operations/update_keyword.rb +99 -0
- data/examples/v201109_1/campaign_management/add_experiment.rb +158 -0
- data/examples/v201109_1/campaign_management/add_keywords_in_bulk.rb +150 -0
- data/examples/v201109_1/campaign_management/add_location_extension.rb +117 -0
- data/examples/v201109_1/campaign_management/add_location_extension_override.rb +83 -0
- data/examples/v201109_1/campaign_management/get_all_disapproved_ads.rb +93 -0
- data/examples/v201109_1/campaign_management/promote_experiment.rb +77 -0
- data/examples/v201109_1/campaign_management/set_ad_parameters.rb +114 -0
- data/examples/v201109_1/campaign_management/validate_text_ad.rb +106 -0
- data/examples/v201109_1/error_handling/handle_captcha_challenge.rb +93 -0
- data/examples/v201109_1/error_handling/handle_partial_failures.rb +126 -0
- data/examples/v201109_1/error_handling/handle_policy_violation_error.rb +137 -0
- data/examples/v201109_1/error_handling/handle_two_factor_authorization_error.rb +87 -0
- data/examples/v201109_1/misc/get_all_images_and_videos.rb +101 -0
- data/examples/v201109_1/misc/upload_image.rb +90 -0
- data/examples/v201109_1/misc/use_oauth.rb +97 -0
- data/examples/v201109_1/optimization/estimate_keyword_traffic.rb +129 -0
- data/examples/v201109_1/optimization/get_keyword_bid_simulations.rb +92 -0
- data/examples/v201109_1/optimization/get_keyword_ideas.rb +113 -0
- data/examples/v201109_1/optimization/get_placement_ideas.rb +106 -0
- data/examples/v201109_1/remarketing/add_audience.rb +115 -0
- data/examples/v201109_1/remarketing/add_conversion_tracker.rb +97 -0
- data/examples/v201109_1/reporting/download_criteria_report.rb +79 -0
- data/examples/v201109_1/reporting/get_campaign_stats.rb +105 -0
- data/examples/v201109_1/reporting/get_defined_reports.rb +75 -0
- data/examples/{v201109/reporting/download_defined_report.rb → v201109_1/reporting/get_report_fields.rb} +15 -11
- data/examples/v201109_1/reporting/parallel_report_download.rb +159 -0
- data/examples/v201109_1/targeting/add_campaign_targeting_criteria.rb +118 -0
- data/examples/v201109_1/targeting/get_campaign_targeting_criteria.rb +102 -0
- data/examples/v201109_1/targeting/get_targetable_languages_and_carriers.rb +86 -0
- data/examples/v201109_1/targeting/lookup_location.rb +103 -0
- data/lib/adwords_api.rb +15 -88
- data/lib/adwords_api/api_config.rb +75 -33
- data/lib/adwords_api/client_login_header_handler.rb +17 -26
- data/lib/adwords_api/credential_handler.rb +29 -65
- data/lib/adwords_api/report_header_handler.rb +65 -0
- data/lib/adwords_api/report_utils.rb +12 -36
- data/lib/adwords_api/v201109/ad_extension_override_service.rb +3 -3
- data/lib/adwords_api/v201109/ad_extension_override_service_registry.rb +2 -2
- data/lib/adwords_api/v201109/ad_group_ad_service.rb +3 -3
- data/lib/adwords_api/v201109/ad_group_ad_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/ad_group_criterion_service.rb +3 -3
- data/lib/adwords_api/v201109/ad_group_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/ad_group_service.rb +3 -3
- data/lib/adwords_api/v201109/ad_group_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/ad_param_service.rb +3 -3
- data/lib/adwords_api/v201109/ad_param_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/alert_service.rb +3 -3
- data/lib/adwords_api/v201109/alert_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/budget_order_service.rb +42 -0
- data/lib/adwords_api/v201109/budget_order_service_registry.rb +46 -0
- data/lib/adwords_api/v201109/bulk_mutate_job_service.rb +3 -3
- data/lib/adwords_api/v201109/bulk_mutate_job_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/campaign_ad_extension_service.rb +3 -3
- data/lib/adwords_api/v201109/campaign_ad_extension_service_registry.rb +2 -2
- data/lib/adwords_api/v201109/campaign_criterion_service.rb +3 -3
- data/lib/adwords_api/v201109/campaign_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/campaign_service.rb +3 -3
- data/lib/adwords_api/v201109/campaign_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/campaign_target_service.rb +3 -3
- data/lib/adwords_api/v201109/campaign_target_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/constant_data_service.rb +3 -3
- data/lib/adwords_api/v201109/constant_data_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/conversion_tracker_service.rb +3 -3
- data/lib/adwords_api/v201109/conversion_tracker_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/create_account_service.rb +3 -3
- data/lib/adwords_api/v201109/create_account_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/customer_sync_service.rb +3 -3
- data/lib/adwords_api/v201109/customer_sync_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/data_service.rb +3 -3
- data/lib/adwords_api/v201109/data_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/experiment_service.rb +3 -3
- data/lib/adwords_api/v201109/experiment_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/geo_location_service.rb +3 -3
- data/lib/adwords_api/v201109/geo_location_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/info_service.rb +3 -3
- data/lib/adwords_api/v201109/info_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/location_criterion_service.rb +3 -3
- data/lib/adwords_api/v201109/location_criterion_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/media_service.rb +3 -3
- data/lib/adwords_api/v201109/media_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/mutate_job_service.rb +3 -3
- data/lib/adwords_api/v201109/mutate_job_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/report_definition_service.rb +3 -12
- data/lib/adwords_api/v201109/report_definition_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/serviced_account_service.rb +3 -3
- data/lib/adwords_api/v201109/serviced_account_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/targeting_idea_service.rb +3 -3
- data/lib/adwords_api/v201109/targeting_idea_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/traffic_estimator_service.rb +3 -3
- data/lib/adwords_api/v201109/traffic_estimator_service_registry.rb +1 -1
- data/lib/adwords_api/v201109/user_list_service.rb +3 -3
- data/lib/adwords_api/v201109/user_list_service_registry.rb +1 -1
- data/lib/adwords_api/v201109_1/ad_extension_override_service.rb +38 -0
- data/lib/adwords_api/v201109_1/ad_extension_override_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/ad_group_ad_service.rb +38 -0
- data/lib/adwords_api/v201109_1/ad_group_ad_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/ad_group_criterion_service.rb +38 -0
- data/lib/adwords_api/v201109_1/ad_group_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/ad_group_service.rb +38 -0
- data/lib/adwords_api/v201109_1/ad_group_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/ad_param_service.rb +38 -0
- data/lib/adwords_api/v201109_1/ad_param_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/alert_service.rb +34 -0
- data/lib/adwords_api/v201109_1/alert_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/budget_order_service.rb +42 -0
- data/lib/adwords_api/v201109_1/budget_order_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/bulk_mutate_job_service.rb +38 -0
- data/lib/adwords_api/v201109_1/bulk_mutate_job_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/campaign_ad_extension_service.rb +38 -0
- data/lib/adwords_api/v201109_1/campaign_ad_extension_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/campaign_criterion_service.rb +38 -0
- data/lib/adwords_api/v201109_1/campaign_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/campaign_service.rb +38 -0
- data/lib/adwords_api/v201109_1/campaign_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/campaign_target_service.rb +38 -0
- data/lib/adwords_api/v201109_1/campaign_target_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/constant_data_service.rb +38 -0
- data/lib/adwords_api/v201109_1/constant_data_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/conversion_tracker_service.rb +38 -0
- data/lib/adwords_api/v201109_1/conversion_tracker_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/create_account_service.rb +34 -0
- data/lib/adwords_api/v201109_1/create_account_service_registry.rb +47 -0
- data/lib/adwords_api/v201109_1/customer_sync_service.rb +34 -0
- data/lib/adwords_api/v201109_1/customer_sync_service_registry.rb +47 -0
- data/lib/adwords_api/v201109_1/data_service.rb +38 -0
- data/lib/adwords_api/v201109_1/data_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/experiment_service.rb +38 -0
- data/lib/adwords_api/v201109_1/experiment_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/geo_location_service.rb +34 -0
- data/lib/adwords_api/v201109_1/geo_location_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/info_service.rb +34 -0
- data/lib/adwords_api/v201109_1/info_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/location_criterion_service.rb +34 -0
- data/lib/adwords_api/v201109_1/location_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/media_service.rb +38 -0
- data/lib/adwords_api/v201109_1/media_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/mutate_job_service.rb +42 -0
- data/lib/adwords_api/v201109_1/mutate_job_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/report_definition_service.rb +38 -0
- data/lib/adwords_api/v201109_1/report_definition_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/serviced_account_service.rb +34 -0
- data/lib/adwords_api/v201109_1/serviced_account_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/targeting_idea_service.rb +38 -0
- data/lib/adwords_api/v201109_1/targeting_idea_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/traffic_estimator_service.rb +34 -0
- data/lib/adwords_api/v201109_1/traffic_estimator_service_registry.rb +46 -0
- data/lib/adwords_api/v201109_1/user_list_service.rb +38 -0
- data/lib/adwords_api/v201109_1/user_list_service_registry.rb +46 -0
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_api_config.rb +24 -8
- data/test/adwords_api/test_credential_handler.rb +32 -52
- data/test/coverage.rb +38 -0
- data/test/examples/v201109/test_reporting.rb +0 -12
- data/test/examples/v201109_1/test_account_management.rb +60 -0
- data/test/examples/v201109_1/test_basic_operations.rb +172 -0
- data/test/examples/v201109_1/test_campaign_management.rb +116 -0
- data/test/examples/v201109_1/test_error_handling.rb +63 -0
- data/{lib/adwords_api/v13_login_handler.rb → test/examples/v201109_1/test_misc.rb} +24 -10
- data/test/examples/v201109_1/test_optimization.rb +63 -0
- data/test/{suite_exampletests.rb → examples/v201109_1/test_remarketing.rb} +16 -8
- data/test/examples/v201109_1/test_reporting.rb +77 -0
- data/test/examples/v201109_1/test_targeting.rb +60 -0
- data/test/examples/v201109_1/utils.rb +239 -0
- data/test/suite_exampletests_v201109.rb +37 -0
- data/test/suite_exampletests_v201109_1.rb +37 -0
- data/test/suite_unittests.rb +7 -5
- metadata +136 -11
- data/lib/adwords_api/extensions.rb +0 -269
@@ -0,0 +1,116 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2012, 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
|
+
# Tests the campaign management examples.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
require 'campaign_management/add_experiment'
|
26
|
+
require 'campaign_management/add_keywords_in_bulk'
|
27
|
+
require 'campaign_management/add_location_extension'
|
28
|
+
require 'campaign_management/add_location_extension_override'
|
29
|
+
require 'campaign_management/get_all_disapproved_ads'
|
30
|
+
require 'campaign_management/promote_experiment'
|
31
|
+
require 'campaign_management/set_ad_parameters'
|
32
|
+
require 'campaign_management/validate_text_ad'
|
33
|
+
|
34
|
+
RETRY_INTERVAL = 5
|
35
|
+
RETRIES_COUNT = 3
|
36
|
+
KEYWORD_NUMBER = 3
|
37
|
+
|
38
|
+
class TestCampaignManagementV201109_1 < Test::Unit::TestCase
|
39
|
+
def setup
|
40
|
+
@logger = Logger.new(STDOUT)
|
41
|
+
@logger.level = Logger::ERROR
|
42
|
+
@adwords = AdwordsApi::Api.new
|
43
|
+
@adwords.logger = @logger
|
44
|
+
@utils = UtilsV201109_1.new(@adwords)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_add_experiment
|
48
|
+
campaign = @utils.get_campaign()
|
49
|
+
ad_group = @utils.get_ad_group()
|
50
|
+
criterion = @utils.get_keyword()
|
51
|
+
assert_not_nil(campaign)
|
52
|
+
assert_not_nil(campaign[:id])
|
53
|
+
assert_not_nil(ad_group)
|
54
|
+
assert_not_nil(ad_group[:id])
|
55
|
+
assert_not_nil(criterion)
|
56
|
+
assert_not_nil(criterion[:criterion])
|
57
|
+
assert_not_nil(criterion[:criterion][:id])
|
58
|
+
add_experiment(campaign[:id], ad_group[:id], criterion[:criterion][:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_add_keywords_in_bulk
|
62
|
+
add_keywords_in_bulk()
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_add_location_extension
|
66
|
+
campaign = @utils.get_campaign()
|
67
|
+
assert_not_nil(campaign)
|
68
|
+
assert_not_nil(campaign[:id])
|
69
|
+
add_location_extension(campaign[:id])
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_add_location_extension_override
|
73
|
+
ad = @utils.get_ad()
|
74
|
+
location_extension = @utils.get_location_extension()
|
75
|
+
assert_not_nil(ad)
|
76
|
+
assert_not_nil(ad[:ad])
|
77
|
+
assert_not_nil(ad[:ad][:id])
|
78
|
+
assert_not_nil(location_extension)
|
79
|
+
assert_not_nil(location_extension[:ad_extension])
|
80
|
+
assert_not_nil(location_extension[:ad_extension][:id])
|
81
|
+
add_location_extension_override(
|
82
|
+
ad[:ad][:id], location_extension[:ad_extension][:id])
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_get_all_disapproved_ads
|
86
|
+
ad_group = @utils.get_ad_group()
|
87
|
+
assert_not_nil(ad_group)
|
88
|
+
assert_not_nil(ad_group[:id])
|
89
|
+
get_all_disapproved_ads(ad_group[:id])
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_promote_experiment
|
93
|
+
experiment = @utils.get_experiment()
|
94
|
+
assert_not_nil(experiment)
|
95
|
+
assert_not_nil(experiment[:id])
|
96
|
+
promote_experiment(experiment[:id])
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_set_ad_parameters
|
100
|
+
ad_group = @utils.get_ad_group()
|
101
|
+
assert_not_nil(ad_group)
|
102
|
+
assert_not_nil(ad_group[:id])
|
103
|
+
criterion = @utils.get_keyword()
|
104
|
+
assert_not_nil(criterion)
|
105
|
+
assert_not_nil(criterion[:criterion])
|
106
|
+
assert_not_nil(criterion[:criterion][:id])
|
107
|
+
set_ad_parameters(ad_group[:id], criterion[:criterion][:id])
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_validate_text_ad
|
111
|
+
ad_group = @utils.get_ad_group()
|
112
|
+
assert_not_nil(ad_group)
|
113
|
+
assert_not_nil(ad_group[:id])
|
114
|
+
validate_text_ad(ad_group[:id])
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2012, 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
|
+
# Tests the error handling examples.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
require 'error_handling/handle_captcha_challenge'
|
26
|
+
require 'error_handling/handle_partial_failures'
|
27
|
+
require 'error_handling/handle_policy_violation_error'
|
28
|
+
require 'error_handling/handle_two_factor_authorization_error'
|
29
|
+
|
30
|
+
MAX_RETRIES = 50
|
31
|
+
|
32
|
+
class TestErrorHandlingV201109_1 < Test::Unit::TestCase
|
33
|
+
def setup
|
34
|
+
@logger = Logger.new(STDOUT)
|
35
|
+
@logger.level = Logger::ERROR
|
36
|
+
@adwords = AdwordsApi::Api.new
|
37
|
+
@adwords.logger = @logger
|
38
|
+
@utils = UtilsV201109_1.new(@adwords)
|
39
|
+
end
|
40
|
+
|
41
|
+
# This test is disabled as it requires user input.
|
42
|
+
def disabled_test_handle_captcha_challenge
|
43
|
+
handle_captcha_challenge()
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_handle_partial_failures
|
47
|
+
ad_group = @utils.get_ad_group()
|
48
|
+
assert_not_nil(ad_group)
|
49
|
+
assert_not_nil(ad_group[:id])
|
50
|
+
handle_partial_failures(ad_group[:id])
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_handle_policy_violation_error
|
54
|
+
ad_group = @utils.get_ad_group()
|
55
|
+
assert_not_nil(ad_group)
|
56
|
+
assert_not_nil(ad_group[:id])
|
57
|
+
handle_policy_violation_error(ad_group[:id])
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_handle_two_factor_authorization_error
|
61
|
+
handle_two_factor_authorization_error()
|
62
|
+
end
|
63
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
1
2
|
# Encoding: utf-8
|
2
3
|
#
|
3
|
-
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
4
5
|
#
|
5
|
-
# Copyright:: Copyright
|
6
|
+
# Copyright:: Copyright 2012, Google Inc. All Rights Reserved.
|
6
7
|
#
|
7
8
|
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
8
9
|
# you may not use this file except in compliance with the License.
|
@@ -17,15 +18,28 @@
|
|
17
18
|
# See the License for the specific language governing permissions and
|
18
19
|
# limitations under the License.
|
19
20
|
#
|
20
|
-
#
|
21
|
+
# Tests the misc examples.
|
21
22
|
|
22
|
-
require '
|
23
|
+
require 'test/unit'
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
require 'misc/get_all_images_and_videos'
|
26
|
+
require 'misc/upload_image'
|
27
|
+
require 'misc/use_oauth'
|
28
|
+
|
29
|
+
class TestMiscV201109_1 < Test::Unit::TestCase
|
30
|
+
def setup
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_get_all_images_and_videos
|
34
|
+
get_all_images_and_videos()
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_upload_image
|
38
|
+
upload_image()
|
39
|
+
end
|
40
|
+
|
41
|
+
# This test is disabled as it requires user input.
|
42
|
+
def disabled_test_use_oauth
|
43
|
+
use_oauth()
|
30
44
|
end
|
31
45
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2012, 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
|
+
# Tests the optimization examples.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
require 'optimization/estimate_keyword_traffic'
|
26
|
+
require 'optimization/get_keyword_bid_simulations'
|
27
|
+
require 'optimization/get_keyword_ideas'
|
28
|
+
require 'optimization/get_placement_ideas'
|
29
|
+
|
30
|
+
class TestOptimizationV201109_1 < Test::Unit::TestCase
|
31
|
+
def setup
|
32
|
+
@logger = Logger.new(STDOUT)
|
33
|
+
@logger.level = Logger::ERROR
|
34
|
+
@adwords = AdwordsApi::Api.new
|
35
|
+
@adwords.logger = @logger
|
36
|
+
@utils = UtilsV201109_1.new(@adwords)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_estimate_keyword_traffic
|
40
|
+
estimate_keyword_traffic()
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_get_keyword_bid_simulations
|
44
|
+
ad_group = @utils.get_ad_group()
|
45
|
+
assert_not_nil(ad_group)
|
46
|
+
assert_not_nil(ad_group[:id])
|
47
|
+
keyword = @utils.get_keyword()
|
48
|
+
assert_not_nil(keyword)
|
49
|
+
assert_not_nil(keyword[:criterion])
|
50
|
+
assert_not_nil(keyword[:criterion][:id])
|
51
|
+
get_criterion_bid_landscapes(ad_group[:id], keyword[:criterion][:id])
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_get_keyword_ideas
|
55
|
+
keyword_text = 'orion tours'
|
56
|
+
get_keyword_ideas(keyword_text)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_get_placement_ideas
|
60
|
+
url = 'http://example.google.com'
|
61
|
+
get_placement_ideas(url)
|
62
|
+
end
|
63
|
+
end
|
@@ -18,14 +18,22 @@
|
|
18
18
|
# See the License for the specific language governing permissions and
|
19
19
|
# limitations under the License.
|
20
20
|
#
|
21
|
-
#
|
22
|
-
|
23
|
-
lib = File.expand_path('../../lib/', __FILE__)
|
24
|
-
$:.unshift lib unless $:.include?(lib)
|
21
|
+
# Tests the remarketing examples.
|
25
22
|
|
26
23
|
require 'test/unit'
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
require 'remarketing/add_audience'
|
26
|
+
require 'remarketing/add_conversion_tracker'
|
27
|
+
|
28
|
+
class TestRemarketingV201109_1 < Test::Unit::TestCase
|
29
|
+
def setup
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_add_audience
|
33
|
+
add_audience()
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_add_conversion_tracker
|
37
|
+
add_conversion_tracker()
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2012, 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
|
+
# Tests the reporting examples.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
require 'tempfile'
|
25
|
+
|
26
|
+
require 'reporting/download_criteria_report'
|
27
|
+
require 'reporting/get_campaign_stats'
|
28
|
+
require 'reporting/get_defined_reports'
|
29
|
+
require 'reporting/get_report_fields'
|
30
|
+
require 'reporting/parallel_report_download'
|
31
|
+
|
32
|
+
THREADS = 3
|
33
|
+
MAX_RETRIES = 3
|
34
|
+
BACKOFF_FACTOR = 3
|
35
|
+
|
36
|
+
class TestReportingV201109_1 < Test::Unit::TestCase
|
37
|
+
def setup
|
38
|
+
@logger = Logger.new(STDOUT)
|
39
|
+
@logger.level = Logger::ERROR
|
40
|
+
@adwords = AdwordsApi::Api.new
|
41
|
+
@adwords.logger = @logger
|
42
|
+
@utils = UtilsV201109_1.new(@adwords)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_download_criteria_report
|
46
|
+
file = Tempfile.new('ruby-examples')
|
47
|
+
begin
|
48
|
+
file.close()
|
49
|
+
download_criteria_report(file.path)
|
50
|
+
ensure
|
51
|
+
file.unlink()
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_get_campaign_stats
|
56
|
+
get_campaign_stats()
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_get_defined_reports
|
60
|
+
get_defined_reports()
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_get_report_fields
|
64
|
+
report_type = 'ACCOUNT_PERFORMANCE_REPORT'
|
65
|
+
get_report_fields(report_type)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_parallel_report_download
|
69
|
+
old_dir = Dir.pwd
|
70
|
+
Dir.chdir('/tmp')
|
71
|
+
begin
|
72
|
+
parallel_report_download()
|
73
|
+
ensure
|
74
|
+
Dir.chdir(old_dir)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Encoding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
5
|
+
#
|
6
|
+
# Copyright:: Copyright 2012, 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
|
+
# Tests the targeting examples.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
require 'targeting/add_campaign_targeting_criteria'
|
26
|
+
require 'targeting/get_campaign_targeting_criteria'
|
27
|
+
require 'targeting/get_targetable_languages_and_carriers'
|
28
|
+
require 'targeting/lookup_location'
|
29
|
+
|
30
|
+
class TestTargetingV201109_1 < Test::Unit::TestCase
|
31
|
+
def setup
|
32
|
+
@logger = Logger.new(STDOUT)
|
33
|
+
@logger.level = Logger::ERROR
|
34
|
+
@adwords = AdwordsApi::Api.new
|
35
|
+
@adwords.logger = @logger
|
36
|
+
@utils = UtilsV201109_1.new(@adwords)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_add_campaign_targeting_criteria
|
40
|
+
campaign = @utils.get_campaign()
|
41
|
+
assert_not_nil(campaign)
|
42
|
+
assert_not_nil(campaign[:id])
|
43
|
+
add_campaign_targeting_criteria(campaign[:id])
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_get_campaign_targeting_criteria
|
47
|
+
campaign = @utils.get_campaign()
|
48
|
+
assert_not_nil(campaign)
|
49
|
+
assert_not_nil(campaign[:id])
|
50
|
+
get_campaign_targeting_criteria(campaign[:id])
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_get_targetable_languages_and_carriers
|
54
|
+
get_targetable_languages_and_carriers()
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_lookup_location
|
58
|
+
lookup_location()
|
59
|
+
end
|
60
|
+
end
|