sem4r 0.1.2 → 0.1.3

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.
Files changed (175) hide show
  1. data/Gemfile +13 -2
  2. data/Gemfile.lock +13 -7
  3. data/README.rdoc +44 -7
  4. data/Rakefile +2 -122
  5. data/VERSION.yml +1 -1
  6. data/bin/sem +1 -0
  7. data/examples_sem4r/01_get_account.rb +1 -0
  8. data/examples_sem4r/02_get_info.rb +1 -0
  9. data/examples_sem4r/03_list_ad.rb +1 -0
  10. data/examples_sem4r/04_list_keywords.rb +1 -0
  11. data/examples_sem4r/05_request_report.rb +25 -14
  12. data/examples_sem4r/{05_request_report_2010.rb → 06_request_report_definition.rb} +2 -4
  13. data/examples_sem4r/{06_create_campaigns.rb → 07_create_campaigns.rb} +1 -0
  14. data/examples_sem4r/{07_create_campaigns_block.rb → 08_create_campaigns_block.rb} +1 -0
  15. data/examples_sem4r/{07_create_campaigns_simple.rb → 09_create_campaigns_simple.rb} +1 -0
  16. data/examples_sem4r/{08_ad_params.rb → 10_ad_params.rb} +1 -0
  17. data/examples_sem4r/{09_targeting_idea.rb → 11_targeting_idea.rb} +1 -0
  18. data/examples_sem4r/{10_get_location.rb → 12_get_location.rb} +1 -0
  19. data/examples_sem4r/{11_submit_bulk_job.rb → 13_submit_bulk_job.rb} +1 -1
  20. data/examples_sem4r/{12_list_bulk_job.rb → 14_list_bulk_job.rb} +3 -0
  21. data/examples_sem4r/30_prune_empty_adgroup.rb +1 -0
  22. data/examples_sem4r/31_empty_accounts.rb +1 -0
  23. data/examples_sem4r/example_helper.rb +2 -1
  24. data/lib/sem4r/ad_group/ad_group.rb +22 -7
  25. data/lib/sem4r/ad_group/ad_group_bids.rb +1 -1
  26. data/lib/sem4r/ad_group/ad_group_service.rb +12 -5
  27. data/lib/sem4r/ad_group_ad/ad_group_ad.rb +1 -0
  28. data/lib/sem4r/ad_group_ad/ad_group_ad_operations.rb +1 -0
  29. data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +14 -9
  30. data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +16 -25
  31. data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +18 -14
  32. data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +27 -19
  33. data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +2 -1
  34. data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +1 -0
  35. data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +9 -4
  36. data/lib/sem4r/ad_group_criterion/criterion.rb +1 -0
  37. data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +1 -0
  38. data/lib/sem4r/ad_group_criterion/criterion_placement.rb +1 -0
  39. data/lib/sem4r/ad_param/ad_param.rb +24 -8
  40. data/lib/sem4r/ad_param/ad_param_service.rb +8 -5
  41. data/lib/sem4r/adwords.rb +232 -76
  42. data/lib/sem4r/base.rb +1 -1
  43. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +41 -35
  44. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_account_extension.rb +49 -15
  45. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_selector.rb +29 -20
  46. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +13 -14
  47. data/lib/sem4r/bulk_mutate_job/job_operations.rb +1 -1
  48. data/lib/sem4r/campaign/campaign.rb +1 -0
  49. data/lib/sem4r/campaign/campaign_account_extension.rb +2 -1
  50. data/lib/sem4r/campaign/campaign_service.rb +9 -5
  51. data/lib/sem4r/credentials.rb +11 -5
  52. data/lib/sem4r/geo_location/address.rb +56 -0
  53. data/lib/sem4r/geo_location/geo_location_account_extension.rb +27 -6
  54. data/lib/sem4r/geo_location/geo_location_selector.rb +57 -0
  55. data/lib/sem4r/geo_location/geo_location_service.rb +9 -16
  56. data/lib/sem4r/info/info_account_extension.rb +3 -2
  57. data/lib/sem4r/info/info_selector.rb +2 -1
  58. data/lib/sem4r/info/info_service.rb +10 -3
  59. data/lib/sem4r/operation.rb +39 -20
  60. data/lib/sem4r/report_definition/report_definition.rb +37 -19
  61. data/lib/sem4r/report_definition/report_definition_account_extension.rb +66 -16
  62. data/lib/sem4r/report_definition/report_definition_operation.rb +2 -2
  63. data/lib/sem4r/report_definition/report_definition_selector.rb +1 -1
  64. data/lib/sem4r/report_definition/report_definition_service.rb +11 -7
  65. data/lib/sem4r/report_definition/report_field.rb +3 -2
  66. data/lib/sem4r/sem4r_templates.rb +77 -0
  67. data/lib/sem4r/{services/service.rb → service.rb} +23 -23
  68. data/lib/sem4r/targeting_idea/targeting_idea.rb +4 -4
  69. data/lib/sem4r/targeting_idea/targeting_idea_account_extension.rb +1 -1
  70. data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +6 -6
  71. data/lib/sem4r/targeting_idea/targeting_idea_service.rb +7 -5
  72. data/lib/sem4r/v13_account/account_account_extension.rb +7 -10
  73. data/lib/sem4r/v13_account/account_service.rb +10 -4
  74. data/lib/sem4r/v13_account/billing_address.rb +2 -2
  75. data/lib/sem4r/v13_report/report_service.rb +11 -9
  76. data/lib/sem4r.rb +46 -31
  77. data/lib/{sem4r/cli → sem4r_cli}/cli_helpers.rb +3 -2
  78. data/lib/{sem4r/cli/cli_command.rb → sem4r_cli/cli_mini_framework.rb} +77 -32
  79. data/lib/{sem4r/cli/cli_common_args.rb → sem4r_cli/cli_sem.rb} +177 -157
  80. data/lib/{sem4r/cli/commands/cli_list_ads.rb → sem4r_cli/commands/cli_ads.rb} +7 -9
  81. data/lib/sem4r_cli/commands/cli_campaign.rb +69 -0
  82. data/lib/{sem4r/cli/commands/cli_list_client.rb → sem4r_cli/commands/cli_clients.rb} +2 -2
  83. data/lib/{sem4r/cli → sem4r_cli}/commands/cli_ideas.rb +35 -27
  84. data/lib/{sem4r/cli → sem4r_cli}/commands/cli_info.rb +3 -4
  85. data/lib/{sem4r/cli/commands/cli_repdef.rb → sem4r_cli/commands/cli_job.rb} +57 -55
  86. data/lib/{sem4r/cli/commands/cli_list_keywords.rb → sem4r_cli/commands/cli_keywords.rb} +14 -13
  87. data/lib/sem4r_cli/commands/cli_profile.rb +138 -0
  88. data/lib/{sem4r/cli/commands/cli_report.rb → sem4r_cli/commands/cli_repdef.rb} +67 -20
  89. data/lib/{sem4r/cli/commands/cli_request_report.rb → sem4r_cli/commands/cli_report.rb} +82 -19
  90. data/lib/sem4r_cli.rb +5 -7
  91. data/lib/sem4r_soap/http_connector.rb +206 -0
  92. data/lib/{soap_helpers → sem4r_soap}/soap_attributes.rb +8 -3
  93. data/lib/{sem4r/services → sem4r_soap}/soap_dumper.rb +36 -20
  94. data/lib/{sem4r/services → sem4r_soap}/soap_error.rb +5 -2
  95. data/lib/sem4r_soap/soap_response.rb +75 -0
  96. data/lib/sem4r_soap/soap_service.rb +137 -0
  97. data/lib/{sem4r/cli/cli_sem.rb → sem4r_soap/soap_service_v13.rb} +27 -28
  98. data/lib/sem4r_soap/soap_service_v2010.rb +80 -0
  99. data/lib/sem4r_soap.rb +17 -0
  100. data/sem4r.gemspec +93 -58
  101. data/spec/build_fixtures.rb +49 -42
  102. data/spec/fixtures/password.example.yml +3 -0
  103. data/spec/fixtures/sem4r.example.yml +6 -0
  104. data/spec/fixtures/{services/error.xml → soap_error.xml} +0 -0
  105. data/spec/fixtures/soap_error2.xml +29 -0
  106. data/spec/helpers/dump_interceptor.rb +90 -0
  107. data/spec/helpers/fixtures_bulk_mutate_job.rb +48 -0
  108. data/spec/helpers/fixtures_geo_location.rb +45 -0
  109. data/{lib/sem4r/campaign_criterion/campaign_criterion_service.rb → spec/helpers/fixtures_info.rb} +10 -6
  110. data/spec/helpers/fixtures_report_definition.rb +65 -0
  111. data/spec/{rspec_hash.rb → helpers/rspec_hash.rb} +1 -0
  112. data/spec/{rspec_matchers.rb → helpers/rspec_matchers.rb} +46 -19
  113. data/spec/{rspec_sem4r_helper.rb → helpers/rspec_sem4r_helper.rb} +19 -16
  114. data/spec/{sem4r_stubs.rb → helpers/sem4r_stubs.rb} +5 -4
  115. data/spec/rspec_helper.rb +4 -4
  116. data/spec/sem4r/account_spec.rb +2 -3
  117. data/spec/sem4r/ad_group/ad_group_service_spec.rb +1 -1
  118. data/spec/sem4r/ad_group/ad_group_spec.rb +1 -1
  119. data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +3 -3
  120. data/spec/sem4r/adwords_spec.rb +62 -39
  121. data/{lib/sem4r/cli/commands/cli_list_campaign.rb → spec/sem4r/bulk_mutate_job/bulk_mutate_job_selector_spec.rb} +14 -11
  122. data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +2 -3
  123. data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +23 -17
  124. data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-req.xml +35 -0
  125. data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-res.xml +417 -0
  126. data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-req.xml +106 -0
  127. data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-res.xml +48 -0
  128. data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +5 -7
  129. data/spec/sem4r/campaign/campaign_service_spec.rb +2 -2
  130. data/spec/sem4r/credentials_spec.rb +10 -8
  131. data/spec/sem4r/geo_location/address_spec.rb +62 -0
  132. data/spec/sem4r/geo_location/fixtures/get-req.xml +42 -0
  133. data/spec/sem4r/geo_location/fixtures/get-res.xml +60 -0
  134. data/spec/sem4r/info/fixtures/get-req.xml +34 -0
  135. data/spec/sem4r/info/fixtures/get-res.xml +27 -0
  136. data/spec/sem4r/nokogiri_parsing_spec.rb +1 -0
  137. data/spec/sem4r/operation_spec.rb +72 -0
  138. data/spec/sem4r/report_definition/fixtures/get-list-repdef-req.xml +22 -0
  139. data/spec/sem4r/report_definition/fixtures/get-list-repdef-res.xml +73 -0
  140. data/spec/sem4r/report_definition/fixtures/getReportFields-req.xml +24 -0
  141. data/spec/sem4r/report_definition/fixtures/getReportFields-res.xml +1199 -0
  142. data/spec/sem4r/report_definition/fixtures/mutate-add-report-req.xml +63 -0
  143. data/spec/sem4r/report_definition/fixtures/mutate-add-report-res.xml +68 -0
  144. data/spec/sem4r/report_definition/report_definition_service_spec.rb +5 -5
  145. data/spec/sem4r/report_definition/report_definition_spec.rb +28 -43
  146. data/{lib/sem4r/cli/commands/cli_list_report.rb → spec/sem4r/report_definition/report_field_spec.rb} +12 -10
  147. data/spec/sem4r/rexml_parsing_spec.rb +1 -0
  148. data/spec/sem4r/{services/service_spec.rb → service_spec.rb} +1 -1
  149. data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +1 -1
  150. data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +1 -1
  151. data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +1 -1
  152. data/spec/sem4r/v13_account/account_service_spec.rb +2 -2
  153. data/spec/sem4r/v13_report/report_service_spec.rb +2 -2
  154. data/spec/{sem4r/cli → sem4r_cli}/cli_spec.rb +22 -27
  155. data/spec/{soap_helpers → sem4r_soap}/soap_attributes_spec.rb +3 -3
  156. data/spec/{sem4r/services/soap_message_v13_spec.rb → sem4r_soap/soap_response_spec.rb} +10 -15
  157. data/spec/{sem4r/services/soap_call_spec.rb → sem4r_soap/soap_service_spec.rb} +35 -54
  158. data/tasks/jeweler.rake +66 -0
  159. data/tasks/rspec.rake +21 -0
  160. data/tasks/sem4r.rake +25 -0
  161. data/tasks/yard.rake +31 -0
  162. metadata +173 -76
  163. data/lib/sem4r/ad_extension_override/ad_extension_override_service.rb +0 -30
  164. data/lib/sem4r/api_counters.rb +0 -8
  165. data/lib/sem4r/campaign_target/campaign_target_service.rb +0 -30
  166. data/lib/sem4r/cli/commands/cli_download_report.rb +0 -82
  167. data/lib/sem4r/services/http_connector.rb +0 -93
  168. data/lib/sem4r/services/soap_call.rb +0 -122
  169. data/lib/sem4r/services/soap_connector.rb +0 -139
  170. data/lib/sem4r/services/soap_message_v13.rb +0 -135
  171. data/lib/sem4r/services/soap_message_v2010.rb +0 -184
  172. data/lib/sem4r/v13_traffic_estimator/traffic_estimator_service.rb +0 -30
  173. data/spec/aggregates_rspec_helper.rb +0 -59
  174. data/spec/sem4r/report_definition/fixtures/mutate_add-req.xml +0 -24
  175. data/spec/sem4r/report_definition/fixtures/mutate_add-req_orig.xml +0 -45
