google-adwords-api 1.5.0 → 1.6.0
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.
- checksums.yaml +4 -4
- data/COPYING +0 -0
- data/ChangeLog +4 -0
- data/README.md +9 -236
- data/lib/adwords_api.rb +2 -234
- metadata +8 -134
- data/adwords_api.yml +0 -53
- data/lib/adwords_api/api_config.rb +0 -221
- data/lib/adwords_api/batch_job_utils.rb +0 -334
- data/lib/adwords_api/credential_handler.rb +0 -96
- data/lib/adwords_api/errors.rb +0 -110
- data/lib/adwords_api/incremental_upload_helper.rb +0 -75
- data/lib/adwords_api/query_utils/query_builder.rb +0 -41
- data/lib/adwords_api/query_utils/report_query.rb +0 -30
- data/lib/adwords_api/query_utils/report_query_builder.rb +0 -82
- data/lib/adwords_api/query_utils/service_query.rb +0 -62
- data/lib/adwords_api/query_utils/service_query_builder.rb +0 -83
- data/lib/adwords_api/query_utils/where_builder.rb +0 -97
- data/lib/adwords_api/report_header_handler.rb +0 -80
- data/lib/adwords_api/report_stream.rb +0 -70
- data/lib/adwords_api/report_utils.rb +0 -383
- data/lib/adwords_api/utils.rb +0 -56
- data/lib/adwords_api/utils_reporter.rb +0 -58
- data/lib/adwords_api/v201809/account_label_service.rb +0 -46
- data/lib/adwords_api/v201809/account_label_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_customizer_feed_service.rb +0 -46
- data/lib/adwords_api/v201809/ad_customizer_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_group_ad_service.rb +0 -62
- data/lib/adwords_api/v201809/ad_group_ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_group_bid_modifier_service.rb +0 -54
- data/lib/adwords_api/v201809/ad_group_bid_modifier_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_group_criterion_service.rb +0 -62
- data/lib/adwords_api/v201809/ad_group_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_group_extension_setting_service.rb +0 -54
- data/lib/adwords_api/v201809/ad_group_extension_setting_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_group_feed_service.rb +0 -54
- data/lib/adwords_api/v201809/ad_group_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_group_service.rb +0 -62
- data/lib/adwords_api/v201809/ad_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_param_service.rb +0 -46
- data/lib/adwords_api/v201809/ad_param_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/ad_service.rb +0 -46
- data/lib/adwords_api/v201809/ad_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/adwords_user_list_service.rb +0 -62
- data/lib/adwords_api/v201809/adwords_user_list_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/asset_service.rb +0 -46
- data/lib/adwords_api/v201809/asset_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/batch_job_service.rb +0 -54
- data/lib/adwords_api/v201809/batch_job_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/bidding_strategy_service.rb +0 -54
- data/lib/adwords_api/v201809/bidding_strategy_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/budget_order_service.rb +0 -54
- data/lib/adwords_api/v201809/budget_order_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/budget_service.rb +0 -54
- data/lib/adwords_api/v201809/budget_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/campaign_bid_modifier_service.rb +0 -54
- data/lib/adwords_api/v201809/campaign_bid_modifier_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/campaign_criterion_service.rb +0 -54
- data/lib/adwords_api/v201809/campaign_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/campaign_extension_setting_service.rb +0 -54
- data/lib/adwords_api/v201809/campaign_extension_setting_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/campaign_feed_service.rb +0 -54
- data/lib/adwords_api/v201809/campaign_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/campaign_group_performance_target_service.rb +0 -46
- data/lib/adwords_api/v201809/campaign_group_performance_target_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/campaign_group_service.rb +0 -46
- data/lib/adwords_api/v201809/campaign_group_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/campaign_service.rb +0 -62
- data/lib/adwords_api/v201809/campaign_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/campaign_shared_set_service.rb +0 -54
- data/lib/adwords_api/v201809/campaign_shared_set_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/constant_data_service.rb +0 -110
- data/lib/adwords_api/v201809/constant_data_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/conversion_tracker_service.rb +0 -54
- data/lib/adwords_api/v201809/conversion_tracker_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/custom_affinity_service.rb +0 -62
- data/lib/adwords_api/v201809/custom_affinity_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/customer_extension_setting_service.rb +0 -54
- data/lib/adwords_api/v201809/customer_extension_setting_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/customer_feed_service.rb +0 -54
- data/lib/adwords_api/v201809/customer_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/customer_negative_criterion_service.rb +0 -54
- data/lib/adwords_api/v201809/customer_negative_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/customer_service.rb +0 -62
- data/lib/adwords_api/v201809/customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/customer_sync_service.rb +0 -38
- data/lib/adwords_api/v201809/customer_sync_service_registry.rb +0 -47
- data/lib/adwords_api/v201809/data_service.rb +0 -94
- data/lib/adwords_api/v201809/data_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/draft_async_error_service.rb +0 -46
- data/lib/adwords_api/v201809/draft_async_error_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/draft_service.rb +0 -54
- data/lib/adwords_api/v201809/draft_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/feed_item_service.rb +0 -54
- data/lib/adwords_api/v201809/feed_item_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/feed_item_target_service.rb +0 -54
- data/lib/adwords_api/v201809/feed_item_target_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/feed_mapping_service.rb +0 -54
- data/lib/adwords_api/v201809/feed_mapping_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/feed_service.rb +0 -54
- data/lib/adwords_api/v201809/feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/label_service.rb +0 -54
- data/lib/adwords_api/v201809/label_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/location_criterion_service.rb +0 -46
- data/lib/adwords_api/v201809/location_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/managed_customer_service.rb +0 -78
- data/lib/adwords_api/v201809/managed_customer_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/media_service.rb +0 -54
- data/lib/adwords_api/v201809/media_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/offline_call_conversion_feed_service.rb +0 -38
- data/lib/adwords_api/v201809/offline_call_conversion_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/offline_conversion_adjustment_feed_service.rb +0 -38
- data/lib/adwords_api/v201809/offline_conversion_adjustment_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/offline_conversion_feed_service.rb +0 -38
- data/lib/adwords_api/v201809/offline_conversion_feed_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/offline_data_upload_service.rb +0 -46
- data/lib/adwords_api/v201809/offline_data_upload_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/report_definition_service.rb +0 -38
- data/lib/adwords_api/v201809/report_definition_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/shared_criterion_service.rb +0 -54
- data/lib/adwords_api/v201809/shared_criterion_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/shared_set_service.rb +0 -54
- data/lib/adwords_api/v201809/shared_set_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/targeting_idea_service.rb +0 -38
- data/lib/adwords_api/v201809/targeting_idea_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/traffic_estimator_service.rb +0 -38
- data/lib/adwords_api/v201809/traffic_estimator_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/trial_async_error_service.rb +0 -46
- data/lib/adwords_api/v201809/trial_async_error_service_registry.rb +0 -46
- data/lib/adwords_api/v201809/trial_service.rb +0 -54
- data/lib/adwords_api/v201809/trial_service_registry.rb +0 -46
- data/lib/adwords_api/version.rb +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91ec6f3a83f5affe00c79f9bd1c5f0cd831d8b6f249ed1dda38cdc507353f0d0
|
|
4
|
+
data.tar.gz: 998210bfdf2745291dd5cbceebf2c15c484f580aa64964686792399ad2080c02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 92ad02273f9f74ef83529c8ac1ebecd372560a56a813a7b8397212933a16b60adb672ab85c5b0cf13619419d378fe27e6ec21e112f67481a5cb59744e196c050
|
|
7
|
+
data.tar.gz: cd2ca42ad522be03bc83f9b638f0edb4bde4064646a46e0d0f6ec78093f9dfcad8d353e995b3a362a42e55d6e9c43d66e8ecb7a1e62f859470dc8e15f6383ae3
|
data/COPYING
CHANGED
|
File without changes
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
1.6.0:
|
|
2
|
+
- Adwords API has been sunset. This library is no longer maintained.
|
|
3
|
+
- Please upgrade to the Google Ads API: https://developers.google.com/google-ads/api/docs/client-libs/ruby
|
|
4
|
+
|
|
1
5
|
1.5.0:
|
|
2
6
|
- Remove deprecated API version v201806.
|
|
3
7
|
- Fixed a release script issue that prevented older versions from being
|
data/README.md
CHANGED
|
@@ -1,239 +1,12 @@
|
|
|
1
1
|
# Google AdWords Client Library
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
AdWords API!
|
|
3
|
+
The AdWords API is no longer available. This library is no longer maintained.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
collections.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# Docs for Users
|
|
12
|
-
|
|
13
|
-
## 1 - Installation
|
|
14
|
-
|
|
15
|
-
`google-adwords-api` is a ruby gem. See
|
|
16
|
-
[http://guides.rubygems.org/rubygems-basics/]().
|
|
17
|
-
|
|
18
|
-
Install it using the gem install command:
|
|
19
|
-
|
|
20
|
-
$ gem install --remote google-adwords-api
|
|
21
|
-
|
|
22
|
-
The following gem libraries are required:
|
|
23
|
-
|
|
24
|
-
- google-ads-savon
|
|
25
|
-
- google-ads-common
|
|
26
|
-
|
|
27
|
-
Note: If you're using a version of Ruby lower than 2.2.2, you will need to
|
|
28
|
-
manually install a previous version of Rack, a dependency of our HTTP library.
|
|
29
|
-
You can do this with:
|
|
30
|
-
|
|
31
|
-
$ gem install rack -v 1.6.4
|
|
32
|
-
|
|
33
|
-
## 2 - Using the client library
|
|
34
|
-
|
|
35
|
-
Before starting to use the client library, you need to set up OAuth2. You can
|
|
36
|
-
find our guide on how to obtain OAuth2 credentials
|
|
37
|
-
[on the wiki](https://github.com/googleads/google-api-ads-ruby/wiki/OAuth2).
|
|
38
|
-
|
|
39
|
-
By default, the API uses a config file in `ENV['HOME']/adwords_api.yml`. When
|
|
40
|
-
generating your OAuth2 refresh token, you will be given the option for the
|
|
41
|
-
sample to automatically store the refresh token in this file.
|
|
42
|
-
|
|
43
|
-
You can also pass the API a manually constructed config hash like:
|
|
44
|
-
|
|
45
|
-
adwords = AdwordsApi::Api.new({
|
|
46
|
-
:authentication => {
|
|
47
|
-
:method => 'OAuth2',
|
|
48
|
-
:oauth2_client_id => 'INSERT_OAUTH2_CLIENT_ID_HERE',
|
|
49
|
-
:oauth2_client_secret => 'INSERT_OAUTH2_CLIENT_SECRET_HERE',
|
|
50
|
-
:developer_token => 'DEVELOPER_TOKEN',
|
|
51
|
-
:client_customer_id => '012-345-6789',
|
|
52
|
-
:user_agent => 'Ruby Sample'
|
|
53
|
-
},
|
|
54
|
-
:service => {
|
|
55
|
-
:environment => 'PRODUCTION'
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
Once you have all the requisite setup complete, you're ready to make an API
|
|
60
|
-
call. The easiest way to do this is to look at one of our
|
|
61
|
-
[examples](https://github.com/googleads/google-api-ads-ruby/tree/master/adwords_api/examples).
|
|
62
|
-
The `adwords_on_rails` example will show how to use the web flow, and the other
|
|
63
|
-
examples will use the installed application OAuth2 flow.
|
|
64
|
-
|
|
65
|
-
The basics of making a request are:
|
|
66
|
-
|
|
67
|
-
1. Include the library with `require`:
|
|
68
|
-
|
|
69
|
-
require 'adwords_api'
|
|
70
|
-
|
|
71
|
-
2. Create an API instance:
|
|
72
|
-
|
|
73
|
-
adwords = AdwordsApi::Api.new
|
|
74
|
-
|
|
75
|
-
3. Specify which service you're looking to use, and which version:
|
|
76
|
-
|
|
77
|
-
campaign_srv = adwords.service(:CampaignService, :v201809)
|
|
78
|
-
|
|
79
|
-
4. You should now be able to just use the API methods in the returned object:
|
|
80
|
-
|
|
81
|
-
# Get 'Id', 'Name' and 'Status' fields of all campaigns.
|
|
82
|
-
campaigns = campaign_srv.get({:fields => ['Id', 'Name', 'Status']})
|
|
83
|
-
|
|
84
|
-
See the code in the examples directory for more thorough working examples you
|
|
85
|
-
can build from.
|
|
86
|
-
|
|
87
|
-
*Note*: If your setup requires you to send connections through a proxy server,
|
|
88
|
-
please set the appropriate options in the config file or config hash.
|
|
89
|
-
For example:
|
|
90
|
-
|
|
91
|
-
config[:connection] = {
|
|
92
|
-
:proxy => 'http://user:password@proxy_hostname:8080'
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
### 2.1 - Ruby names for a Ruby library
|
|
96
|
-
|
|
97
|
-
In order to make things more Ruby-like for our Ruby developers, we've renamed
|
|
98
|
-
API objects and methods to more closely match Ruby conventions. This means using
|
|
99
|
-
snake_case for methods and parameters, and UpperCamelCase for class names.
|
|
100
|
-
|
|
101
|
-
For example, the `startDate` field of the Campaign object is named `start_date`
|
|
102
|
-
in the client library. The `get` method, returns a CampaignPage object which has
|
|
103
|
-
`entries` and `total_num_entries` fields. So, to access the return
|
|
104
|
-
values, you would do this:
|
|
105
|
-
|
|
106
|
-
response = campaign_srv.get(selector)
|
|
107
|
-
num_entries = response[:total_num_entries]
|
|
108
|
-
|
|
109
|
-
Essentially, all you have to do is follow Ruby conventions, and the library will
|
|
110
|
-
do the rest. All of the examples are written following this standard.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
### 2.2 - Using the Test Account
|
|
114
|
-
|
|
115
|
-
For testing purposes, obtain a Test Account in the production environment. Any
|
|
116
|
-
request against a Test Account inccurs no API units charge. See
|
|
117
|
-
[this guide](https://developers.google.com/adwords/api/docs/test-accounts) for
|
|
118
|
-
more details.
|
|
119
|
-
|
|
120
|
-
To use the library against a Test Account, set the `client_customer_id` property in
|
|
121
|
-
the configuration file to its client customer ID.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
### 2.3 - Logging
|
|
125
|
-
|
|
126
|
-
It is often useful to see a trace of the raw SOAP XML being sent and received.
|
|
127
|
-
The quickest way of achieving this when debugging your application is by setting
|
|
128
|
-
the `library.log_level` configuration variable to DEBUG.
|
|
129
|
-
|
|
130
|
-
config[:library] = {
|
|
131
|
-
:log_level => 'DEBUG'
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
This can alternatively be done via a configuration file.
|
|
135
|
-
|
|
136
|
-
This will output the SOAP XML to `stderr`, which will usually show up in your
|
|
137
|
-
terminal window.
|
|
138
|
-
|
|
139
|
-
There's also an option of logging requests and XML to a file. In order to enable
|
|
140
|
-
this, you should create a standard Logger object and pass it to the library:
|
|
141
|
-
|
|
142
|
-
require 'logger'
|
|
143
|
-
logger = Logger.new('path/to/log_filename')
|
|
144
|
-
logger.level = Logger::DEBUG
|
|
145
|
-
adwords = AdwordsApi::Api.new
|
|
146
|
-
adwords.logger = logger
|
|
147
|
-
|
|
148
|
-
Request details and units spend are logged at the INFO log level, while raw HTTP
|
|
149
|
-
headers and XML dumps are logged at the DEBUG log level. For more details on
|
|
150
|
-
using Logger refer to the Ruby Logger documentation.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
### 2.4 - Calculating operations usage
|
|
154
|
-
|
|
155
|
-
Each AdWords API operation performed consumes a certain number of operations as
|
|
156
|
-
described in the
|
|
157
|
-
[rate sheet](https://developers.google.com/adwords/api/docs/ratesheet).
|
|
158
|
-
|
|
159
|
-
The amount of operations consumed is returned in the header part of the SOAP
|
|
160
|
-
response. This information can be obtained by passing a user block during the
|
|
161
|
-
method call:
|
|
162
|
-
|
|
163
|
-
response = campaign_srv.get(selector) do |header|
|
|
164
|
-
puts "Operations consumed: %d" % header[:operations]
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
You can also retrieve the response body as the second block parameter:
|
|
168
|
-
|
|
169
|
-
campaign_srv.get(selector) {|header, body| ... }
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
### 2.5 - GZip compression
|
|
173
|
-
|
|
174
|
-
The library offers a transparent compression option which can be enabled in the
|
|
175
|
-
configuration file or by the following setting:
|
|
176
|
-
|
|
177
|
-
config[:connection] = {
|
|
178
|
-
:enable_gzip => true
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
Enabling this option will set the headers required to request the server to
|
|
182
|
-
respond in gzipped format. All requests are sent uncompressed regardless.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
### 2.6 - Utilities
|
|
186
|
-
|
|
187
|
-
The library offers utilities to make fetching reports and using the
|
|
188
|
-
BatchJobService easier. Take a look at our wiki page on
|
|
189
|
-
[AdWords Utilities](https://github.com/googleads/google-api-ads-ruby/wiki/AdWords-Utilities)
|
|
190
|
-
for more information.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
# Docs for Developers
|
|
194
|
-
|
|
195
|
-
## Rake targets
|
|
196
|
-
|
|
197
|
-
To regenerate all the stubs for all versions if needed:
|
|
198
|
-
|
|
199
|
-
$ rake generate
|
|
200
|
-
|
|
201
|
-
To target a specific version:
|
|
202
|
-
|
|
203
|
-
$ rake generate[version]
|
|
204
|
-
|
|
205
|
-
For example:
|
|
206
|
-
|
|
207
|
-
$ rake generate[v201809]
|
|
208
|
-
|
|
209
|
-
To target a specific service in a specific version:
|
|
210
|
-
|
|
211
|
-
$ rake generate[version,service]
|
|
212
|
-
|
|
213
|
-
For example:
|
|
214
|
-
|
|
215
|
-
$ rake generate[v201809,CampaignService]
|
|
216
|
-
|
|
217
|
-
To build the gems:
|
|
218
|
-
|
|
219
|
-
$ gem build google-adwords-api.gemspec
|
|
220
|
-
|
|
221
|
-
To run unit tests on the library:
|
|
222
|
-
|
|
223
|
-
$ rake test
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
## Where do I submit bug reports and feature requests?
|
|
227
|
-
|
|
228
|
-
Bug reports and feature requests can be posted
|
|
229
|
-
[on the library page](https://github.com/googleads/google-api-ads-ruby/issues).
|
|
230
|
-
|
|
231
|
-
Questions can be asked [on the forum](http://groups.google.com/group/adwords-api).
|
|
232
|
-
|
|
233
|
-
Make sure to subscribe to our
|
|
234
|
-
[Google Plus page](https://plus.google.com/+GoogleAdsDevelopers) for API change
|
|
235
|
-
announcements and other news.
|
|
5
|
+
Please upgrade to the
|
|
6
|
+
[Google Ads API](https://developers.google.com/google-ads/api/docs/start).
|
|
236
7
|
|
|
8
|
+
To access the Google Ads API use the
|
|
9
|
+
[google-ads-googleads](https://rubygems.org/gems/google-ads-googleads) library.
|
|
237
10
|
|
|
238
11
|
# Copyright/License Info
|
|
239
12
|
|
|
@@ -257,10 +30,10 @@ limitations under the License.
|
|
|
257
30
|
|
|
258
31
|
Authors:
|
|
259
32
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
33
|
+
- Sérgio Gomes
|
|
34
|
+
- Danial Klimkin
|
|
35
|
+
- Michael Cloonan
|
|
263
36
|
|
|
264
37
|
Maintainer:
|
|
265
38
|
|
|
266
|
-
|
|
39
|
+
- Michael Cloonan
|
data/lib/adwords_api.rb
CHANGED
|
@@ -1,237 +1,5 @@
|
|
|
1
|
-
# Encoding: utf-8
|
|
2
|
-
#
|
|
3
|
-
# Copyright:: Copyright 2010, Google Inc. All Rights Reserved.
|
|
4
|
-
#
|
|
5
|
-
# License:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
14
|
-
# implied.
|
|
15
|
-
# See the License for the specific language governing permissions and
|
|
16
|
-
# limitations under the License.
|
|
17
|
-
#
|
|
18
|
-
# Contains the main classes for the client library.
|
|
19
|
-
|
|
20
|
-
require 'ads_common/api'
|
|
21
|
-
require 'ads_common/savon_headers/oauth_header_handler'
|
|
22
|
-
require 'adwords_api/api_config'
|
|
23
|
-
require 'adwords_api/credential_handler'
|
|
24
|
-
require 'adwords_api/errors'
|
|
25
|
-
require 'adwords_api/report_utils'
|
|
26
|
-
require 'adwords_api/batch_job_utils'
|
|
27
|
-
require 'adwords_api/utils_reporter'
|
|
28
|
-
require 'adwords_api/query_utils/report_query_builder'
|
|
29
|
-
require 'adwords_api/query_utils/service_query_builder'
|
|
30
|
-
|
|
31
1
|
# Main namespace for all the client library's modules and classes.
|
|
32
2
|
module AdwordsApi
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
#
|
|
36
|
-
# Holds all the services, as well as login credentials.
|
|
37
|
-
#
|
|
38
|
-
class Api < AdsCommon::Api
|
|
39
|
-
|
|
40
|
-
attr_reader :utils_reporter
|
|
41
|
-
|
|
42
|
-
# Constructor for API.
|
|
43
|
-
def initialize(provided_config = nil)
|
|
44
|
-
super(provided_config)
|
|
45
|
-
@credential_handler = AdwordsApi::CredentialHandler.new(@config)
|
|
46
|
-
@utils_reporter = AdwordsApi::UtilsReporter.new(@credential_handler)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Getter for the API service configurations
|
|
50
|
-
def api_config()
|
|
51
|
-
AdwordsApi::ApiConfig
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# Retrieve correct soap_header_handler.
|
|
55
|
-
#
|
|
56
|
-
# Args:
|
|
57
|
-
# - auth_handler: instance of an AdsCommon::Auth::BaseHandler subclass to
|
|
58
|
-
# handle authentication
|
|
59
|
-
# - version: intended API version
|
|
60
|
-
# - header_ns: header namespace
|
|
61
|
-
# - default_ns: default namespace
|
|
62
|
-
#
|
|
63
|
-
# Returns:
|
|
64
|
-
# - SOAP header handler
|
|
65
|
-
#
|
|
66
|
-
def soap_header_handler(auth_handler, version, header_ns, default_ns)
|
|
67
|
-
auth_method = @config.read('authentication.method', :OAUTH2)
|
|
68
|
-
handler_class = case auth_method
|
|
69
|
-
when :OAUTH2, :OAUTH2_SERVICE_ACCOUNT
|
|
70
|
-
AdsCommon::SavonHeaders::OAuthHeaderHandler
|
|
71
|
-
else
|
|
72
|
-
raise AdsCommon::Errors::AuthError,
|
|
73
|
-
"Unknown auth method: %s" % auth_method
|
|
74
|
-
end
|
|
75
|
-
return handler_class.new(@credential_handler, auth_handler, header_ns,
|
|
76
|
-
default_ns, version)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# Helper method to provide a simple way of doing a validate-only operation
|
|
80
|
-
# without the need to change credentials. Executes a block of code as an
|
|
81
|
-
# validate-only operation and/or returns the current status of the property.
|
|
82
|
-
#
|
|
83
|
-
# Args:
|
|
84
|
-
# - accepts a block, which it will execute as a validate-only operation
|
|
85
|
-
#
|
|
86
|
-
# Returns:
|
|
87
|
-
# - block execution result, if block given
|
|
88
|
-
# - boolean indicating whether validate-only operations are currently
|
|
89
|
-
# enabled or disabled, if no block provided
|
|
90
|
-
#
|
|
91
|
-
def validate_only(&block)
|
|
92
|
-
return (block_given?) ?
|
|
93
|
-
run_with_temporary_flag(:@validate_only, true, block) :
|
|
94
|
-
@credential_handler.validate_only
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# Helper method to provide a simple way of performing validate-only
|
|
98
|
-
# operations. Sets the value of the property
|
|
99
|
-
# that controls whether validate-only operations are enabled or disabled.
|
|
100
|
-
#
|
|
101
|
-
# Args:
|
|
102
|
-
# - value: the new value for the property (boolean)
|
|
103
|
-
#
|
|
104
|
-
def validate_only=(value)
|
|
105
|
-
@credential_handler.validate_only = value
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# Helper method to skip the report header when downloading reports.
|
|
109
|
-
#
|
|
110
|
-
# Args:
|
|
111
|
-
# - value: whether to skip the report header (boolean)
|
|
112
|
-
#
|
|
113
|
-
def skip_report_header=(value)
|
|
114
|
-
@config.set('library.skip_report_header', value)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Helper method to skip the report summary when downloading reports.
|
|
118
|
-
#
|
|
119
|
-
# Args:
|
|
120
|
-
# - value: whether to skip the report summary (boolean)
|
|
121
|
-
#
|
|
122
|
-
def skip_report_summary=(value)
|
|
123
|
-
@config.set('library.skip_report_summary', value)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
# Helper method to skip the column header when downloading reports.
|
|
127
|
-
#
|
|
128
|
-
# Args:
|
|
129
|
-
# - value: whether to skip the column header (boolean)
|
|
130
|
-
#
|
|
131
|
-
def skip_column_header=(value)
|
|
132
|
-
@config.set('library.skip_column_header', value)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# Helper method to include zero impressions when downloading reports.
|
|
136
|
-
#
|
|
137
|
-
# Args:
|
|
138
|
-
# - value: whether to include zero impressions (boolean)
|
|
139
|
-
#
|
|
140
|
-
def include_zero_impressions=(value)
|
|
141
|
-
@config.set('library.include_zero_impressions', value)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
# Helper method to use raw enum values when downloading reports.
|
|
145
|
-
#
|
|
146
|
-
# Args:
|
|
147
|
-
# - value: whether to use raw enum values (boolean)
|
|
148
|
-
#
|
|
149
|
-
def use_raw_enum_values=(value)
|
|
150
|
-
@config.set('library.use_raw_enum_values', value)
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
# Helper method to provide a simple way of performing requests with support
|
|
154
|
-
# for partial failures. Executes a block of code with partial failures
|
|
155
|
-
# enabled and/or returns the current status of the property.
|
|
156
|
-
#
|
|
157
|
-
# Args:
|
|
158
|
-
# - accepts a block, which it will execute as a partial failure operation
|
|
159
|
-
#
|
|
160
|
-
# Returns:
|
|
161
|
-
# - block execution result, if block given
|
|
162
|
-
# - boolean indicating whether partial failure operations are currently
|
|
163
|
-
# enabled or disabled, if no block provided
|
|
164
|
-
#
|
|
165
|
-
def partial_failure(&block)
|
|
166
|
-
return (block_given?) ?
|
|
167
|
-
run_with_temporary_flag(:@partial_failure, true, block) :
|
|
168
|
-
@credential_handler.partial_failure
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
# Helper method to provide a simple way of performing requests with support
|
|
172
|
-
# for partial failures.
|
|
173
|
-
#
|
|
174
|
-
# Args:
|
|
175
|
-
# - value: the new value for the property (boolean)
|
|
176
|
-
#
|
|
177
|
-
def partial_failure=(value)
|
|
178
|
-
@credential_handler.partial_failure = value
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
# Returns an instance of ReportUtils object with all utilities relevant to
|
|
182
|
-
# the reporting.
|
|
183
|
-
#
|
|
184
|
-
# Args:
|
|
185
|
-
# - version: version of the API to use (optional).
|
|
186
|
-
#
|
|
187
|
-
def report_utils(version = nil)
|
|
188
|
-
version = api_config.default_version if version.nil?
|
|
189
|
-
# Check if version exists.
|
|
190
|
-
if !api_config.versions.include?(version)
|
|
191
|
-
raise AdsCommon::Errors::Error, "Unknown version '%s'" % version
|
|
192
|
-
end
|
|
193
|
-
return AdwordsApi::ReportUtils.new(self, version)
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
# Returns an instance of BatchJobUtils object with all utilities relevant
|
|
197
|
-
# to running batch jobs.
|
|
198
|
-
#
|
|
199
|
-
# Args:
|
|
200
|
-
# - version: version of the API to use (optional).
|
|
201
|
-
#
|
|
202
|
-
def batch_job_utils(version = nil)
|
|
203
|
-
version = api_config.default_version if version.nil?
|
|
204
|
-
# Check if version exists.
|
|
205
|
-
if !api_config.versions.include?(version)
|
|
206
|
-
raise AdsCommon::Errors::Error, "Unknown version '%s'" % version
|
|
207
|
-
end
|
|
208
|
-
return AdwordsApi::BatchJobUtils.new(self, version)
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
# Returns an instance of ReportQueryBuilder to aid in generating AWQL for
|
|
212
|
-
# reports.
|
|
213
|
-
def report_query_builder(&block)
|
|
214
|
-
return AdwordsApi::ReportQueryBuilder.new(self, &block)
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
# Returns an instance of ServiceQueryBuilder to aid in generating AWQL for
|
|
218
|
-
# service queries.
|
|
219
|
-
def service_query_builder(&block)
|
|
220
|
-
return AdwordsApi::ServiceQueryBuilder.new(self, &block)
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
private
|
|
224
|
-
|
|
225
|
-
# Executes block with a temporary flag set to a given value. Returns block
|
|
226
|
-
# result.
|
|
227
|
-
def run_with_temporary_flag(flag_name, flag_value, block)
|
|
228
|
-
previous = @credential_handler.instance_variable_get(flag_name)
|
|
229
|
-
@credential_handler.instance_variable_set(flag_name, flag_value)
|
|
230
|
-
begin
|
|
231
|
-
return block.call
|
|
232
|
-
ensure
|
|
233
|
-
@credential_handler.instance_variable_set(flag_name, previous)
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
end
|
|
3
|
+
puts "The AdWords API is no longer available.\nUse the Google Ads API instead:
|
|
4
|
+
https://developers.google.com/google-ads/api/docs/client-libs/ruby"
|
|
237
5
|
end
|