sem4r 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/LICENSE +22 -0
  2. data/README.rdoc +74 -0
  3. data/Rakefile +126 -0
  4. data/VERSION.yml +5 -0
  5. data/bin/sem +34 -0
  6. data/config/sem4r.example.yml +51 -0
  7. data/examples_blog/2009-11-29-hello-world.rb +12 -0
  8. data/examples_blog/2009-12-12-create-campaign.rb +29 -0
  9. data/examples_blog/2010-02-06-constants-scope.rb +8 -0
  10. data/examples_blog/2010-02-07-ad-parameters.rb +47 -0
  11. data/examples_sem4r/01_get_account.rb +37 -0
  12. data/examples_sem4r/02_get_info.rb +32 -0
  13. data/examples_sem4r/03_list_ad.rb +47 -0
  14. data/examples_sem4r/04_list_keywords.rb +54 -0
  15. data/examples_sem4r/05_request_report.rb +51 -0
  16. data/examples_sem4r/05_request_report_2010.rb +40 -0
  17. data/examples_sem4r/06_create_campaigns.rb +86 -0
  18. data/examples_sem4r/07_create_campaigns_block.rb +99 -0
  19. data/examples_sem4r/07_create_campaigns_simple.rb +65 -0
  20. data/examples_sem4r/08_ad_params.rb +70 -0
  21. data/examples_sem4r/09_targeting_idea.rb +59 -0
  22. data/examples_sem4r/10_get_location.rb +28 -0
  23. data/examples_sem4r/11_submit_bulk_job.rb +82 -0
  24. data/examples_sem4r/12_list_bulk_job.rb +29 -0
  25. data/examples_sem4r/30_prune_empty_adgroup.rb +50 -0
  26. data/examples_sem4r/31_empty_accounts.rb +40 -0
  27. data/examples_sem4r/example_helper.rb +115 -0
  28. data/lib/sem4r/account.rb +349 -0
  29. data/lib/sem4r/ad_extension_override/ad_extension_override_service.rb +30 -0
  30. data/lib/sem4r/ad_group/ad_group.rb +340 -0
  31. data/lib/sem4r/ad_group/ad_group_bids.rb +170 -0
  32. data/lib/sem4r/ad_group/ad_group_service.rb +75 -0
  33. data/lib/sem4r/ad_group/mobile_ad_image.rb +33 -0
  34. data/lib/sem4r/ad_group_ad/ad_group_ad.rb +98 -0
  35. data/lib/sem4r/ad_group_ad/ad_group_ad_operations.rb +38 -0
  36. data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +56 -0
  37. data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +137 -0
  38. data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +98 -0
  39. data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +144 -0
  40. data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +115 -0
  41. data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +35 -0
  42. data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +58 -0
  43. data/lib/sem4r/ad_group_criterion/criterion.rb +67 -0
  44. data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +80 -0
  45. data/lib/sem4r/ad_group_criterion/criterion_placement.rb +66 -0
  46. data/lib/sem4r/ad_param/ad_param.rb +96 -0
  47. data/lib/sem4r/ad_param/ad_param_operation.rb +34 -0
  48. data/lib/sem4r/ad_param/ad_param_service.rb +59 -0
  49. data/lib/sem4r/adwords.rb +242 -0
  50. data/lib/sem4r/api_counters.rb +7 -0
  51. data/lib/sem4r/base.rb +43 -0
  52. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +108 -0
  53. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_selector.rb +56 -0
  54. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +57 -0
  55. data/lib/sem4r/bulk_mutate_job/job_operations.rb +35 -0
  56. data/lib/sem4r/campaign/campaign.rb +193 -0
  57. data/lib/sem4r/campaign/campaign_service.rb +91 -0
  58. data/lib/sem4r/campaign_criterion/campaign_criterion_service.rb +30 -0
  59. data/lib/sem4r/campaign_target/campaign_target_service.rb +30 -0
  60. data/lib/sem4r/cli/cli_command.rb +101 -0
  61. data/lib/sem4r/cli/cli_commands.rb +60 -0
  62. data/lib/sem4r/cli/cli_common_args.rb +293 -0
  63. data/lib/sem4r/cli/cli_download_report.rb +81 -0
  64. data/lib/sem4r/cli/cli_helpers.rb +57 -0
  65. data/lib/sem4r/cli/cli_ideas.rb +100 -0
  66. data/lib/sem4r/cli/cli_list_ads.rb +74 -0
  67. data/lib/sem4r/cli/cli_list_keywords.rb +76 -0
  68. data/lib/sem4r/cli/cli_request_report.rb +104 -0
  69. data/lib/sem4r/cli/cli_sem.rb +64 -0
  70. data/lib/sem4r/common/operation.rb +78 -0
  71. data/lib/sem4r/credentials.rb +86 -0
  72. data/lib/sem4r/extensions.rb +62 -0
  73. data/lib/sem4r/geo_location/geo_location_service.rb +59 -0
  74. data/lib/sem4r/info/info_service.rb +115 -0
  75. data/lib/sem4r/report_definition/report_definition.rb +104 -0
  76. data/lib/sem4r/report_definition/report_definition_operation.rb +34 -0
  77. data/lib/sem4r/report_definition/report_definition_selector.rb +31 -0
  78. data/lib/sem4r/report_definition/report_definition_service.rb +55 -0
  79. data/lib/sem4r/sem4r_error.rb +28 -0
  80. data/lib/sem4r/services/service.rb +74 -0
  81. data/lib/sem4r/services/soap_call.rb +100 -0
  82. data/lib/sem4r/services/soap_connector.rb +284 -0
  83. data/lib/sem4r/services/soap_error.rb +38 -0
  84. data/lib/sem4r/services/soap_message_v13.rb +129 -0
  85. data/lib/sem4r/services/soap_message_v2009.rb +170 -0
  86. data/lib/sem4r/soap_attributes.rb +141 -0
  87. data/lib/sem4r/targeting_idea/targeting_idea.rb +158 -0
  88. data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +200 -0
  89. data/lib/sem4r/targeting_idea/targeting_idea_service.rb +51 -0
  90. data/lib/sem4r/v13_account/account_service.rb +54 -0
  91. data/lib/sem4r/v13_account/billing_address.rb +67 -0
  92. data/lib/sem4r/v13_report/report.rb +185 -0
  93. data/lib/sem4r/v13_report/report_job.rb +51 -0
  94. data/lib/sem4r/v13_report/report_service.rb +89 -0
  95. data/lib/sem4r/v13_traffic_estimator/traffic_estimator_service.rb +30 -0
  96. data/lib/sem4r.rb +142 -0
  97. data/lib/sem4r_cli.rb +40 -0
  98. data/sem4r.gemspec +247 -0
  99. data/spec/aggregates_spec_helper.rb +59 -0
  100. data/spec/fixtures/sem4r.example.yml +26 -0
  101. data/spec/fixtures/services/ad_group/get-first-req.xml +28 -0
  102. data/spec/fixtures/services/ad_group/get-first-res.xml +91 -0
  103. data/spec/fixtures/services/ad_group/get-manual-cpm-bids-req.xml +106 -0
  104. data/spec/fixtures/services/ad_group/get-manual-cpm-bids-res.xml +75 -0
  105. data/spec/fixtures/services/ad_group/mutate_add-req.xml +52 -0
  106. data/spec/fixtures/services/ad_group/mutate_add-res.xml +33 -0
  107. data/spec/fixtures/services/ad_group_ad/get_mobile_ad-req.xml +28 -0
  108. data/spec/fixtures/services/ad_group_ad/get_mobile_ad-res.xml +194 -0
  109. data/spec/fixtures/services/ad_group_ad/get_text_ad-req.xml +29 -0
  110. data/spec/fixtures/services/ad_group_ad/get_text_ad-res.xml +55 -0
  111. data/spec/fixtures/services/ad_group_ad/mutate_add_mobile_ad-req.xml +50 -0
  112. data/spec/fixtures/services/ad_group_ad/mutate_add_mobile_ad-res.xml +42 -0
  113. data/spec/fixtures/services/ad_group_ad/mutate_add_text_ad-req.xml +37 -0
  114. data/spec/fixtures/services/ad_group_ad/mutate_add_text_ad-res.xml +32 -0
  115. data/spec/fixtures/services/ad_group_ad/mutate_add_two_criterions-req.xml +83 -0
  116. data/spec/fixtures/services/ad_group_ad/mutate_add_two_criterions-res.xml +95 -0
  117. data/spec/fixtures/services/ad_group_criterion/get-req.xml +28 -0
  118. data/spec/fixtures/services/ad_group_criterion/get-res.xml +242 -0
  119. data/spec/fixtures/services/ad_group_criterion/mutate_add_criterion_keyword-req.xml +48 -0
  120. data/spec/fixtures/services/ad_group_criterion/mutate_add_criterion_keyword-res.xml +47 -0
  121. data/spec/fixtures/services/ad_group_criterion/mutate_add_criterion_placement-req.xml +35 -0
  122. data/spec/fixtures/services/ad_group_criterion/mutate_add_criterion_placement-res.xml +32 -0
  123. data/spec/fixtures/services/ad_group_criterion/mutate_add_negative_keyword-req.xml +37 -0
  124. data/spec/fixtures/services/ad_group_criterion/mutate_add_negative_keyword-res.xml +51 -0
  125. data/spec/fixtures/services/ad_param/mutate_set-req.xml +43 -0
  126. data/spec/fixtures/services/ad_param/mutate_set-res.xml +29 -0
  127. data/spec/fixtures/services/bulk_mutate_job/get-req.xml +36 -0
  128. data/spec/fixtures/services/bulk_mutate_job/get-res.xml +54 -0
  129. data/spec/fixtures/services/bulk_mutate_job/mutate-req.xml +69 -0
  130. data/spec/fixtures/services/bulk_mutate_job/mutate-res.xml +48 -0
  131. data/spec/fixtures/services/campaign/get-req.xml +37 -0
  132. data/spec/fixtures/services/campaign/get-res.xml +1986 -0
  133. data/spec/fixtures/services/campaign/mutate_add-req.xml +37 -0
  134. data/spec/fixtures/services/campaign/mutate_add-res.xml +42 -0
  135. data/spec/fixtures/services/error.xml +28 -0
  136. data/spec/fixtures/services/info/get_unit_count-req.xml +30 -0
  137. data/spec/fixtures/services/info/get_unit_count-res.xml +29 -0
  138. data/spec/fixtures/services/report_definition/mutate_add-req.xml +24 -0
  139. data/spec/fixtures/services/report_definition/mutate_add-req_orig.xml +45 -0
  140. data/spec/fixtures/services/targeting_idea/get-req-all-options.xml +57 -0
  141. data/spec/fixtures/services/targeting_idea/get-req.xml +60 -0
  142. data/spec/fixtures/services/targeting_idea/get-res.xml +3601 -0
  143. data/spec/fixtures/services/v13_account/get_account_info-req.xml +23 -0
  144. data/spec/fixtures/services/v13_account/get_account_info-res.xml +54 -0
  145. data/spec/fixtures/services/v13_account/get_client_accounts-req.xml +22 -0
  146. data/spec/fixtures/services/v13_account/get_client_accounts-res.xml +37 -0
  147. data/spec/fixtures/services/v13_report/get_all_jobs-req.xml +21 -0
  148. data/spec/fixtures/services/v13_report/get_all_jobs-res.xml +109 -0
  149. data/spec/fixtures/services/v13_report/schedule_report_job-req.xml +56 -0
  150. data/spec/fixtures/services/v13_report/schedule_report_job-res.xml +24 -0
  151. data/spec/sem4r/account_spec.rb +86 -0
  152. data/spec/sem4r/ad_group/ad_group_bids_spec.rb +67 -0
  153. data/spec/sem4r/ad_group/ad_group_service_spec.rb +66 -0
  154. data/spec/sem4r/ad_group/ad_group_spec.rb +212 -0
  155. data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +88 -0
  156. data/spec/sem4r/ad_group_ad/ad_group_ad_service_spec.rb +55 -0
  157. data/spec/sem4r/ad_group_ad/ad_group_ad_spec.rb +173 -0
  158. data/spec/sem4r/ad_group_criterion/ad_group_criterion_bids_spec.rb +60 -0
  159. data/spec/sem4r/ad_group_criterion/ad_group_criterion_service_spec.rb +55 -0
  160. data/spec/sem4r/ad_group_criterion/ad_group_criterion_spec.rb +103 -0
  161. data/spec/sem4r/ad_group_criterion/criterion_spec.rb +85 -0
  162. data/spec/sem4r/ad_param/ad_param_service_spec.rb +55 -0
  163. data/spec/sem4r/ad_param/ad_param_spec.rb +59 -0
  164. data/spec/sem4r/adwords_spec.rb +110 -0
  165. data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +63 -0
  166. data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +69 -0
  167. data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +48 -0
  168. data/spec/sem4r/campaign/campaign_service_spec.rb +66 -0
  169. data/spec/sem4r/campaign/campaign_spec.rb +105 -0
  170. data/spec/sem4r/cli/cli_spec.rb +71 -0
  171. data/spec/sem4r/credentials_spec.rb +65 -0
  172. data/spec/sem4r/report_definition/report_definition_service_spec.rb +44 -0
  173. data/spec/sem4r/report_definition/report_definition_spec.rb +105 -0
  174. data/spec/sem4r/rexml_parsing_spec.rb +103 -0
  175. data/spec/sem4r/services/service_spec.rb +36 -0
  176. data/spec/sem4r/services/soap_call_spec.rb +115 -0
  177. data/spec/sem4r/services/soap_message_v13_spec.rb +54 -0
  178. data/spec/sem4r/soap_attributes_spec.rb +116 -0
  179. data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +120 -0
  180. data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +44 -0
  181. data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +53 -0
  182. data/spec/sem4r/v13_account/account_service_spec.rb +60 -0
  183. data/spec/sem4r/v13_report/report_service_spec.rb +104 -0
  184. data/spec/sem4r/v13_report/report_spec.rb +79 -0
  185. data/spec/sem4r_spec_helper.rb +353 -0
  186. data/spec/spec_helper.rb +12 -0
  187. metadata +375 -0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,74 @@