data/Gemfile CHANGED
@@ -1,11 +1,22 @@
1
1
  source :gemcutter
2
2
 
3
3
  gem "builder"
4
- gem "jeweler"
5
- gem "rake"
6
4
  gem "nokogiri"
5
+ gem "httpclient"
6
+ gem 'highline', :require => 'highline/import'
7
+
8
+ group :development do
9
+ gem "jeweler"
10
+ gem "rake"
11
+ gem "yard"
12
+ gem "bundler" # funny!
13
+ end
7
14
 
8
15
  group :test do
9
16
  gem "differ"
10
17
  gem "rspec"
11
18
  end
19
+
20
+ #platforms :jruby do
21
+ # gem 'jruby-openssl'
22
+ #end
data/Gemfile.lock CHANGED
@@ -5,6 +5,8 @@ GEM
5
5
  diff-lcs (1.1.2)
6
6
  differ (0.1.1)
7
7
  git (1.2.5)
8
+ highline (1.6.1)
9
+ httpclient (2.1.5.2)
8
10
  jeweler (1.5.1)
9
11
  bundler (~> 1.0.0)
10
12
  git (>= 1.2.5)
@@ -13,15 +15,16 @@ GEM
13
15
  nokogiri (1.4.4-java)
14
16
  weakling (>= 0.0.3)
