sem4r 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. data/Gemfile +11 -0
  2. data/Gemfile.lock +36 -0
  3. data/README.rdoc +30 -0
  4. data/Rakefile +15 -12
  5. data/VERSION.yml +1 -1
  6. data/examples_blog/2009-11-29-hello-world.rb +0 -1
  7. data/examples_sem4r/01_get_account.rb +1 -1
  8. data/examples_sem4r/02_get_info.rb +6 -2
  9. data/examples_sem4r/03_list_ad.rb +1 -1
  10. data/examples_sem4r/04_list_keywords.rb +1 -1
  11. data/examples_sem4r/05_request_report.rb +1 -2
  12. data/examples_sem4r/05_request_report_2010.rb +19 -4
  13. data/examples_sem4r/06_create_campaigns.rb +1 -1
  14. data/examples_sem4r/07_create_campaigns_block.rb +1 -1
  15. data/examples_sem4r/07_create_campaigns_simple.rb +1 -1
  16. data/examples_sem4r/08_ad_params.rb +1 -1
  17. data/examples_sem4r/09_targeting_idea.rb +1 -1
  18. data/examples_sem4r/10_get_location.rb +1 -1
  19. data/examples_sem4r/11_submit_bulk_job.rb +1 -1
  20. data/examples_sem4r/12_list_bulk_job.rb +1 -1
  21. data/examples_sem4r/30_prune_empty_adgroup.rb +1 -1
  22. data/examples_sem4r/31_empty_accounts.rb +1 -1
  23. data/examples_sem4r/example_helper.rb +5 -10
  24. data/lib/sem4r/account.rb +3 -306
  25. data/lib/sem4r/ad_group/ad_group.rb +16 -14
  26. data/lib/sem4r/ad_group/ad_group_bids.rb +11 -10
  27. data/lib/sem4r/ad_group/ad_group_service.rb +5 -5
  28. data/lib/sem4r/ad_group_ad/ad_group_ad.rb +1 -1
  29. data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +5 -5
  30. data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +9 -9
  31. data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +9 -9
  32. data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +6 -6
  33. data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +5 -6
  34. data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +0 -1
  35. data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +4 -4
  36. data/lib/sem4r/ad_group_criterion/criterion.rb +3 -3
  37. data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +3 -3
  38. data/lib/sem4r/ad_group_criterion/criterion_placement.rb +2 -2
  39. data/lib/sem4r/ad_param/ad_param.rb +3 -3
  40. data/lib/sem4r/ad_param/ad_param_service.rb +5 -5
  41. data/lib/sem4r/adwords.rb +1 -0
  42. data/lib/sem4r/api_counters.rb +1 -0
  43. data/lib/sem4r/base.rb +1 -0
  44. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +2 -2
  45. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_account_extension.rb +59 -0
  46. data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +5 -5
  47. data/lib/sem4r/campaign/campaign.rb +10 -10
  48. data/lib/sem4r/campaign/campaign_account_extension.rb +87 -0
  49. data/lib/sem4r/campaign/campaign_service.rb +6 -6
  50. data/lib/sem4r/campaign_target/campaign_target_service.rb +22 -22
  51. data/lib/sem4r/cli/cli_command.rb +1 -0
  52. data/lib/sem4r/cli/cli_common_args.rb +10 -3
  53. data/lib/sem4r/cli/cli_helpers.rb +1 -0
  54. data/lib/sem4r/cli/cli_sem.rb +1 -0
  55. data/lib/sem4r/cli/{cli_download_report.rb → commands/cli_download_report.rb} +2 -1
  56. data/lib/sem4r/cli/{cli_ideas.rb → commands/cli_ideas.rb} +1 -0
  57. data/lib/sem4r/cli/{cli_commands.rb → commands/cli_info.rb} +3 -23
  58. data/lib/sem4r/cli/{cli_list_ads.rb → commands/cli_list_ads.rb} +1 -0
  59. data/lib/sem4r/cli/commands/cli_list_campaign.rb +35 -0
  60. data/lib/sem4r/cli/commands/cli_list_client.rb +36 -0
  61. data/lib/sem4r/cli/{cli_list_keywords.rb → commands/cli_list_keywords.rb} +1 -0
  62. data/lib/sem4r/cli/commands/cli_list_report.rb +34 -0
  63. data/lib/sem4r/cli/commands/cli_repdef.rb +109 -0
  64. data/lib/sem4r/cli/commands/cli_report.rb +78 -0
  65. data/lib/sem4r/cli/{cli_request_report.rb → commands/cli_request_report.rb} +1 -0
  66. data/lib/sem4r/credentials.rb +1 -0
  67. data/lib/sem4r/extensions.rb +22 -1
  68. data/lib/sem4r/geo_location/geo_location_account_extension.rb +43 -0
  69. data/lib/sem4r/geo_location/geo_location_service.rb +4 -4
  70. data/lib/sem4r/info/info_account_extension.rb +48 -0
  71. data/lib/sem4r/info/info_selector.rb +108 -0
  72. data/lib/sem4r/info/info_service.rb +11 -66
  73. data/lib/sem4r/{common/operation.rb → operation.rb} +3 -1
  74. data/lib/sem4r/report_definition/report_definition.rb +75 -15
  75. data/lib/sem4r/report_definition/report_definition_account_extension.rb +79 -0
  76. data/lib/sem4r/report_definition/report_definition_operation.rb +3 -1
  77. data/lib/sem4r/report_definition/report_definition_service.rb +7 -7
  78. data/lib/sem4r/report_definition/report_field.rb +57 -0
  79. data/lib/sem4r/sem4r_error.rb +1 -0
  80. data/lib/sem4r/services/http_connector.rb +93 -0
  81. data/lib/sem4r/services/service.rb +1 -1
  82. data/lib/sem4r/services/soap_call.rb +27 -5
  83. data/lib/sem4r/services/soap_connector.rb +2 -147
  84. data/lib/sem4r/services/soap_dumper.rb +105 -0
  85. data/lib/sem4r/services/soap_message_v13.rb +15 -9
  86. data/lib/sem4r/services/{soap_message_v2009.rb → soap_message_v2010.rb} +26 -12
  87. data/lib/sem4r/targeting_idea/targeting_idea.rb +16 -11
  88. data/lib/sem4r/targeting_idea/targeting_idea_account_extension.rb +52 -0
  89. data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +36 -10
  90. data/lib/sem4r/targeting_idea/targeting_idea_service.rb +5 -5
  91. data/lib/sem4r/v13_account/account_account_extension.rb +103 -0
  92. data/lib/sem4r/v13_account/billing_address.rb +10 -21
  93. data/lib/sem4r/v13_report/report.rb +8 -8
  94. data/lib/sem4r/v13_report/report_account_extension.rb +63 -0
  95. data/lib/sem4r/v13_report/report_job.rb +1 -1
  96. data/lib/sem4r.rb +27 -6
  97. data/lib/sem4r_cli.rb +4 -6
  98. data/lib/{sem4r → soap_helpers}/soap_attributes.rb +105 -13
  99. data/sem4r.gemspec +229 -190
  100. data/spec/{aggregates_spec_helper.rb → aggregates_rspec_helper.rb} +0 -0
  101. data/spec/build_fixtures.rb +84 -0
  102. data/spec/rspec_hash.rb +66 -0
  103. data/spec/{spec_helper.rb → rspec_helper.rb} +4 -2
  104. data/spec/rspec_matchers.rb +102 -0
  105. data/spec/rspec_sem4r_helper.rb +88 -0
  106. data/spec/sem4r/account_spec.rb +3 -4
  107. data/spec/sem4r/ad_group/ad_group_bids_spec.rb +4 -3
  108. data/spec/sem4r/ad_group/ad_group_service_spec.rb +8 -7
  109. data/spec/sem4r/ad_group/ad_group_spec.rb +5 -4
  110. data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-first-req.xml +0 -0
  111. data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-first-res.xml +0 -0
  112. data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-manual-cpm-bids-req.xml +0 -0
  113. data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-manual-cpm-bids-res.xml +0 -0
  114. data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/mutate_add-req.xml +0 -0
  115. data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/mutate_add-res.xml +0 -0
  116. data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +3 -3
  117. data/spec/sem4r/ad_group_ad/ad_group_ad_service_spec.rb +6 -5
  118. data/spec/sem4r/ad_group_ad/ad_group_ad_spec.rb +6 -5
  119. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_mobile_ad-req.xml +0 -0
  120. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_mobile_ad-res.xml +0 -0
  121. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_text_ad-req.xml +0 -0
  122. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_text_ad-res.xml +0 -0
  123. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_mobile_ad-req.xml +0 -0
  124. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_mobile_ad-res.xml +0 -0
  125. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_text_ad-req.xml +0 -0
  126. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_text_ad-res.xml +0 -0
  127. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_two_criterions-req.xml +0 -0
  128. data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_two_criterions-res.xml +0 -0
  129. data/spec/sem4r/ad_group_criterion/ad_group_criterion_bids_spec.rb +5 -4
  130. data/spec/sem4r/ad_group_criterion/ad_group_criterion_service_spec.rb +6 -5
  131. data/spec/sem4r/ad_group_criterion/ad_group_criterion_spec.rb +6 -5
  132. data/spec/sem4r/ad_group_criterion/criterion_spec.rb +5 -4
  133. data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/get-req.xml +0 -0
  134. data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/get-res.xml +0 -0
  135. data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_keyword-req.xml +0 -0
  136. data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_keyword-res.xml +0 -0
  137. data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_placement-req.xml +0 -0
  138. data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_placement-res.xml +0 -0
  139. data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_negative_keyword-req.xml +0 -0
  140. data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_negative_keyword-res.xml +0 -0
  141. data/spec/sem4r/ad_param/ad_param_service_spec.rb +6 -5
  142. data/spec/sem4r/ad_param/ad_param_spec.rb +3 -2
  143. data/spec/{fixtures/services/ad_param → sem4r/ad_param/fixtures}/mutate_set-req.xml +0 -0
  144. data/spec/{fixtures/services/ad_param → sem4r/ad_param/fixtures}/mutate_set-res.xml +0 -0
  145. data/spec/sem4r/adwords_spec.rb +1 -1
  146. data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +6 -5
  147. data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +4 -3
  148. data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/get-req.xml +0 -0
  149. data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/get-res.xml +0 -0
  150. data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-req.xml +0 -0
  151. data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-res.xml +0 -0
  152. data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +3 -2
  153. data/spec/sem4r/campaign/campaign_service_spec.rb +8 -7
  154. data/spec/sem4r/campaign/campaign_spec.rb +3 -2
  155. data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/get-req.xml +0 -0
  156. data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/get-res.xml +0 -0
  157. data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/mutate_add-req.xml +0 -0
  158. data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/mutate_add-res.xml +0 -0
  159. data/spec/sem4r/cli/cli_spec.rb +2 -3
  160. data/spec/sem4r/credentials_spec.rb +1 -1
  161. data/spec/sem4r/info/account_info_extension_spec.rb +51 -0
  162. data/spec/sem4r/info/fixtures/get_unit_count-req.xml +34 -0
  163. data/spec/sem4r/info/fixtures/get_unit_count-res.xml +27 -0
  164. data/spec/sem4r/nokogiri_parsing_spec.rb +105 -0
  165. data/spec/{fixtures/services/report_definition → sem4r/report_definition/fixtures}/mutate_add-req.xml +0 -0
  166. data/spec/{fixtures/services/report_definition → sem4r/report_definition/fixtures}/mutate_add-req_orig.xml +0 -0
  167. data/spec/sem4r/report_definition/report_definition_service_spec.rb +5 -3
  168. data/spec/sem4r/report_definition/report_definition_spec.rb +6 -3
  169. data/spec/sem4r/rexml_parsing_spec.rb +22 -22
  170. data/spec/sem4r/services/service_spec.rb +2 -1
  171. data/spec/sem4r/services/soap_call_spec.rb +6 -5
  172. data/spec/sem4r/services/soap_message_v13_spec.rb +5 -11
  173. data/spec/{fixtures/services/targeting_idea → sem4r/targeting_idea/fixtures}/get-req-all-options.xml +0 -0
  174. data/spec/{fixtures/services/targeting_idea → sem4r/targeting_idea/fixtures}/get-req.xml +9 -11
  175. data/spec/sem4r/targeting_idea/fixtures/get-res.xml +2276 -0
  176. data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +30 -11
  177. data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +4 -3
  178. data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +5 -4
  179. data/spec/sem4r/v13_account/account_account_extension_spec.rb +47 -0
  180. data/spec/sem4r/v13_account/account_service_spec.rb +6 -5
  181. data/spec/sem4r/v13_account/billing_address_spec.rb +40 -0
  182. data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-req.xml +0 -0
  183. data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-res.xml +0 -0
  184. data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-req.xml +0 -0
  185. data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-res.xml +0 -0
  186. data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/get_all_jobs-req.xml +0 -0
  187. data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/get_all_jobs-res.xml +2 -2
  188. data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-req.xml +0 -0
  189. data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-res.xml +0 -0
  190. data/spec/sem4r/v13_report/report_service_spec.rb +13 -11
  191. data/spec/sem4r/v13_report/report_spec.rb +4 -3
  192. data/spec/sem4r_stubs.rb +182 -0
  193. data/spec/soap_helpers/soap_attributes_spec.rb +129 -0
  194. metadata +225 -125
  195. data/spec/fixtures/services/info/get_unit_count-req.xml +0 -30
  196. data/spec/fixtures/services/info/get_unit_count-res.xml +0 -29
  197. data/spec/fixtures/services/targeting_idea/get-res.xml +0 -3601
  198. data/spec/sem4r/soap_attributes_spec.rb +0 -116
  199. data/spec/sem4r_spec_helper.rb +0 -353
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -22,7 +23,7 @@
22
23
  #
