adwords4r 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/ChangeLog.txt +2 -0
  2. data/Rakefile +4 -4
  3. data/Todo.txt +6 -2
  4. data/examples/campaign.rb +5 -5
  5. data/lib/adwords4r.rb +23 -2
  6. data/lib/adwords4r/registry.rb +31 -0
  7. data/lib/adwords4r/v2/AccountService.rb +2 -0
  8. data/lib/adwords4r/v2/AccountServiceDriver.rb +2 -0
  9. data/lib/adwords4r/v2/AdGroupService.rb +2 -0
  10. data/lib/adwords4r/v2/AdGroupServiceDriver.rb +2 -0
  11. data/lib/adwords4r/v2/CampaignService.rb +2 -0
  12. data/lib/adwords4r/v2/CampaignServiceDriver.rb +2 -0
  13. data/lib/adwords4r/v2/CreativeService.rb +2 -0
  14. data/lib/adwords4r/v2/CreativeServiceDriver.rb +2 -0
  15. data/lib/adwords4r/v2/CriterionService.rb +2 -0
  16. data/lib/adwords4r/v2/CriterionServiceDriver.rb +2 -0
  17. data/lib/adwords4r/v2/InfoService.rb +2 -0
  18. data/lib/adwords4r/v2/InfoServiceDriver.rb +2 -0
  19. data/lib/adwords4r/v2/KeywordService.rb +2 -0
  20. data/lib/adwords4r/v2/KeywordServiceDriver.rb +2 -0
  21. data/lib/adwords4r/v2/ReportService.rb +2 -0
  22. data/lib/adwords4r/v2/ReportServiceDriver.rb +2 -0
  23. data/lib/adwords4r/v2/TrafficEstimatorService.rb +2 -0
  24. data/lib/adwords4r/v2/TrafficEstimatorServiceDriver.rb +2 -0
  25. data/lib/adwords4r/v3/AccountService.rb +2 -0
  26. data/lib/adwords4r/v3/AccountServiceDriver.rb +2 -0
  27. data/lib/adwords4r/v3/AdGroupService.rb +2 -0
  28. data/lib/adwords4r/v3/AdGroupServiceDriver.rb +2 -0
  29. data/lib/adwords4r/v3/CampaignService.rb +2 -0
  30. data/lib/adwords4r/v3/CampaignServiceDriver.rb +2 -0
  31. data/lib/adwords4r/v3/CreativeService.rb +2 -0
  32. data/lib/adwords4r/v3/CreativeServiceDriver.rb +2 -0
  33. data/lib/adwords4r/v3/CriterionService.rb +2 -0
  34. data/lib/adwords4r/v3/CriterionServiceDriver.rb +2 -0
  35. data/lib/adwords4r/v3/InfoService.rb +2 -0
  36. data/lib/adwords4r/v3/InfoServiceDriver.rb +2 -0
  37. data/lib/adwords4r/v3/KeywordService.rb +2 -0
  38. data/lib/adwords4r/v3/KeywordServiceDriver.rb +2 -0
  39. data/lib/adwords4r/v3/KeywordToolService.rb +2 -0
  40. data/lib/adwords4r/v3/KeywordToolServiceDriver.rb +2 -0
  41. data/lib/adwords4r/v3/ReportService.rb +2 -0
  42. data/lib/adwords4r/v3/ReportServiceDriver.rb +2 -0
  43. data/lib/adwords4r/v3/TrafficEstimatorService.rb +2 -0
  44. data/lib/adwords4r/v3/TrafficEstimatorServiceDriver.rb +2 -0
  45. metadata +3 -2
@@ -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.3'
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
- #fixImport(v, File.join(gendir, "#{name}.rb"))
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
- # outfile.puts "module AdWords"
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
- # outfile.puts "end"
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
@@ -19,16 +19,17 @@ end
19
19
 
20
20
  begin
21
21
  adwords = AdWords::API.new
22
- #pp adwords.thismethodDoesNotExist()
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
- pp adwords.addCampaign(c)
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
-
@@ -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("#{requestName}.method(\"new\")")
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 'adwords4r/v2/AccountService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -149,3 +150,4 @@ private
149
150
  end
150
151
  end
151
152
 
153
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v2}getAdGroupList
@@ -313,3 +314,4 @@ class AdGroupStatus < ::String
313
314
  Enabled = AdGroupStatus.new("Enabled")
314
315
  Paused = AdGroupStatus.new("Paused")
315
316
  end
317
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v2/AdGroupService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -93,3 +94,4 @@ private
93
94
  end
94
95
  end
95
96
 
97
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v2}getCampaign
@@ -513,3 +514,4 @@ class CampaignStatus < ::String
513
514
  Pending = CampaignStatus.new("Pending")
514
515
  Suspended = CampaignStatus.new("Suspended")
515
516
  end
517
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v2/CampaignService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -107,3 +108,4 @@ private
107
108
  end
108
109
  end
109
110
 
111
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v2}getAllCreatives
@@ -397,3 +398,4 @@ class ImageType < ::String
397
398
  Flash = ImageType.new("flash")
398
399
  Image = ImageType.new("image")
399
400
  end
401
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v2/CreativeService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -100,3 +101,4 @@ private
100
101
  end
