sem4r 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -2
- data/Gemfile.lock +13 -7
- data/README.rdoc +44 -7
- data/Rakefile +2 -122
- data/VERSION.yml +1 -1
- data/bin/sem +1 -0
- data/examples_sem4r/01_get_account.rb +1 -0
- data/examples_sem4r/02_get_info.rb +1 -0
- data/examples_sem4r/03_list_ad.rb +1 -0
- data/examples_sem4r/04_list_keywords.rb +1 -0
- data/examples_sem4r/05_request_report.rb +25 -14
- data/examples_sem4r/{05_request_report_2010.rb → 06_request_report_definition.rb} +2 -4
- data/examples_sem4r/{06_create_campaigns.rb → 07_create_campaigns.rb} +1 -0
- data/examples_sem4r/{07_create_campaigns_block.rb → 08_create_campaigns_block.rb} +1 -0
- data/examples_sem4r/{07_create_campaigns_simple.rb → 09_create_campaigns_simple.rb} +1 -0
- data/examples_sem4r/{08_ad_params.rb → 10_ad_params.rb} +1 -0
- data/examples_sem4r/{09_targeting_idea.rb → 11_targeting_idea.rb} +1 -0
- data/examples_sem4r/{10_get_location.rb → 12_get_location.rb} +1 -0
- data/examples_sem4r/{11_submit_bulk_job.rb → 13_submit_bulk_job.rb} +1 -1
- data/examples_sem4r/{12_list_bulk_job.rb → 14_list_bulk_job.rb} +3 -0
- data/examples_sem4r/30_prune_empty_adgroup.rb +1 -0
- data/examples_sem4r/31_empty_accounts.rb +1 -0
- data/examples_sem4r/example_helper.rb +2 -1
- data/lib/sem4r/ad_group/ad_group.rb +22 -7
- data/lib/sem4r/ad_group/ad_group_bids.rb +1 -1
- data/lib/sem4r/ad_group/ad_group_service.rb +12 -5
- data/lib/sem4r/ad_group_ad/ad_group_ad.rb +1 -0
- data/lib/sem4r/ad_group_ad/ad_group_ad_operations.rb +1 -0
- data/lib/sem4r/ad_group_ad/ad_group_ad_service.rb +14 -9
- data/lib/sem4r/ad_group_ad/ad_group_mobile_ad.rb +16 -25
- data/lib/sem4r/ad_group_ad/ad_group_text_ad.rb +18 -14
- data/lib/sem4r/ad_group_criterion/ad_group_criterion.rb +27 -19
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_bids.rb +2 -1
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_operations.rb +1 -0
- data/lib/sem4r/ad_group_criterion/ad_group_criterion_service.rb +9 -4
- data/lib/sem4r/ad_group_criterion/criterion.rb +1 -0
- data/lib/sem4r/ad_group_criterion/criterion_keyword.rb +1 -0
- data/lib/sem4r/ad_group_criterion/criterion_placement.rb +1 -0
- data/lib/sem4r/ad_param/ad_param.rb +24 -8
- data/lib/sem4r/ad_param/ad_param_service.rb +8 -5
- data/lib/sem4r/adwords.rb +232 -76
- data/lib/sem4r/base.rb +1 -1
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job.rb +41 -35
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_account_extension.rb +49 -15
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_selector.rb +29 -20
- data/lib/sem4r/bulk_mutate_job/bulk_mutate_job_service.rb +13 -14
- data/lib/sem4r/bulk_mutate_job/job_operations.rb +1 -1
- data/lib/sem4r/campaign/campaign.rb +1 -0
- data/lib/sem4r/campaign/campaign_account_extension.rb +2 -1
- data/lib/sem4r/campaign/campaign_service.rb +9 -5
- data/lib/sem4r/credentials.rb +11 -5
- data/lib/sem4r/geo_location/address.rb +56 -0
- data/lib/sem4r/geo_location/geo_location_account_extension.rb +27 -6
- data/lib/sem4r/geo_location/geo_location_selector.rb +57 -0
- data/lib/sem4r/geo_location/geo_location_service.rb +9 -16
- data/lib/sem4r/info/info_account_extension.rb +3 -2
- data/lib/sem4r/info/info_selector.rb +2 -1
- data/lib/sem4r/info/info_service.rb +10 -3
- data/lib/sem4r/operation.rb +39 -20
- data/lib/sem4r/report_definition/report_definition.rb +37 -19
- data/lib/sem4r/report_definition/report_definition_account_extension.rb +66 -16
- data/lib/sem4r/report_definition/report_definition_operation.rb +2 -2
- data/lib/sem4r/report_definition/report_definition_selector.rb +1 -1
- data/lib/sem4r/report_definition/report_definition_service.rb +11 -7
- data/lib/sem4r/report_definition/report_field.rb +3 -2
- data/lib/sem4r/sem4r_templates.rb +77 -0
- data/lib/sem4r/{services/service.rb → service.rb} +23 -23
- data/lib/sem4r/targeting_idea/targeting_idea.rb +4 -4
- data/lib/sem4r/targeting_idea/targeting_idea_account_extension.rb +1 -1
- data/lib/sem4r/targeting_idea/targeting_idea_selector.rb +6 -6
- data/lib/sem4r/targeting_idea/targeting_idea_service.rb +7 -5
- data/lib/sem4r/v13_account/account_account_extension.rb +7 -10
- data/lib/sem4r/v13_account/account_service.rb +10 -4
- data/lib/sem4r/v13_account/billing_address.rb +2 -2
- data/lib/sem4r/v13_report/report_service.rb +11 -9
- data/lib/sem4r.rb +46 -31
- data/lib/{sem4r/cli → sem4r_cli}/cli_helpers.rb +3 -2
- data/lib/{sem4r/cli/cli_command.rb → sem4r_cli/cli_mini_framework.rb} +77 -32
- data/lib/{sem4r/cli/cli_common_args.rb → sem4r_cli/cli_sem.rb} +177 -157
- data/lib/{sem4r/cli/commands/cli_list_ads.rb → sem4r_cli/commands/cli_ads.rb} +7 -9
- data/lib/sem4r_cli/commands/cli_campaign.rb +69 -0
- data/lib/{sem4r/cli/commands/cli_list_client.rb → sem4r_cli/commands/cli_clients.rb} +2 -2
- data/lib/{sem4r/cli → sem4r_cli}/commands/cli_ideas.rb +35 -27
- data/lib/{sem4r/cli → sem4r_cli}/commands/cli_info.rb +3 -4
- data/lib/{sem4r/cli/commands/cli_repdef.rb → sem4r_cli/commands/cli_job.rb} +57 -55
- data/lib/{sem4r/cli/commands/cli_list_keywords.rb → sem4r_cli/commands/cli_keywords.rb} +14 -13
- data/lib/sem4r_cli/commands/cli_profile.rb +138 -0
- data/lib/{sem4r/cli/commands/cli_report.rb → sem4r_cli/commands/cli_repdef.rb} +67 -20
- data/lib/{sem4r/cli/commands/cli_request_report.rb → sem4r_cli/commands/cli_report.rb} +82 -19
- data/lib/sem4r_cli.rb +5 -7
- data/lib/sem4r_soap/http_connector.rb +206 -0
- data/lib/{soap_helpers → sem4r_soap}/soap_attributes.rb +8 -3
- data/lib/{sem4r/services → sem4r_soap}/soap_dumper.rb +36 -20
- data/lib/{sem4r/services → sem4r_soap}/soap_error.rb +5 -2
- data/lib/sem4r_soap/soap_response.rb +75 -0
- data/lib/sem4r_soap/soap_service.rb +137 -0
- data/lib/{sem4r/cli/cli_sem.rb → sem4r_soap/soap_service_v13.rb} +27 -28
- data/lib/sem4r_soap/soap_service_v2010.rb +80 -0
- data/lib/sem4r_soap.rb +17 -0
- data/sem4r.gemspec +93 -58
- data/spec/build_fixtures.rb +49 -42
- data/spec/fixtures/password.example.yml +3 -0
- data/spec/fixtures/sem4r.example.yml +6 -0
- data/spec/fixtures/{services/error.xml → soap_error.xml} +0 -0
- data/spec/fixtures/soap_error2.xml +29 -0
- data/spec/helpers/dump_interceptor.rb +90 -0
- data/spec/helpers/fixtures_bulk_mutate_job.rb +48 -0
- data/spec/helpers/fixtures_geo_location.rb +45 -0
- data/{lib/sem4r/campaign_criterion/campaign_criterion_service.rb → spec/helpers/fixtures_info.rb} +10 -6
- data/spec/helpers/fixtures_report_definition.rb +65 -0
- data/spec/{rspec_hash.rb → helpers/rspec_hash.rb} +1 -0
- data/spec/{rspec_matchers.rb → helpers/rspec_matchers.rb} +46 -19
- data/spec/{rspec_sem4r_helper.rb → helpers/rspec_sem4r_helper.rb} +19 -16
- data/spec/{sem4r_stubs.rb → helpers/sem4r_stubs.rb} +5 -4
- data/spec/rspec_helper.rb +4 -4
- data/spec/sem4r/account_spec.rb +2 -3
- data/spec/sem4r/ad_group/ad_group_service_spec.rb +1 -1
- data/spec/sem4r/ad_group/ad_group_spec.rb +1 -1
- data/spec/sem4r/ad_group_ad/ad_group_ad_operation_spec.rb +3 -3
- data/spec/sem4r/adwords_spec.rb +62 -39
- data/{lib/sem4r/cli/commands/cli_list_campaign.rb → spec/sem4r/bulk_mutate_job/bulk_mutate_job_selector_spec.rb} +14 -11
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_service_spec.rb +2 -3
- data/spec/sem4r/bulk_mutate_job/bulk_mutate_job_spec.rb +23 -17
- data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-req.xml +35 -0
- data/spec/sem4r/bulk_mutate_job/fixtures/get-list_job-res.xml +417 -0
- data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-req.xml +106 -0
- data/spec/sem4r/bulk_mutate_job/fixtures/mutate-add_job-res.xml +48 -0
- data/spec/sem4r/bulk_mutate_job/job_operation_spec.rb +5 -7
- data/spec/sem4r/campaign/campaign_service_spec.rb +2 -2
- data/spec/sem4r/credentials_spec.rb +10 -8
- data/spec/sem4r/geo_location/address_spec.rb +62 -0
- data/spec/sem4r/geo_location/fixtures/get-req.xml +42 -0
- data/spec/sem4r/geo_location/fixtures/get-res.xml +60 -0
- data/spec/sem4r/info/fixtures/get-req.xml +34 -0
- data/spec/sem4r/info/fixtures/get-res.xml +27 -0
- data/spec/sem4r/nokogiri_parsing_spec.rb +1 -0
- data/spec/sem4r/operation_spec.rb +72 -0
- data/spec/sem4r/report_definition/fixtures/get-list-repdef-req.xml +22 -0
- data/spec/sem4r/report_definition/fixtures/get-list-repdef-res.xml +73 -0
- data/spec/sem4r/report_definition/fixtures/getReportFields-req.xml +24 -0
- data/spec/sem4r/report_definition/fixtures/getReportFields-res.xml +1199 -0
- data/spec/sem4r/report_definition/fixtures/mutate-add-report-req.xml +63 -0
- data/spec/sem4r/report_definition/fixtures/mutate-add-report-res.xml +68 -0
- data/spec/sem4r/report_definition/report_definition_service_spec.rb +5 -5
- data/spec/sem4r/report_definition/report_definition_spec.rb +28 -43
- data/{lib/sem4r/cli/commands/cli_list_report.rb → spec/sem4r/report_definition/report_field_spec.rb} +12 -10
- data/spec/sem4r/rexml_parsing_spec.rb +1 -0
- data/spec/sem4r/{services/service_spec.rb → service_spec.rb} +1 -1
- data/spec/sem4r/targeting_idea/targeting_idea_selector_spec.rb +1 -1
- data/spec/sem4r/targeting_idea/targeting_idea_service_spec.rb +1 -1
- data/spec/sem4r/targeting_idea/targeting_idea_spec.rb +1 -1
- data/spec/sem4r/v13_account/account_service_spec.rb +2 -2
- data/spec/sem4r/v13_report/report_service_spec.rb +2 -2
- data/spec/{sem4r/cli → sem4r_cli}/cli_spec.rb +22 -27
- data/spec/{soap_helpers → sem4r_soap}/soap_attributes_spec.rb +3 -3
- data/spec/{sem4r/services/soap_message_v13_spec.rb → sem4r_soap/soap_response_spec.rb} +10 -15
- data/spec/{sem4r/services/soap_call_spec.rb → sem4r_soap/soap_service_spec.rb} +35 -54
- data/tasks/jeweler.rake +66 -0
- data/tasks/rspec.rake +21 -0
- data/tasks/sem4r.rake +25 -0
- data/tasks/yard.rake +31 -0
- metadata +173 -76
- data/lib/sem4r/ad_extension_override/ad_extension_override_service.rb +0 -30
- data/lib/sem4r/api_counters.rb +0 -8
- data/lib/sem4r/campaign_target/campaign_target_service.rb +0 -30
- data/lib/sem4r/cli/commands/cli_download_report.rb +0 -82
- data/lib/sem4r/services/http_connector.rb +0 -93
- data/lib/sem4r/services/soap_call.rb +0 -122
- data/lib/sem4r/services/soap_connector.rb +0 -139
- data/lib/sem4r/services/soap_message_v13.rb +0 -135
- data/lib/sem4r/services/soap_message_v2010.rb +0 -184
- data/lib/sem4r/v13_traffic_estimator/traffic_estimator_service.rb +0 -30
- data/spec/aggregates_rspec_helper.rb +0 -59
- data/spec/sem4r/report_definition/fixtures/mutate_add-req.xml +0 -24
- data/spec/sem4r/report_definition/fixtures/mutate_add-req_orig.xml +0 -45
@@ -0,0 +1,63 @@
|
|
1
|
+
<!-- Post to 'https://adwords-sandbox.google.com/api/adwords/cm/v201008/ReportDefinitionService' -->
|
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'>
|
4
|
+
<env:Header>
|
5
|
+
<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
|
+
</RequestHeader>
|
16
|
+
</env:Header>
|
17
|
+
<env:Body>
|
18
|
+
<mutate>
|
19
|
+
<operations xsi:type='n1:ReportDefinitionOperation' xmlns:n1='https://adwords.google.com/api/adwords/cm/v201008'>
|
20
|
+
<operator>
|
21
|
+
ADD
|
22
|
+
</operator>
|
23
|
+
<operand>
|
24
|
+
<selector>
|
25
|
+
<fields>
|
26
|
+
AdGroupId
|
27
|
+
</fields>
|
28
|
+
<fields>
|
29
|
+
Id
|
30
|
+
</fields>
|
31
|
+
<fields>
|
32
|
+
KeywordText
|
33
|
+
</fields>
|
34
|
+
<fields>
|
35
|
+
KeywordMatchType
|
36
|
+
</fields>
|
37
|
+
<fields>
|
38
|
+
Impressions
|
39
|
+
</fields>
|
40
|
+
<fields>
|
41
|
+
Clicks
|
42
|
+
</fields>
|
43
|
+
<fields>
|
44
|
+
Cost
|
45
|
+
</fields>
|
46
|
+
</selector>
|
47
|
+
<reportName>
|
48
|
+
Keywords performance report #1290336379254
|
49
|
+
</reportName>
|
50
|
+
<reportType>
|
51
|
+
KEYWORDS_PERFORMANCE_REPORT
|
52
|
+
</reportType>
|
53
|
+
<dateRangeType>
|
54
|
+
LAST_WEEK
|
55
|
+
</dateRangeType>
|
56
|
+
<downloadFormat>
|
57
|
+
CSV
|
58
|
+
</downloadFormat>
|
59
|
+
</operand>
|
60
|
+
</operations>
|
61
|
+
</mutate>
|
62
|
+
</env:Body>
|
63
|
+
</env:Envelope>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
|
2
|
+
<soap:Header>
|
3
|
+
<ResponseHeader xmlns='https://adwords.google.com/api/adwords/cm/v201008'>
|
4
|
+
<requestId>
|
5
|
+
0789bb35587ef7a3c09857e7dc98f468
|
6
|
+
</requestId>
|
7
|
+
<operations>
|
8
|
+
1
|
9
|
+
</operations>
|
10
|
+
<responseTime>
|
11
|
+
342
|
12
|
+
</responseTime>
|
13
|
+
<units>
|
14
|
+
1
|
15
|
+
</units>
|
16
|
+
</ResponseHeader>
|
17
|
+
</soap:Header>
|
18
|
+
<soap:Body>
|
19
|
+
<mutateResponse xmlns='https://adwords.google.com/api/adwords/cm/v201008'>
|
20
|
+
<rval>
|
21
|
+
<id>
|
22
|
+
9257
|
23
|
+
</id>
|
24
|
+
<selector>
|
25
|
+
<fields>
|
26
|
+
AdGroupId
|
27
|
+
</fields>
|
28
|
+
<fields>
|
29
|
+
Id
|
30
|
+
</fields>
|
31
|
+
<fields>
|
32
|
+
KeywordText
|
33
|
+
</fields>
|
34
|
+
<fields>
|
35
|
+
KeywordMatchType
|
36
|
+
</fields>
|
37
|
+
<fields>
|
38
|
+
Impressions
|
39
|
+
</fields>
|
40
|
+
<fields>
|
41
|
+
Clicks
|
42
|
+
</fields>
|
43
|
+
<fields>
|
44
|
+
Cost
|
45
|
+
</fields>
|
46
|
+
</selector>
|
47
|
+
<reportName>
|
48
|
+
Keywords performance report #1290336379254
|
49
|
+
</reportName>
|
50
|
+
<reportType>
|
51
|
+
KEYWORDS_PERFORMANCE_REPORT
|
52
|
+
</reportType>
|
53
|
+
<hasAttachment>
|
54
|
+
false
|
55
|
+
</hasAttachment>
|
56
|
+
<dateRangeType>
|
57
|
+
LAST_WEEK
|
58
|
+
</dateRangeType>
|
59
|
+
<downloadFormat>
|
60
|
+
CSV
|
61
|
+
</downloadFormat>
|
62
|
+
<creationTime>
|
63
|
+
20101210 105826 America/Los_Angeles
|
64
|
+
</creationTime>
|
65
|
+
</rval>
|
66
|
+
</mutateResponse>
|
67
|
+
</soap:Body>
|
68
|
+
</soap:Envelope>
|
@@ -20,7 +20,6 @@
|
|
20
20
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
#
|
24
23
|
# -------------------------------------------------------------------------
|
25
24
|
|
26
25
|
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
@@ -33,13 +32,14 @@ describe ReportDefinitionService do
|
|
33
32
|
end
|
34
33
|
|
35
34
|
it "should define 'mutate'" do
|
36
|
-
|
37
|
-
response_xml = read_xml("report_definition", "mutate-res.xml")
|
35
|
+
@credentials.stub(:mutable?).and_return(true)
|
36
|
+
response_xml = read_xml("report_definition", "mutate-add-report-res.xml")
|
38
37
|
connector = mock("connector")
|
39
38
|
connector.should_receive(:send).and_return(response_xml)
|
39
|
+
|
40
40
|
service = ReportDefinitionService.new(connector)
|
41
|
-
soap_message = service.
|
42
|
-
els = soap_message.response.xpath("//
|
41
|
+
soap_message = service.mutate(@credentials ,"xml")
|
42
|
+
els = soap_message.response.xpath("//mutateResponse")
|
43
43
|
els.should_not be_empty
|
44
44
|
end
|
45
45
|
|
@@ -20,7 +20,6 @@
|
|
20
20
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
#
|
24
23
|
# -------------------------------------------------------------------------
|
25
24
|
|
26
25
|
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
@@ -36,13 +35,13 @@ describe ReportDefinition do
|
|
36
35
|
@account = stub_account(services)
|
37
36
|
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
it "create should accept a block (instance_eval)" do
|
39
|
+
rd = ReportDefinition.create(@account) do
|
40
|
+
name "report"
|
41
|
+
end
|
42
|
+
rd.name.should == "report"
|
43
|
+
rd.id.should == 9257
|
44
|
+
end
|
46
45
|
|
47
46
|
|
48
47
|
# it "create should accept a block (call)" do
|
@@ -62,47 +61,33 @@ describe ReportDefinition do
|
|
62
61
|
# end
|
63
62
|
# adgroup.bids.should be_instance_of(ManualCPCAdGroupBids)
|
64
63
|
# end
|
65
|
-
#
|
66
|
-
# it "create should accept a manual cpm bids" do
|
67
|
-
# adgroup = AdGroup.create(@campaign) do
|
68
|
-
# name "sem4r library"
|
69
|
-
# manual_cpm_bids do
|
70
|
-
# max_cpm 10000
|
71
|
-
# end
|
72
|
-
# end
|
73
|
-
# adgroup.bids.should be_instance_of(ManualCPMAdGroupBids)
|
74
|
-
# end
|
75
64
|
#
|
76
65
|
|
77
66
|
it "should build xml (input for google)" do
|
78
|
-
pending "test"
|
79
67
|
report_definition = ReportDefinition.new(@account) do
|
80
|
-
name
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
68
|
+
name "Keywords performance report #1290336379254"
|
69
|
+
type "KEYWORDS_PERFORMANCE_REPORT"
|
70
|
+
date_range "LAST_WEEK"
|
71
|
+
format "CSV"
|
72
|
+
|
73
|
+
field "AdGroupId"
|
74
|
+
field "Id"
|
75
|
+
field "KeywordText"
|
76
|
+
field "KeywordMatchType"
|
77
|
+
field "Impressions"
|
78
|
+
field "Clicks"
|
79
|
+
field "Cost"
|
85
80
|
end
|
86
|
-
expected_xml = read_model("//operand", "report_definition", "
|
87
|
-
|
88
|
-
report_definition.to_xml("operand").should xml_equivalent(expected_xml)
|
81
|
+
expected_xml = read_model("//operand", "report_definition", "mutate-add-report-req.xml")
|
82
|
+
report_definition.should xml_equivalent(expected_xml)
|
89
83
|
end
|
90
84
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
#
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# it "should parse xml (produced by google) with manual cpm bids" do
|
101
|
-
# el = read_model("//entries", "services", "ad_group", "get-manual-cpm-bids-res.xml")
|
102
|
-
# adgroup = AdGroup.from_element(@campaign, el)
|
103
|
-
# adgroup.bids.should be_instance_of(ManualCPMAdGroupBids)
|
104
|
-
# end
|
105
|
-
|
106
|
-
|
85
|
+
it "should parse xml (produced by google)" do
|
86
|
+
el = read_model("//entries", "report_definition", "get-list-repdef-res.xml")
|
87
|
+
repdef = ReportDefinition.from_element(@account, el)
|
88
|
+
# adgroup.id.should == 3060217923
|
89
|
+
repdef.name.should == "Keywords performance report #1290336379254"
|
90
|
+
repdef.type.should == ReportDefinition::KEYWORDS_PERFORMANCE_REPORT
|
91
|
+
end
|
107
92
|
|
108
93
|
end
|
data/{lib/sem4r/cli/commands/cli_list_report.rb → spec/sem4r/report_definition/report_field_spec.rb}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
# -------------------------------------------------------------------------
|
3
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining
|
6
6
|
# a copy of this software and associated documentation files (the
|
7
7
|
# "Software"), to deal in the Software without restriction, including
|
@@ -9,10 +9,10 @@
|
|
9
9
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
10
|
# permit persons to whom the Software is furnished to do so, subject to
|
11
11
|
# the following conditions:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# The above copyright notice and this permission notice shall be
|
14
14
|
# included in all copies or substantial portions of the Software.
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
17
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
18
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -20,15 +20,17 @@
|
|
20
20
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
#
|
24
23
|
# -------------------------------------------------------------------------
|
25
24
|
|
26
|
-
|
25
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
27
26
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
describe ReportField do
|
28
|
+
include Sem4rSpecHelper
|
29
|
+
|
30
|
+
it "should parse xml (produced by google)" do
|
31
|
+
el = read_model("//rval", "report_definition", "getReportFields-res.xml")
|
32
|
+
report_field = ReportField.from_element(el)
|
33
|
+
report_field.field_name.should == "AdGroupId"
|
32
34
|
end
|
33
35
|
|
34
|
-
end
|
36
|
+
end
|
@@ -23,7 +23,7 @@
|
|
23
23
|
#
|
24
24
|
# -------------------------------------------------------------------------
|
25
25
|
|
26
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
26
|
+
require File.expand_path(File.dirname(__FILE__) + '/../rspec_helper')
|
27
27
|
|
28
28
|
describe Service do
|
29
29
|
include Sem4rSpecHelper
|
@@ -26,7 +26,7 @@
|
|
26
26
|
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
27
27
|
|
28
28
|
describe TargetingIdeaSelector do
|
29
|
-
include Sem4rSpecHelper
|
29
|
+
include Sem4rSpecHelper
|
30
30
|
|
31
31
|
it "should produce xml (input for google)" do
|
32
32
|
idea_selector = TargetingIdeaSelector.new do
|
@@ -37,7 +37,7 @@ describe TargetingIdeaService do
|
|
37
37
|
connector = mock("connector")
|
38
38
|
connector.should_receive(:send).and_return(response_xml)
|
39
39
|
service = TargetingIdeaService.new(connector)
|
40
|
-
soap_message = service.get( @credentials,
|
40
|
+
soap_message = service.get( @credentials, "xml" )
|
41
41
|
els = soap_message.response.xpath("//getResponse")
|
42
42
|
els.should_not be_empty
|
43
43
|
end
|
@@ -26,7 +26,7 @@
|
|
26
26
|
require File.expand_path(File.dirname(__FILE__) + '/../../rspec_helper')
|
27
27
|
|
28
28
|
describe TargetingIdea do
|
29
|
-
include Sem4rSpecHelper
|
29
|
+
include Sem4rSpecHelper
|
30
30
|
|
31
31
|
it "should parse xml (produced by google)" do
|
32
32
|
el = read_model("//entries", "targeting_idea", "get-res.xml")
|
@@ -39,7 +39,7 @@ describe AccountService do
|
|
39
39
|
connector.should_receive(:send).and_return(response_xml)
|
40
40
|
|
41
41
|
service = AccountService.new(connector)
|
42
|
-
soap_message = service.account_info(
|
42
|
+
soap_message = service.account_info(@credentials)
|
43
43
|
|
44
44
|
els = soap_message.response.xpath("//getAccountInfoResponse")
|
45
45
|
els.should_not be_empty
|
@@ -52,7 +52,7 @@ describe AccountService do
|
|
52
52
|
connector.should_receive(:send).and_return(response_xml)
|
53
53
|
|
54
54
|
service = AccountService.new(connector)
|
55
|
-
soap_message = service.client_accounts(
|
55
|
+
soap_message = service.client_accounts(@credentials)
|
56
56
|
|
57
57
|
els = soap_message.response.xpath("//getClientAccountsResponse")
|
58
58
|
els.should_not be_empty
|
@@ -39,7 +39,7 @@ describe ReportService do
|
|
39
39
|
connector.should_receive(:send).and_return(response_xml)
|
40
40
|
|
41
41
|
report_service = ReportService.new(connector)
|
42
|
-
soap_message = report_service.all(
|
42
|
+
soap_message = report_service.all(@credentials)
|
43
43
|
|
44
44
|
els = soap_message.response.xpath("//getAllJobsReturn")
|
45
45
|
els.should_not be_empty
|
@@ -53,7 +53,7 @@ describe ReportService do
|
|
53
53
|
connector.should_receive(:send).and_return(response_xml)
|
54
54
|
|
55
55
|
report_service = ReportService.new(connector)
|
56
|
-
soap_message = report_service.validate(
|
56
|
+
soap_message = report_service.validate(@credentials, "xml" )
|
57
57
|
|
58
58
|
els = soap_message.response.xpath("//getAllJobsReturn")
|
59
59
|
els.should_not be_empty
|
@@ -23,48 +23,43 @@
|
|
23
23
|
#
|
24
24
|
# -------------------------------------------------------------------------
|
25
25
|
|
26
|
-
require File.dirname(__FILE__) + '
|
26
|
+
require File.dirname(__FILE__) + '/../rspec_helper'
|
27
27
|
|
28
28
|
describe "cli" do
|
29
29
|
include Sem4rSpecHelper
|
30
30
|
|
31
|
-
describe CliSem do
|
32
|
-
|
31
|
+
describe Sem4rCli::CliSem do
|
32
|
+
|
33
33
|
it "should show help" do
|
34
34
|
out = with_stdout_captured do
|
35
|
-
cli
|
35
|
+
cli = Sem4rCli::CliSem.new
|
36
36
|
args = %w{ -h }
|
37
37
|
cli.parse_and_run(args)
|
38
38
|
end
|
39
|
-
out.should match("Usage")
|
39
|
+
out.should match("Usage")
|
40
40
|
end
|
41
|
-
|
42
41
|
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
cmd = CliCommonArgs.new
|
51
|
-
ret = cmd.parse(args)
|
52
|
-
end
|
53
|
-
out.should match("Usage")
|
54
|
-
ret.should be_false
|
43
|
+
it "should show help and exit" do
|
44
|
+
ret = true
|
45
|
+
out = with_stdout_captured do
|
46
|
+
args = %w{ -h }
|
47
|
+
cmd = Sem4rCli::CliSem.new
|
48
|
+
ret = cmd.parse_and_run(args)
|
55
49
|
end
|
50
|
+
out.should match("Usage")
|
51
|
+
ret.should be_true
|
52
|
+
end
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
64
|
-
out.should match("sem4r version")
|
65
|
-
ret.should be_false
|
54
|
+
it "should show version and exit" do
|
55
|
+
ret = true
|
56
|
+
out = with_stdout_captured do
|
57
|
+
args = %w{ --version }
|
58
|
+
cmd = Sem4rCli::CliSem.new
|
59
|
+
ret = cmd.parse_and_run(args)
|
66
60
|
end
|
67
|
-
|
61
|
+
out.should match("sem4r version")
|
62
|
+
ret.should be_true
|
68
63
|
end
|
69
64
|
|
70
65
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
# -------------------------------------------------------------------------
|
2
3
|
# Copyright (c) 2009-2010 Sem4r sem4ruby@gmail.com
|
3
4
|
#
|
@@ -19,15 +20,14 @@
|
|
19
20
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#
|
23
23
|
# -------------------------------------------------------------------------
|
24
24
|
|
25
25
|
require File.expand_path(File.dirname(__FILE__) + '/../rspec_helper')
|
26
26
|
|
27
|
-
describe SoapAttributes do
|
27
|
+
describe Sem4rSoap::SoapAttributes do
|
28
28
|
|
29
29
|
class TSoapAttributes
|
30
|
-
include
|
30
|
+
include Sem4rSoap::SoapAttributes
|
31
31
|
|
32
32
|
enum :Types, [:Daily, :Monthly, :Weekly, :Yearly]
|
33
33
|
enum :Columns, [:Id, :Campaign, :Keyword]
|
@@ -20,29 +20,24 @@
|
|
20
20
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
#
|
24
23
|
# -------------------------------------------------------------------------
|
25
24
|
|
26
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
25
|
+
require File.expand_path(File.dirname(__FILE__) + '/../rspec_helper')
|
27
26
|
|
28
|
-
describe
|
27
|
+
describe Sem4rSoap::SoapResponse do
|
29
28
|
include Sem4rSpecHelper
|
30
29
|
|
31
|
-
|
32
|
-
@credentials = stub_credentials
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should update counters" do
|
30
|
+
it "should update counters (v13 api)" do
|
36
31
|
response_xml = read_xml("v13_report", "get_all_jobs-res.xml")
|
37
|
-
|
38
|
-
connector.should_receive(:send).and_return(response_xml)
|
39
|
-
|
40
|
-
message_v13 = SoapMessageV13.new(connector, @credentials)
|
41
|
-
message_v13.body = ""
|
42
|
-
message_v13.send("service_url", "soap_action")
|
43
|
-
|
32
|
+
message_v13 = Sem4rSoap::SoapResponse.new.parse_response(response_xml)
|
44
33
|
message_v13.counters.should_not be_empty
|
45
34
|
message_v13.counters.should == { :response_time => 177, :operations => 4, :units => 4 }
|
46
35
|
end
|
47
36
|
|
37
|
+
it "should update counters (v2010 api)" do
|
38
|
+
response_xml = read_xml("ad_group", "get-first-res.xml")
|
39
|
+
message = Sem4rSoap::SoapResponse.new.parse_response(response_xml)
|
40
|
+
message.counters.should_not be_empty
|
41
|
+
message.counters.should == { :response_time => 170, :operations => 2, :units => 2 }
|
42
|
+
end
|
48
43
|
end
|
@@ -20,32 +20,26 @@
|
|
20
20
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
#
|
24
23
|
# -------------------------------------------------------------------------
|
25
24
|
|
26
|
-
require File.expand_path(File.dirname(__FILE__) + '
|
25
|
+
require File.expand_path(File.dirname(__FILE__) + '/../rspec_helper')
|
27
26
|
|
28
|
-
describe
|
27
|
+
describe Sem4rSoap::SoapService do
|
29
28
|
include Sem4rSpecHelper
|
30
29
|
|
31
|
-
|
32
|
-
mock("connector", :send => "send")
|
33
|
-
end
|
34
|
-
|
35
|
-
class TSoapService
|
36
|
-
include SoapCall
|
30
|
+
class TSoapService < Sem4rSoap::SoapServiceV2010
|
37
31
|
|
38
32
|
def initialize(connector)
|
33
|
+
super()
|
39
34
|
@connector = connector
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
private
|
37
|
+
soap_call :get, :mutate => false
|
38
|
+
soap_call :get_with_arg, :mutate => false
|
39
|
+
soap_call :mutate
|
40
|
+
soap_call :mutate_bis, :mutate => true
|
48
41
|
|
42
|
+
# private
|
49
43
|
|
50
44
|
def _get(xml)
|
51
45
|
<<-EOFS
|
@@ -58,59 +52,46 @@ describe SoapCall do
|
|
58
52
|
end
|
59
53
|
end
|
60
54
|
|
55
|
+
before do
|
56
|
+
@connector = mock("connector", :send => "send")
|
57
|
+
@readonly_credentials = stub_credentials
|
58
|
+
@service = TSoapService.new(@connector)
|
59
|
+
end
|
61
60
|
|
62
|
-
it "should define a new method" do
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
it "should define a new method get" do
|
62
|
+
@service.methods.should include(:get) if RUBY_VERSION =~ /1\.9/
|
63
|
+
@service.methods.should include("get") if RUBY_VERSION =~ /1\.8/
|
64
|
+
r = @service.methods.grep /^get$/
|
66
65
|
r.length.should == 1
|
67
66
|
end
|
68
67
|
|
69
|
-
# it "should add a parameter to private method" do
|
70
|
-
# pending "test"
|
71
|
-
# get = TSoapService.instance_method(:get)
|
72
|
-
# _get = TSoapService.instance_method(:_get)
|
73
|
-
# get.arity.should == _get.arity + 1
|
74
|
-
# end
|
75
|
-
|
76
68
|
it "calling 'get' should call private method _get" do
|
77
|
-
|
78
|
-
|
79
|
-
@connector = mock("connector", :send => "send")
|
80
|
-
# @connector.should_receive().with("get")
|
81
|
-
t = TSoapService.new(@connector)
|
82
|
-
t.should_receive(:_get).with("foo").and_return("get")
|
83
|
-
soap_message = t.get(credentials, "foo")
|
84
|
-
# soap_message.response.should == "send"
|
69
|
+
@service.should_receive(:_get).with("foo").and_return("get")
|
70
|
+
soap_message = @service.get(@readonly_credentials, "foo")
|
85
71
|
end
|
86
72
|
|
87
73
|
it "calling 'get_with_arg' should call private method _get_with_arg" do
|
88
|
-
|
89
|
-
|
90
|
-
t.get_with_arg(credentials, "foo")
|
74
|
+
@service.should_receive(:_get_with_arg).with("foo").and_return("get")
|
75
|
+
@service.get_with_arg(@readonly_credentials, "foo")
|
91
76
|
end
|
92
77
|
|
93
78
|
it "calling 'mutate' should raise an exception with read_only profile" do
|
94
|
-
|
95
|
-
|
96
|
-
t = TSoapService.new(mock_connector)
|
97
|
-
t.should_not_receive(:_mutate)
|
98
|
-
lambda{ t.mutate(credentials, "foo")}.should raise_error(RuntimeError)
|
79
|
+
@service.should_not_receive(:_mutate)
|
80
|
+
lambda{ @service.mutate(@readonly_credentials, "foo")}.should raise_error(RuntimeError)
|
99
81
|
end
|
100
82
|
|
101
|
-
it "call '
|
102
|
-
|
103
|
-
|
104
|
-
t = TSoapService.new(mock_connector)
|
105
|
-
t.should_receive(:_mutate).with("foo").and_return("")
|
106
|
-
t.mutate(credentials, "foo")
|
83
|
+
it "call 'mutate_bis' should raise an exception with read_only profile" do
|
84
|
+
@service.should_not_receive(:_mutate_bis)
|
85
|
+
lambda{ @service.mutate_bis(@readonly_credentials, "foo")}.should raise_error(RuntimeError)
|
107
86
|
end
|
108
87
|
|
109
|
-
it "call '
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
88
|
+
it "call 'mutate' should call private methods _mutate with the right profile" do
|
89
|
+
@mutable_credentials = stub_credentials
|
90
|
+
@mutable_credentials.should_receive(:mutable?).and_return(true)
|
91
|
+
@mutable_service = TSoapService.new(@connector)
|
92
|
+
|
93
|
+
@mutable_service.should_receive(:_mutate).with("foo").and_return("")
|
94
|
+
@mutable_service.mutate(@mutable_credentials, "foo")
|
115
95
|
end
|
96
|
+
|
116
97
|
end
|