15
17
  rake (0.8.7)
16
- rspec (2.1.0)
17
- rspec-core (~> 2.1.0)
18
- rspec-expectations (~> 2.1.0)
19
- rspec-mocks (~> 2.1.0)
20
- rspec-core (2.1.0)
21
- rspec-expectations (2.1.0)
18
+ rspec (2.2.0)
19
+ rspec-core (~> 2.2)
20
+ rspec-expectations (~> 2.2)
21
+ rspec-mocks (~> 2.2)
22
+ rspec-core (2.2.1)
23
+ rspec-expectations (2.2.0)
22
24
  diff-lcs (~> 1.1.2)
23
- rspec-mocks (2.1.0)
25
+ rspec-mocks (2.2.0)
24
26
  weakling (0.0.4-java)
27
+ yard (0.6.3)
25
28
 
26
29
  PLATFORMS
27
30
  java
@@ -30,7 +33,10 @@ PLATFORMS
30
33
  DEPENDENCIES
31
34
  builder
32
35
  differ
36
+ highline
37
+ httpclient
33
38
  jeweler
34
39
  nokogiri
35
40
  rake
36
41
  rspec
42
+ yard
data/README.rdoc CHANGED
@@ -40,20 +40,57 @@ You can list all client accounts:
40
40
  See directory examples_sem4r[http://github.com/sem4r/sem4r/tree/master/examples_sem4r/examples_sem4r] for more examples.
41
41
  Follow the sem4r.com[http://www.sem4r.com] feed for announcements of new releases.
42
42
 
43
- == Install
44
-
45
- sudo gem install sem4r
46
-
47
43
  == Ruby Versions
48
44
 
49
- Sem4r tested on following ruby version:
45
+ Sem4r last gem was tested on following rubies:
50
46
 
51
47
  * 1.9.2-p0 - linux (works)
52
48
  * jruby 1.5.5 - linux (some example are not working, certificate verify failed OpenSSL in sandbox)
53
49
  * ...
54
50
 
51
+ == Install
52
+
53
+ sudo gem install sem4r
54
+
55
+ == Api status
56
+
57
+ === Campaign Data Management
58
+
59
+ * CampaignService: ...
60
+ * CampaignTargetService: ...
61
+ * AdGroupService: ...
62
+ * AdGroupAdService: ...
63
+ * CampaignAdExtensionService: ...
64
+ * AdExtensionOverrideService: ...
65
+ * CampaignCriterionService: ...
66
+ * AdGroupCriterionService: ...
67
+ * AdParamService: ...
68
+ * UserListService: ...
69
+
70
+ === Optimization
71
+
72
+ * BidLandscapeService: ...
73
+ * ReportDefinitionService
74
+ * TargetingIdeaService
75
+ * TrafficEstimatorService
76
+
77
+ === Account Management
78
+
79
+ * AlertService
80
+ * CustomerSyncService
81
+ * InfoService
82
+ * ServicedAccountService
83
+
84
+ === Utility
85
+
86
+ * BulkMutateJobService
87
+ * GeoLocationService
88
+ * MediaService
89
+
55
90
  == How to submit a bug report
56
91
 
92
+ ...
93
+
57
94
  == Contribute
58
95
 
59
96
  So you want your prefered service supported by sem4r. Great! Please follow this steps:
@@ -71,9 +108,9 @@ So you want your prefered service supported by sem4r. Great! Please follow this
71
108
 
72
109
  == Contributors
73
110
 
74
- If I miss someone send me a note.
111
+ If I miss someone send me[sem4ruby@gmail.com] a note.
75
112
 
76
- * Glenn Gillen {http://github.com/rubypond}
113
+ * Glenn Gillen[http://github.com/rubypond]
77
114
 
78
115
 
79
116
  To see all contributors execute: git shortlog -n -s --no-merges
data/Rakefile CHANGED
@@ -1,129 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- #
5
- # jeweler
6
- #
7
- begin
8
- require 'jeweler'
9
- Jeweler::Tasks.new do |gem|
10
-
11
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
12
- gem.name = "sem4r"
13
- gem.summary = %Q{Library to access google adwords api. Works with ruby 1.9 and ruby 1.8}
14
- gem.description = %Q{
15
- Sem4r is a library to access google adwords api.
16
- It will works with ruby 1.9 and ruby 1.8 without soap4r.
17
- It uses a high level model instead of a low level api.
18
- You think about clients, campaigns, keywords and not about operations, operands, selectors, service calls.
19
-
20
- This is a ALPHA version don't use in production.
21
- If you are interested in this project let me now: install it and update periodically, so the gemcutter
22
- download counter go up. Or subscribe to my feed at sem4r.com. Or watch the project on github.
23
- Or simply drop me a line in email. However I will know there is someone out of here.
24
- }
25
-
26
- gem.authors = ["Sem4r"]
27
- gem.email = "sem4ruby@gmail.com"
28
- gem.homepage = "http://www.sem4r.com"
29
-
30
- #
31
- # dependecies
32
- #
33
- # gem.add_dependency 'patron'
34
- gem.add_dependency 'builder'
35
- gem.add_dependency 'nokogiri'
36
- gem.add_development_dependency 'rspec'
37
- gem.add_development_dependency 'differ'
38
-
39
- #
40
- # files
41
- #
42
- gem.files = %w{LICENSE README.rdoc Rakefile VERSION.yml sem4r.gemspec Gemfile Gemfile.lock}
43
- gem.files << 'config/sem4r.example.yml'
44
- gem.files.concat Dir['examples_sem4r/*.rb']
45
- gem.files.concat Dir['examples_blog/*.rb']
46
- gem.files.concat Dir['lib/**/*.rb']
47
-
48
- #
49
- # test files
50
- #
51
- gem.test_files = Dir['spec/**/*.rb']
52
- gem.test_files.concat Dir['spec/**/*.xml']
53
- gem.test_files.concat Dir['spec/fixtures/**/*']
54
-
55
- #
56
- # rubyforge
57
- #
58
- # gem.rubyforge_project = 'sem'
59
- end
60
-
61
- # Jeweler::RubyforgeTasks.new do |rubyforge|
62
- # rubyforge.doc_task = "rdoc"
63
- # end
64
-
65
- Jeweler::GemcutterTasks.new
66
- rescue LoadError
67
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
68
- end
69
-
70
- #
71
- # rdoc
72
- #
73
- require 'rake/rdoctask'
74
-
75
- Rake::RDocTask.new do |rdoc|
76
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
77
- rdoc.rdoc_dir = 'rdoc'
78
- rdoc.title = "sem4r #{version}"
79
- rdoc.rdoc_files.include('README*')
80
- rdoc.rdoc_files.include('lib/**/*.rb')
81
- end
82
-
83
- #
84
- # spec
85
- #
86
-
87
- require 'rspec/core/rake_task'
88
- RSpec::Core::RakeTask.new(:spec)
89
-
90
- RSpec::Core::RakeTask.new do |t|
91
- t.rspec_opts = ["--color", "--format", "spec", '--backtrace']
92
- t.pattern = 'spec/**/*_spec.rb'
93
- end
94
-
95
- #desc "Generate HTML report for failing examples"
96
- #RSpec::Core::RakeTask.new('failing_examples_with_html') do |spec|
97
- # spec.pattern = 'failing_examples/**/*.rb'
98
- # spec.rspec_opts = ["--format", "html:doc/reports/tools/failing_examples.html", "--diff"]
99
- # spec.fail_on_error = false
100
- #end
4
+ # Load tasks
5
+ Dir.glob('tasks/**/*.rake').each { |r| Rake.application.add_import r }
101
6
 
102
7
  task :test => :check_dependencies
103
8
  task :default => :spec
104
9
 
105
- ###############################################################################
106
- # Sem4r
107
-
108
- namespace :sem4r do
109
- #
110
- # examples
111
- #
112
- desc 'run all sem4r example'
113
- task :examples do
114
-
115
- Dir['examples_sem4r/*.rb'].sort.each do |filename|
116
- next unless filename =~ /\d\d.+\.rb$/
117
- unless system "ruby #{filename}"
118
- exit
119
- end
120
- end
121
- puts "All examples run successfull"
122
-
123
- end
124
-
125
- desc "Start an IRB shell"
126
- task :shell do
127
- sh 'IRBRC=`pwd`/config/irbrc.rb irb'
128
- end
129
- end
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 2
4
+ :patch: 3
5
5
  :build:
data/bin/sem CHANGED
@@ -31,4 +31,5 @@ $:.unshift(cwd) unless $:.include?(cwd)
31
31
  require 'sem4r_cli'
32
32
 
33
33
  include Sem4r
34
+ include Sem4rCli
34
35
  exit CliSem.run
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -21,30 +22,40 @@
21
22
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23
  # -------------------------------------------------------------------
23
24
 
24
- require File.expand_path( File.join( File.dirname(__FILE__), "example_helper") )
25
+ require File.expand_path(File.join(File.dirname(__FILE__), "example_helper"))
25
26
 
26
27
  run_example(__FILE__) do |adwords|
27
28
  account = adwords.account
29
+
30
+ puts "report list:"
28
31
  account.p_reports
29
32
 
33
+ puts ""
34
+ puts "schedule new report."
30
35
  report = account.report do
31
- name "Test Report"
32
- type "Structure"
33
- start_day "2009-01-01"
34
- end_day "2009-01-31"
35
- aggregation "Keyword"
36
- column "Campaign"
37
- column "AdGroup"
38
- column "Keyword"
39
- column "KeywordTypeDisplay"
36
+ name "Test Report"
37
+ type "Structure"
38
+ start_day "2009-01-01"
39
+ end_day "2009-01-31"
40
+ aggregation "Keyword"
41
+ column "Campaign"
42
+ column "AdGroup"
43
+ column "Keyword"
44
+ column "KeywordTypeDisplay"
40
45
  end
41
46
 
42
47
  report.validate
43
48
  job = report.schedule
44
- job.wait(5) { |r, s| puts "status #{s}" }
45
- report.download(tmp_dirname + "/05_request_report.xml")
49
+ puts "wait 10 sec. before each check status"
50
+ job.wait(10) do |r, s|
51
+ puts "status #{s}"
52
+ end
53
+
54
+ puts ""
55
+ puts "download report in #{tmp_dirname + '/05_request_report.xml'}"
56
+ report.download(tmp_dirname + '/05_request_report.xml')
46
57
 
58
+ puts ""
59
+ puts "refresh report list:"
47
60
  account.p_reports(true)
48
- report = account.reports.first
49
- puts report.status(true)
50
61
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -29,13 +30,10 @@ run_example(__FILE__) do |adwords|
29
30
 
30
31
  # account.report_fields
31
32
 
32
-
33
33
  rd = account.report_definition do
34
34
  name "Keywords performance report #1290336379254"
35
35
  type "KEYWORDS_PERFORMANCE_REPORT"
36
- date_range "CUSTOM_DATE"
37
- from "20100101"
38
- to "20100110"
36
+ date_range "LAST_WEEK"
39
37
  format "CSV"
40
38
 
41
39
  field "AdGroupId"
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -23,7 +24,6 @@
23
24
 
24
25
  require File.expand_path( File.join( File.dirname(__FILE__), "example_helper") )
25
26
 
26
-
27
27
  def create_bulk_mutate_job(campaign, adgroup)
28
28
  text_ad1 = AdGroupTextAd.new(adgroup)
29
29
  text_ad1.headline = "Cruise to Mars Sector 1"
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -26,4 +27,6 @@ require File.expand_path( File.join( File.dirname(__FILE__), "example_helper") )
26
27
  run_example(__FILE__) do |adwords|
27
28
  account = adwords.account
28
29
  account.p_jobs
30
+ account.job_result(38444)
31
+ # account.job_delete(33669)
29
32
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -29,7 +30,7 @@ require 'sem4r'
29
30
  include Sem4r
30
31
 
31
32
  def tmp_dirname
32
- d = File.join( File.dirname(__FILE__), "..", "tmp" )
33
+ d = File.expand_path( File.join( File.dirname(__FILE__), "..", "tmp" ) )
33
34
  return d if File.directory?(d)
34
35
 
35
36
  if RUBY_PLATFORM.include?("linux")
@@ -65,6 +65,10 @@ module Sem4r
65
65
  "#{@id ? @id : 'unsaved'} '#{@name}' (#{@status}) - #{@bid}"
66
66
  end
67
67
 
68
+ # Build xml into Builder
69
+ #
70
+ # @param [Builder::XmlMarkup]
71
+ #
68
72
  def xml(t)
69
73
  t.campaignId campaign.id
70
74
  t.name name
@@ -72,6 +76,12 @@ module Sem4r
72
76
  @bids.to_xml(t) if @bids
73
77
  end
74
78
 
79
+ #
80
+ # Marshall this object to xml
81
+ #
82
+ # @param [String] top level tag
83
+ # @return [Builder::XmlMarkup]
84
+ #
75
85
  def to_xml(tag)
76
86
  builder = Builder::XmlMarkup.new
77
87
  builder.tag!(tag) { |t|
@@ -94,6 +104,11 @@ module Sem4r
94
104
  new(campaign, &block).save
95
105
  end
96
106
 
107
+ #
108
+ # Unmarshal this object from xml
109
+ #
110
+ # @param [Nokogiri::Element] xml element
111
+ #
97
112
  def self.from_element(campaign, el)
98
113
  new(campaign) do
99
114
  @id = el.at_xpath("id").text.strip.to_i
@@ -115,7 +130,7 @@ module Sem4r
115
130
 
116
131
  def _save
117
132
  unless @id
118
- soap_message = service.ad_group.create(credentials, to_xml("operand"))
133
+ soap_message = service.ad_group.create( credentials, to_xml("operand") )
119
134
  add_counters( soap_message.counters )
120
135
  rval = soap_message.response.xpath("//mutateResponse/rval").first
121
136
  id = rval.xpath("value/id").first
@@ -126,7 +141,7 @@ module Sem4r
126
141
  public
127
142
 
128
143
  def delete
129
- soap_message = service.ad_group.delete(credentials, @id)
144
+ soap_message = service.ad_group.delete( credentials, @id )
130
145
  add_counters( soap_message.counters )
131
146
  @id = -1 # logical delete
132
147
  end
@@ -179,7 +194,7 @@ module Sem4r
179
194
  private
180
195
 
181
196
  def _ads
182
- soap_message = service.ad_group_ad.all(credentials, id)
197
+ soap_message = service.ad_group_ad.all( credentials, id )
183
198
  add_counters( soap_message.counters )
184
199
  rval = soap_message.response.xpath("//getResponse/rval").first
185
200
  els = rval.xpath( "entries/ad" )
@@ -199,7 +214,7 @@ module Sem4r
199
214
  xml + o.to_xml("operations")
200
215
  end
201
216
 
202
- soap_message = service.ad_group_ad.mutate(credentials, xml)
217
+ soap_message = service.ad_group_ad.mutate( credentials, xml )
203
218
  add_counters( soap_message.counters )
204
219
  els = soap_message.response.xpath("//mutateResponse/rval/value/ad/id")
205
220
 
@@ -266,7 +281,7 @@ module Sem4r
266
281
  private
267
282
 
268
283
  def _criterions
269
- soap_message = service.ad_group_criterion.all(credentials, id)
284
+ soap_message = service.ad_group_criterion.all( credentials, id )
270
285
  add_counters( soap_message.counters )
271
286
  rval = soap_message.response.xpath("//getResponse/rval").first
272
287
  els = rval.xpath( "entries/criterion" )
@@ -287,7 +302,7 @@ module Sem4r
287
302
  o = AdGroupCriterionOperation.new.add(ad)
288
303
  xml + o.to_xml("operations")
289
304
  end
290
- soap_message = service.ad_group_criterion.mutate(credentials, xml)
305
+ soap_message = service.ad_group_criterion.mutate( credentials, xml )
291
306
  add_counters( soap_message.counters )
292
307
  els = soap_message.response.xpath("//mutateResponse/rval/value/criterion/id")
293
308
  els.each_with_index do |e,index|
@@ -324,7 +339,7 @@ module Sem4r
324
339
  private
325
340
 
326
341
  def _ad_params
327
- soap_message = service.ad_param.all(credentials, id)
342
+ soap_message = service.ad_param.all( credentials, id )
328
343
  add_counters( soap_message.counters )
329
344
  rval = soap_message.response.xpath("//getResponse/rval").first
330
345
  els = rval.xpath( "entries" )
@@ -23,7 +23,7 @@
23
23
 
24
24
  module Sem4r
25
25
  class AdGroupBids
26
- include SoapAttributes
26
+ include Sem4rSoap::SoapAttributes
27
27
 
28
28
  enum :Types, [
29
29
  :BudgetOptimizerAdGroupBids,
@@ -22,19 +22,26 @@
22
22
  # -------------------------------------------------------------------
23
23
 
24
24
  module Sem4r
25
- class AdGroupService
26
- include SoapCall
25
+
26
+ #
27
+ # @private
28
+ #
29
+ class AdGroupService < Sem4rSoap::SoapServiceV2010
27
30
 
28
31
  def initialize(connector)
32
+ super()
29
33
  @connector = connector
30
34
  @service_namespace = "https://adwords.google.com/api/adwords/cm/v201008"
31
35
  @header_namespace = @service_namespace
32
36
  @sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/v201008/AdGroupService"
37
+ init(@header_namespace, @service_namespace)
33
38
  end
34
39
 
35
- soap_call_v2010 :all, :mutate => false
36
- soap_call_v2010 :create, :mutate => true
37
- soap_call_v2010 :delete, :mutate => true
40
+ soap_call :all, :mutate => false
41
+ soap_call :create, :mutate => true
42
+ soap_call :delete, :mutate => true
43
+
44
+ private
38
45
 
39
46
  def _all(campaign_id)
40
47
  <<-EOFS
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -22,20 +23,24 @@
22
23
  # -------------------------------------------------------------------
23
24
 
24
25
  module Sem4r
25
- class AdGroupAdService
26
- include SoapCall
26
+
27
+ #
28
+ # @private
29
+ #
30
+ class AdGroupAdService < Sem4rSoap::SoapServiceV2010
27
31
 
28
32
  def initialize(connector)
29
- @connector = connector
30
- @service_namespace = "https://adwords.google.com/api/adwords/cm/v201008"
31
- @header_namespace = @service_namespace
32
-
33
+ @connector = connector
34
+ @service_namespace = "https://adwords.google.com/api/adwords/cm/v201008"
35
+ @header_namespace = @service_namespace
36
+
33
37
  @sandbox_service_url = "https://adwords-sandbox.google.com/api/adwords/cm/v201008/AdGroupAdService"
38
+ init(@header_namespace, @service_namespace)
34
39
  end
35
40
 
36
- soap_call_v2010 :all, :mutate => false
37
- soap_call_v2010 :mutate
38
-
41
+ soap_call :all, :mutate => false
42
+ soap_call :mutate
43
+
39
44
  private
40
45
 
41
46
  def _all(ad_group_id)