google-adwords-api 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4 -0
- data/README +124 -107
- data/examples/v201306/misc/use_oauth2_jwt.rb +5 -1
- data/examples/v201309/misc/use_oauth2_jwt.rb +5 -1
- data/examples/v201402/account_management/create_account.rb +95 -0
- data/examples/v201402/account_management/get_account_alerts.rb +122 -0
- data/examples/v201402/account_management/get_account_changes.rb +145 -0
- data/examples/v201402/account_management/get_account_hierarchy.rb +103 -0
- data/examples/v201402/advanced_operations/add_ad_group_bid_modifier.rb +105 -0
- data/examples/v201402/advanced_operations/add_click_to_download_ad.rb +137 -0
- data/examples/v201402/advanced_operations/add_places_location_extensions.rb +159 -0
- data/examples/v201402/advanced_operations/add_places_location_extensions.rb~ +159 -0
- data/examples/v201402/advanced_operations/add_site_links.rb +306 -0
- data/examples/v201402/advanced_operations/get_ad_group_bid_modifiers.rb +106 -0
- data/examples/v201402/advanced_operations/update_site_links.rb +194 -0
- data/examples/v201402/advanced_operations/upload_offline_conversions.rb +117 -0
- data/examples/v201402/advanced_operations/use_shared_bidding_strategy.rb +163 -0
- data/examples/v201402/basic_operations/add_ad_groups.rb +142 -0
- data/examples/v201402/basic_operations/add_ad_groups.rb~ +147 -0
- data/examples/v201402/basic_operations/add_campaigns.rb +153 -0
- data/examples/v201402/basic_operations/add_keywords.rb +116 -0
- data/examples/v201402/basic_operations/add_text_ads.rb +113 -0
- data/examples/v201402/basic_operations/delete_ad.rb +93 -0
- data/examples/v201402/basic_operations/delete_ad_group.rb +110 -0
- data/examples/v201402/basic_operations/delete_campaign.rb +111 -0
- data/examples/v201402/basic_operations/delete_keyword.rb +98 -0
- data/examples/v201402/basic_operations/get_ad_groups.rb +106 -0
- data/examples/v201402/basic_operations/get_campaigns.rb +101 -0
- data/examples/v201402/basic_operations/get_campaigns_with_awql.rb +93 -0
- data/examples/v201402/basic_operations/get_keywords.rb +112 -0
- data/examples/v201402/basic_operations/get_text_ads.rb +114 -0
- data/examples/v201402/basic_operations/pause_ad.rb +92 -0
- data/examples/v201402/basic_operations/update_ad_group.rb +89 -0
- data/examples/v201402/basic_operations/update_campaign.rb +90 -0
- data/examples/v201402/basic_operations/update_keyword.rb +110 -0
- data/examples/v201402/campaign_management/add_experiment.rb +166 -0
- data/examples/v201402/campaign_management/add_keywords_in_bulk.rb +158 -0
- data/examples/v201402/campaign_management/add_location_extension.rb +125 -0
- data/examples/v201402/campaign_management/get_all_disapproved_ads.rb +101 -0
- data/examples/v201402/campaign_management/get_all_disapproved_ads_with_awql.rb +93 -0
- data/examples/v201402/campaign_management/promote_experiment.rb +85 -0
- data/examples/v201402/campaign_management/set_ad_parameters.rb +122 -0
- data/examples/v201402/campaign_management/set_criterion_bid_modifier.rb +108 -0
- data/examples/v201402/campaign_management/validate_text_ad.rb +114 -0
- data/examples/v201402/error_handling/handle_captcha_challenge.rb +93 -0
- data/examples/v201402/error_handling/handle_partial_failures.rb +134 -0
- data/examples/v201402/error_handling/handle_policy_violation_error.rb +145 -0
- data/examples/v201402/error_handling/handle_two_factor_authorization_error.rb +88 -0
- data/examples/v201402/misc/create_ad_words_session_without_properties_file.rb +94 -0
- data/examples/v201402/misc/create_ad_words_session_without_properties_file.rb~ +94 -0
- data/examples/v201402/misc/get_all_images_and_videos.rb +108 -0
- data/examples/v201402/misc/setup_oauth2.rb +88 -0
- data/examples/v201402/misc/upload_image.rb +97 -0
- data/examples/v201402/misc/use_oauth2_jwt.rb +97 -0
- data/examples/v201402/optimization/estimate_keyword_traffic.rb +137 -0
- data/examples/v201402/optimization/get_keyword_bid_simulations.rb +100 -0
- data/examples/v201402/optimization/get_keyword_ideas.rb +130 -0
- data/examples/v201402/optimization/get_placement_ideas.rb +112 -0
- data/examples/v201402/remarketing/add_audience.rb +123 -0
- data/examples/v201402/remarketing/add_conversion_tracker.rb +105 -0
- data/examples/v201402/remarketing/add_conversion_tracker.rb~ +109 -0
- data/examples/v201402/reporting/download_criteria_report.rb +87 -0
- data/examples/v201402/reporting/download_criteria_report_with_awql.rb +86 -0
- data/examples/v201402/reporting/get_report_fields.rb +79 -0
- data/examples/v201402/reporting/parallel_report_download.rb +171 -0
- data/examples/v201402/shopping_campaigns/add_product_partition_tree.rb +269 -0
- data/examples/v201402/shopping_campaigns/add_product_partition_tree.rb~ +269 -0
- data/examples/v201402/shopping_campaigns/add_product_scope.rb +133 -0
- data/examples/v201402/shopping_campaigns/add_shopping_campaign.rb +135 -0
- data/examples/v201402/shopping_campaigns/add_shopping_campaign.rb~ +136 -0
- data/examples/v201402/shopping_campaigns/get_product_category_taxonomy.rb +117 -0
- data/examples/v201402/shopping_campaigns/get_product_category_taxonomy.rb~ +128 -0
- data/examples/v201402/shopping_campaigns/set_product_sales_channel.rb +98 -0
- data/examples/v201402/shopping_campaigns/set_product_sales_channel.rb~ +98 -0
- data/examples/v201402/targeting/add_campaign_targeting_criteria.rb +157 -0
- data/examples/v201402/targeting/add_demographic_targeting_criteria.rb +116 -0
- data/examples/v201402/targeting/get_campaign_targeting_criteria.rb +110 -0
- data/examples/v201402/targeting/get_targetable_languages_and_carriers.rb +94 -0
- data/examples/v201402/targeting/lookup_location.rb +112 -0
- data/lib/adwords_api.rb +7 -0
- data/lib/adwords_api/api_config.rb +76 -4
- data/lib/adwords_api/report_header_handler.rb +1 -1
- data/lib/adwords_api/v201402/ad_group_ad_service.rb +42 -0
- data/lib/adwords_api/v201402/ad_group_ad_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/ad_group_bid_modifier_service.rb +42 -0
- data/lib/adwords_api/v201402/ad_group_bid_modifier_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/ad_group_criterion_service.rb +42 -0
- data/lib/adwords_api/v201402/ad_group_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/ad_group_feed_service.rb +42 -0
- data/lib/adwords_api/v201402/ad_group_feed_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/ad_group_service.rb +42 -0
- data/lib/adwords_api/v201402/ad_group_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/ad_param_service.rb +38 -0
- data/lib/adwords_api/v201402/ad_param_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/adwords_user_list_service.rb +38 -0
- data/lib/adwords_api/v201402/adwords_user_list_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/alert_service.rb +34 -0
- data/lib/adwords_api/v201402/alert_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/bidding_strategy_service.rb +42 -0
- data/lib/adwords_api/v201402/bidding_strategy_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/budget_order_service.rb +42 -0
- data/lib/adwords_api/v201402/budget_order_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/budget_service.rb +42 -0
- data/lib/adwords_api/v201402/budget_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/campaign_ad_extension_service.rb +38 -0
- data/lib/adwords_api/v201402/campaign_ad_extension_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/campaign_criterion_service.rb +42 -0
- data/lib/adwords_api/v201402/campaign_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/campaign_feed_service.rb +42 -0
- data/lib/adwords_api/v201402/campaign_feed_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/campaign_service.rb +42 -0
- data/lib/adwords_api/v201402/campaign_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/constant_data_service.rb +66 -0
- data/lib/adwords_api/v201402/constant_data_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/conversion_tracker_service.rb +38 -0
- data/lib/adwords_api/v201402/conversion_tracker_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/customer_feed_service.rb +42 -0
- data/lib/adwords_api/v201402/customer_feed_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/customer_service.rb +38 -0
- data/lib/adwords_api/v201402/customer_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/customer_sync_service.rb +34 -0
- data/lib/adwords_api/v201402/customer_sync_service_registry.rb +47 -0
- data/lib/adwords_api/v201402/data_service.rb +46 -0
- data/lib/adwords_api/v201402/data_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/experiment_service.rb +38 -0
- data/lib/adwords_api/v201402/experiment_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/feed_item_service.rb +42 -0
- data/lib/adwords_api/v201402/feed_item_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/feed_mapping_service.rb +42 -0
- data/lib/adwords_api/v201402/feed_mapping_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/feed_service.rb +42 -0
- data/lib/adwords_api/v201402/feed_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/geo_location_service.rb +34 -0
- data/lib/adwords_api/v201402/geo_location_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/location_criterion_service.rb +38 -0
- data/lib/adwords_api/v201402/location_criterion_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/managed_customer_service.rb +50 -0
- data/lib/adwords_api/v201402/managed_customer_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/media_service.rb +42 -0
- data/lib/adwords_api/v201402/media_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/mutate_job_service.rb +42 -0
- data/lib/adwords_api/v201402/mutate_job_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/offline_conversion_feed_service.rb +34 -0
- data/lib/adwords_api/v201402/offline_conversion_feed_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/report_definition_service.rb +34 -0
- data/lib/adwords_api/v201402/report_definition_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/targeting_idea_service.rb +38 -0
- data/lib/adwords_api/v201402/targeting_idea_service_registry.rb +46 -0
- data/lib/adwords_api/v201402/traffic_estimator_service.rb +34 -0
- data/lib/adwords_api/v201402/traffic_estimator_service_registry.rb +46 -0
- data/lib/adwords_api/version.rb +1 -1
- data/test/adwords_api/test_adwords_api.rb +15 -2
- data/test/adwords_api/test_adwords_api.rb~ +127 -0
- data/test/templates/v201306/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201306/misc_use_oauth2_jwt.def +1 -1
- data/test/templates/v201309/basic_operations_get_campaigns.def +1 -1
- data/test/templates/v201309/misc_use_oauth2_jwt.def +1 -1
- metadata +146 -2
data/ChangeLog
CHANGED
data/README
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# Google AdWords and DoubleClick Ad Exchange Buyer Client Library
|
|
2
2
|
|
|
3
3
|
Welcome to the next generation Google-developed Ruby client library for the
|
|
4
4
|
AdWords and DoubleClick Ad Exchange Buyer API!
|
|
@@ -8,216 +8,230 @@ programming interface that lets you handle everything in native Ruby
|
|
|
8
8
|
collections.
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# Docs for Users
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## 1 - Installation
|
|
14
14
|
|
|
15
|
-
google-adwords-api and google-adx-buyer-api are ruby gems.
|
|
16
|
-
|
|
15
|
+
`google-adwords-api` and `google-adx-buyer-api` are ruby gems. See
|
|
16
|
+
[http://docs.rubygems.org/read/book/1]().
|
|
17
17
|
|
|
18
18
|
Install them using the gem install command:
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
|
|
20
|
+
$ gem install --remote google-adwords-api
|
|
21
|
+
$ gem install --remote google-adx-buyer-api
|
|
21
22
|
|
|
22
23
|
Please note the google-adx-buyer-api gem contains only DoubleClick Ad Exchange
|
|
23
24
|
Buyer client library examples. You need the AdWords library in order to use it
|
|
24
25
|
which is installed automatically as a dependency.
|
|
25
26
|
|
|
26
27
|
The following gem libraries are required:
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
- savon
|
|
30
|
+
- google-ads-common
|
|
29
31
|
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
## 2 - Using the client library
|
|
32
34
|
|
|
33
35
|
Include the library with 'require':
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
require 'adwords_api'
|
|
35
38
|
|
|
36
39
|
Then create an API instance:
|
|
37
|
-
|
|
40
|
+
|
|
41
|
+
adwords = AdwordsApi::Api.new
|
|
38
42
|
|
|
39
43
|
The created API object will grant you access to all the services for all of the
|
|
40
|
-
currently supported vesions of the APIs. It uses a config file in
|
|
41
|
-
|
|
44
|
+
currently supported vesions of the APIs. It uses a config file in
|
|
45
|
+
`ENV['HOME']/adwords_api.yml` to read all of your configurations by default.
|
|
42
46
|
|
|
43
47
|
There is an example configuration file shipped with these libraries.
|
|
44
48
|
|
|
45
49
|
You can also pass API a manually constructed config hash like:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Once the library instance is
|
|
50
|
+
|
|
51
|
+
adwords = AdwordsApi::Api.new({
|
|
52
|
+
:authentication => {
|
|
53
|
+
:method => 'OAuth2',
|
|
54
|
+
:oauth2_client_id => 'INSERT_OAUTH2_CLIENT_ID_HERE',
|
|
55
|
+
:oauth2_client_secret => 'INSERT_OAUTH2_CLIENT_SECRET_HERE',
|
|
56
|
+
:developer_token => 'DEVELOPER_TOKEN',
|
|
57
|
+
:client_customer_id => '012-345-6789',
|
|
58
|
+
:user_agent => 'Ruby Sample'
|
|
59
|
+
},
|
|
60
|
+
:service => {
|
|
61
|
+
:environment => 'PRODUCTION'
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
To obtain OAuth2 client credentials, follow the instructions
|
|
66
|
+
[on the wiki](https://github.com/googleads/google-api-ads-ruby/wiki/OAuth2).
|
|
67
|
+
|
|
68
|
+
Once the library instance is created, specify which service you're looking to
|
|
65
69
|
use, and which version:
|
|
66
|
-
campaign_srv = adwords.service(:CampaignService, :v201309)
|
|
67
70
|
|
|
68
|
-
|
|
71
|
+
campaign_srv = adwords.service(:CampaignService, :v201309)
|
|
72
|
+
|
|
73
|
+
You should now be able to just use the API methods in the object you were
|
|
69
74
|
returned:
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
|
|
76
|
+
# Get 'Id', 'Name' and 'Status' fields of all campaigns.
|
|
77
|
+
campaigns = campaign_srv.get({:fields => ['Id', 'Name', 'Status']})
|
|
72
78
|
|
|
73
79
|
See the code in the examples directory for working examples you can build from.
|
|
74
80
|
|
|
75
|
-
*Note*:
|
|
76
|
-
please set the appropriate options in the config file or config hash.
|
|
77
|
-
|
|
78
|
-
:proxy => 'http://user:password@proxy_hostname:8080'
|
|
79
|
-
}
|
|
81
|
+
*Note*: If your setup requires you to send connections through a proxy server,
|
|
82
|
+
please set the appropriate options in the config file or config hash.
|
|
83
|
+
For example:
|
|
80
84
|
|
|
81
|
-
|
|
85
|
+
config[:connection] = {
|
|
86
|
+
:proxy => 'http://user:password@proxy_hostname:8080'
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
*Note*: If you are using Ruby 1.8 you may need to include RubyGems to be able
|
|
82
90
|
to require other gems code. There are several ways to do it, the easiest one is
|
|
83
91
|
to pass '-rubygems' parameter to the ruby interpreter:
|
|
84
|
-
|
|
92
|
+
|
|
93
|
+
$ ruby -rubygems my_program_that_uses_gems
|
|
85
94
|
|
|
86
95
|
you can also set this up in the environment:
|
|
87
|
-
|
|
96
|
+
|
|
97
|
+
$ export RUBYOPT="rubygems"
|
|
88
98
|
|
|
89
99
|
or add it to the bash configuration file:
|
|
90
|
-
|
|
100
|
+
|
|
101
|
+
$ echo 'export RUBYOPT="rubygems"' >> ~/.bashrc
|
|
91
102
|
|
|
92
103
|
|
|
93
|
-
|
|
104
|
+
### 2.1 - Ruby names for a Ruby library
|
|
94
105
|
|
|
95
106
|
In order to make things more Ruby-like for our Ruby developers, we've renamed
|
|
96
107
|
API objects and methods to more closely match Ruby conventions. This means using
|
|
97
108
|
snake_case for methods and parameters, and UpperCamelCase for class names.
|
|
98
109
|
|
|
99
|
-
For example, the
|
|
100
|
-
in the client library. The
|
|
101
|
-
|
|
110
|
+
For example, the `startDate` field of the Campaign object is named `start_date`
|
|
111
|
+
in the client library. The `get` method, returns a CampaignPage object which has
|
|
112
|
+
`entries` and `total_num_entries` fields. So, to access the return
|
|
102
113
|
values, you would do this:
|
|
103
114
|
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
response = campaign_srv.get(selector)
|
|
116
|
+
num_entries = response[:total_num_entries]
|
|
106
117
|
|
|
107
118
|
Essentially, all you have to do is follow Ruby conventions, and the library will
|
|
108
119
|
do the rest. All of the examples are written following this standard.
|
|
109
120
|
|
|
110
121
|
|
|
111
|
-
|
|
122
|
+
### 2.2 - Using the Test Account
|
|
112
123
|
|
|
113
124
|
For testing purposes, obtain a Test Account in the production environment. Any
|
|
114
|
-
request against a Test Account inccurs no API units charge. See
|
|
115
|
-
|
|
125
|
+
request against a Test Account inccurs no API units charge. See
|
|
126
|
+
[this guide](https://developers.google.com/adwords/api/docs/test-accounts) for
|
|
127
|
+
more details.
|
|
116
128
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
To use the library against a Test Account, set client_customer_id property in
|
|
129
|
+
To use the library against a Test Account, set the `client_customer_id` property in
|
|
120
130
|
the configuration file to its client customer ID.
|
|
121
131
|
|
|
122
132
|
|
|
123
|
-
|
|
133
|
+
### 2.3 - Logging
|
|
124
134
|
|
|
125
135
|
It is often useful to see a trace of the raw SOAP XML being sent and received.
|
|
126
136
|
The quickest way of achieving this when debugging your application is by setting
|
|
127
|
-
the library.log_level configuration variable to
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
the `library.log_level` configuration variable to DEBUG.
|
|
138
|
+
|
|
139
|
+
config[:library] = {
|
|
140
|
+
:log_level => 'DEBUG'
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
This can alternatively be done via a configuration file.
|
|
132
144
|
|
|
133
|
-
This will output the SOAP XML to stderr
|
|
145
|
+
This will output the SOAP XML to `stderr`, which will usually show up in your
|
|
134
146
|
terminal window.
|
|
135
147
|
|
|
136
148
|
There's also an option of logging requests and XML to a file. In order to enable
|
|
137
149
|
this, you should create a standard Logger object and pass it to the library:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
150
|
+
|
|
151
|
+
require 'logger'
|
|
152
|
+
logger = Logger.new('path/to/log_filename')
|
|
153
|
+
logger.level = Logger::DEBUG
|
|
154
|
+
adwords = AdwordsApi::Api.new
|
|
155
|
+
adwords.logger = logger
|
|
143
156
|
|
|
144
157
|
Request details and units spend are logged at the INFO log level, while raw HTTP
|
|
145
158
|
headers and XML dumps are logged at the DEBUG log level. For more details on
|
|
146
159
|
using Logger refer to the Ruby Logger documentation.
|
|
147
160
|
|
|
148
|
-
=== 2.4 - Calculating operations usage
|
|
149
161
|
|
|
150
|
-
|
|
151
|
-
described in the rate sheet:
|
|
162
|
+
### 2.4 - Calculating operations usage
|
|
152
163
|
|
|
153
|
-
|
|
164
|
+
Each AdWords API operation performed consumes a certain number of operations as
|
|
165
|
+
described in the
|
|
166
|
+
[rate sheet](https://developers.google.com/adwords/api/docs/ratesheet).
|
|
154
167
|
|
|
155
168
|
The amount of operations consumed is returned in the header part of the SOAP
|
|
156
169
|
response. This information can be obtained by passing a user block during the
|
|
157
170
|
method call:
|
|
158
171
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
response = campaign_srv.get(selector) do |header|
|
|
173
|
+
puts "Operations consumed: %d" % header[:operations]
|
|
174
|
+
end
|
|
162
175
|
|
|
163
176
|
You can also retrieve the response body as the second block parameter:
|
|
164
|
-
campaign_srv.get(selector) {|header, body| ... }
|
|
165
177
|
|
|
166
|
-
|
|
178
|
+
campaign_srv.get(selector) {|header, body| ... }
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
### 2.5 - GZip compression
|
|
167
182
|
|
|
168
183
|
The library offers a transparent compression option which can be enabled in the
|
|
169
184
|
configuration file or by the following setting:
|
|
170
185
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
186
|
+
config[:connection] = {
|
|
187
|
+
:enable_gzip => true
|
|
188
|
+
}
|
|
174
189
|
|
|
175
190
|
Enabling this option will set the headers required to request the server to
|
|
176
191
|
respond in gzipped format. All requests are sent uncompressed regardless.
|
|
177
192
|
|
|
178
193
|
|
|
179
|
-
|
|
194
|
+
# Docs for Developers
|
|
180
195
|
|
|
181
|
-
|
|
196
|
+
## Rake targets
|
|
182
197
|
|
|
183
|
-
|
|
184
|
-
to regenerate the stubs if needed
|
|
198
|
+
$ rake generate
|
|
185
199
|
|
|
186
|
-
|
|
187
|
-
$ gem build google-adx-buyer-api.gemspec
|
|
188
|
-
to build the gems
|
|
200
|
+
to regenerate the stubs if needed
|
|
189
201
|
|
|
190
|
-
|
|
191
|
-
|
|
202
|
+
$ gem build google-adwords-api.gemspec
|
|
203
|
+
$ gem build google-adx-buyer-api.gemspec
|
|
192
204
|
|
|
205
|
+
to build the gems
|
|
193
206
|
|
|
194
|
-
|
|
207
|
+
$ rake test
|
|
195
208
|
|
|
196
|
-
|
|
209
|
+
to run unit tests on the library
|
|
197
210
|
|
|
198
|
-
http://code.google.com/p/google-api-ads-ruby/issues
|
|
199
211
|
|
|
200
|
-
|
|
212
|
+
## Where do I submit bug reports and feature requests?
|
|
201
213
|
|
|
202
|
-
|
|
214
|
+
Bug reports and feature requests can be posted
|
|
215
|
+
[on the library page](https://github.com/googleads/google-api-ads-ruby/issues).
|
|
203
216
|
|
|
204
|
-
|
|
205
|
-
other news:
|
|
217
|
+
Questions can be asked [on the forum](http://groups.google.com/group/adwords-api).
|
|
206
218
|
|
|
207
|
-
|
|
219
|
+
Make sure to subscribe to our
|
|
220
|
+
[Google Plus page](https://plus.google.com/+GoogleAdsDevelopers) for API change
|
|
221
|
+
announcements and other news.
|
|
208
222
|
|
|
209
223
|
|
|
210
|
-
|
|
224
|
+
# Copyright/License Info
|
|
211
225
|
|
|
212
|
-
|
|
226
|
+
## Licence
|
|
213
227
|
|
|
214
228
|
Copyright 2010-2013, Google Inc. All Rights Reserved.
|
|
215
229
|
|
|
216
230
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
217
231
|
you may not use this file except in compliance with the License.
|
|
218
|
-
You may obtain a copy of the License at
|
|
232
|
+
You may obtain a copy of the License at:
|
|
219
233
|
|
|
220
|
-
|
|
234
|
+
> [http://www.apache.org/licenses/LICENSE-2.0]()
|
|
221
235
|
|
|
222
236
|
Unless required by applicable law or agreed to in writing, software
|
|
223
237
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
@@ -225,11 +239,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
225
239
|
See the License for the specific language governing permissions and
|
|
226
240
|
limitations under the License.
|
|
227
241
|
|
|
228
|
-
|
|
242
|
+
## Authors
|
|
229
243
|
|
|
230
244
|
Authors:
|
|
231
|
-
|
|
232
|
-
|
|
245
|
+
|
|
246
|
+
- api.sgomes (Sérgio Gomes)
|
|
247
|
+
- api.dklimkin@gmail.com (Danial Klimkin)
|
|
248
|
+
- api.mcloonan@gmail.com (Michael Cloonan)
|
|
233
249
|
|
|
234
250
|
Maintainer:
|
|
235
|
-
|
|
251
|
+
|
|
252
|
+
- api.mcloonan@gmail.com (Michael Cloonan)
|
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
21
|
# This example illustrates how to use OAuth2.0 authentication method with
|
|
22
|
-
# Service Account (JWT).
|
|
22
|
+
# Service Account (JWT). For this example to work, your Service Account must be
|
|
23
|
+
# a Google Apps for Business Account.
|
|
24
|
+
#
|
|
25
|
+
# See https://developers.google.com/adwords/api/docs/guides/service-accounts
|
|
26
|
+
# for more information.
|
|
23
27
|
#
|
|
24
28
|
# Tags: CampaignService.get
|
|
25
29
|
|
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
# limitations under the License.
|
|
20
20
|
#
|
|
21
21
|
# This example illustrates how to use OAuth2.0 authentication method with
|
|
22
|
-
# Service Account (JWT).
|
|
22
|
+
# Service Account (JWT). For this example to work, your Service Account must be
|
|
23
|
+
# a Google Apps for Business Account.
|
|
24
|
+
#
|
|
25
|
+
# See https://developers.google.com/adwords/api/docs/guides/service-accounts
|
|
26
|
+
# for more information.
|
|
23
27
|
#
|
|
24
28
|
# Tags: CampaignService.get
|
|
25
29
|
|
|
@@ -0,0 +1,95 @@
|
|
|
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 create an account. Note by default this
|
|
22
|
+
# account will only be accessible via parent MCC.
|
|
23
|
+
#
|
|
24
|
+
# Note: This code example uses MCC-level calls and won't work with Test
|
|
25
|
+
# Accounts, see: https://developers.google.com/adwords/api/docs/test-accounts
|
|
26
|
+
#
|
|
27
|
+
# Tags: ManagedCustomerService.mutate
|
|
28
|
+
|
|
29
|
+
require 'adwords_api'
|
|
30
|
+
require 'adwords_api/utils'
|
|
31
|
+
|
|
32
|
+
def create_account()
|
|
33
|
+
# AdwordsApi::Api will read a config file from ENV['HOME']/adwords_api.yml
|
|
34
|
+
# when called without parameters.
|
|
35
|
+
adwords = AdwordsApi::Api.new
|
|
36
|
+
|
|
37
|
+
# To enable logging of SOAP requests, set the log_level value to 'DEBUG' in
|
|
38
|
+
# the configuration file or provide your own logger:
|
|
39
|
+
# adwords.logger = Logger.new('adwords_xml.log')
|
|
40
|
+
|
|
41
|
+
managed_customer_srv = adwords.service(:ManagedCustomerService, API_VERSION)
|
|
42
|
+
|
|
43
|
+
# Create a local Customer object.
|
|
44
|
+
customer = {
|
|
45
|
+
:name => 'Account created with ManagedCustomerService',
|
|
46
|
+
:currency_code => 'EUR',
|
|
47
|
+
:date_time_zone => 'Europe/London'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Prepare operation to create an account.
|
|
51
|
+
operation = {
|
|
52
|
+
:operator => 'ADD',
|
|
53
|
+
:operand => customer
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# Create the account. It is possible to create multiple accounts with one
|
|
57
|
+
# request by sending an array of operations.
|
|
58
|
+
response = managed_customer_srv.mutate([operation])
|
|
59
|
+
|
|
60
|
+
response[:value].each do |new_account|
|
|
61
|
+
puts "Account with customer ID '%s' was successfully created." %
|
|
62
|
+
AdwordsApi::Utils.format_id(new_account[:customer_id])
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if __FILE__ == $0
|
|
67
|
+
API_VERSION = :v201402
|
|
68
|
+
|
|
69
|
+
begin
|
|
70
|
+
create_account()
|
|
71
|
+
|
|
72
|
+
# Authorization error.
|
|
73
|
+
rescue AdsCommon::Errors::OAuth2VerificationRequired => e
|
|
74
|
+
puts "Authorization credentials are not valid. Edit adwords_api.yml for " +
|
|
75
|
+
"OAuth2 client ID and secret and run misc/setup_oauth2.rb example " +
|
|
76
|
+
"to retrieve and store OAuth2 tokens."
|
|
77
|
+
puts "See this wiki page for more details:\n\n " +
|
|
78
|
+
'http://code.google.com/p/google-api-ads-ruby/wiki/OAuth2'
|
|
79
|
+
|
|
80
|
+
# HTTP errors.
|
|
81
|
+
rescue AdsCommon::Errors::HttpError => e
|
|
82
|
+
puts "HTTP Error: %s" % e
|
|
83
|
+
|
|
84
|
+
# API errors.
|
|
85
|
+
rescue AdwordsApi::Errors::ApiException => e
|
|
86
|
+
puts "Message: %s" % e.message
|
|
87
|
+
puts 'Errors:'
|
|
88
|
+
e.errors.each_with_index do |error, index|
|
|
89
|
+
puts "\tError [%d]:" % (index + 1)
|
|
90
|
+
error.each do |field, value|
|
|
91
|
+
puts "\t\t%s: %s" % [field, value]
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|