23
24
  # -------------------------------------------------------------------------
24
25
 
25
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
26
+ require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
26
27
 
27
28
  describe TargetingIdeaSelector do
28
29
  include Sem4rSpecHelper, AggregatesSpecHelper
@@ -43,16 +44,22 @@ describe TargetingIdeaSelector do
43
44
  end
44
45
 
45
46
  related_to_keyword_search_parameter do
46
- text 'dvd player'
47
- match_type 'EXACT'
47
+ ['dvd player', 'car stereo'].each do |term|
48
+ text term
49
+ match_type 'EXACT'
50
+ end
48
51
  end
49
52
 
50
53
  country_target_search_parameter do
51
54
  country_code 'US'
52
55
  end
56
+
57
+ ngram_group_search_parameter do
58
+ ngram 'dvd player'
59
+ end
53
60
  end
54
61
 
55
- xml_expected = read_model("//s:selector", "services", "targeting_idea", "get-req.xml")
62
+ xml_expected = read_model("//selector", "targeting_idea", "get-req.xml")
56
63
  idea_selector.to_xml.should xml_equivalent(xml_expected)
57
64
  end
58
65
 
@@ -69,7 +76,7 @@ describe TargetingIdeaSelector do
69
76
  match_type 'EXACT'
70
77
  end
