baidu 1.2.10 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +82 -0
- data/Rakefile +1 -0
- data/baidu.gemspec +26 -0
- data/lib/baidu.rb +46 -468
- data/lib/baidu/auth.rb +5 -0
- data/lib/baidu/map.rb +66 -0
- data/lib/baidu/rank.rb +5 -0
- data/lib/baidu/sem.rb +14 -0
- data/lib/baidu/sem/account.rb +31 -0
- data/lib/baidu/sem/adgroup.rb +55 -0
- data/lib/baidu/sem/base.rb +96 -0
- data/lib/baidu/sem/bulk.rb +75 -0
- data/lib/baidu/sem/campaign.rb +96 -0
- data/lib/baidu/sem/creative.rb +33 -0
- data/lib/baidu/sem/enum.rb +70 -0
- data/lib/baidu/sem/keyword.rb +35 -0
- data/lib/baidu/sem/kr.rb +9 -0
- data/lib/baidu/sem/new_creative.rb +32 -0
- data/lib/baidu/sem/report.rb +107 -0
- data/lib/baidu/sem/search.rb +79 -0
- data/lib/baidu/version.rb +3 -0
- data/lib/ext.rb +46 -0
- data/spec/map_spec.rb +77 -0
- data/spec/sem_adgroup_spec.rb +119 -0
- data/spec/sem_api_response_spec.rb +97 -0
- data/spec/sem_bulk_spec.rb +89 -0
- data/spec/sem_campaign_spec.rb +94 -0
- data/spec/sem_creative_spec.rb +79 -0
- data/spec/sem_keyword_spec.rb +48 -0
- data/spec/sem_report_spec.rb +52 -0
- data/spec/sem_search_spec.rb +80 -0
- data/spec/spec_helper.rb +356 -0
- metadata +87 -15
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Baidu::SEM::AdgroupService do
|
4
|
+
subject{Baidu::SEM::AdgroupService.new($auth)}
|
5
|
+
describe '#getAllAdgroupId' do
|
6
|
+
it "should return hash with correct format calling getAllAdgroupId " do
|
7
|
+
response = subject.getAllAdgroupId
|
8
|
+
response.status.should == 0
|
9
|
+
response.desc.should == 'success'
|
10
|
+
response.quota.should == 2
|
11
|
+
response.rquota.should > 0
|
12
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
13
|
+
# response.class.should == Hash
|
14
|
+
# response.should have_key :campaign_adgroup_ids
|
15
|
+
# response = response[:campaign_adgroup_ids]
|
16
|
+
# response.first.should have_key :campaign_id
|
17
|
+
# response.first.should have_key :adgroup_ids
|
18
|
+
# campaign_id = response.first[:campaign_id]
|
19
|
+
# campaign_id.to_i.to_s.should == campaign_id
|
20
|
+
# response.first[:adgroup_ids].class.should == Array
|
21
|
+
# adgroup_id = response.first[:adgroup_ids].first
|
22
|
+
# adgroup_id.to_i.to_s.should == adgroup_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#getAdgroupIdByCampaignId' do
|
27
|
+
# subject{Baidu::SEM::AdgroupService.new($auth)}
|
28
|
+
it "should return hash with correct format calling getAdgroupIdByCampaignId" do
|
29
|
+
response = subject.getAdgroupIdByCampaignId({:campaignIds=>[$campaign_id]})
|
30
|
+
response.status.should == 0
|
31
|
+
response.desc.should == 'success'
|
32
|
+
response.quota.should == 2
|
33
|
+
response.rquota.should > 0
|
34
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#getAdgroupByCampaignId' do
|
39
|
+
# subject{Baidu::SEM::AdgroupService.new($auth)}
|
40
|
+
it "should return hash with correct format calling getAdgroupByCampaignId" do
|
41
|
+
pending
|
42
|
+
response = subject.getAdgroupByCampaignId({:campaignIds=>[$campaign_id]})
|
43
|
+
response.status.should == 0
|
44
|
+
response.desc.should == 'success'
|
45
|
+
response.quota.should == 2
|
46
|
+
response.rquota.should > 0
|
47
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
48
|
+
# response.class.should == Hash
|
49
|
+
# response.should have_key :campaign_adgroups
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# describe '#getAdgroupByAdgroupId' do
|
54
|
+
# # subject{Baidu::SEM::AdgroupService.new($auth)}
|
55
|
+
# it "should return hash with correct format calling getAdgroupByAdgroupId" do
|
56
|
+
# pending
|
57
|
+
# response = subject.getAdgroupByAdgroupId({:adgroupIds => $adgroup_ids})
|
58
|
+
# response.status.should == 0
|
59
|
+
# response.desc.should == 'success'
|
60
|
+
# response.quota.should == 2
|
61
|
+
# response.rquota.should > 0
|
62
|
+
# expect{ApiResponse.verify(response.body)}.not_to raise_error
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
|
66
|
+
describe '#addAdgroup #updateAdgroup #getAdgroupByAdgroupId #deleteAdgroup' do
|
67
|
+
# subject {Baidu::SEM::AdgroupService.new($aut)}
|
68
|
+
it "is not ready yet" do
|
69
|
+
#addAdgroup
|
70
|
+
adgroupType_add = {:campaignId=>$campaign_id,:adgroupName=>'adgroupName1',:maxPrice=>2}
|
71
|
+
response = subject.addAdgroup({:adgroupTypes => [adgroupType_add]})
|
72
|
+
response.status.should == 0
|
73
|
+
response.desc.should == 'success'
|
74
|
+
response.quota.should == 2
|
75
|
+
response.rquota.should > 0
|
76
|
+
# ap response.body
|
77
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
78
|
+
|
79
|
+
#parse and verify adgroup_id
|
80
|
+
adgroup_id = response.body[:adgroup_types][:adgroup_id]
|
81
|
+
adgroup_id.to_i.to_s.should == adgroup_id
|
82
|
+
|
83
|
+
#updateAdgroup
|
84
|
+
adgroupType_update = {:adgroupId => adgroup_id, :adgroupName => 'adgroupName2'}
|
85
|
+
# ap adgroupType
|
86
|
+
response = subject.updateAdgroup({:adgroupTypes=>[adgroupType_update]})
|
87
|
+
response.status.should == 0
|
88
|
+
response.desc.should == 'success'
|
89
|
+
response.quota.should == 2
|
90
|
+
response.rquota.should > 0
|
91
|
+
# ap response.body
|
92
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
93
|
+
|
94
|
+
#getAdgroupByAdgroupId
|
95
|
+
response = subject.getAdgroupByAdgroupId({:adgroupIds=>[adgroup_id]})
|
96
|
+
response.status.should == 0
|
97
|
+
response.desc.should == 'success'
|
98
|
+
response.quota.should == 2
|
99
|
+
response.rquota.should > 0
|
100
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
101
|
+
response.body[:adgroup_types][:adgroup_name].should == 'adgroupName2'
|
102
|
+
|
103
|
+
|
104
|
+
#deleteAdgroup
|
105
|
+
response = subject.deleteAdgroup({:adgroupIds => [adgroup_id]})
|
106
|
+
response.status.should == 0
|
107
|
+
response.desc.should == 'success'
|
108
|
+
response.quota.should == 2
|
109
|
+
response.rquota.should > 0
|
110
|
+
# ap response.body
|
111
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
112
|
+
ap response.body
|
113
|
+
# it "is not implemented yet" do
|
114
|
+
# pending("this is pending before we have testing-purpose account")
|
115
|
+
# end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe ApiResponse do
|
3
|
+
let(:adgroup_type_sample) {
|
4
|
+
{
|
5
|
+
:adgroup_id => "8888888",
|
6
|
+
:campaign_id => "88888888",
|
7
|
+
:adgroup_name => "测试adgroup",
|
8
|
+
:max_price => "1.0",
|
9
|
+
:negative_words => "测试negative_words",
|
10
|
+
:pause => false,
|
11
|
+
:status => "31"
|
12
|
+
}}
|
13
|
+
|
14
|
+
let(:campaign_adgroup) {{
|
15
|
+
:campaign_id => "8888888",
|
16
|
+
:adgroup_types => [{
|
17
|
+
:adgroup_id => "8888888",
|
18
|
+
:campaign_id => "88888888",
|
19
|
+
:adgroup_name => "测试adgroup",
|
20
|
+
:max_price => "1.0",
|
21
|
+
:negative_words => "测试negative_words",
|
22
|
+
:pause => false,
|
23
|
+
:status => "31"
|
24
|
+
}]
|
25
|
+
}}
|
26
|
+
|
27
|
+
subject {ApiResponse}
|
28
|
+
|
29
|
+
it "should verify correct :campaign_id" do
|
30
|
+
expect{subject.verify({:campaign_id => "8888888"})}.not_to raise_error
|
31
|
+
expect{subject.verify({:campaign_id => "abc"})}.to raise_error
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should verify :adgroup_id" do
|
35
|
+
expect{subject.verify({:adgroup_id => "88888888"})}.not_to raise_error
|
36
|
+
expect{subject.verify({:adgroup_id => "abc"})}.to raise_error
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should verify :adgroup_name" do
|
40
|
+
expect{subject.verify({:adgroup_name => "adgroup_name1"})}.not_to raise_error
|
41
|
+
expect{subject.verify({:adgroup_name => ""})}.to raise_error
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should verify :max_price" do
|
45
|
+
expect{subject.verify({:max_price => "0.2"})}.not_to raise_error
|
46
|
+
expect{subject.verify({:max_price => 0.2})}.to raise_error
|
47
|
+
expect{subject.verify({:max_price => 'abc'})}.to raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should verify :pause" do
|
51
|
+
expect{subject.verify({:pause =>true})}.not_to raise_error
|
52
|
+
expect{subject.verify({:pause =>'true'})}.to raise_error
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should verify :status" do
|
56
|
+
expect{subject.verify({:status => '131'})}.not_to raise_error
|
57
|
+
expect{subject.verify({:status => ''})}.to raise_error
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should verify :campaign_adgroups" do
|
61
|
+
campaign_adgroups = []
|
62
|
+
campaign_adgroups << campaign_adgroup
|
63
|
+
|
64
|
+
expect{subject.verify(campaign_adgroup)}.not_to raise_error
|
65
|
+
expect{subject.verify({:campaign_adgroups => campaign_adgroups})}.not_to raise_error
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should verify :exact_negative_words" do
|
69
|
+
exact_negative_words = []
|
70
|
+
exact_negative_words << 'nega1'
|
71
|
+
exact_negative_words << '否定词2'
|
72
|
+
negative_words = {:negative_words => exact_negative_words}
|
73
|
+
exact_negative_words = {:exact_negative_words => exact_negative_words}
|
74
|
+
|
75
|
+
expect{subject.verify(exact_negative_words)}.not_to raise_error
|
76
|
+
expect{subject.verify(negative_words)}.not_to raise_error
|
77
|
+
end
|
78
|
+
|
79
|
+
it "adgroup_types" do
|
80
|
+
adgroup_types = []
|
81
|
+
adgroup_types << adgroup_type_sample
|
82
|
+
adgroup_types << adgroup_type_sample
|
83
|
+
adgroup_types = {:adgroup_types => adgroup_types}
|
84
|
+
adgroup_type = {:adgroup_type => adgroup_type_sample}
|
85
|
+
|
86
|
+
expect{subject.verify(adgroup_types)}.not_to raise_error
|
87
|
+
expect{subject.verify(adgroup_type)}.not_to raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it "campaign_infos" do
|
91
|
+
campaign_infos = {}
|
92
|
+
campaign_infos[:campaign_id] = '88888888'
|
93
|
+
campaign_infos[:campaign_name] = 'campaign_name'
|
94
|
+
|
95
|
+
expect{subject.verify({:campaign_infos => campaign_infos})}.not_to raise_error
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Baidu::SEM::BulkJobService do
|
3
|
+
subject{Baidu::SEM::BulkJobService.new($auth)}
|
4
|
+
let(:startTime){(Time.now - 24*3600).utc.iso8601}
|
5
|
+
let(:options){{:startTime=>startTime}}
|
6
|
+
describe '#getChangedCampaignId' do
|
7
|
+
it "getChangedCampaignId" do
|
8
|
+
# options = {}
|
9
|
+
# options[:startTime] = startTime
|
10
|
+
response = subject.getChangedCampaignId(options).body
|
11
|
+
expect{ApiResponse.verify(response)}.not_to raise_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#getChangedId' do
|
16
|
+
it "getChangedId" do
|
17
|
+
# options = {}
|
18
|
+
# options[:startTime] = startTime
|
19
|
+
response = subject.getChangedId(options).body
|
20
|
+
expect{ApiResponse.verify(response)}.not_to raise_error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#getChangedNewCreativeId' do
|
25
|
+
it "getChangedNewCreativeId" do
|
26
|
+
# options = {}
|
27
|
+
# options[:startTime] = startTime
|
28
|
+
options[:newCreativeType] = 1
|
29
|
+
response = subject.getChangedNewCreativeId(options).body
|
30
|
+
expect{ApiResponse.verify(response)}.not_to raise_error
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#getChangedScale' do
|
35
|
+
it "getChangedScale" do
|
36
|
+
response = subject.getChangedScale(options).body
|
37
|
+
expect{ApiResponse.verify(response)}.not_to raise_error
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#getAllObjects' do
|
42
|
+
it "getAllObjects" do
|
43
|
+
response = subject.getAllObjects.body
|
44
|
+
expect{ApiResponse.verify(response)}.not_to raise_error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#getAllChangedObjects' do
|
49
|
+
it "getAllChangedObjects" do
|
50
|
+
response = subject.getAllChangedObjects(options).body
|
51
|
+
expect{ApiResponse.verify(response)}.not_to raise_error
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#getFileState' do
|
56
|
+
it "getFileState" do
|
57
|
+
pending('error:Last file task not finish')
|
58
|
+
response = subject.getAllObjects.body
|
59
|
+
file_id = response[:file_id]
|
60
|
+
options[:fileId] = file_id
|
61
|
+
response = subject.getFileState(options).body
|
62
|
+
expect{ApiResponse.verify(response)}.not_to raise_error
|
63
|
+
sleep 3
|
64
|
+
response = subject.getFilePath(options).body
|
65
|
+
expect{ApiResponse.verify(response)}.not_to raise_error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#getChangedAdgroupId' do
|
70
|
+
it "getChangedAdgroupId" do
|
71
|
+
response = subject.getChangedAdgroupId(options).body
|
72
|
+
expect{ApiResponse.verify(response)}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#getChangedItemId' do
|
77
|
+
it "getChangedItemId" do
|
78
|
+
response = subject.getChangedItemId(options).body
|
79
|
+
expect{ApiResponse.verify(response)}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#getSelectedObjects' do
|
84
|
+
it "getSelectedObjects" do
|
85
|
+
response = subject.getSelectedObjects(options).body
|
86
|
+
expect{ApiResponse.verify(response)}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Baidu::SEM::CampaignService do
|
3
|
+
subject{Baidu::SEM::CampaignService.new($auth)}
|
4
|
+
|
5
|
+
describe '#addCampaign #updateCampaign #getCampaignByCampaignId #deleteCampaign' do
|
6
|
+
it "should not raise errors when add, update, and delete a temp campaign" do
|
7
|
+
#addCampaign
|
8
|
+
campaign_type_add = {
|
9
|
+
:campaignName=> 'campaignName1',
|
10
|
+
:budget => '100',
|
11
|
+
:negativeWords => ['7day'],
|
12
|
+
:exactNegativeWords => ['7daysin']
|
13
|
+
}
|
14
|
+
options = {:campaignTypes => [campaign_type_add]}
|
15
|
+
response = subject.addCampaign(options)
|
16
|
+
response.status.should == 0
|
17
|
+
response.desc.should == 'success'
|
18
|
+
response.quota.should == 2
|
19
|
+
response.rquota.should > 0
|
20
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
21
|
+
|
22
|
+
#parse and verify campaign_id
|
23
|
+
campaign_id = response.body[:campaign_types][:campaign_id]
|
24
|
+
campaign_id.to_i.to_s.should == campaign_id
|
25
|
+
|
26
|
+
#updateCampaign
|
27
|
+
campaign_type_update =
|
28
|
+
{
|
29
|
+
:campaignId => campaign_id,
|
30
|
+
:campaignName => 'campaignName3',
|
31
|
+
:budget => '101',
|
32
|
+
:negativeWords => ['8day'],
|
33
|
+
:exactNegativeWords => ['8daysin']
|
34
|
+
}
|
35
|
+
sleep 2
|
36
|
+
options = {:campaignTypes => [campaign_type_update]}
|
37
|
+
response = subject.updateCampaign(options)
|
38
|
+
ap response.body
|
39
|
+
response.status.should == 0
|
40
|
+
response.desc.should == 'success'
|
41
|
+
response.quota.should == 2
|
42
|
+
response.rquota.should > 0
|
43
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
44
|
+
|
45
|
+
#check the result of updateCampaign by getCampaignByCampaignId
|
46
|
+
response = subject.getCampaignByCampaignId({:campaignIds => [campaign_id]})
|
47
|
+
response.status.should == 0
|
48
|
+
response.desc.should == 'success'
|
49
|
+
response.quota.should == 2
|
50
|
+
response.rquota.should > 0
|
51
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
52
|
+
# ap response.body
|
53
|
+
response.body[:campaign_types][:campaign_name].should == 'campaignName3'
|
54
|
+
response.body[:campaign_types][:budget].should == '101.0'
|
55
|
+
response.body[:campaign_types][:negative_words].should == '8day'
|
56
|
+
response.body[:campaign_types][:exact_negative_words].should == "8daysin"
|
57
|
+
|
58
|
+
#deleteCampaign
|
59
|
+
response = subject.deleteCampaign({:campaignIds=>[campaign_id]})
|
60
|
+
response.status.should == 0
|
61
|
+
response.desc.should == 'success'
|
62
|
+
response.quota.should == 2
|
63
|
+
response.rquota.should > 0
|
64
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
65
|
+
response.body[:result].should == '1'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# describe '#getCampaignByCampaignId' do
|
70
|
+
# it "getCampaignByCampaignId" do
|
71
|
+
# # puts '==============='
|
72
|
+
# # puts subject.example('getAllCampaign')
|
73
|
+
# # {:GetCampaignByCampaignIdRequest=>{:campaignIds=>["long"]}}
|
74
|
+
# # puts '==============='
|
75
|
+
# response = subject.getCampaignByCampaignId({:campaignIds=>[$campaign_id]})
|
76
|
+
# response.status.should == 0
|
77
|
+
# response.desc.should == 'success'
|
78
|
+
# response.quota.should == 2
|
79
|
+
# response.rquota.should > 0
|
80
|
+
# expect{ApiResponse.verify(response.body)}.not_to raise_error
|
81
|
+
# end
|
82
|
+
# end
|
83
|
+
|
84
|
+
describe '#getAllCampaign' do
|
85
|
+
it "getAllCampaign" do
|
86
|
+
response = subject.getAllCampaign({})
|
87
|
+
response.status.should == 0
|
88
|
+
response.desc.should == 'success'
|
89
|
+
response.quota.should == 2
|
90
|
+
response.rquota.should > 0
|
91
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'uri'
|
3
|
+
describe Baidu::SEM::CreativeService do
|
4
|
+
subject{Baidu::SEM::CreativeService.new($auth)}
|
5
|
+
let(:new_title){'新测试创意标题'}
|
6
|
+
it '#addCreative #updateCreative #getCreativeByCreativeId #deleteCreative' do
|
7
|
+
#addCreative
|
8
|
+
creativeType = {
|
9
|
+
:adgroupId => $adgroup_id,
|
10
|
+
:title => '测试创意标题',
|
11
|
+
:description1 => '测试创意首行测试创意首行测试创意首行',
|
12
|
+
:description2 => '测试创意次行测试创意次行测试创意次行',
|
13
|
+
:pcDestinationUrl => $pcDestinationUrl,
|
14
|
+
:pcDisplayUrl=> URI($pcDestinationUrl).host,
|
15
|
+
:mobileDestinationUrl => $mobileDestinationUrl,
|
16
|
+
:mobileDisplayUrl=> URI($mobileDestinationUrl).host
|
17
|
+
}
|
18
|
+
# {:creativeTypes=>[{
|
19
|
+
# :creativeId=>"long",
|
20
|
+
# :adgroupId=>"long",
|
21
|
+
# :title=>"string",
|
22
|
+
# :description1=>"string",
|
23
|
+
# :description2=>"string",
|
24
|
+
# :pcDestinationUrl=>"string",
|
25
|
+
# :pcDisplayUrl=>"string",
|
26
|
+
# :mobileDestinationUrl=>"string",
|
27
|
+
# :mobileDisplayUrl=>"string",
|
28
|
+
# :pause=>"boolean",
|
29
|
+
# :status=>"int"}]
|
30
|
+
# }
|
31
|
+
# }
|
32
|
+
|
33
|
+
# puts subject.example('addCreative')
|
34
|
+
response = subject.addCreative({:creativeTypes => [creativeType]})
|
35
|
+
response.status.should == 0
|
36
|
+
response.desc.should == 'success'
|
37
|
+
response.quota.should == 2
|
38
|
+
response.rquota.should > 0
|
39
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
40
|
+
|
41
|
+
creative_id = response.body[:creative_types][:creative_id]
|
42
|
+
|
43
|
+
|
44
|
+
# updateCreative
|
45
|
+
creativeType = {
|
46
|
+
:creativeId=>creative_id,
|
47
|
+
:title => new_title,
|
48
|
+
:description1 => '艺龙酒店测试创意首行测试创意首行测试创意首行',
|
49
|
+
:description2 => '艺龙酒店测试创意首行测试创意首行测试创意次行',
|
50
|
+
:pcDestinationUrl => 'http://hotel.elong.com/beijing/'
|
51
|
+
}
|
52
|
+
response = subject.updateCreative(:creativeTypes => [creativeType])
|
53
|
+
response.status.should == 0
|
54
|
+
response.desc.should == 'success'
|
55
|
+
response.quota.should == 2
|
56
|
+
response.rquota.should > 0
|
57
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
58
|
+
|
59
|
+
#getCreativeByCreativeId
|
60
|
+
sleep 3
|
61
|
+
response = subject.getCreativeByCreativeId(:creativeIds => [creative_id])
|
62
|
+
response.status.should == 0
|
63
|
+
response.desc.should == 'success'
|
64
|
+
response.quota.should == 2
|
65
|
+
response.rquota.should > 0
|
66
|
+
response.body[:creative_types][:title].should == new_title
|
67
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
68
|
+
|
69
|
+
#deleteCreative
|
70
|
+
response = subject.deleteCreative({:creativeIds => [creative_id]})
|
71
|
+
response.status.should == 0
|
72
|
+
response.desc.should == 'success'
|
73
|
+
response.quota.should == 2
|
74
|
+
response.rquota.should > 0
|
75
|
+
response.body[:result].should == '1'
|
76
|
+
expect{ApiResponse.verify(response.body)}.not_to raise_error
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|