1
+ = Sem4r
2
+
3
+ Sem4r is a ruby library to access google adwords api, that works with ruby 1.9 and 1.8.
4
+
5
+ The Google AdWords Api (http://code.google.com/apis/adwords/) is a
6
+ webservice soap protocol. From the official site:
7
+
8
+ The Google AdWords API lets developers build applications that interact directly
9
+ with the AdWords platform. With these applications, advertisers and third
10
+ parties can more efficiently and creatively manage their large or complex
11
+ AdWords accounts and campaigns.
12
+
13
+ The official google adwords ruby library adwords4r doesn't work with ruby 1.9,
14
+ because uses soap4r. The soap4r is not supported by ruby 1.9.
15
+ Sem4r don't uses soap4r.
16
+
17
+ Main idea is to use a high level model instead of a low level api.
18
+ You think about clients, campaigns, keywords and not about operations, operands, service calls.
19
+ In the future, the library might decide which api use (sync or async) and when call it!
20
+
21
+ == Usage
22
+
23
+ To access adwords api you need:
24
+ - email account (for sandbox environment a gmail account <myaccount>@gmail.com)
25
+ - password
26
+ - developer token (for sandbox environment is like <myaccount>@gmail.com++EUR)
27
+
28
+ To access the sandbox environment
29
+
30
+ adwords = Adwords.sandbox( :email => "<myaccount>@gmail.com", :password => "secret", :developer_token => "<myaccount>@gmail.com++EUR")
31
+
32
+ To print details about the current account:
33
+
34
+ adwords.account.p_info
35
+
36
+ You can list all client accounts:
37
+
38
+ adwords.account.p_clients
39
+
40
+ See directory examples_sem4r[http://github.com/sem4r/sem4r/tree/master/examples_sem4r/examples_sem4r] for more examples.
41
+ Follow the sem4r.com[http://www.sem4r.com] feed for announcements of new releases.
42
+
43
+ == Install
44
+
45
+ sudo gem install sem4r
46
+
47
+ == Contributors
48
+
49
+ * Glenn Gillen {http://github.com/rubypond}
50
+
51
+ == License
52
+
53
+ (The MIT License)
54
+
55
+ Copyright (c) 2009 - 2010 {Sem4r}[http://www.sem4r.com]
56
+
57
+ Permission is hereby granted, free of charge, to any person obtaining
58
+ a copy of this software and associated documentation files (the
59
+ 'Software'), to deal in the Software without restriction, including
60
+ without limitation the rights to use, copy, modify, merge, publish,
61
+ distribute, sublicense, and/or sell copies of the Software, and to
62
+ permit persons to whom the Software is furnished to do so, subject to
63
+ the following conditions:
64
+
65
+ The above copyright notice and this permission notice shall be
66
+ included in all copies or substantial portions of the Software.
67
+
68
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
69
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
70
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
71
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
72
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
73
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
74
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,126 @@
1
+ require 'rubygems'
2
+ require 'rake'
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_development_dependency 'rspec'
36
+ gem.add_development_dependency 'differ'
37
+
38
+ #
39
+ # files
40
+ #
41
+ gem.files = %w{LICENSE README.rdoc Rakefile VERSION.yml sem4r.gemspec}
42
+ gem.files << 'config/sem4r.example.yml'
43
+ gem.files.concat Dir['examples_sem4r/*.rb']
44
+ gem.files.concat Dir['examples_blog/*.rb']
45
+ gem.files.concat Dir['lib/**/*.rb']
46
+
47
+ #
48
+ # test files
49
+ #
50
+ gem.test_files = Dir['spec/**/*.rb']
51
+ gem.test_files.concat Dir['spec/fixtures/**/*']
52
+
53
+ #
54
+ # rubyforge
55
+ #
56
+ # gem.rubyforge_project = 'sem'
57
+ end
58
+
59
+ # Jeweler::RubyforgeTasks.new do |rubyforge|
60
+ # rubyforge.doc_task = "rdoc"
61
+ # end
62
+
63
+ Jeweler::GemcutterTasks.new
64
+ rescue LoadError
65
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
66
+ end
67
+
68
+ #
69
+ # rdoc
70
+ #
71
+ require 'rake/rdoctask'
72
+
73
+ Rake::RDocTask.new do |rdoc|
74
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
75
+ rdoc.rdoc_dir = 'rdoc'
76
+ rdoc.title = "sem4r #{version}"
77
+ rdoc.rdoc_files.include('README*')
78
+ rdoc.rdoc_files.include('lib/**/*.rb')
79
+ end
80
+
81
+ #
82
+ # spec
83
+ #
84
+
85
+ #require 'spec/rake/spectask'
86
+ #
87
+ #desc "Run all examples"
88
+ #Spec::Rake::SpecTask.new('spec') do |t|
89
+ # t.spec_files = FileList['spec/**/*_spec.rb']
90
+ #end
91
+ #
92
+ #desc "Generate HTML report for failing examples"
93
+ #Spec::Rake::SpecTask.new('failing_examples_with_html') do |t|
94
+ # t.spec_files = FileList['failing_examples/**/*.rb']
95
+ # t.spec_opts = ["--format", "html:doc/reports/tools/failing_examples.html", "--diff"]
96
+ # t.fail_on_error = false
97
+ #end
98
+
99
+ task :test => :check_dependencies
100
+ task :default => :spec
101
+
102
+ ###############################################################################
103
+ # Sem4r
104
+
105
+ namespace :sem4r do
106
+ #
107
+ # examples
108
+ #
109
+ desc 'run all sem4r example'
110
+ task :examples do
111
+
112
+ Dir['examples_sem4r/*.rb'].sort.each do |filename|
113
+ next unless filename =~ /\d\d.+\.rb$/
114
+ unless system "ruby #{filename}"
115
+ exit
116
+ end
117
+ end
118
+ puts "All examples run successfull"
119
+
120
+ end
121
+
122
+ desc "Start an IRB shell"
123
+ task :shell do
124
+ sh 'IRBRC=`pwd`/config/irbrc.rb irb'
125
+ end
126
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 1
5
+ :build:
data/bin/sem ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # -------------------------------------------------------------------------
4
+ # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining
7
+ # a copy of this software and associated documentation files (the
8
+ # "Software"), to deal in the Software without restriction, including
9
+ # without limitation the rights to use, copy, modify, merge, publish,
10
+ # distribute, sublicense, and/or sell copies of the Software, and to
11
+ # permit persons to whom the Software is furnished to do so, subject to
12
+ # the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be
15
+ # included in all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ #
25
+ # -------------------------------------------------------------------------
26
+
27
+ require 'rubygems'
28
+
29
+ cwd = File.expand_path( File.join( File.dirname(__FILE__), "..", "lib" ) )
30
+ $:.unshift(cwd) unless $:.include?(cwd)
31
+ require 'sem4r_cli'
32
+
33
+ include Sem4r
34
+ exit CliSem.run
@@ -0,0 +1,51 @@
1
+ #
2
+ # Example config file
3
+ # Adwords profiles
4
+ #
5
+ google_adwords:
6
+
7
+ sandbox:
8
+ # default environment is sandbox (cannot be changed)
9
+ email: example@gmail.com
10
+ password: password
11
+ developer_token: example@gmail.com++EUR
12
+ mutable: true
13
+
14
+ production:
15
+ # default environment is production (cannot be changed)
16
+ email: production@mysite.com
17
+ password: password
18
+ developer_token: productiondevelopertoken
19
+ mutable: true
20
+
21
+ # immutable profile
22
+ # cannot be called service that modify account
23
+ # as adding keyword, disable adgroup, ...
24
+ sandbox_read_only:
25
+ environment: sandbox
26
+ email: example@gmail.com
27
+ password: password
28
+ developer_token: example@gmail.com++EUR
29
+ mutable: false
30
+
31
+ production_read_only:
32
+ environment: production
33
+ email: production@mysite.com
34
+ password: password
35
+ developer_token: productiondevelopertoken
36
+ mutable: false
37
+
38
+ myclient_sandbox:
39
+ environment: sandbox
40
+ email: example@gmail.com
41
+ password: password
42
+ developer_token: example@gmail.com++EUR
43
+ mutable: true
44
+
45
+ myclient_production:
46
+ environment: production
47
+ email: production@anothersite.com
48
+ password: password
49
+ developer_token: productiondevelopertoken
50
+ mutable: true
51
+
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'sem4r'
3
+ include Sem4r
4
+
5
+ adwords = Adwords.sandbox
6
+
7
+ #adwords = Adwords.sandbox(
8
+ # :email => "<myaccount>@gmail.com",
9
+ # :password => "secret",
10
+ # :developer_token => "<myaccount>@gmail.com++EUR")
11
+ adwords.account.p_client_accounts
12
+
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'sem4r'
3
+ include Sem4r
4
+
5
+ adwords = Adwords.sandbox
6
+
7
+ #adwords = Adwords.sandbox(
8
+ # :email => "<myaccount>@gmail.com",
9
+ # :password => "secret",
10
+ # :developer_token => "<myaccount>@gmail.com++EUR")
11
+
12
+ account = adwords.account.client_accounts[1]
13
+
14
+ campaign = account.create_campaign do
15
+ name "new campaign #{Time.now.strftime('%m%d-%H%M%S')}"
16
+
17
+ adgroup do
18
+ name "new adgroup #{Time.now.strftime('%m%d-%H%M%S')}"
19
+ keyword do
20
+ text "keyword"
21
+ match "BROAD"
22
+ end
23
+ placement do
24
+ url "www.example.com"
25
+ end
26
+ end
27
+ end
28
+
29
+ campaign.p_adgroups(true)
@@ -0,0 +1,8 @@
1
+ class A
2
+ C = "c"
3
+ end
4
+
5
+ puts RUBY_VERSION
6
+ A.new.instance_eval do
7
+ puts C
8
+ end
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'sem4r'
3
+ include Sem4r
4
+
5
+ adwords = Adwords.sandbox
6
+
7
+ #adwords = Adwords.sandbox(
8
+ # :email => "<myaccount>@gmail.com",
9
+ # :password => "secret",
10
+ # :developer_token => "<myaccount>@gmail.com++EUR")
11
+
12
+ client_account = adwords.account.client_accounts.first
13
+
14
+ campaign = client_account.campaign do
15
+ name "Skis"
16
+
17
+ adgroup do
18
+ name "Skis for sales"
19
+
20
+ text_ad do
21
+ headline "Save on Rossignol skis"
22
+ description1 "Great deal on Rissignol starting at"
23
+ description2 "{param1:lowprices}! Save {param2: big time}!"
24
+ url "http://skideals.com"
25
+ display_url "www.SkiDeals.com"
26
+ end
27
+
28
+ keyword do
29
+ text "ski deal rossignol"
30
+ match "BROAD"
31
+
32
+ ad_param do
33
+ index 1
34
+ text "$279"
35
+ end
36
+
37
+ ad_param do
38
+ index 2
39
+ text "20%"
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ campaign.adgroups(true).each do |adgroup|
46
+ adgroup.p_ad_params
47
+ end
@@ -0,0 +1,37 @@
1
+ # -------------------------------------------------------------------
2
+ # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ # -------------------------------------------------------------------
23
+
24
+ require File.dirname(__FILE__) + "/example_helper"
25
+
26
+ run_example(__FILE__) do |adwords|
27
+ account = adwords.account
28
+ account.p_client_accounts
29
+
30
+ client_account = account.client_accounts.first
31
+ client_account.p_campaigns
32
+
33
+ unless client_account.campaigns.empty?
34
+ campaign = client_account.campaigns.first
35
+ campaign.p_ad_groups
36
+ end
37
+ end
@@ -0,0 +1,32 @@
1
+ # -------------------------------------------------------------------
2
+ # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ # -------------------------------------------------------------------
23
+
24
+ require File.dirname(__FILE__) + "/example_helper"
25
+
26
+ run_example(__FILE__) do |adwords|
27
+ adwords.account.p_info
28
+ (Account::UsageTypes - [Account::METHOD_COST]).each do |usage_type|
29
+ n = adwords.account.year_unit_cost(usage_type)
30
+ puts "#{usage_type} -> #{n}"
31
+ end
32
+ end
@@ -0,0 +1,47 @@
1
+ # -------------------------------------------------------------------
2
+ # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ # -------------------------------------------------------------------
23
+
24
+ require File.dirname(__FILE__) + "/example_helper"
25
+
26
+ run_example(__FILE__) do |adwords|
27
+ puts "List AdGroup Advertising"
28
+
29
+ adwords.account.client_accounts.each do |client_account|
30
+ puts "examinate account '#{client_account.credentials.client_email}'"
31
+ client_account.campaigns.each do |campaign|
32
+ puts "examinate campaign '#{campaign}'"
33
+ campaign.ad_groups.each do |ad_group|
34
+ puts "examinate adgroup '#{ad_group}'"
35
+ ad_group.ads.each do |ad|
36
+ row = []
37
+ row << client_account.credentials.client_email
38
+ row << campaign.name
39
+ row << ad_group.name
40
+ row << ad.url
41
+ row << ad.display_url
42
+ puts row.join(",")
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,54 @@
1
+ # -------------------------------------------------------------------
2
+ # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ # -------------------------------------------------------------------
23
+
24
+ require File.dirname(__FILE__) + "/example_helper"
25
+
26
+ run_example(__FILE__) do |adwords|
27
+ puts "List AdGroup Keywords"
28
+
29
+ adwords.account.client_accounts.each do |client_account|
30
+ puts "examinate account '#{client_account.credentials.client_email}'"
31
+ client_account.campaigns.each do |campaign|
32
+ puts "examinate campaign '#{campaign}'"
33
+ campaign.ad_groups.each do |ad_group|
34
+ ad_group.criterions.each do |criterion|
35
+ row = []
36
+ row << client_account.credentials.client_email
37
+ row << campaign.name
38
+ row << ad_group.name
39
+
40
+ row << criterion.type
41
+ case criterion.type
42
+ when Criterion::Keyword
43
+ row << criterion.text
44
+ row << criterion.match
45
+ when Criterion::Placement
46
+ row << criterion.url
47
+ end
48
+
49
+ puts row.join(",")
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,51 @@
1
+ # -------------------------------------------------------------------
2
+ # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ # -------------------------------------------------------------------
23
+
24
+
25
+ require File.dirname(__FILE__) + "/example_helper"
26
+
27
+ run_example(__FILE__) do |adwords|
28
+ account = adwords.account
29
+ account.p_reports
30
+
31
+ report = account.report do
32
+ name "Test Report"
33
+ type "Structure"
34
+ start_day "2009-01-01"
35
+ end_day "2009-01-31"
36
+ aggregation "Keyword"
37
+ column "Campaign"
38
+ column "AdGroup"
39
+ column "Keyword"
40
+ column "KeywordTypeDisplay"
41
+ end
42
+
43
+ report.validate
44
+ job = report.schedule
45
+ job.wait(5) { |r, s| puts "status #{s}" }
46
+ report.download(tmp_dirname + "/05_request_report.xml")
47
+
48
+ account.p_reports(true)
49
+ report = account.reports.first
50
+ puts report.status(true)
51
+ end
@@ -0,0 +1,40 @@
1
+ # -------------------------------------------------------------------
2
+ # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ # -------------------------------------------------------------------
23
+
24
+
25
+ require File.dirname(__FILE__) + "/example_helper"
26
+
27
+ run_example(__FILE__) do |adwords|
28
+
29
+ account = adwords.account
30
+
31
+ # account.p_report_definitions
32
+
33
+ rd = account.report_definition do
34
+ name "report"
35
+ end
36
+ rd.save
37
+
38
+ puts rd.to_s
39
+
40
+ end