71
78
  end
72
- read_model("//s:requestedAttributeTypes", "services", "targeting_idea", "get-req-all-options.xml") do |attribute_type|
79
+ read_model("//requestedAttributeTypes", "targeting_idea", "get-req-all-options.xml") do |attribute_type|
73
80
  idea_selector.to_xml.should xml_contains(attribute_type)
74
81
  end
75
82
  end
@@ -77,10 +84,12 @@ describe TargetingIdeaSelector do
77
84
  describe RelatedToKeywordSearchParameter do
78
85
  it "should produce xml (input for google)" do
79
86
  sp = RelatedToKeywordSearchParameter.new do
80
- text "dvd player"
81
- match_type "EXACT"
87
+ ['dvd player', 'car stereo'].each do |term|
88
+ text term
89
+ match_type 'EXACT'
90
+ end
82
91
  end
83
- xml_expected = read_model("//s:searchParameters[@xsi:type='s:RelatedToKeywordSearchParameter']", "services", "targeting_idea", "get-req.xml")
92
+ xml_expected = read_model("//searchParameters[@type='RelatedToKeywordSearchParameter']", "targeting_idea", "get-req.xml")
84
93
  sp.to_xml.should xml_equivalent(xml_expected)
85
94
  end
86
95
  end
@@ -91,7 +100,7 @@ describe TargetingIdeaSelector do
91
100
  text "media player"
