adwords4r 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.txt +2 -0
- data/Rakefile +4 -4
- data/Todo.txt +6 -2
- data/examples/campaign.rb +5 -5
- data/lib/adwords4r.rb +23 -2
- data/lib/adwords4r/registry.rb +31 -0
- data/lib/adwords4r/v2/AccountService.rb +2 -0
- data/lib/adwords4r/v2/AccountServiceDriver.rb +2 -0
- data/lib/adwords4r/v2/AdGroupService.rb +2 -0
- data/lib/adwords4r/v2/AdGroupServiceDriver.rb +2 -0
- data/lib/adwords4r/v2/CampaignService.rb +2 -0
- data/lib/adwords4r/v2/CampaignServiceDriver.rb +2 -0
- data/lib/adwords4r/v2/CreativeService.rb +2 -0
- data/lib/adwords4r/v2/CreativeServiceDriver.rb +2 -0
- data/lib/adwords4r/v2/CriterionService.rb +2 -0
- data/lib/adwords4r/v2/CriterionServiceDriver.rb +2 -0
- data/lib/adwords4r/v2/InfoService.rb +2 -0
- data/lib/adwords4r/v2/InfoServiceDriver.rb +2 -0
- data/lib/adwords4r/v2/KeywordService.rb +2 -0
- data/lib/adwords4r/v2/KeywordServiceDriver.rb +2 -0
- data/lib/adwords4r/v2/ReportService.rb +2 -0
- data/lib/adwords4r/v2/ReportServiceDriver.rb +2 -0
- data/lib/adwords4r/v2/TrafficEstimatorService.rb +2 -0
- data/lib/adwords4r/v2/TrafficEstimatorServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/AccountService.rb +2 -0
- data/lib/adwords4r/v3/AccountServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/AdGroupService.rb +2 -0
- data/lib/adwords4r/v3/AdGroupServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/CampaignService.rb +2 -0
- data/lib/adwords4r/v3/CampaignServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/CreativeService.rb +2 -0
- data/lib/adwords4r/v3/CreativeServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/CriterionService.rb +2 -0
- data/lib/adwords4r/v3/CriterionServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/InfoService.rb +2 -0
- data/lib/adwords4r/v3/InfoServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/KeywordService.rb +2 -0
- data/lib/adwords4r/v3/KeywordServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/KeywordToolService.rb +2 -0
- data/lib/adwords4r/v3/KeywordToolServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/ReportService.rb +2 -0
- data/lib/adwords4r/v3/ReportServiceDriver.rb +2 -0
- data/lib/adwords4r/v3/TrafficEstimatorService.rb +2 -0
- data/lib/adwords4r/v3/TrafficEstimatorServiceDriver.rb +2 -0
- metadata +3 -2
data/ChangeLog.txt
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
0.4 Now all generated classes are within the Adwords module. Will make it easier to use that in Rails. Support for gen classes in a module is not implemented in soap4r for doc/literal style (it works for rpc/encoded). I logged a bug for soap4r. In the meantime I had to fix adwords4r from my module using module_eval to patch the Mapping class.
|
2
|
+
0.3 fixed the bug in InfoService and many others. I fix the wsdl before generation.
|
1
3
|
0.2 added packaging, made it a gem, and added a setup program, for easy installation in all configurations (gem and non gem).
|
2
4
|
0.1 -first version, not fully tested
|
3
5
|
works for Campaigns
|
data/Rakefile
CHANGED
@@ -20,7 +20,7 @@ end
|
|
20
20
|
|
21
21
|
CLOBBER.include('pkg')
|
22
22
|
|
23
|
-
CURRENT_VERSION = '0.
|
23
|
+
CURRENT_VERSION = '0.4'
|
24
24
|
PKG_VERSION = ENV['REL'] ? ENV['REL'] : CURRENT_VERSION
|
25
25
|
|
26
26
|
SRC_RB = FileList['lib/**/*.rb']
|
@@ -62,7 +62,7 @@ task :generate do
|
|
62
62
|
worker.opt.update(getWsdlOpt(name))
|
63
63
|
worker.run
|
64
64
|
fixImport(v, File.join(gendir, "#{name}Driver.rb"))
|
65
|
-
|
65
|
+
fixImport(v, File.join(gendir, "#{name}.rb"))
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -72,7 +72,7 @@ def fixImport(version, file)
|
|
72
72
|
tempfile = file + '.tmp'
|
73
73
|
outfile = File.new(tempfile,"w")
|
74
74
|
File.open(file, "r") do |infile|
|
75
|
-
|
75
|
+
outfile.puts "module AdWords"
|
76
76
|
#outfile.puts "module AdWordsV#{version}"
|
77
77
|
infile.each do |l|
|
78
78
|
if (l =~/require.*Service.rb/) then
|
@@ -82,7 +82,7 @@ def fixImport(version, file)
|
|
82
82
|
outfile.puts l
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
85
|
+
outfile.puts "end"
|
86
86
|
end
|
87
87
|
outfile.close
|
88
88
|
File.rename(tempfile, file)
|
data/Todo.txt
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
adwords4r todo list
|
2
2
|
---
|
3
|
-
|
4
|
-
- gem file
|
3
|
+
- use XSD::CodeGen::GenSupport.capitalize and unCapitalize instead of my own methods
|
5
4
|
- handling quota management in the driver
|
6
5
|
- pass in a hash for complex objects
|
7
6
|
- comments everywhere, rdoc
|
8
7
|
- documentation
|
9
8
|
- more samples
|
9
|
+
|
10
|
+
OK- make it work with all generated classes in their own module
|
11
|
+
OK- fix bug in InfoService
|
12
|
+
OK- gem file
|
13
|
+
OK- traditional setup file
|
data/examples/campaign.rb
CHANGED
@@ -19,16 +19,17 @@ end
|
|
19
19
|
|
20
20
|
begin
|
21
21
|
adwords = AdWords::API.new
|
22
|
-
|
22
|
+
|
23
|
+
res = adwords.getCampaign(6000213)
|
24
|
+
puts dumpObj(res)
|
23
25
|
res = adwords.getAllAdWordsCampaigns(123)
|
24
|
-
pp res
|
25
26
|
res.each {|c| puts dumpObj(c)}
|
26
27
|
#adwords.getAllAdWordsCampaigns(123).each {|c| puts dumpObj(c)}
|
27
|
-
c = Campaign.new
|
28
|
+
c = AdWords::Campaign.new
|
28
29
|
c.dailyBudget = 10000
|
29
30
|
c.status = 'Paused'
|
30
31
|
c.name = "Test P@ #{rand(10000)}"
|
31
|
-
|
32
|
+
puts dumpObj(adwords.addCampaign(c).addCampaignReturn)
|
32
33
|
|
33
34
|
rescue AdWords::Error::UnknownAPICall => e
|
34
35
|
puts e
|
@@ -36,4 +37,3 @@ rescue AdWords::Error::ApiError => e
|
|
36
37
|
puts e.code
|
37
38
|
puts e.message
|
38
39
|
end
|
39
|
-
|
data/lib/adwords4r.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
require 'soap/soap'
|
1
2
|
require 'adwords4r/credentials'
|
2
3
|
require 'adwords4r/services'
|
3
|
-
require 'soap/soap'
|
4
4
|
|
5
5
|
module AdWords
|
6
6
|
|
@@ -21,13 +21,14 @@ module AdWords
|
|
21
21
|
end
|
22
22
|
@drivers = Hash.new
|
23
23
|
prepareDrivers
|
24
|
+
fix_soap4r
|
24
25
|
end
|
25
26
|
|
26
27
|
def method_missing(m, *args)
|
27
28
|
methodName = m.id2name
|
28
29
|
requestName = AdWords::fix_case_up(m.id2name) # upper first character
|
29
30
|
if valid_call?(methodName)
|
30
|
-
constructor = eval("
|
31
|
+
constructor = eval("AdWords::#{requestName}.method(\"new\")")
|
31
32
|
req = constructor.call(*args)
|
32
33
|
resp = eval("getDriver(methodName).#{methodName}(req)")
|
33
34
|
return resp
|
@@ -41,6 +42,26 @@ module AdWords
|
|
41
42
|
|
42
43
|
private
|
43
44
|
|
45
|
+
#nasty but does the job
|
46
|
+
#Todo: remove when Hiroshi fix soap4r bug
|
47
|
+
#Todo: it would be more elegant to use alias_method but I could not
|
48
|
+
#make it work with class methods
|
49
|
+
#Todo: could also check if the class is in my module before adding it
|
50
|
+
def fix_soap4r
|
51
|
+
a = %q{
|
52
|
+
def self.class_from_name(name, lenient = false)
|
53
|
+
const = const_from_name('AdWords::' + name, lenient)
|
54
|
+
if const.is_a?(::Class)
|
55
|
+
const
|
56
|
+
else
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
}
|
61
|
+
|
62
|
+
SOAP::Mapping.module_eval(a)
|
63
|
+
end
|
64
|
+
|
44
65
|
def prepareDrivers()
|
45
66
|
Service.doRequire(@version)
|
46
67
|
Service.getServices(@version).each {|s| @drivers[s] = prepareDriver(s)}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'soap/rpc/driver'
|
2
|
+
require 'soap/rpc/mapping'
|
3
|
+
|
4
|
+
module SOAP
|
5
|
+
module Mapping
|
6
|
+
|
7
|
+
# alias_method :old_class_from_name, :class_from_name
|
8
|
+
# def Mapping.class_from_name(*args)
|
9
|
+
# puts 'in new_class'
|
10
|
+
# result = Mapping.old_class_from_name(*args)
|
11
|
+
# return result
|
12
|
+
# end
|
13
|
+
|
14
|
+
class AdWords4rRegistry < ::SOAP::Mapping::WSDLLiteralRegistry
|
15
|
+
def any2obj(node, obj_class = nil)
|
16
|
+
puts 'adwords4r any2obj'
|
17
|
+
unless obj_class
|
18
|
+
#puts 'adwords4r any2obj node ' + node.elemname.name
|
19
|
+
typestr = XSD::CodeGen::GenSupport.safeconstname(node.elename.name)
|
20
|
+
puts 'typestr'
|
21
|
+
obj_class = Mapping.class_from_name('AdWords::' + typestr)
|
22
|
+
puts 'in literal any2obj obj_class =' + obj_class.to_s + typestr
|
23
|
+
require 'pp'
|
24
|
+
pp obj_class
|
25
|
+
end
|
26
|
+
super(node, obj_class)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
module AdWords
|
1
2
|
require 'xsd/qname'
|
2
3
|
|
3
4
|
# {https://adwords.google.com/api/adwords/v2}createAdWordsAccount
|
@@ -624,3 +625,4 @@ class TaxStatus < ::String
|
|
624
625
|
SubjectToTax = TaxStatus.new("SubjectToTax")
|
625
626
|
ZeroRated = TaxStatus.new("ZeroRated")
|
626
627
|
end
|
628
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
module AdWords
|
1
2
|
require 'xsd/qname'
|
2
3
|
|
3
4
|
# {https://adwords.google.com/api/adwords/v3}createAdWordsAccount
|
@@ -624,3 +625,4 @@ class TaxStatus < ::String
|
|
624
625
|
SubjectToTax = TaxStatus.new("SubjectToTax")
|
625
626
|
ZeroRated = TaxStatus.new("ZeroRated")
|
626
627
|
end
|
628
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
module AdWords
|
1
2
|
require 'xsd/qname'
|
2
3
|
|
3
4
|
# {https://adwords.google.com/api/adwords/v3}getCampaign
|
@@ -527,3 +528,4 @@ class NetworkType < ::String
|
|
527
528
|
GoogleSearch = NetworkType.new("GoogleSearch")
|
528
529
|
SearchNetwork = NetworkType.new("SearchNetwork")
|
529
530
|
end
|
531
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: adwords4r
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "0.
|
7
|
-
date: 2006-
|
6
|
+
version: "0.4"
|
7
|
+
date: 2006-05-03 00:00:00 -07:00
|
8
8
|
summary: Client library for the AdWords API.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- Rakefile
|
39
39
|
- lib/adwords4r.rb
|
40
40
|
- lib/adwords4r/credentials.rb
|
41
|
+
- lib/adwords4r/registry.rb
|
41
42
|
- lib/adwords4r/services.rb
|
42
43
|
- lib/adwords4r/v2/AccountService.rb
|
43
44
|
- lib/adwords4r/v2/AccountServiceDriver.rb
|