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,239 @@
|
|
1
|
+
# Encoding: utf-8
|
2
|
+
#
|
3
|
+
# Author:: api.dklimkin@gmail.com (Danial Klimkin)
|
4
|
+
#
|
5
|
+
# Copyright:: Copyright 2012, 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
|
+
# Utilities and constants for example tests.
|
21
|
+
|
22
|
+
API_VERSION = :v201109_1
|
23
|
+
PAGE_SIZE = 500
|
24
|
+
|
25
|
+
class UtilsV201109_1
|
26
|
+
def initialize(adwords)
|
27
|
+
@adwords = adwords
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_campaign
|
31
|
+
@campaign ||= create_campaign()
|
32
|
+
return @campaign
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_ad_group
|
36
|
+
@ad_group ||= create_ad_group()
|
37
|
+
return @ad_group
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_ad
|
41
|
+
@ad ||= create_ad(get_ad_group()[:id])
|
42
|
+
return @ad
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_keyword
|
46
|
+
@keyword ||= create_keyword(get_ad_group()[:id])
|
47
|
+
return @keyword
|
48
|
+
end
|
49
|
+
|
50
|
+
def get_location_extension
|
51
|
+
@location_extension ||= create_location_extension(get_campaign()[:id])
|
52
|
+
return @location_extension
|
53
|
+
end
|
54
|
+
|
55
|
+
def get_experiment
|
56
|
+
@experiment ||= create_experiment(
|
57
|
+
get_campaign()[:id], get_ad_group()[:id], get_keyword[:criterion][:id])
|
58
|
+
return @experiment
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def create_campaign
|
64
|
+
campaign_srv = @adwords.service(:CampaignService, API_VERSION)
|
65
|
+
campaign = {
|
66
|
+
:name => "Example tests campaign #%d" % (Time.new.to_f * 1000).to_i,
|
67
|
+
:status => 'PAUSED',
|
68
|
+
:bidding_strategy => {:xsi_type => 'ManualCPC'},
|
69
|
+
:budget => {
|
70
|
+
:period => 'DAILY',
|
71
|
+
:amount => {:micro_amount => 50000000},
|
72
|
+
:delivery_method => 'STANDARD'
|
73
|
+
},
|
74
|
+
:network_setting => {
|
75
|
+
:target_google_search => true,
|
76
|
+
:target_search_network => true,
|
77
|
+
:target_content_network => false,
|
78
|
+
:target_content_contextual => false
|
79
|
+
}
|
80
|
+
}
|
81
|
+
operation = {:operator => 'ADD', :operand => campaign}
|
82
|
+
response = campaign_srv.mutate([operation])
|
83
|
+
return response[:value].first
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_ad_group
|
87
|
+
campaign = get_campaign()
|
88
|
+
ad_group_srv = @adwords.service(:AdGroupService, API_VERSION)
|
89
|
+
ad_group = {
|
90
|
+
:name => "Example tests ad group #%d" % (Time.new.to_f * 1000).to_i,
|
91
|
+
:status => 'ENABLED',
|
92
|
+
:campaign_id => campaign[:id],
|
93
|
+
:bids => {
|
94
|
+
:xsi_type => 'ManualCPCAdGroupBids',
|
95
|
+
:keyword_max_cpc => {:amount => {:micro_amount => 10000000}},
|
96
|
+
}
|
97
|
+
}
|
98
|
+
operation = {:operator => 'ADD', :operand => ad_group}
|
99
|
+
response = ad_group_srv.mutate([operation])
|
100
|
+
return response[:value].first
|
101
|
+
end
|
102
|
+
|
103
|
+
def create_ad(ad_group_id)
|
104
|
+
ad_group_ad_srv = @adwords.service(:AdGroupAdService, API_VERSION)
|
105
|
+
text_ad = {
|
106
|
+
:xsi_type => 'TextAd',
|
107
|
+
:headline => 'Examples test ad %d' % (Time.new.to_f * 1000).to_i,
|
108
|
+
:description1 => 'testing ruby examples',
|
109
|
+
:description2 => 'all your base are belong to us',
|
110
|
+
:url => 'http://www.example.com',
|
111
|
+
:display_url => 'www.example.com'
|
112
|
+
}
|
113
|
+
operation = {:operator => 'ADD',
|
114
|
+
:operand => {:ad_group_id => ad_group_id, :ad => text_ad}}
|
115
|
+
response = ad_group_ad_srv.mutate([operation])
|
116
|
+
return response[:value].first
|
117
|
+
end
|
118
|
+
|
119
|
+
def create_keyword(ad_group_id)
|
120
|
+
ad_group_criterion_srv =
|
121
|
+
@adwords.service(:AdGroupCriterionService, API_VERSION)
|
122
|
+
keyword = {
|
123
|
+
:xsi_type => 'BiddableAdGroupCriterion',
|
124
|
+
:ad_group_id => ad_group_id,
|
125
|
+
:criterion => {
|
126
|
+
:xsi_type => 'Keyword',
|
127
|
+
:text => 'mars cruise',
|
128
|
+
:match_type => 'BROAD'
|
129
|
+
}
|
130
|
+
}
|
131
|
+
operation = {:operator => 'ADD', :operand => keyword}
|
132
|
+
response = ad_group_criterion_srv.mutate([operation])
|
133
|
+
return response[:value].first
|
134
|
+
end
|
135
|
+
|
136
|
+
def create_location_extension(campaign_id)
|
137
|
+
campaign_ad_ext_srv =
|
138
|
+
@adwords.service(:CampaignAdExtensionService, API_VERSION)
|
139
|
+
geo_location_srv = @adwords.service(:GeoLocationService, API_VERSION)
|
140
|
+
|
141
|
+
selector = {
|
142
|
+
:addresses => [
|
143
|
+
{
|
144
|
+
:street_address => '1600 Amphitheatre Parkway',
|
145
|
+
:city_name => 'Mountain View',
|
146
|
+
:province_code => 'CA',
|
147
|
+
:postal_code => '94043',
|
148
|
+
:country_code => 'US'
|
149
|
+
}
|
150
|
+
]
|
151
|
+
}
|
152
|
+
|
153
|
+
locations = geo_location_srv.get(selector)
|
154
|
+
raise StandardError, 'Unable to retrieve geo locations.' if locations.nil?
|
155
|
+
|
156
|
+
operations = locations.map do |location|
|
157
|
+
{
|
158
|
+
:operator => 'ADD',
|
159
|
+
:operand => {
|
160
|
+
:campaign_id => campaign_id,
|
161
|
+
:status => 'ACTIVE',
|
162
|
+
:ad_extension => {
|
163
|
+
:xsi_type => 'LocationExtension',
|
164
|
+
:address => location[:address],
|
165
|
+
:geo_point => location[:geo_point],
|
166
|
+
:encoded_location => location[:encoded_location],
|
167
|
+
:source => 'ADWORDS_FRONTEND'
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
173
|
+
response = campaign_ad_ext_srv.mutate(operations)
|
174
|
+
extension = response[:value].first
|
175
|
+
return extension
|
176
|
+
end
|
177
|
+
|
178
|
+
def create_experiment(campaign_id, ad_group_id, criterion_id)
|
179
|
+
experiment_srv = @adwords.service(:ExperimentService, API_VERSION)
|
180
|
+
ad_group_srv = @adwords.service(:AdGroupService, API_VERSION)
|
181
|
+
ad_group_criterion_srv =
|
182
|
+
@adwords.service(:AdGroupCriterionService, API_VERSION)
|
183
|
+
|
184
|
+
operation = {
|
185
|
+
:operator => 'ADD',
|
186
|
+
:operand => {
|
187
|
+
:campaign_id => campaign_id,
|
188
|
+
:name => "Examples test experiment #%d" % (Time.new.to_f * 1000).to_i,
|
189
|
+
:query_percentage => 10,
|
190
|
+
:start_date_time => Time.now.strftime('%Y%m%d %H%M%S'),
|
191
|
+
}
|
192
|
+
}
|
193
|
+
response = experiment_srv.mutate([operation])
|
194
|
+
experiment = response[:value].first
|
195
|
+
|
196
|
+
raise StandardError, 'Failed to create experiment' if experiment.nil?
|
197
|
+
|
198
|
+
ad_group = {
|
199
|
+
:id => ad_group_id,
|
200
|
+
:experiment_data => {
|
201
|
+
:experiment_id => experiment[:id],
|
202
|
+
:experiment_delta_status => 'MODIFIED',
|
203
|
+
:experiment_bid_multipliers => {
|
204
|
+
:xsi_type => 'ManualCPCAdGroupExperimentBidMultipliers',
|
205
|
+
:max_cpc_multiplier => {:multiplier => 1.5}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
operation = {:operator => 'SET', :operand => ad_group}
|
211
|
+
response = ad_group_srv.mutate([operation])
|
212
|
+
ad_group = response[:value].first
|
213
|
+
|
214
|
+
raise StandardError, 'Failed to assign experiment' if ad_group.nil?
|
215
|
+
|
216
|
+
ad_group_criterion = {
|
217
|
+
:xsi_type => 'BiddableAdGroupCriterion',
|
218
|
+
:ad_group_id => ad_group_id,
|
219
|
+
:criterion => {:id => criterion_id},
|
220
|
+
:experiment_data => {
|
221
|
+
:xsi_type => 'BiddableAdGroupCriterionExperimentData',
|
222
|
+
:experiment_id => experiment[:id],
|
223
|
+
:experiment_delta_status => 'MODIFIED',
|
224
|
+
:experiment_bid_multiplier => {
|
225
|
+
:xsi_type => 'ManualCPCAdGroupCriterionExperimentBidMultiplier',
|
226
|
+
:max_cpc_multiplier => {:multiplier => 1.5}
|
227
|
+
}
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
operation = {:operator => 'SET', :operand => ad_group_criterion}
|
232
|
+
response = ad_group_criterion_srv.mutate([operation])
|
233
|
+
criterion = response[:value].first
|
234
|
+
|
235
|
+
raise StandardError, 'Failed to assign criterion' if criterion.nil?
|
236
|
+
|
237
|
+
return experiment
|
238
|
+
end
|
239
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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
|
+
# Test suite for v201109 example tests.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
$:.unshift File.expand_path('../../lib/', __FILE__)
|
26
|
+
$:.unshift File.expand_path('../../', __FILE__)
|
27
|
+
|
28
|
+
version = 'v201109'
|
29
|
+
|
30
|
+
examples_path =
|
31
|
+
File.expand_path(File.join('..', '..', 'examples', version), __FILE__)
|
32
|
+
$:.unshift(examples_path)
|
33
|
+
|
34
|
+
tests_path = File.join(File.dirname(__FILE__), 'examples', version)
|
35
|
+
require File.join(tests_path, 'utils.rb')
|
36
|
+
tests_mask = File.join(tests_path, 'test_*.rb')
|
37
|
+
Dir.glob(tests_mask).each {|file| require file}
|
@@ -0,0 +1,37 @@
|
|
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
|
+
# Test suite for v201109_1 example tests.
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
|
25
|
+
$:.unshift File.expand_path('../../lib/', __FILE__)
|
26
|
+
$:.unshift File.expand_path('../../', __FILE__)
|
27
|
+
|
28
|
+
version = 'v201109_1'
|
29
|
+
|
30
|
+
examples_path =
|
31
|
+
File.expand_path(File.join('..', '..', 'examples', version), __FILE__)
|
32
|
+
$:.unshift(examples_path)
|
33
|
+
|
34
|
+
tests_path = File.join(File.dirname(__FILE__), 'examples', version)
|
35
|
+
require File.join(tests_path, 'utils.rb')
|
36
|
+
tests_mask = File.join(tests_path, 'test_*.rb')
|
37
|
+
Dir.glob(tests_mask).each {|file| require file}
|
data/test/suite_unittests.rb
CHANGED
@@ -20,13 +20,15 @@
|
|
20
20
|
#
|
21
21
|
# Test suite for unit tests.
|
22
22
|
|
23
|
-
lib = File.expand_path('../lib/', __FILE__)
|
24
|
-
$:.unshift lib unless $:.include?(lib)
|
25
|
-
|
26
23
|
require 'test/unit'
|
27
24
|
|
25
|
+
$:.unshift File.expand_path('../../lib/', __FILE__)
|
26
|
+
$:.unshift File.expand_path('../../', __FILE__)
|
27
|
+
|
28
28
|
# AdWords API units tests.
|
29
|
-
|
29
|
+
adwords_mask = File.join(File.dirname(__FILE__), 'adwords_api', 'test_*.rb')
|
30
|
+
Dir.glob(adwords_mask).each {|file| require file}
|
30
31
|
|
31
32
|
# Reported bugs tests.
|
32
|
-
|
33
|
+
bugs_mask = File.join(File.dirname(__FILE__), 'bugs', 'test_*.rb')
|
34
|
+
Dir.glob(bugs_mask).each {|file| require file}
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-adwords-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 7
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 0.6.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Danial Klimkin
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2012-
|
18
|
+
date: 2012-05-15 00:00:00 +04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ~>
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 41
|
28
30
|
segments:
|
29
31
|
- 0
|
30
32
|
- 9
|
@@ -40,11 +42,12 @@ dependencies:
|
|
40
42
|
requirements:
|
41
43
|
- - ~>
|
42
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
43
46
|
segments:
|
44
47
|
- 0
|
45
|
-
-
|
46
|
-
-
|
47
|
-
version: 0.
|
48
|
+
- 7
|
49
|
+
- 0
|
50
|
+
version: 0.7.0
|
48
51
|
type: :runtime
|
49
52
|
version_requirements: *id002
|
50
53
|
description: google-adwords-api is a AdWords API client library for Ruby
|
@@ -57,8 +60,59 @@ extensions: []
|
|
57
60
|
extra_rdoc_files: []
|
58
61
|
|
59
62
|
files:
|
63
|
+
- examples/v201109_1/reporting/download_criteria_report.rb
|
64
|
+
- examples/v201109_1/reporting/get_defined_reports.rb
|
65
|
+
- examples/v201109_1/reporting/get_campaign_stats.rb
|
66
|
+
- examples/v201109_1/reporting/parallel_report_download.rb
|
67
|
+
- examples/v201109_1/reporting/get_report_fields.rb
|
68
|
+
- examples/v201109_1/error_handling/handle_policy_violation_error.rb
|
69
|
+
- examples/v201109_1/error_handling/handle_two_factor_authorization_error.rb
|
70
|
+
- examples/v201109_1/error_handling/handle_captcha_challenge.rb
|
71
|
+
- examples/v201109_1/error_handling/handle_partial_failures.rb
|
72
|
+
- examples/v201109_1/targeting/lookup_location.rb
|
73
|
+
- examples/v201109_1/targeting/get_targetable_languages_and_carriers.rb
|
74
|
+
- examples/v201109_1/targeting/add_campaign_targeting_criteria.rb
|
75
|
+
- examples/v201109_1/targeting/get_campaign_targeting_criteria.rb
|
76
|
+
- examples/v201109_1/campaign_management/validate_text_ad.rb
|
77
|
+
- examples/v201109_1/campaign_management/add_experiment.rb
|
78
|
+
- examples/v201109_1/campaign_management/set_ad_parameters.rb
|
79
|
+
- examples/v201109_1/campaign_management/add_location_extension.rb
|
80
|
+
- examples/v201109_1/campaign_management/add_keywords_in_bulk.rb
|
81
|
+
- examples/v201109_1/campaign_management/promote_experiment.rb
|
82
|
+
- examples/v201109_1/campaign_management/get_all_disapproved_ads.rb
|
83
|
+
- examples/v201109_1/campaign_management/add_location_extension_override.rb
|
84
|
+
- examples/v201109_1/account_management/get_account_hierarchy.rb
|
85
|
+
- examples/v201109_1/account_management/get_account_changes.rb
|
86
|
+
- examples/v201109_1/account_management/get_client_unit_usage.rb
|
87
|
+
- examples/v201109_1/account_management/get_client_customer_id.rb
|
88
|
+
- examples/v201109_1/account_management/get_account_alerts.rb
|
89
|
+
- examples/v201109_1/account_management/create_account.rb
|
90
|
+
- examples/v201109_1/optimization/estimate_keyword_traffic.rb
|
91
|
+
- examples/v201109_1/optimization/get_keyword_bid_simulations.rb
|
92
|
+
- examples/v201109_1/optimization/get_keyword_ideas.rb
|
93
|
+
- examples/v201109_1/optimization/get_placement_ideas.rb
|
94
|
+
- examples/v201109_1/basic_operations/update_campaign.rb
|
95
|
+
- examples/v201109_1/basic_operations/get_campaigns.rb
|
96
|
+
- examples/v201109_1/basic_operations/get_ad_groups.rb
|
97
|
+
- examples/v201109_1/basic_operations/add_campaigns.rb
|
98
|
+
- examples/v201109_1/basic_operations/delete_ad_group.rb
|
99
|
+
- examples/v201109_1/basic_operations/delete_keyword.rb
|
100
|
+
- examples/v201109_1/basic_operations/delete_ad.rb
|
101
|
+
- examples/v201109_1/basic_operations/add_ad_groups.rb
|
102
|
+
- examples/v201109_1/basic_operations/update_ad_group.rb
|
103
|
+
- examples/v201109_1/basic_operations/get_keywords.rb
|
104
|
+
- examples/v201109_1/basic_operations/delete_campaign.rb
|
105
|
+
- examples/v201109_1/basic_operations/get_text_ads.rb
|
106
|
+
- examples/v201109_1/basic_operations/add_keywords.rb
|
107
|
+
- examples/v201109_1/basic_operations/add_text_ads.rb
|
108
|
+
- examples/v201109_1/basic_operations/pause_ad.rb
|
109
|
+
- examples/v201109_1/basic_operations/update_keyword.rb
|
110
|
+
- examples/v201109_1/misc/upload_image.rb
|
111
|
+
- examples/v201109_1/misc/get_all_images_and_videos.rb
|
112
|
+
- examples/v201109_1/misc/use_oauth.rb
|
113
|
+
- examples/v201109_1/remarketing/add_conversion_tracker.rb
|
114
|
+
- examples/v201109_1/remarketing/add_audience.rb
|
60
115
|
- examples/v201109/reporting/download_criteria_report.rb
|
61
|
-
- examples/v201109/reporting/download_defined_report.rb
|
62
116
|
- examples/v201109/reporting/get_defined_reports.rb
|
63
117
|
- examples/v201109/reporting/get_campaign_stats.rb
|
64
118
|
- examples/v201109/reporting/parallel_report_download.rb
|
@@ -114,6 +168,63 @@ files:
|
|
114
168
|
- lib/adwords_api/version.rb
|
115
169
|
- lib/adwords_api/report_utils.rb
|
116
170
|
- lib/adwords_api/credential_handler.rb
|
171
|
+
- lib/adwords_api/v201109_1/mutate_job_service.rb
|
172
|
+
- lib/adwords_api/v201109_1/conversion_tracker_service_registry.rb
|
173
|
+
- lib/adwords_api/v201109_1/info_service_registry.rb
|
174
|
+
- lib/adwords_api/v201109_1/ad_extension_override_service_registry.rb
|
175
|
+
- lib/adwords_api/v201109_1/campaign_target_service.rb
|
176
|
+
- lib/adwords_api/v201109_1/experiment_service_registry.rb
|
177
|
+
- lib/adwords_api/v201109_1/alert_service_registry.rb
|
178
|
+
- lib/adwords_api/v201109_1/campaign_criterion_service.rb
|
179
|
+
- lib/adwords_api/v201109_1/budget_order_service.rb
|
180
|
+
- lib/adwords_api/v201109_1/ad_group_ad_service_registry.rb
|
181
|
+
- lib/adwords_api/v201109_1/customer_sync_service_registry.rb
|
182
|
+
- lib/adwords_api/v201109_1/budget_order_service_registry.rb
|
183
|
+
- lib/adwords_api/v201109_1/experiment_service.rb
|
184
|
+
- lib/adwords_api/v201109_1/alert_service.rb
|
185
|
+
- lib/adwords_api/v201109_1/customer_sync_service.rb
|
186
|
+
- lib/adwords_api/v201109_1/serviced_account_service_registry.rb
|
187
|
+
- lib/adwords_api/v201109_1/location_criterion_service_registry.rb
|
188
|
+
- lib/adwords_api/v201109_1/targeting_idea_service.rb
|
189
|
+
- lib/adwords_api/v201109_1/geo_location_service.rb
|
190
|
+
- lib/adwords_api/v201109_1/ad_group_criterion_service.rb
|
191
|
+
- lib/adwords_api/v201109_1/campaign_target_service_registry.rb
|
192
|
+
- lib/adwords_api/v201109_1/user_list_service_registry.rb
|
193
|
+
- lib/adwords_api/v201109_1/constant_data_service_registry.rb
|
194
|
+
- lib/adwords_api/v201109_1/ad_group_ad_service.rb
|
195
|
+
- lib/adwords_api/v201109_1/traffic_estimator_service_registry.rb
|
196
|
+
- lib/adwords_api/v201109_1/campaign_service.rb
|
197
|
+
- lib/adwords_api/v201109_1/conversion_tracker_service.rb
|
198
|
+
- lib/adwords_api/v201109_1/media_service_registry.rb
|
199
|
+
- lib/adwords_api/v201109_1/campaign_ad_extension_service_registry.rb
|
200
|
+
- lib/adwords_api/v201109_1/campaign_service_registry.rb
|
201
|
+
- lib/adwords_api/v201109_1/bulk_mutate_job_service.rb
|
202
|
+
- lib/adwords_api/v201109_1/user_list_service.rb
|
203
|
+
- lib/adwords_api/v201109_1/location_criterion_service.rb
|
204
|
+
- lib/adwords_api/v201109_1/ad_group_service.rb
|
205
|
+
- lib/adwords_api/v201109_1/ad_group_service_registry.rb
|
206
|
+
- lib/adwords_api/v201109_1/ad_param_service.rb
|
207
|
+
- lib/adwords_api/v201109_1/traffic_estimator_service.rb
|
208
|
+
- lib/adwords_api/v201109_1/info_service.rb
|
209
|
+
- lib/adwords_api/v201109_1/data_service_registry.rb
|
210
|
+
- lib/adwords_api/v201109_1/serviced_account_service.rb
|
211
|
+
- lib/adwords_api/v201109_1/create_account_service.rb
|
212
|
+
- lib/adwords_api/v201109_1/ad_extension_override_service.rb
|
213
|
+
- lib/adwords_api/v201109_1/report_definition_service.rb
|
214
|
+
- lib/adwords_api/v201109_1/ad_param_service_registry.rb
|
215
|
+
- lib/adwords_api/v201109_1/mutate_job_service_registry.rb
|
216
|
+
- lib/adwords_api/v201109_1/constant_data_service.rb
|
217
|
+
- lib/adwords_api/v201109_1/ad_group_criterion_service_registry.rb
|
218
|
+
- lib/adwords_api/v201109_1/campaign_ad_extension_service.rb
|
219
|
+
- lib/adwords_api/v201109_1/campaign_criterion_service_registry.rb
|
220
|
+
- lib/adwords_api/v201109_1/report_definition_service_registry.rb
|
221
|
+
- lib/adwords_api/v201109_1/media_service.rb
|
222
|
+
- lib/adwords_api/v201109_1/geo_location_service_registry.rb
|
223
|
+
- lib/adwords_api/v201109_1/targeting_idea_service_registry.rb
|
224
|
+
- lib/adwords_api/v201109_1/create_account_service_registry.rb
|
225
|
+
- lib/adwords_api/v201109_1/bulk_mutate_job_service_registry.rb
|
226
|
+
- lib/adwords_api/v201109_1/data_service.rb
|
227
|
+
- lib/adwords_api/report_header_handler.rb
|
117
228
|
- lib/adwords_api/api_config.rb
|
118
229
|
- lib/adwords_api/v201109/mutate_job_service.rb
|
119
230
|
- lib/adwords_api/v201109/conversion_tracker_service_registry.rb
|
@@ -123,8 +234,10 @@ files:
|
|
123
234
|
- lib/adwords_api/v201109/experiment_service_registry.rb
|
124
235
|
- lib/adwords_api/v201109/alert_service_registry.rb
|
125
236
|
- lib/adwords_api/v201109/campaign_criterion_service.rb
|
237
|
+
- lib/adwords_api/v201109/budget_order_service.rb
|
126
238
|
- lib/adwords_api/v201109/ad_group_ad_service_registry.rb
|
127
239
|
- lib/adwords_api/v201109/customer_sync_service_registry.rb
|
240
|
+
- lib/adwords_api/v201109/budget_order_service_registry.rb
|
128
241
|
- lib/adwords_api/v201109/experiment_service.rb
|
129
242
|
- lib/adwords_api/v201109/alert_service.rb
|
130
243
|
- lib/adwords_api/v201109/customer_sync_service.rb
|
@@ -170,10 +283,19 @@ files:
|
|
170
283
|
- lib/adwords_api/v201109/bulk_mutate_job_service_registry.rb
|
171
284
|
- lib/adwords_api/v201109/data_service.rb
|
172
285
|
- lib/adwords_api/errors.rb
|
173
|
-
- lib/adwords_api/extensions.rb
|
174
286
|
- lib/adwords_api/client_login_header_handler.rb
|
175
|
-
- lib/adwords_api/v13_login_handler.rb
|
176
287
|
- lib/adwords_api.rb
|
288
|
+
- test/suite_exampletests_v201109_1.rb
|
289
|
+
- test/examples/v201109_1/utils.rb
|
290
|
+
- test/examples/v201109_1/test_error_handling.rb
|
291
|
+
- test/examples/v201109_1/test_targeting.rb
|
292
|
+
- test/examples/v201109_1/test_misc.rb
|
293
|
+
- test/examples/v201109_1/test_remarketing.rb
|
294
|
+
- test/examples/v201109_1/test_account_management.rb
|
295
|
+
- test/examples/v201109_1/test_optimization.rb
|
296
|
+
- test/examples/v201109_1/test_reporting.rb
|
297
|
+
- test/examples/v201109_1/test_basic_operations.rb
|
298
|
+
- test/examples/v201109_1/test_campaign_management.rb
|
177
299
|
- test/examples/v201109/utils.rb
|
178
300
|
- test/examples/v201109/test_error_handling.rb
|
179
301
|
- test/examples/v201109/test_targeting.rb
|
@@ -184,13 +306,14 @@ files:
|
|
184
306
|
- test/examples/v201109/test_reporting.rb
|
185
307
|
- test/examples/v201109/test_basic_operations.rb
|
186
308
|
- test/examples/v201109/test_campaign_management.rb
|
309
|
+
- test/suite_exampletests_v201109.rb
|
187
310
|
- test/bugs/test_issue_00000031.rb
|
311
|
+
- test/coverage.rb
|
188
312
|
- test/suite_unittests.rb
|
189
313
|
- test/adwords_api/test_report_utils.rb
|
190
314
|
- test/adwords_api/test_credential_handler.rb
|
191
315
|
- test/adwords_api/test_api_config.rb
|
192
316
|
- test/adwords_api/test_utils.rb
|
193
|
-
- test/suite_exampletests.rb
|
194
317
|
- COPYING
|
195
318
|
- README
|
196
319
|
- ChangeLog
|
@@ -209,6 +332,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
332
|
requirements:
|
210
333
|
- - ">="
|
211
334
|
- !ruby/object:Gem::Version
|
335
|
+
hash: 3
|
212
336
|
segments:
|
213
337
|
- 0
|
214
338
|
version: "0"
|
@@ -217,6 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
341
|
requirements:
|
218
342
|
- - ">="
|
219
343
|
- !ruby/object:Gem::Version
|
344
|
+
hash: 23
|
220
345
|
segments:
|
221
346
|
- 1
|
222
347
|
- 3
|