92
101
  match_type "EXACT"
93
102
  end
94
- xml_expected = read_model("//s:searchParameters[@xsi:type='s:ExcludedKeywordSearchParameter']", "services", "targeting_idea", "get-req.xml")
103
+ xml_expected = read_model("//searchParameters[@type='ExcludedKeywordSearchParameter']", "targeting_idea", "get-req.xml")
95
104
  sp.to_xml.should xml_equivalent(xml_expected)
96
105
  end
97
106
  end
@@ -102,7 +111,7 @@ describe TargetingIdeaSelector do
102
111
  match_type 'BROAD'
103
112
  match_type "EXACT"
104
113
  end
105
- xml_expected = read_model("//s:searchParameters[@xsi:type='s:KeywordMatchTypeSearchParameter']", "services", "targeting_idea", "get-req.xml")
114
+ xml_expected = read_model("//searchParameters[@type='KeywordMatchTypeSearchParameter']", "targeting_idea", "get-req.xml")
106
115
  sp.to_xml.should xml_equivalent(xml_expected)
107
116
  end
108
117
  end
@@ -112,7 +121,17 @@ describe TargetingIdeaSelector do
112
121
  sp = CountryTargetSearchParameter.new do
113
122
  country_code 'US'
114
123
  end
115
- xml_expected = read_model("//s:searchParameters[@xsi:type='s:CountryTargetSearchParameter']", "services", "targeting_idea", "get-req.xml")
124
+ xml_expected = read_model("//searchParameters[@type='CountryTargetSearchParameter']", "targeting_idea", "get-req.xml")
125
+ sp.to_xml.should xml_equivalent(xml_expected)
126
+ end
127
+ end
128
+
129
+ describe NgramGroupsSearchParameter do
130
+ it "should produce xml (input for google)" do
131
+ sp = NgramGroupsSearchParameter.new do
132
+ ngram 'dvd player'
133
+ end
134
+ xml_expected = read_model("//searchParameters[@type='NgramGroupsSearchParameter']", "targeting_idea", "get-req.xml")
116
135
  sp.to_xml.should xml_equivalent(xml_expected)
