sem4r 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/Gemfile.lock +36 -0
- data/README.rdoc +30 -0
- data/Rakefile +15 -12
- data/VERSION.yml +1 -1
- data/examples_blog/2009-11-29-hello-world.rb +0 -1
- data/examples_sem4r/01_get_account.rb +1 -1
- data/examples_sem4r/02_get_info.rb +6 -2
- data/examples_sem4r/03_list_ad.rb +1 -1
- data/examples_sem4r/04_list_keywords.rb +1 -1
- data/examples_sem4r/05_request_report.rb +1 -2
- data/examples_sem4r/05_request_report_2010.rb +19 -4
- data/examples_sem4r/06_create_campaigns.rb +1 -1
- data/examples_sem4r/07_create_campaigns_block.rb +1 -1
- data/examples_sem4r/07_create_campaigns_simple.rb +1 -1
- data/examples_sem4r/08_ad_params.rb +1 -1
- data/examples_sem4r/09_targeting_idea.rb +1 -1
- data/examples_sem4r/10_get_location.rb +1 -1
- data/examples_sem4r/11_submit_bulk_job.rb +1 -1
- data/examples_sem4r/12_list_bulk_job.rb +1 -1
- data/examples_sem4r/30_prune_empty_adgroup.rb +1 -1
- data/examples_sem4r/31_empty_accounts.rb +1 -1
- data/examples_sem4r/example_helper.rb +5 -10
- data/lib/sem4r/account.rb +3 -306
- data/lib/sem4r/ad_group/ad_group.rb +16 -14
- data/lib/sem4r/ad_group/ad_group_bids.rb +11 -10
- data/lib/sem4r/ad_group/ad_group_service.rb +5 -5
- data/lib/sem4r/ad_group_ad/ad_group_ad.rb +1 -1
- data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +5 -5
- data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +9 -9
- data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +9 -9
- data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +6 -6
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +5 -6
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +0 -1
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +4 -4
- data/lib/sem4r/ad_group_criterion/criterion.rb +3 -3
- data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +3 -3
- data/lib/sem4r/ad_group_criterion/criterion_placement.rb +2 -2
- data/lib/sem4r/ad_param/ad_param.rb +3 -3
- data/lib/sem4r/ad_param/ad_param_service.rb +5 -5
- data/lib/sem4r/adwords.rb +1 -0
- data/lib/sem4r/api_counters.rb +1 -0
- data/lib/sem4r/base.rb +1 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +2 -2
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_account_extension.rb +59 -0
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +5 -5
- data/lib/sem4r/campaign/campaign.rb +10 -10
- data/lib/sem4r/campaign/campaign_account_extension.rb +87 -0
- data/lib/sem4r/campaign/campaign_service.rb +6 -6
- data/lib/sem4r/campaign_target/campaign_target_service.rb +22 -22
- data/lib/sem4r/cli/cli_command.rb +1 -0
- data/lib/sem4r/cli/cli_common_args.rb +10 -3
- data/lib/sem4r/cli/cli_helpers.rb +1 -0
- data/lib/sem4r/cli/cli_sem.rb +1 -0
- data/lib/sem4r/cli/{cli_download_report.rb → commands/cli_download_report.rb} +2 -1
- data/lib/sem4r/cli/{cli_ideas.rb → commands/cli_ideas.rb} +1 -0
- data/lib/sem4r/cli/{cli_commands.rb → commands/cli_info.rb} +3 -23
- data/lib/sem4r/cli/{cli_list_ads.rb → commands/cli_list_ads.rb} +1 -0
- data/lib/sem4r/cli/commands/cli_list_campaign.rb +35 -0
- data/lib/sem4r/cli/commands/cli_list_client.rb +36 -0
- data/lib/sem4r/cli/{cli_list_keywords.rb → commands/cli_list_keywords.rb} +1 -0
- data/lib/sem4r/cli/commands/cli_list_report.rb +34 -0
- data/lib/sem4r/cli/commands/cli_repdef.rb +109 -0
- data/lib/sem4r/cli/commands/cli_report.rb +78 -0
- data/lib/sem4r/cli/{cli_request_report.rb → commands/cli_request_report.rb} +1 -0
- data/lib/sem4r/credentials.rb +1 -0
- data/lib/sem4r/extensions.rb +22 -1
- data/lib/sem4r/geo_location/geo_location_account_extension.rb +43 -0
- data/lib/sem4r/geo_location/geo_location_service.rb +4 -4
- data/lib/sem4r/info/info_account_extension.rb +48 -0
- data/lib/sem4r/info/info_selector.rb +108 -0
- data/lib/sem4r/info/info_service.rb +11 -66
- data/lib/sem4r/{common/operation.rb → operation.rb} +3 -1
- data/lib/sem4r/report_definition/report_definition.rb +75 -15
- data/lib/sem4r/report_definition/report_definition_account_extension.rb +79 -0
- data/lib/sem4r/report_definition/report_definition_operation.rb +3 -1
- data/lib/sem4r/report_definition/report_definition_service.rb +7 -7
- data/lib/sem4r/report_definition/report_field.rb +57 -0
- data/lib/sem4r/sem4r_error.rb +1 -0
- data/lib/sem4r/services/http_connector.rb +93 -0
- data/lib/sem4r/services/service.rb +1 -1
- data/lib/sem4r/services/soap_call.rb +27 -5
- data/lib/sem4r/services/soap_connector.rb +2 -147
- data/lib/sem4r/services/soap_dumper.rb +105 -0
- data/lib/sem4r/services/soap_message_v13.rb +15 -9
- data/lib/sem4r/services/{soap_message_v2009.rb → soap_message_v2010.rb} +26 -12
- data/lib/sem4r/targeting_idea/targeting_idea.rb +16 -11
- data/lib/sem4r/targeting_idea/targeting_idea_account_extension.rb +52 -0
- data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +36 -10
- data/lib/sem4r/targeting_idea/targeting_idea_service.rb +5 -5
- data/lib/sem4r/v13_account/account_account_extension.rb +103 -0
- data/lib/sem4r/v13_account/billing_address.rb +10 -21
- data/lib/sem4r/v13_report/report.rb +8 -8
- data/lib/sem4r/v13_report/report_account_extension.rb +63 -0
- data/lib/sem4r/v13_report/report_job.rb +1 -1
- data/lib/sem4r.rb +27 -6
- data/lib/sem4r_cli.rb +4 -6
- data/lib/{sem4r → soap_helpers}/soap_attributes.rb +105 -13
- data/sem4r.gemspec +229 -190
- data/spec/{aggregates_spec_helper.rb → aggregates_rspec_helper.rb} +0 -0
- data/spec/build_fixtures.rb +84 -0
- data/spec/rspec_hash.rb +66 -0
- data/spec/{spec_helper.rb → rspec_helper.rb} +4 -2
- data/spec/rspec_matchers.rb +102 -0
- data/spec/rspec_sem4r_helper.rb +88 -0
- data/spec/sem4r/account_spec.rb +3 -4
- data/spec/sem4r/ad_group/ad_group_bids_spec.rb +4 -3
- data/spec/sem4r/ad_group/ad_group_service_spec.rb +8 -7
- data/spec/sem4r/ad_group/ad_group_spec.rb +5 -4
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-first-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-first-res.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-manual-cpm-bids-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/get-manual-cpm-bids-res.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/ad_group → sem4r/ad_group/fixtures}/mutate_add-res.xml +0 -0
- data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +3 -3
- data/spec/sem4r/ad_group_ad/ad_group_ad_service_spec.rb +6 -5
- data/spec/sem4r/ad_group_ad/ad_group_ad_spec.rb +6 -5
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_mobile_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_mobile_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_text_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/get_text_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_mobile_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_mobile_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_text_ad-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_text_ad-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_two_criterions-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_ad → sem4r/ad_group_ad/fixtures}/mutate_add_two_criterions-res.xml +0 -0
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_bids_spec.rb +5 -4
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_service_spec.rb +6 -5
- data/spec/sem4r/ad_group_criterion/ad_group_criterion_spec.rb +6 -5
- data/spec/sem4r/ad_group_criterion/criterion_spec.rb +5 -4
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_keyword-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_keyword-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_placement-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_criterion_placement-res.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_negative_keyword-req.xml +0 -0
- data/spec/{fixtures/services/ad_group_criterion → sem4r/ad_group_criterion/fixtures}/mutate_add_negative_keyword-res.xml +0 -0
- data/spec/sem4r/ad_param/ad_param_service_spec.rb +6 -5
- data/spec/sem4r/ad_param/ad_param_spec.rb +3 -2
- data/spec/{fixtures/services/ad_param → sem4r/ad_param/fixtures}/mutate_set-req.xml +0 -0
- data/spec/{fixtures/services/ad_param → sem4r/ad_param/fixtures}/mutate_set-res.xml +0 -0
- data/spec/sem4r/adwords_spec.rb +1 -1
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +6 -5
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +4 -3
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-req.xml +0 -0
- data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-res.xml +0 -0
- data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +3 -2
- data/spec/sem4r/campaign/campaign_service_spec.rb +8 -7
- data/spec/sem4r/campaign/campaign_spec.rb +3 -2
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/get-req.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/get-res.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/campaign → sem4r/campaign/fixtures}/mutate_add-res.xml +0 -0
- data/spec/sem4r/cli/cli_spec.rb +2 -3
- data/spec/sem4r/credentials_spec.rb +1 -1
- data/spec/sem4r/info/account_info_extension_spec.rb +51 -0
- data/spec/sem4r/info/fixtures/get_unit_count-req.xml +34 -0
- data/spec/sem4r/info/fixtures/get_unit_count-res.xml +27 -0
- data/spec/sem4r/nokogiri_parsing_spec.rb +105 -0
- data/spec/{fixtures/services/report_definition → sem4r/report_definition/fixtures}/mutate_add-req.xml +0 -0
- data/spec/{fixtures/services/report_definition → sem4r/report_definition/fixtures}/mutate_add-req_orig.xml +0 -0
- data/spec/sem4r/report_definition/report_definition_service_spec.rb +5 -3
- data/spec/sem4r/report_definition/report_definition_spec.rb +6 -3
- data/spec/sem4r/rexml_parsing_spec.rb +22 -22
- data/spec/sem4r/services/service_spec.rb +2 -1
- data/spec/sem4r/services/soap_call_spec.rb +6 -5
- data/spec/sem4r/services/soap_message_v13_spec.rb +5 -11
- data/spec/{fixtures/services/targeting_idea → sem4r/targeting_idea/fixtures}/get-req-all-options.xml +0 -0
- data/spec/{fixtures/services/targeting_idea → sem4r/targeting_idea/fixtures}/get-req.xml +9 -11
- data/spec/sem4r/targeting_idea/fixtures/get-res.xml +2276 -0
- data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +30 -11
- data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +4 -3
- data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +5 -4
- data/spec/sem4r/v13_account/account_account_extension_spec.rb +47 -0
- data/spec/sem4r/v13_account/account_service_spec.rb +6 -5
- data/spec/sem4r/v13_account/billing_address_spec.rb +40 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-req.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_account_info-res.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-req.xml +0 -0
- data/spec/{fixtures/services/v13_account → sem4r/v13_account/fixtures}/get_client_accounts-res.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/get_all_jobs-req.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/get_all_jobs-res.xml +2 -2
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-req.xml +0 -0
- data/spec/{fixtures/services/v13_report → sem4r/v13_report/fixtures}/schedule_report_job-res.xml +0 -0
- data/spec/sem4r/v13_report/report_service_spec.rb +13 -11
- data/spec/sem4r/v13_report/report_spec.rb +4 -3
- data/spec/sem4r_stubs.rb +182 -0
- data/spec/soap_helpers/soap_attributes_spec.rb +129 -0
- metadata +225 -125
- data/spec/fixtures/services/info/get_unit_count-req.xml +0 -30
- data/spec/fixtures/services/info/get_unit_count-res.xml +0 -29
- data/spec/fixtures/services/targeting_idea/get-res.xml +0 -3601
- data/spec/sem4r/soap_attributes_spec.rb +0 -116
- data/spec/sem4r_spec_helper.rb +0 -353
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe AdParamService do
|
28
29
|
include Sem4rSpecHelper
|
@@ -32,23 +33,23 @@ describe AdParamService do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should define 'all'" do
|
35
|
-
response_xml =
|
36
|
+
response_xml = read_xml("ad_param", "mutate_set-res.xml")
|
36
37
|
connector = mock("connector")
|
37
38
|
connector.should_receive(:send).and_return(response_xml)
|
38
39
|
service = AdParamService.new(connector)
|
39
40
|
soap_message = service.all( @credentials, "ad_group_id" )
|
40
|
-
els =
|
41
|
+
els = soap_message.response.xpath("//mutateResponse")
|
41
42
|
els.should_not be_empty
|
42
43
|
end
|
43
44
|
|
44
45
|
it "should define 'set'" do
|
45
46
|
@credentials.should_receive(:mutable?).and_return(true)
|
46
|
-
response_xml =
|
47
|
+
response_xml = read_xml("ad_param", "mutate_set-res.xml")
|
47
48
|
connector = mock("connector")
|
48
49
|
connector.should_receive(:send).and_return(response_xml)
|
49
50
|
service = AdParamService.new(connector)
|
50
51
|
soap_message = service.mutate( @credentials, "xml" )
|
51
|
-
els =
|
52
|
+
els = soap_message.response.xpath("//mutateResponse")
|
52
53
|
els.should_not be_empty
|
53
54
|
end
|
54
55
|
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe AdParam do
|
28
29
|
|
@@ -48,7 +49,7 @@ describe AdParam do
|
|
48
49
|
|
49
50
|
it "should parse xml" do
|
50
51
|
@adgroup.should_receive(:find_criterion).with(100).and_return(@criterion)
|
51
|
-
el = read_model("//rval", "
|
52
|
+
el = read_model("//rval", "ad_param", "mutate_set-res.xml")
|
52
53
|
ad_param = AdParam.from_element(@adgroup, el)
|
53
54
|
ad_param.index.should == 1
|
54
55
|
ad_param.text.should == "$99.99"
|
File without changes
|
File without changes
|
data/spec/sem4r/adwords_spec.rb
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
#
|
23
23
|
# -------------------------------------------------------------------------
|
24
24
|
|
25
|
-
require File.expand_path(File.dirname(__FILE__) + '/../
|
25
|
+
require File.expand_path(File.dirname(__FILE__) + '/../rspec_helper')
|
26
26
|
|
27
27
|
describe Adwords do
|
28
28
|
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe BulkMutateJobService do
|
28
29
|
include Sem4rSpecHelper
|
@@ -32,7 +33,7 @@ describe BulkMutateJobService do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should define 'all'" do
|
35
|
-
response_xml =
|
36
|
+
response_xml = read_xml("bulk_mutate_job", "get-res.xml")
|
36
37
|
connector = mock("connector")
|
37
38
|
connector.should_receive(:send).and_return(response_xml)
|
38
39
|
service = BulkMutateJobService.new(connector)
|
@@ -41,13 +42,13 @@ describe BulkMutateJobService do
|
|
41
42
|
operation.stub(:to_xml).and_return("xml")
|
42
43
|
|
43
44
|
soap_message = service.all( @credentials, operation )
|
44
|
-
els =
|
45
|
+
els = soap_message.response.xpath("//getResponse")
|
45
46
|
els.should_not be_empty
|
46
47
|
end
|
47
48
|
|
48
49
|
it "should define 'mutate'" do
|
49
50
|
@credentials.should_receive(:mutable?).and_return(true)
|
50
|
-
response_xml =
|
51
|
+
response_xml = read_xml("bulk_mutate_job", "mutate-res.xml")
|
51
52
|
connector = mock("connector")
|
52
53
|
connector.should_receive(:send).and_return(response_xml)
|
53
54
|
service = BulkMutateJobService.new(connector)
|
@@ -56,7 +57,7 @@ describe BulkMutateJobService do
|
|
56
57
|
operation.stub(:to_xml).and_return("xml")
|
57
58
|
|
58
59
|
soap_message = service.mutate( @credentials, operation )
|
59
|
-
els =
|
60
|
+
els = soap_message.response.xpath("//mutateResponse")
|
60
61
|
els.should_not be_empty
|
61
62
|
end
|
62
63
|
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe BulkMutateJob do
|
28
29
|
include Sem4rSpecHelper, AggregatesSpecHelper
|
@@ -50,7 +51,7 @@ describe BulkMutateJob do
|
|
50
51
|
end
|
51
52
|
|
52
53
|
it "should parse xml" do
|
53
|
-
el = read_model("//rval", "
|
54
|
+
el = read_model("//rval", "bulk_mutate_job", "get-res.xml")
|
54
55
|
job = BulkMutateJob.from_element(el)
|
55
56
|
job.id.should == 56889
|
56
57
|
job.status.should == "PENDING"
|
@@ -62,7 +63,7 @@ describe BulkMutateJob do
|
|
62
63
|
@campaign.stub(:id).and_return(100)
|
63
64
|
job = create_bulk_mutate_job(@campaign, @adgroup)
|
64
65
|
|
65
|
-
expected = read_model("//operand", "
|
66
|
+
expected = read_model("//operand", "bulk_mutate_job", "mutate-req.xml")
|
66
67
|
job.to_xml('operand').should xml_equivalent(expected)
|
67
68
|
end
|
68
69
|
end
|
File without changes
|
File without changes
|
data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-req.xml
RENAMED
File without changes
|
data/spec/{fixtures/services/bulk_mutate_job → sem4r/bulk_mutate_job/fixtures}/mutate-res.xml
RENAMED
File without changes
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe JobOperation do
|
28
29
|
include Sem4rSpecHelper, AggregatesSpecHelper
|
@@ -41,7 +42,7 @@ describe JobOperation do
|
|
41
42
|
job_operation = JobOperation.new
|
42
43
|
job_operation.add(bulk_mutate_job)
|
43
44
|
|
44
|
-
expected_xml = read_model("//operation", "
|
45
|
+
expected_xml = read_model("//operation", "bulk_mutate_job", "mutate-req.xml")
|
45
46
|
job_operation.to_xml('operation').should xml_equivalent(expected_xml)
|
46
47
|
end
|
47
48
|
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe CampaignService do
|
28
29
|
include Sem4rSpecHelper
|
@@ -32,34 +33,34 @@ describe CampaignService do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should define 'all'" do
|
35
|
-
response_xml =
|
36
|
+
response_xml = read_xml("campaign", "get-res.xml")
|
36
37
|
connector = mock("connector")
|
37
38
|
connector.should_receive(:send).and_return(response_xml)
|
38
39
|
service = CampaignService.new(connector)
|
39
40
|
soap_message = service.all( @credentials )
|
40
|
-
els =
|
41
|
+
els = soap_message.response.xpath("//getResponse")
|
41
42
|
els.should_not be_empty
|
42
43
|
end
|
43
44
|
|
44
45
|
it "should define 'create'" do
|
45
46
|
@credentials.should_receive(:mutable?).and_return(true)
|
46
|
-
response_xml =
|
47
|
+
response_xml = read_xml("campaign", "mutate_add-res.xml")
|
47
48
|
connector = mock("connector")
|
48
49
|
connector.should_receive(:send).and_return(response_xml)
|
49
50
|
service = CampaignService.new(connector)
|
50
51
|
soap_message = service.create( @credentials, "xml" )
|
51
|
-
|
52
|
+
els = soap_message.response.xpath("//mutateResponse")
|
52
53
|
els.should_not be_empty
|
53
54
|
end
|
54
55
|
|
55
56
|
it "should define 'delete'" do
|
56
57
|
@credentials.should_receive(:mutable?).and_return(true)
|
57
|
-
response_xml =
|
58
|
+
response_xml = read_xml("campaign", "mutate_add-res.xml")
|
58
59
|
connector = mock("connector")
|
59
60
|
connector.should_receive(:send).and_return(response_xml)
|
60
61
|
service = CampaignService.new(connector)
|
61
62
|
soap_message = service.delete( @credentials, "xml" )
|
62
|
-
els =
|
63
|
+
els = soap_message.response.xpath("//mutateResponse")
|
63
64
|
els.should_not be_empty
|
64
65
|
end
|
65
66
|
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
|
28
29
|
describe Campaign do
|
@@ -55,7 +56,7 @@ describe Campaign do
|
|
55
56
|
end
|
56
57
|
|
57
58
|
it "should parse xml (produced by google)" do
|
58
|
-
el = read_model("//entries", "
|
59
|
+
el = read_model("//entries", "campaign", "get-res.xml")
|
59
60
|
campaign = Campaign.from_element(@account, el)
|
60
61
|
campaign.id.should == 53614
|
61
62
|
campaign.name.should == "test campaign"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/sem4r/cli/cli_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -22,13 +23,11 @@
|
|
22
23
|
#
|
23
24
|
# -------------------------------------------------------------------------
|
24
25
|
|
25
|
-
require File.dirname(__FILE__) + '/../../
|
26
|
-
|
26
|
+
require File.dirname(__FILE__) + '/../../rspec_helper'
|
27
27
|
|
28
28
|
describe "cli" do
|
29
29
|
include Sem4rSpecHelper
|
30
30
|
|
31
|
-
|
32
31
|
describe CliSem do
|
33
32
|
|
34
33
|
it "should show help" do
|
@@ -0,0 +1,51 @@
|
|
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.dirname(__FILE__) + '/../../rspec_helper'
|
27
|
+
|
28
|
+
describe "cli" 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
|
+
describe "account management" do
|
44
|
+
|
45
|
+
it "should retrieve cost" do
|
46
|
+
@account.year_unit_cost("UNIT_COUNT").should == 0
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<!-- Post to 'https://adwords-sandbox.google.com/api/adwords/info/v201008/InfoService' -->
|
2
|
+
|
3
|
+
<env:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:env='http://schemas.xmlsoap.org/soap/envelope/' xmlns='https://adwords.google.com/api/adwords/cm/v201008' xmlns:s='https://adwords.google.com/api/adwords/info/v201008'>
|
4
|
+
<env:Header>
|
5
|
+
<s:RequestHeader env:mustUnderstand='0'>
|
6
|
+
<authToken>
|
7
|
+
***censured***
|
8
|
+
</authToken>
|
9
|
+
<userAgent>
|
10
|
+
Sem4r Adwords Ruby Client Library (http://github.com/sem4r/sem4r)
|
11
|
+
</userAgent>
|
12
|
+
<developerToken>
|
13
|
+
***censured***
|
14
|
+
</developerToken>
|
15
|
+
</s:RequestHeader>
|
16
|
+
</env:Header>
|
17
|
+
<env:Body>
|
18
|
+
<s:get>
|
19
|
+
<s:selector>
|
20
|
+
<s:dateRange>
|
21
|
+
<min>
|
22
|
+
20100101
|
23
|
+
</min>
|
24
|
+
<max>
|
25
|
+
20101120
|
26
|
+
</max>
|
27
|
+
</s:dateRange>
|
28
|
+
<s:apiUsageType>
|
29
|
+
UNIT_COUNT
|
30
|
+
</s:apiUsageType>
|
31
|
+
</s:selector>
|
32
|
+
</s:get>
|
33
|
+
</env:Body>
|
34
|
+
</env:Envelope>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
|
2
|
+
<soap:Header>
|
3
|
+
<ResponseHeader xmlns:ns2='https://adwords.google.com/api/adwords/cm/v201008' xmlns='https://adwords.google.com/api/adwords/info/v201008'>
|
4
|
+
<ns2:requestId>
|
5
|
+
731b12813c87527c580a88ef93578944
|
6
|
+
</ns2:requestId>
|
7
|
+
<ns2:operations>
|
8
|
+
1
|
9
|
+
</ns2:operations>
|
10
|
+
<ns2:responseTime>
|
11
|
+
291
|
12
|
+
</ns2:responseTime>
|
13
|
+
<ns2:units>
|
14
|
+
1
|
15
|
+
</ns2:units>
|
16
|
+
</ResponseHeader>
|
17
|
+
</soap:Header>
|
18
|
+
<soap:Body>
|
19
|
+
<getResponse xmlns='https://adwords.google.com/api/adwords/info/v201008' xmlns:ns2='https://adwords.google.com/api/adwords/cm/v201008'>
|
20
|
+
<rval>
|
21
|
+
<cost>
|
22
|
+
0
|
23
|
+
</cost>
|
24
|
+
</rval>
|
25
|
+
</getResponse>
|
26
|
+
</soap:Body>
|
27
|
+
</soap:Envelope>
|
@@ -0,0 +1,105 @@
|
|
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.expand_path(File.dirname(__FILE__) + '/../rspec_helper')
|
26
|
+
|
27
|
+
describe "Test Parsing with Nokogiri" do
|
28
|
+
include Sem4rSpecHelper
|
29
|
+
|
30
|
+
|
31
|
+
# it "ddd" do
|
32
|
+
# pending "test"
|
33
|
+
# xml_document = read_xml_document("services", "ad_group_ad", "mutate_add_two_criterions-res.xml")
|
34
|
+
# els = xml_document.xpath("//mutateResponse/rval/value/ad/id")
|
35
|
+
# els.each {|e| puts e.text.strip.to_i }
|
36
|
+
# end
|
37
|
+
|
38
|
+
it "test_account_get_client_accounts" do
|
39
|
+
xml_document = read_xml_document("v13_account", "get_client_accounts-res.xml")
|
40
|
+
els = xml_document.xpath("//getClientAccountsReturn")
|
41
|
+
els.length.should == 5
|
42
|
+
end
|
43
|
+
|
44
|
+
it "test_campaign_get" do
|
45
|
+
xml_document = read_xml_document("campaign", "get-res.xml")
|
46
|
+
rval = xml_document.xpath("//getResponse/rval").first
|
47
|
+
els = rval.xpath( "entries" )
|
48
|
+
|
49
|
+
ids_expected =
|
50
|
+
["53614", "53615", "53616", "54034", "54035", "55405", "55420", "56761",
|
51
|
+
"62742", "62743", "62744", "62745", "62746", "62747", "62748"]
|
52
|
+
|
53
|
+
names_expected = [
|
54
|
+
"test campaign",
|
55
|
+
"campaign 2010-02-06 13:43:10 +0100",
|
56
|
+
"campaign 2010-02-06 13:49:21 +0100",
|
57
|
+
"campaign 2010-02-07 19:35:49 +0100",
|
58
|
+
"campaign 2010-02-07 19:39:17 +0100",
|
59
|
+
"campaign 2010-02-08 23:51:06 +0100",
|
60
|
+
"campaign 2010-02-08 23:55:21 +0100",
|
61
|
+
"campaign 2010-02-09 22:17:19 +0100",
|
62
|
+
"campaign 2010-02-13 09:29:08 +0100",
|
63
|
+
"campaign 2010-02-13 09:37:09 +0100",
|
64
|
+
"campaign 2010-02-13 09:37:58 +0100",
|
65
|
+
"campaign 2010-02-13 09:38:20 +0100",
|
66
|
+
"campaign 2010-02-13 09:38:39 +0100",
|
67
|
+
"campaign 2010-02-13 09:39:14 +0100",
|
68
|
+
"campaign 2010-02-13 09:39:46 +0100"]
|
69
|
+
|
70
|
+
ids = els.map do |el|
|
71
|
+
el.at_xpath("id").text.strip
|
72
|
+
end
|
73
|
+
|
74
|
+
names = els.map do |el|
|
75
|
+
el.at_xpath("name" ).text.strip
|
76
|
+
end
|
77
|
+
|
78
|
+
ids_expected.should == ids
|
79
|
+
names_expected.should == names
|
80
|
+
end
|
81
|
+
|
82
|
+
it "test_adgroup_criterion_get" do
|
83
|
+
xml_document = read_xml_document("ad_group_criterion", "get-res.xml")
|
84
|
+
rval = xml_document.xpath("//getResponse/rval").first
|
85
|
+
|
86
|
+
el = rval.xpath("entries/criterion[@type='Keyword']").first
|
87
|
+
|
88
|
+
el.at_xpath("id").text.should == "11536082"
|
89
|
+
el.at_xpath("text").text.should == "pippo"
|
90
|
+
el.at_xpath("matchType").text.should == "BROAD"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "test_info_get" do
|
94
|
+
xml_document = read_xml_document("info", "get_unit_count-res.xml")
|
95
|
+
|
96
|
+
response_header = xml_document.at_xpath("//ResponseHeader")
|
97
|
+
response_header.at_xpath("operations").text.strip.should == "1"
|
98
|
+
response_header.at_xpath("responseTime").text.strip.should == "291"
|
99
|
+
response_header.at_xpath("units").text.strip.should == "1"
|
100
|
+
|
101
|
+
cost = xml_document.at_xpath("//getResponse/rval/cost")
|
102
|
+
cost.text.strip.should == "0"
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
File without changes
|
File without changes
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
describe ReportDefinitionService do
|
28
29
|
include Sem4rSpecHelper
|
@@ -32,12 +33,13 @@ describe ReportDefinitionService do
|
|
32
33
|
end
|
33
34
|
|
34
35
|
it "should define 'mutate'" do
|
35
|
-
|
36
|
+
pending "test"
|
37
|
+
response_xml = read_xml("report_definition", "mutate-res.xml")
|
36
38
|
connector = mock("connector")
|
37
39
|
connector.should_receive(:send).and_return(response_xml)
|
38
40
|
service = ReportDefinitionService.new(connector)
|
39
41
|
soap_message = service.all( @credentials )
|
40
|
-
els =
|
42
|
+
els = soap_message.response.xpath("//getResponse")
|
41
43
|
els.should_not be_empty
|
42
44
|
end
|
43
45
|
|
@@ -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__) + '/../../
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
26
27
|
|
27
28
|
|
28
29
|
describe ReportDefinition do
|
@@ -74,6 +75,7 @@ describe ReportDefinition do
|
|
74
75
|
#
|
75
76
|
|
76
77
|
it "should build xml (input for google)" do
|
78
|
+
pending "test"
|
77
79
|
report_definition = ReportDefinition.new(@account) do
|
78
80
|
name "report"
|
79
81
|
# manual_cpc_bids do
|
@@ -81,8 +83,9 @@ describe ReportDefinition do
|
|
81
83
|
# site_max_cpc 30000000
|
82
84
|
# end
|
83
85
|
end
|
84
|
-
|
85
|
-
|
86
|
+
expected_xml = read_model("//operand", "report_definition", "mutate_add-req.xml")
|
87
|
+
puts expected_xml.to_s
|
88
|
+
report_definition.to_xml("operand").should xml_equivalent(expected_xml)
|
86
89
|
end
|
87
90
|
|
88
91
|
#
|