adwords4r 11.0.3 → 11.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.txt +12 -0
- data/Copying.txt +10 -25
- data/Licence.txt +10 -7
- data/Rakefile +1 -1
- data/Readme.txt +36 -39
- data/examples/{campaign.rb → old/campaign.rb} +0 -0
- data/examples/{framework.rb → old/framework.rb} +0 -0
- data/examples/{get_free_usage_this_month.rb → old/get_free_usage_this_month.rb} +0 -0
- data/examples/{get_unit_count.rb → old/get_unit_count.rb} +0 -0
- data/examples/{keyword_tool_demo.rb → old/keyword_tool_demo.rb} +0 -0
- data/examples/{traffic_estimator.rb → old/traffic_estimator.rb} +0 -0
- data/examples/reports.rb +172 -0
- data/lib/adwords4r.rb +54 -2
- metadata +9 -9
- data/Todo.txt +0 -21
data/ChangeLog.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
11.1.0
|
2
|
+
- Added additional attributes to the AdWords::Error::ApiError class.
|
3
|
+
This should make it easier to get all the useful SOAP fault information, some of which wasn't available in the previous version.
|
4
|
+
The extra attributes are :trigger_ex, :soap_faultcode_ex, :soap_faultstring_ex, and :code_ex
|
5
|
+
- Added static methods to the AdWords::API class to retrieve API unit usage information.
|
6
|
+
AdWords::API.get_total_units() will return the a running total of API units used since the API was initialized.
|
7
|
+
AdWords::API.get_last_units() will return the number of API units used for the last API call.
|
8
|
+
- Started the process of creating new sample code. The existing code samples are a bit lacking and were moved to the 'examples/old' directory.
|
9
|
+
A new sample program, 'examples/reports.rb' was created. This sample validates, schedules, and downloads a Keyword Structure report.
|
10
|
+
It's a fairly extensive sample and illustrates some of the new API features as well as general best-practices.
|
11
|
+
Look for more sample code in future releases.
|
12
|
+
|
1
13
|
11.0.3
|
2
14
|
- update soap4r minimum version requirement in the .gem file to 1.5.8, as there are compatibility problems with 1.5.6
|
3
15
|
- the ADWORDS4R_DEBUG environment variable was causing problems when it was not set instead of silently disabling debugging; this is fixed.
|
data/Copying.txt
CHANGED
@@ -1,28 +1,13 @@
|
|
1
|
-
Copyright
|
2
|
-
All rights reserved.
|
1
|
+
Copyright 2008, Google Inc. All Rights Reserved.
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
7
6
|
|
8
|
-
|
9
|
-
notice, this list of conditions and the following disclaimer.
|
10
|
-
* Redistributions in binary form must reproduce the above
|
11
|
-
copyright notice, this list of conditions and the following disclaimer
|
12
|
-
in the documentation and/or other materials provided with the
|
13
|
-
distribution.
|
14
|
-
* Neither the name of Google Inc. nor the names of its
|
15
|
-
contributors may be used to endorse or promote products derived from
|
16
|
-
this software without specific prior written permission.
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
17
8
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/Licence.txt
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
Copyright
|
2
|
-
All rights reserved.
|
1
|
+
Copyright 2008, Google Inc. All Rights Reserved.
|
3
2
|
|
4
|
-
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
5
6
|
|
6
|
-
|
7
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
-
* Neither the name of Google, Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
8
|
|
10
|
-
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/Rakefile
CHANGED
data/Readme.txt
CHANGED
@@ -3,8 +3,6 @@ Google adwwords4r Library
|
|
3
3
|
|
4
4
|
Welcome to adwords4r: Bringing the delights of ruby programming to the AdWords world!
|
5
5
|
|
6
|
-
AdWords::API.new.getAllAdWordsCampaigns(123).each {|c| puts c.name}
|
7
|
-
|
8
6
|
Documentation and comments are a work in progress.
|
9
7
|
|
10
8
|
|
@@ -12,7 +10,8 @@ Useful Web Resources
|
|
12
10
|
--------------------
|
13
11
|
|
14
12
|
- AdWords home: https://adwords.google.com/
|
15
|
-
-
|
13
|
+
- AdWords API discussion forum: http://groups.google.com/group/adwords-api
|
14
|
+
- AdWords API documentation: http://www.google.com/apis/adwords/developer/index.html
|
16
15
|
- This project's Google Code page: http://code.google.com/p/google-api-adwords-ruby/
|
17
16
|
|
18
17
|
|
@@ -24,10 +23,9 @@ adwords4r is a ruby gem. See http://docs.rubygems.org/read/book/1
|
|
24
23
|
Install it using the gem install command.
|
25
24
|
> gem install --remote adwords4r
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
(see gem file for details)
|
26
|
+
The following gem libraries are required:
|
27
|
+
- soap4r v1.5.8 or greater
|
28
|
+
- httpclient v2.1.2 or greater
|
31
29
|
|
32
30
|
It's pretty easy to use.
|
33
31
|
See http://docs.rubygems.org/read/chapter/3#page70 for how to set the rubygem environment.
|
@@ -42,36 +40,32 @@ Then
|
|
42
40
|
require 'adwords4r'
|
43
41
|
|
44
42
|
adwords = AdWords::API.new
|
45
|
-
creates a driver for the latest version of AdWords API using credentials
|
46
|
-
There is an example in the root adwords4r directory.
|
43
|
+
creates a driver for the latest version of AdWords API using a credentials file in ENV['HOME']/adwords.properties
|
44
|
+
There is an example credentials in the root adwords4r directory.
|
47
45
|
You can also pass API a manually constructed AdWordsCredentials object like:
|
48
|
-
adwords = AdWords::API.new(AdWords::AdWordsCredentials.new(
|
49
|
-
|
50
|
-
'
|
51
|
-
'
|
52
|
-
'
|
53
|
-
|
46
|
+
adwords = AdWords::API.new(AdWords::AdWordsCredentials.new({
|
47
|
+
'developerToken' => 'DEVELOPER_TOKEN',
|
48
|
+
'applicationToken' => 'APPLICATION_TOKEN',
|
49
|
+
'useragent' => 'Ruby Sample',
|
50
|
+
'password' => 'PASSWORD',
|
51
|
+
'email' => 'user@domain.com'
|
52
|
+
'clientEmail' => 'user2@domain.com',
|
53
|
+
}))
|
54
54
|
|
55
55
|
If you want something more specific, use the optional parameters of the constructor
|
56
56
|
adwords = AdWords::API.new(credentials, version)
|
57
57
|
|
58
58
|
In order to use the sandbox, you can add a credential named
|
59
|
-
alternateUrl
|
59
|
+
alternateUrl like:
|
60
60
|
alternateUrl=https://sandbox.google.com/api/adwords/v11/
|
61
61
|
|
62
62
|
Then just use methods of the API against your driver.
|
63
|
-
|
64
|
-
|
65
|
-
See sample code in examples.
|
66
|
-
|
67
|
-
The client code will generate warnings in the console:
|
68
|
-
Many: warning: already initialized constant XXX
|
69
|
-
A few: at depth 0 - 20: unable to get local issuer certificate
|
70
|
-
These are not serious: I need to make them go but they do not affect the correctness of the program.
|
63
|
+
See sample code in examples, particularly reports.rb
|
71
64
|
|
72
65
|
It is often useful to see a trace of the raw SOAP XML being sent and received.
|
73
66
|
To enable this, set the ADWORDS4R_DEBUG environment variable to TRUE.
|
74
|
-
e.g. in the bash shell,
|
67
|
+
e.g. in the bash shell, export ADWORDS4R_DEBUG=TRUE
|
68
|
+
or from your Ruby code, ENV['ADWORDS4R_DEBUG'] = 'TRUE'
|
75
69
|
The SOAP logs will be written to the current directory.
|
76
70
|
|
77
71
|
|
@@ -84,18 +78,21 @@ rake generate
|
|
84
78
|
to regenerate the bindings if needed
|
85
79
|
rake package
|
86
80
|
to package the gem and create a release
|
87
|
-
rake publish
|
88
|
-
to publish the gem to rubyforge
|
89
81
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
82
|
+
|
83
|
+
Copyright/License Info
|
84
|
+
----------------------
|
85
|
+
|
86
|
+
Copyright 2008, Google Inc. All Rights Reserved.
|
87
|
+
|
88
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
89
|
+
you may not use this file except in compliance with the License.
|
90
|
+
You may obtain a copy of the License at
|
91
|
+
|
92
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
93
|
+
|
94
|
+
Unless required by applicable law or agreed to in writing, software
|
95
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
96
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
97
|
+
See the License for the specific language governing permissions and
|
98
|
+
limitations under the License.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/examples/reports.rb
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# Copyright 2008, Google Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
# 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 implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
# This code sample illustrates how to schedule and download an AdWords report
|
18
|
+
# using the adwords4r client library.
|
19
|
+
|
20
|
+
require 'rubygems'
|
21
|
+
gem 'soap4r', '>= 1.5.8'
|
22
|
+
require 'adwords4r'
|
23
|
+
|
24
|
+
|
25
|
+
def main()
|
26
|
+
begin
|
27
|
+
# AdWords::AdWordsCredentials.new will read a credentials file from
|
28
|
+
# ENV['HOME']/adwords.properties when called without parameters.
|
29
|
+
# The latest versioned release of the API will be assumed.
|
30
|
+
#
|
31
|
+
# Credentials can be either for the production or Sandbox environments.
|
32
|
+
# Production environment credentials overview:
|
33
|
+
# http://www.google.com/apis/adwords/developer/index.html
|
34
|
+
# Sandbox environment credentials overview:
|
35
|
+
# http://www.google.com/apis/adwords/developer/adwords_api_sandbox.html
|
36
|
+
#
|
37
|
+
# Instead of reading them from a file, the credentials can be
|
38
|
+
# specified inline as a hash:
|
39
|
+
#
|
40
|
+
# creds = {
|
41
|
+
# 'developerToken' => 'user@domain.com++USD',
|
42
|
+
# 'useragent' => 'Sample User Agent',
|
43
|
+
# 'password' => 'password',
|
44
|
+
# 'email' => 'user@domain.com',
|
45
|
+
# 'clientEmail' => 'client_1+user@domain.com',
|
46
|
+
# 'applicationToken' => 'IGNORED',
|
47
|
+
# 'alternateUrl' => 'https://sandbox.google.com/api/adwords/v11/',
|
48
|
+
# }
|
49
|
+
# adwords = AdWords::API.new(AdWords::AdWordsCredentials.new(creds), 11)
|
50
|
+
|
51
|
+
adwords = AdWords::API.new
|
52
|
+
|
53
|
+
report_name = 'Report-%s' % DateTime.now.to_s
|
54
|
+
|
55
|
+
# The following example creates a Structure report with Keyword aggregation.
|
56
|
+
# Because it is a Structure report, startDay and endDay values are ignored.
|
57
|
+
# See http://www.google.com/apis/adwords/developer/ReportService.html for
|
58
|
+
# more information about the different reports you can create.
|
59
|
+
|
60
|
+
job = AdWords::DefinedReportJob.new
|
61
|
+
job.selectedReportType = 'Structure'
|
62
|
+
job.aggregationTypes = 'Keyword'
|
63
|
+
job.name = report_name
|
64
|
+
job.selectedColumns = %w{Campaign AdGroup Keyword KeywordTypeDisplay}
|
65
|
+
job.startDay = '2008-01-01'
|
66
|
+
job.endDay = '2008-01-31'
|
67
|
+
|
68
|
+
# Validate the report definition to make sure it is valid.
|
69
|
+
# If it is not, an AdWords::Error::ApiError will be thrown.
|
70
|
+
|
71
|
+
adwords.validateReportJob(job)
|
72
|
+
|
73
|
+
# Since validation passed, schedule the report.
|
74
|
+
|
75
|
+
job_id = adwords.scheduleReportJob(job).scheduleReportJobReturn
|
76
|
+
sleep_interval = 10
|
77
|
+
puts 'Scheduled report with id %d. Now sleeping %d seconds.' %
|
78
|
+
[job_id, sleep_interval]
|
79
|
+
sleep(sleep_interval)
|
80
|
+
|
81
|
+
# Repeatedly check the report status until it is finished.
|
82
|
+
# 'Pending' and 'InProgress' statuses indicate the job is still being run.
|
83
|
+
|
84
|
+
status = adwords.getReportJobStatus(job_id).getReportJobStatusReturn
|
85
|
+
while status != 'Completed' && status != 'Failed'
|
86
|
+
puts 'Report status is %s. Now sleeping another %d seconds.' %
|
87
|
+
[status, sleep_interval]
|
88
|
+
sleep(sleep_interval)
|
89
|
+
status = adwords.getReportJobStatus(job_id).getReportJobStatusReturn
|
90
|
+
end
|
91
|
+
|
92
|
+
if status == 'Completed'
|
93
|
+
report_url = adwords.getReportDownloadUrl(job_id).
|
94
|
+
getReportDownloadUrlReturn
|
95
|
+
puts 'Report is completed. Downloading report from %s' % report_url
|
96
|
+
|
97
|
+
# Download the report via the HTTPClient library and write it to disk.
|
98
|
+
# The report is an XML document; the actual element names vary depending
|
99
|
+
# on what type of report run and columns requested.
|
100
|
+
|
101
|
+
client = HTTPClient.new
|
102
|
+
report_data = client.get_content(report_url)
|
103
|
+
file_name = '%s.xml' % report_name # Add path to write report elsewhere.
|
104
|
+
begin
|
105
|
+
open(file_name, 'w') {|file| file.puts(report_data)}
|
106
|
+
puts 'Report has been written to %s' % file_name
|
107
|
+
|
108
|
+
rescue Errno::ENOENT, Errno::EACCES => e
|
109
|
+
puts 'Unable to write file: %s' % e
|
110
|
+
end
|
111
|
+
else
|
112
|
+
# Reports that pass validation will normally not fail, but if there is
|
113
|
+
# an error in the report generation service it can sometimes happen.
|
114
|
+
|
115
|
+
puts 'Report generation failed.'
|
116
|
+
end
|
117
|
+
|
118
|
+
rescue Errno::ECONNRESET, SOAP::HTTPStreamError, SocketError => e
|
119
|
+
# This exception indicates a connection-level error.
|
120
|
+
# In general, it is likely to be transitory.
|
121
|
+
|
122
|
+
puts 'Connection Error: %s' % e
|
123
|
+
puts 'Source: %s' % e.backtrace.first
|
124
|
+
|
125
|
+
rescue AdWords::Error::UnknownAPICall => e
|
126
|
+
# This exception is thrown when an unknown SOAP method is invoked.
|
127
|
+
|
128
|
+
puts e
|
129
|
+
puts 'Source: %s' % e.backtrace.first
|
130
|
+
|
131
|
+
rescue AdWords::Error::ApiError => e
|
132
|
+
# This exception maps to receiving a SOAP Fault back from the service.
|
133
|
+
# The e.soap_faultstring_ex, e.code_ex, and potentially e.trigger_ex
|
134
|
+
# attributes are the most useful, but other attributes may be populated
|
135
|
+
# as well. To display all attributes, the following can be used:
|
136
|
+
#
|
137
|
+
# e.instance_variables.each do |var|
|
138
|
+
# value = e.instance_variable_get(var)
|
139
|
+
# if ! value.nil?
|
140
|
+
# puts '%s => %s' % [var, value]
|
141
|
+
# end
|
142
|
+
# end
|
143
|
+
|
144
|
+
puts 'SOAP Error: %s (code: %d)' % [e.soap_faultstring_ex, e.code_ex]
|
145
|
+
puts 'Trigger: %s' % e.trigger_ex unless e.trigger_ex.nil?
|
146
|
+
puts 'Source: %s' % e.backtrace.first
|
147
|
+
|
148
|
+
ensure
|
149
|
+
# Display API unit usage information. This data is stored as a class variable
|
150
|
+
# in the AdWords::API class and accessed via static methods.
|
151
|
+
# AdWords::API.get_total_units() returns a running total of units used in
|
152
|
+
# the scope of the current program.
|
153
|
+
# AdWords::API.get_last_units() returns the number used in the last API call.
|
154
|
+
|
155
|
+
puts
|
156
|
+
puts '%d API units consumed total (%d in last call).' %
|
157
|
+
[AdWords::API.get_total_units(), AdWords::API.get_last_units()]
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
if __FILE__ == $0
|
163
|
+
# The adwords4r library can log all SOAP requests and responses to files.
|
164
|
+
# This is often useful for debugging purposes.
|
165
|
+
# To enable this, set the ADWORDS4R_DEBUG environement varaible to 'true'.
|
166
|
+
# This can be done either from your operating system environment or via
|
167
|
+
# code, as done below.
|
168
|
+
|
169
|
+
ENV['ADWORDS4R_DEBUG'] = 'false'
|
170
|
+
|
171
|
+
main()
|
172
|
+
end
|
data/lib/adwords4r.rb
CHANGED
@@ -6,6 +6,7 @@ rescue
|
|
6
6
|
end
|
7
7
|
require 'soap/soap'
|
8
8
|
require 'soap/mapping'
|
9
|
+
require 'soap/rpc/driver'
|
9
10
|
require 'adwords4r/credentials'
|
10
11
|
require 'adwords4r/services'
|
11
12
|
|
@@ -28,6 +29,26 @@ end
|
|
28
29
|
module AdWords
|
29
30
|
|
30
31
|
class API
|
32
|
+
|
33
|
+
@@total_units = 0
|
34
|
+
@@last_units = 0
|
35
|
+
|
36
|
+
def API.add_total_units(increment)
|
37
|
+
@@total_units += increment
|
38
|
+
end
|
39
|
+
|
40
|
+
def API.get_total_units()
|
41
|
+
return @@total_units
|
42
|
+
end
|
43
|
+
|
44
|
+
def API.set_last_units(value)
|
45
|
+
@@last_units = value
|
46
|
+
end
|
47
|
+
|
48
|
+
def API.get_last_units()
|
49
|
+
return @@last_units
|
50
|
+
end
|
51
|
+
|
31
52
|
attr_reader :credentials, :drivers, :version
|
32
53
|
@methodMap = Hash.new
|
33
54
|
|
@@ -49,7 +70,7 @@ module AdWords
|
|
49
70
|
else
|
50
71
|
raise(Error::UnknownAPICall, "Unknown API Call: #{requestName}", caller)
|
51
72
|
end
|
52
|
-
|
73
|
+
# Handle AdWords Application-level error
|
53
74
|
rescue SOAP::FaultError => fault
|
54
75
|
raise(Error::ApiError.new(fault), "#{methodName} Call Failed: #{fault.faultstring.to_s}", caller)
|
55
76
|
end
|
@@ -77,6 +98,9 @@ module AdWords
|
|
77
98
|
driver = eval("AdWords::#{getServiceName(s)}.new")
|
78
99
|
end
|
79
100
|
@credentials.handlers.each {|h| driver.headerhandler << h}
|
101
|
+
|
102
|
+
# Add response filter to this driver for API unit usage processing.
|
103
|
+
driver.filterchain << ResponseFilter.new
|
80
104
|
|
81
105
|
if !ENV['ADWORDS4R_DEBUG'].nil? && ENV['ADWORDS4R_DEBUG'].upcase == 'TRUE'
|
82
106
|
driver.wiredump_file_base = "SOAP_#{$$}"
|
@@ -108,7 +132,6 @@ module AdWords
|
|
108
132
|
|
109
133
|
# Raised if a call returns with a SOAP error, gives you easy access to adwords error fields
|
110
134
|
class ApiError < Error
|
111
|
-
|
112
135
|
attr_accessor :soap_faultcode
|
113
136
|
attr_accessor :soap_faultstring
|
114
137
|
attr_accessor :top_code
|
@@ -122,15 +145,28 @@ module AdWords
|
|
122
145
|
attr_accessor :textIndex
|
123
146
|
attr_accessor :textLength
|
124
147
|
attr_accessor :trigger
|
148
|
+
|
149
|
+
# These *_ex attributes have been added to correct deficiencies with the initial implementation.
|
150
|
+
# They should expose more useful information (i.e. text of errors instead of a SOAP element)
|
151
|
+
# and proper mapping of a fault's trigger and code.
|
152
|
+
# The old attributes are left behind for backward compatibility; hopefully this isn't too confusing!
|
153
|
+
attr_accessor :trigger_ex
|
154
|
+
attr_accessor :soap_faultcode_ex
|
155
|
+
attr_accessor :soap_faultstring_ex
|
156
|
+
attr_accessor :code_ex
|
125
157
|
|
126
158
|
def initialize(soap_fault)
|
127
159
|
@soap_faultcode = protect { soap_fault.faultcode }
|
160
|
+
@soap_faultcode_ex = protect { soap_fault.faultcode.text }
|
128
161
|
@soap_faultstring = protect { soap_fault.faultstring }
|
162
|
+
@soap_faultstring_ex = protect { soap_fault.faultstring.text }
|
129
163
|
if protect { soap_fault.detail and soap_fault.detail.fault }
|
130
164
|
fault = soap_fault.detail.fault
|
131
165
|
@top_code = protect { fault.code }
|
132
166
|
@internal = protect { fault.internal }
|
133
167
|
@message = protect { fault.message }
|
168
|
+
@trigger_ex = protect { fault.trigger }
|
169
|
+
@code_ex = protect { fault.code }
|
134
170
|
if protect { fault.errors and fault.errors.size > 0 }
|
135
171
|
error = fault.errors.first
|
136
172
|
@code = protect { error.code }
|
@@ -156,6 +192,22 @@ module AdWords
|
|
156
192
|
end
|
157
193
|
end
|
158
194
|
|
195
|
+
# SOAP filter to process response messages for API unit usage information.
|
196
|
+
class ResponseFilter < SOAP::Filter::Handler
|
197
|
+
def on_inbound(xml, opt)
|
198
|
+
# Parse the response XML string for the <operations> header value.
|
199
|
+
if xml =~ %r{<units.+?>(\d+)</units>}
|
200
|
+
units = $1.to_i
|
201
|
+
# Since we don't really have an instance of a useful class here,
|
202
|
+
# we're stuck sticking the value in a class variable for AdWords::API.
|
203
|
+
AdWords::API.set_last_units(units)
|
204
|
+
AdWords::API.add_total_units(units)
|
205
|
+
end
|
206
|
+
|
207
|
+
return xml
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
159
211
|
# These class module methods are helper functions
|
160
212
|
class <<self
|
161
213
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: adwords4r
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 11.0
|
7
|
-
date:
|
6
|
+
version: 11.1.0
|
7
|
+
date: 2008-02-29 00:00:00 -05:00
|
8
8
|
summary: Client library for the AdWords API.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -32,7 +32,6 @@ files:
|
|
32
32
|
- Licence.txt
|
33
33
|
- setup.rb
|
34
34
|
- Authors.txt
|
35
|
-
- Todo.txt
|
36
35
|
- ChangeLog.txt
|
37
36
|
- Copying.txt
|
38
37
|
- Readme.txt
|
@@ -101,12 +100,13 @@ files:
|
|
101
100
|
- lib/adwords4r/v11/SiteSuggestionService.rb
|
102
101
|
- lib/adwords4r/v11/SiteSuggestionServiceMappingRegistry.rb
|
103
102
|
- lib/adwords4r/v11/SiteSuggestionServiceDriver.rb
|
104
|
-
- examples/
|
105
|
-
- examples/campaign.rb
|
106
|
-
- examples/
|
107
|
-
- examples/
|
108
|
-
- examples/
|
109
|
-
- examples/
|
103
|
+
- examples/reports.rb
|
104
|
+
- examples/old/campaign.rb
|
105
|
+
- examples/old/framework.rb
|
106
|
+
- examples/old/get_free_usage_this_month.rb
|
107
|
+
- examples/old/get_unit_count.rb
|
108
|
+
- examples/old/keyword_tool_demo.rb
|
109
|
+
- examples/old/traffic_estimator.rb
|
110
110
|
test_files: []
|
111
111
|
|
112
112
|
rdoc_options: []
|
data/Todo.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
adwords4r todo list
|
2
|
-
---
|
3
|
-
- use XSD::CodeGen::GenSupport.capitalize and unCapitalize instead of my own methods
|
4
|
-
- use SOAP::Property.loadproperty
|
5
|
-
0% ruby -rpp -rsoap/property -e 'pp
|
6
|
-
SOAP::Property.loadproperty("adwords.properties")'
|
7
|
-
#<SOAP::Property:0xb7ebd5b8
|
8
|
-
@hook={},
|
9
|
-
@locked=false,
|
10
|
-
@self_hook=[],
|
11
|
-
@store=
|
12
|
-
{"password"=>"my_very_secret_password",
|
13
|
-
"useragent"=>"P@ playing with the API from ruby",
|
14
|
-
"token"=>"my_token",
|
15
|
-
"email"=>"toto@example.com"}>
|
16
|
-
- fix the bug in reports
|
17
|
-
- handling quota management in the driver
|
18
|
-
- pass in a hash for complex objects
|
19
|
-
- comments everywhere, rdoc
|
20
|
-
- documentation
|
21
|
-
- more samples: traffic_estimator, report,
|