117
136
  end
118
137
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -22,7 +23,7 @@
22
23
  #
23
24
  # -------------------------------------------------------------------------
24
25
 
25
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
26
+ require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
26
27
 
27
28
  describe TargetingIdeaService do
28
29
  include Sem4rSpecHelper
@@ -32,12 +33,12 @@ describe TargetingIdeaService do
32
33
  end
33
34
 
34
35
  it "should define 'get'" do
35
- response_xml = read_xml_file("services", "targeting_idea", "get-res.xml")
36
+ response_xml = read_xml("targeting_idea", "get-res.xml")
36
37
  connector = mock("connector")
37
38
  connector.should_receive(:send).and_return(response_xml)
38
39
  service = TargetingIdeaService.new(connector)
39
40
  soap_message = service.get( @credentials, "xml" )
40
- els = REXML::XPath.match( soap_message.response, "//getResponse")
41
+ els = soap_message.response.xpath("//getResponse")
41
42
  els.should_not be_empty
42
43
  end
43
44
 
@@ -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,20 @@
22
23
  #
23
24
  # -------------------------------------------------------------------------
24
25
 
25
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
26
+ require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
26
27
 
27
28
  describe TargetingIdea do
28
29
  include Sem4rSpecHelper, AggregatesSpecHelper
29
30
 
30
31
  it "should parse xml (produced by google)" do
31
- el = read_model("//entries", "services", "targeting_idea", "get-res.xml")
32
+ el = read_model("//entries", "targeting_idea", "get-res.xml")
32
33
  idea = TargetingIdea.from_element(el)
33
34
  idea.should have(2).attributes
34
35
  end
35
36
 
36
37
  describe TKeywordAttribute do
37
38
  it "should parse xml (produced by google)" do
38
- el = read_model("//value", "services", "targeting_idea", "get-res.xml")
39
+ el = read_model("//value", "targeting_idea", "get-res.xml")
39
40
  attr = TKeywordAttribute.from_element(el)
40
41
  attr.text.should == "sample keyword"
41
42
  attr.match_type.should == "EXACT"
@@ -44,7 +45,7 @@ describe TargetingIdea do
44
45
 
45
46
  describe TIdeaTypeAttribute do
46
47
  it "should parse xml (produced by google)" do
47
- el = read_model("//value[@type='IdeaTypeAttribute']", "services", "targeting_idea", "get-res.xml")
48
+ el = read_model("//value[@type='IdeaTypeAttribute']", "targeting_idea", "get-res.xml")
48
49
  attr = TIdeaTypeAttribute.from_element(el)
49
50
  attr.value.should == "KEYWORD"
50
51
  end
@@ -0,0 +1,47 @@
1
+ # -*- coding: utf-8 -*-
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.
23
+ #
24
+ # -------------------------------------------------------------------------
25
+
26
+ require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
27
+
28
+ describe AccountAccountExtension do
29
+ include Sem4rSpecHelper
30
+
31
+ before do
32
+ services = stub("services")
33
+ stub_service_account(services)
34
+ stub_service_info(services)
35
+ stub_service_campaign(services)
36
+ stub_service_report(services)
37
+ @adwords = stub_adwords(services)
38
+ @credentials = stub_credentials
39
+
40
+ @account = Account.new(@adwords, @credentials)
41
+ end
42
+
43
+ it "should extracts list of account with 'account.client_accounts'" do
44
+ @account.client_accounts.should have(5).items
45
+ end
46
+
47
+ end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -22,7 +23,7 @@
22
23
  #
23
24
  # -------------------------------------------------------------------------
24
25
 
25
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
26
+ require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
26
27
 
27
28
  describe AccountService do
28
29
  include Sem4rSpecHelper
@@ -32,7 +33,7 @@ describe AccountService do
32
33
  end
33
34
 
34
35
  it "should define 'account_info'" do
35
- response_xml = read_xml_file("services", "v13_account", "get_account_info-res.xml")
36
+ response_xml = read_xml("v13_account", "get_account_info-res.xml")
36
37
 
37
38
  connector = mock("connector")
38
39
  connector.should_receive(:send).and_return(response_xml)