101
102
  end
102
103
 
104
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v2}getAllCriteria
@@ -411,3 +412,4 @@ class KeywordType < ::String
411
412
  Exact = KeywordType.new("Exact")
412
413
  Phrase = KeywordType.new("Phrase")
413
414
  end
415
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v2/CriterionService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -93,3 +94,4 @@ private
93
94
  end
94
95
  end
95
96
 
97
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v2}getOperationCount
@@ -256,3 +257,4 @@ class ApiException
256
257
  @violations = violations
257
258
  end
258
259
  end
260
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v2/InfoService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -86,3 +87,4 @@ private
86
87
  end
87
88
  end
88
89
 
90
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v2}getAllKeywords
@@ -539,3 +540,4 @@ class KeywordType < ::String
539
540
  Exact = KeywordType.new("Exact")
540
541
  Phrase = KeywordType.new("Phrase")
541
542
  end
543
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v2/KeywordService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -121,3 +122,4 @@ private
121
122
  end
122
123
  end
123
124
 
125
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v2}scheduleReportJob
@@ -565,3 +566,4 @@ class AdGroupStatus < ::String
565
566
  Enabled = AdGroupStatus.new("Enabled")
566
567
  Paused = AdGroupStatus.new("Paused")
567
568
  end
569
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v2/ReportService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -79,3 +80,4 @@ private
79
80
  end
80
81
  end
81
82
 
83
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v2}estimateCampaignList
@@ -247,3 +248,4 @@ class KeywordType < ::String
247
248
  Exact = KeywordType.new("Exact")
248
249
  Phrase = KeywordType.new("Phrase")
249
250
  end
251
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v2/TrafficEstimatorService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -58,3 +59,4 @@ private
58
59
  end
59
60
  end
60
61
 
62
+ 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 'adwords4r/v3/AccountService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -149,3 +150,4 @@ private
149
150
  end
150
151
  end
151
152
 
153
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v3}getAdGroupList
@@ -316,3 +317,4 @@ class AdGroupStatus < ::String
316
317
  Enabled = AdGroupStatus.new("Enabled")
317
318
  Paused = AdGroupStatus.new("Paused")
318
319
  end
320
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/AdGroupService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -93,3 +94,4 @@ private
93
94
  end
94
95
  end
95
96
 
97
+ 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
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/CampaignService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -107,3 +108,4 @@ private
107
108
  end
108
109
  end
109
110
 
111
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v3}getAllCreatives
@@ -397,3 +398,4 @@ class ImageType < ::String
397
398
  Flash = ImageType.new("flash")
398
399
  Image = ImageType.new("image")
399
400
  end
401
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/CreativeService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -100,3 +101,4 @@ private
100
101
  end
101
102
  end
102
103
 
104
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v3}getAllCriteria
@@ -411,3 +412,4 @@ class KeywordType < ::String
411
412
  Exact = KeywordType.new("Exact")
412
413
  Phrase = KeywordType.new("Phrase")
413
414
  end
415
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/CriterionService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -93,3 +94,4 @@ private
93
94
  end
94
95
  end
95
96
 
97
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v3}getOperationCount
@@ -256,3 +257,4 @@ class ApiException
256
257
  @violations = violations
257
258
  end
258
259
  end
260
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/InfoService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -86,3 +87,4 @@ private
86
87
  end
87
88
  end
88
89
 
90
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v3}getAllKeywords
@@ -539,3 +540,4 @@ class KeywordType < ::String
539
540
  Exact = KeywordType.new("Exact")
540
541
  Phrase = KeywordType.new("Phrase")
541
542
  end
543
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/KeywordService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -121,3 +122,4 @@ private
121
122
  end
122
123
  end
123
124
 
125
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v3}getKeywordVariations
@@ -223,3 +224,4 @@ class KeywordType < ::String
223
224
  Exact = KeywordType.new("Exact")
224
225
  Phrase = KeywordType.new("Phrase")
225
226
  end
227
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/KeywordToolService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -51,3 +52,4 @@ private
51
52
  end
52
53
  end
53
54
 
55
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v3}scheduleReportJob
@@ -565,3 +566,4 @@ class AdGroupStatus < ::String
565
566
  Enabled = AdGroupStatus.new("Enabled")
566
567
  Paused = AdGroupStatus.new("Paused")
567
568
  end
569
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/ReportService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -79,3 +80,4 @@ private
79
80
  end
80
81
  end
81
82
 
83
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'xsd/qname'
2
3
 
3
4
  # {https://adwords.google.com/api/adwords/v3}estimateCampaignList
@@ -261,3 +262,4 @@ class KeywordType < ::String
261
262
  Exact = KeywordType.new("Exact")
262
263
  Phrase = KeywordType.new("Phrase")
263
264
  end
265
+ end
@@ -1,3 +1,4 @@
1
+ module AdWords
1
2
  require 'adwords4r/v3/TrafficEstimatorService'
2
3
 
3
4
  require 'soap/rpc/driver'
@@ -58,3 +59,4 @@ private
58
59
  end
59
60
  end
60
61
 
62
+ 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.3"
7
- date: 2006-04-21 00:00:00 -07:00
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