@@ -40,12 +41,12 @@ describe AccountService do
40
41
  service = AccountService.new(connector)
41
42
  soap_message = service.account_info( @credentials )
42
43
 
43
- els = REXML::XPath.match( soap_message.response, "//getAccountInfoResponse")
44
+ els = soap_message.response.xpath("//getAccountInfoResponse")
44
45
  els.should_not be_empty
45
46
  end
46
47
 
47
48
  it "should define 'client_accounts'" do
48
- response_xml = read_xml_file("services", "v13_account", "get_client_accounts-res.xml")
49
+ response_xml = read_xml("v13_account", "get_client_accounts-res.xml")
49
50
 
50
51
  connector = mock("connector")
51
52
  connector.should_receive(:send).and_return(response_xml)
@@ -53,7 +54,7 @@ describe AccountService do
53
54
  service = AccountService.new(connector)
54
55
  soap_message = service.client_accounts( @credentials )
55
56
 
56
- els = REXML::XPath.match( soap_message.response, "//getClientAccountsResponse")
57
+ els = soap_message.response.xpath("//getClientAccountsResponse")
57
58
  els.should_not be_empty
58
59
  end
59
60
 
@@ -0,0 +1,40 @@
1
+ # -*- coding: utf-8 -*-
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.
23
+ #
24
+ # -------------------------------------------------------------------------
25
+
26
+ require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
27
+
28
+ describe BillingAddress do
29
+ include Sem4rSpecHelper
30
+
31
+ it "should parse xml (produced by google)" do
32
+ model = read_model( "//billingAddress", "v13_account", "get_account_info-res.xml")
33
+ ba = BillingAddress.from_element(model)
34
+ ba.city.should == "Mountain View"
35
+ ba.country_code.should == "US"
36
+ ba.phone.should == "4085551212"
37
+ ba.email.should == "Some@email"
38
+ end
39
+
40
+ end
@@ -14,8 +14,8 @@
14
14
  </requestId>
15
15
  </soapenv:Header>
16
16
  <soapenv:Body>
17
- <getAllJobsResponse xmlns=''>
18
-
17
+ <getAllJobsResponse>
18
+ <!-- <getAllJobsResponse xmlns=''> -->
19
19
  <ns1:getAllJobsReturn xsi:type='ns1:DefinedReportJob' xmlns:ns1='https://adwords.google.com/api/adwords/v13'>
20
20
  <ns1:clientEmails xsi:nil='true'/>
21
21
  <ns1:crossClient>false</ns1:crossClient>
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -22,7 +23,7 @@
22
23
  #
23
24
  # -------------------------------------------------------------------------
24
25
 
25
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
26
+ require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
26
27
 
27
28
  describe ReportService do
28
29
  include Sem4rSpecHelper
@@ -32,7 +33,7 @@ describe ReportService do
32
33
  end
33
34
 
34
35
  it "should define 'all'" do
35
- response_xml = read_xml_file("services", "v13_report", "get_all_jobs-res.xml")
36
+ response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
36
37
 
37
38
  connector = mock("connector")
38
39
  connector.should_receive(:send).and_return(response_xml)
@@ -40,13 +41,13 @@ describe ReportService do
40
41
  report_service = ReportService.new(connector)
41
42
  soap_message = report_service.all( @credentials )
42
43
 
43
- els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
44
+ els = soap_message.response.xpath("//getAllJobsReturn")
44
45
  els.should_not be_empty
45
46
  els.should have(4).elements
46
47
  end
47
48
 
48
49
  it "should define 'validate'" do
49
- response_xml = read_xml_file("services", "v13_report", "get_all_jobs-res.xml")
50
+ response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
50
51
 
51
52
  connector = mock("connector")
52
53
  connector.should_receive(:send).and_return(response_xml)
@@ -54,13 +55,13 @@ describe ReportService do
54
55
  report_service = ReportService.new(connector)
55
56
  soap_message = report_service.validate( @credentials, "xml" )
56
57
 
57
- els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
58
+ els = soap_message.response.xpath("//getAllJobsReturn")
58
59
  els.should_not be_empty
59
60
  els.should have(4).elements
60
61
  end
61
62
 
62
63
  it "should define 'schedule'" do
63
- response_xml = read_xml_file("services", "v13_report", "get_all_jobs-res.xml")
64
+ response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
64
65
 
65
66
  connector = mock("connector")
66
67
  connector.should_receive(:send).and_return(response_xml)
@@ -68,13 +69,13 @@ describe ReportService do
68
69
  report_service = ReportService.new(connector)
69
70
  soap_message = report_service.schedule( @credentials, "xml" )
70
71
 
71
- els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
72
+ els = soap_message.response.xpath("//getAllJobsReturn")
72
73
  els.should_not be_empty
73
74
  els.should have(4).elements
74
75
  end
75
76
 
76
77
  it "should define 'status'" do
77
- response_xml = read_xml_file("services", "v13_report", "get_all_jobs-res.xml")
78
+ response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
78
79
 
79
80
  connector = mock("connector")
80
81
  connector.should_receive(:send).and_return(response_xml)
@@ -82,13 +83,14 @@ describe ReportService do
82
83
  report_service = ReportService.new(connector)
83
84
  soap_message = report_service.status( @credentials, "job_id" )
84
85
 
85
- els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
86
+ # els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
87
+ els = soap_message.response.xpath("//getAllJobsReturn")
86
88
  els.should_not be_empty
87
89
  els.should have(4).elements
88
90
  end
89
91
 
90
92
  it "should define 'url'" do
91
- response_xml = read_xml_file("services", "v13_report", "get_all_jobs-res.xml")
93
+ response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
92
94
 
93
95
  connector = mock("connector")
94
96
  connector.should_receive(:send).and_return(response_xml)
@@ -96,7 +98,7 @@ describe ReportService do
96
98
  report_service = ReportService.new(connector)
97
99
  soap_message = report_service.url( @credentials, "job_id" )
98
100
 
99
- els = REXML::XPath.match( soap_message.response, "//getAllJobsResponse/getAllJobsReturn")
101
+ els = soap_message.response.xpath("//getAllJobsReturn")
100
102
  els.should_not be_empty
101
103
  els.should have(4).elements
102
104
  end
@@ -1,3 +1,4 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # -------------------------------------------------------------------------
2
3
  # Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
3
4
  #
@@ -22,7 +23,7 @@
22
23
  #
23
24
  # -------------------------------------------------------------------------
24
25
 
25
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
26
+ require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
26
27
 
27
28
  describe Report do
28
29
  include Sem4rSpecHelper
@@ -51,7 +52,7 @@ describe Report do
51
52
  end
52
53
 
53
54
  it "should parse xml (produced by google)" do
54
- el = read_model("//getAllJobsReturn", "services", "v13_report", "get_all_jobs-res.xml")
55
+ el = read_model("//getAllJobsReturn", "v13_report", "get_all_jobs-res.xml")
55
56
  report = Report.from_element(@account, el)
56
57
  report.id.should == 11
57
58
  report.name.should == "report [11]"
@@ -72,7 +73,7 @@ describe Report do
72
73
  column "KeywordTypeDisplay"
73
74
  end
74
75
 
75
- expected = read_model("//job", "services", "v13_report", "schedule_report_job-req.xml")
76
+ expected = read_model("//job", "v13_report", "schedule_report_job-req.xml")
76
77
  report.to_xml.should xml_equivalent(expected)
77
78
  end
78
79
 
@@ -0,0 +1,182 @@
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
+
26
+ module Sem4rSpecHelper
27
+
28
+ #############################################################################
29
+ # stub services
30
+
31
+ def stub_service_account(service)
32
+ xml_document = read_xml_document("v13_account", "get_account_info-res.xml")
33
+ soap_message_account_info = stub("soap_message_account_info", :response => xml_document, :counters => nil)
34
+
35
+ xml_document = read_xml_document("v13_account", "get_client_accounts-res.xml")
36
+ soap_message_client_accounts = stub("soap_message_client_accounts", :response => xml_document, :counters => nil)
37
+
38
+ service_account = stub("service_account",
39
+ :account_info => soap_message_account_info,
40
+ :client_accounts => soap_message_client_accounts)
41
+ service.stub(:account).and_return(service_account)
42
+ end
43
+
44
+ def stub_service_info(service)
45
+ xml_document = read_xml_document("info", "get_unit_count-res.xml")
46
+ soap_message = stub("soap_message", :response => xml_document, :counters => nil)
47
+
48
+ service_info = stub("service_info", :get => soap_message)
49
+ service.stub(:info).and_return(service_info)
50
+ end
51
+
52
+ def stub_service_campaign(service)
53
+ xml_document = read_xml_document("campaign", "mutate_add-res.xml")
54
+ soap_message_create = stub("soap_message_create", :response => xml_document, :counters => nil)
55
+
56
+ xml_document = read_xml_document("campaign", "get-res.xml")
57
+ soap_message_all = stub("soap_message_all", :response => xml_document, :counters => nil)
58
+
59
+ service_campaign = stub("service_campaign",
60
+ :create => soap_message_create,
61
+ :all => soap_message_all)
62
+ service.stub(:campaign).and_return(service_campaign)
63
+ end
64
+
65
+ def stub_service_ad_group(service)
66
+ xml_document = read_xml_document("ad_group", "mutate_add-res.xml")
67
+ soap_message = stub("soap_message", :response => xml_document, :counters => nil)
68
+
69
+ service_ad_group = stub("service_ad_group", :create => soap_message)
70
+ service.stub(:ad_group).and_return(service_ad_group)
71
+ end
72
+
73
+ def stub_service_ad_group_ad(service)
74
+ xml_document = read_xml_document("ad_group_ad", "mutate_add_text_ad-res.xml")
75
+ soap_message = stub("soap_message", :response => xml_document, :counters => nil)
76
+
77
+ service_ad_group_ad = stub("service_ad_group_ad", :mutate => soap_message)
78
+ service.stub(:ad_group_ad).and_return(service_ad_group_ad)
79
+ end
80
+
81
+ def stub_service_ad_group_criterion(service)
82
+ xml_document = read_xml_document("ad_group_criterion", "mutate_add_criterion_keyword-res.xml")
83
+ soap_message = stub("soap_message", :response => xml_document, :counters => nil)
84
+
85
+ service_ad_group_criterion = stub("service_ad_group_criterion", :mutate => soap_message)
86
+ service.stub(:ad_group_criterion).and_return(service_ad_group_criterion)
87
+ end
88
+
89
+ def stub_service_ad_param(service)
90
+ # xml_document = read_xml_document("services", "ad_group_criterion_service", "mutate_add_criterion_keyword-res.xml")
91
+ soap_message = stub("soap_message", :response => nil, :counters => nil)
92
+
93
+ service_ad_param = stub("service_ad_param", :mutate => soap_message)
94
+ service.stub(:ad_param).and_return(service_ad_param)
95
+ end
96
+
97
+ def stub_service_report(service)
98
+ all_xml_document = read_xml_document("v13_report", "get_all_jobs-res.xml")
99
+ all_soap_message = stub("soap_message", :response => all_xml_document, :counters => nil)
100
+ set_soap_message = stub("soap_message", :response => nil, :counters => nil)
101
+
102
+ service_report = stub("service_report",
103
+ :set => set_soap_message,
104
+ :all => all_soap_message)
105
+
106
+ service.stub(:report).and_return(service_report)
107
+ end
108
+
109
+ def stub_service_report_definition(service)
110
+ service_report_definition = stub("service_report_definition")
111
+ service.stub(:report_definition).and_return(service_report_definition)
112
+ end
113
+
114
+ #############################################################################
115
+
116
+ def stub_services
117
+ double("services")
118
+ end
119
+
120
+ def stub_adwords(services = nil)
121
+ stub("adwords",
122
+ :service => services ||= stub_services,
123
+ :add_counters => nil)
124
+ end
125
+
126
+ def stub_credentials
127
+ stub("credentials",
128
+ :sandbox? => true,
129
+ :email => "example@gmail.com",
130
+ :password => "secret",
131
+ :client_email => nil,
132
+ :useragent => "sem4r",
133
+ :developer_token => "dev_token",
134
+ :authentication_token => "1234567890",
135
+ :mutable? => false
136
+ )
137
+ end
138
+
139
+ def stub_account(services = nil)
140
+ adwords = stub_adwords(services)
141
+ credentials = stub_credentials
142
+ account = stub("account",
143
+ :adwords => adwords,
144
+ :credentials => credentials,
145
+ :id => 1000)
146
+ account
147
+ end
148
+
149
+ def stub_campaign(services = nil)
150
+ adwords = stub_adwords(services)
151
+ credentials = stub_credentials
152
+
153
+ campaign = stub("campaign",
154
+ :adwords => adwords,
155
+ :credentials => credentials,
156
+ :inside_initialize? => false,
157
+ :id => 1000)
158
+ campaign
159
+ end
160
+
161
+ def stub_adgroup(services = nil, id = 1000)
162
+ adwords = stub_adwords(services)
163
+ credentials = stub_credentials
164
+ stub("adgroup",
165
+ :adwords => adwords,
166
+ :credentials => credentials,
167
+ :inside_initialize? => false,
168
+ :id => id)
169
+ end
170
+
171
+ def stub_criterion(services = nil)
172
+ adwords = stub_adwords(services)
173
+ credentials = stub_credentials
174
+
175
+ stub("criterion",
176
+ :adwords => adwords,
177
+ :credentials => credentials,
178
+ :inside_initialize? => false,
179
+ :id => 1000,
180
+ :ad_group => stub_adgroup(services))
181
+ end
182
+ end