ppc 1.3.0 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/LICENSE +334 -17
- data/README.md +75 -3
- data/lib/ppc.rb +3 -1
- data/lib/ppc/api.rb +137 -2
- data/lib/ppc/api/baidu.rb +20 -99
- data/lib/ppc/api/baidu/account.rb +21 -21
- data/lib/ppc/api/baidu/bulk.rb +39 -3
- data/lib/ppc/api/baidu/creative.rb +33 -33
- data/lib/ppc/api/baidu/group.rb +14 -14
- data/lib/ppc/api/baidu/keyword.rb +57 -46
- data/lib/ppc/api/baidu/phone_new_creative.rb +51 -0
- data/lib/ppc/api/baidu/plan.rb +34 -31
- data/lib/ppc/api/baidu/rank.rb +23 -0
- data/lib/ppc/api/baidu/report.rb +100 -81
- data/lib/ppc/api/qihu.rb +150 -0
- data/lib/ppc/api/qihu/account.rb +86 -0
- data/lib/ppc/api/qihu/bulk.rb +35 -0
- data/lib/ppc/api/qihu/creative.rb +108 -0
- data/lib/ppc/api/qihu/group.rb +96 -0
- data/lib/ppc/api/qihu/keyword.rb +113 -0
- data/lib/ppc/api/qihu/plan.rb +64 -0
- data/lib/ppc/api/qihu/rank.rb +25 -0
- data/lib/ppc/api/qihu/report.rb +159 -0
- data/lib/ppc/api/qihu/sublink.rb +71 -0
- data/lib/ppc/api/shenma.rb +64 -0
- data/lib/ppc/api/shenma/report.rb +135 -0
- data/lib/ppc/api/sm.rb +50 -0
- data/lib/ppc/api/sm/account.rb +44 -0
- data/lib/ppc/api/sm/bulk.rb +69 -0
- data/lib/ppc/api/sm/creative.rb +86 -0
- data/lib/ppc/api/sm/group.rb +94 -0
- data/lib/ppc/api/sm/keyword.rb +132 -0
- data/lib/ppc/api/sm/phone_new_creative.rb +51 -0
- data/lib/ppc/api/sm/plan.rb +63 -0
- data/lib/ppc/api/sm/report.rb +136 -0
- data/lib/ppc/api/sogou.rb +118 -0
- data/lib/ppc/api/sogou/account.rb +42 -0
- data/lib/ppc/api/sogou/bulk.rb +69 -0
- data/lib/ppc/api/sogou/creative.rb +117 -0
- data/lib/ppc/api/sogou/group.rb +123 -0
- data/lib/ppc/api/sogou/keyword.rb +188 -0
- data/lib/ppc/api/sogou/plan.rb +66 -0
- data/lib/ppc/api/sogou/report.rb +129 -0
- data/lib/ppc/ext.rb +17 -0
- data/lib/ppc/operation.rb +50 -36
- data/lib/ppc/operation/account.rb +19 -7
- data/lib/ppc/operation/creative.rb +7 -7
- data/lib/ppc/operation/group.rb +2 -2
- data/lib/ppc/operation/keyword.rb +11 -8
- data/lib/ppc/operation/report.rb +23 -0
- data/ppc.gemspec +14 -4
- data/spec/baidu/api_baidu_account_spec.rb +16 -0
- data/spec/baidu/api_baidu_creative_spec.rb +73 -0
- data/spec/{api_baidu_group_spec.rb → baidu/api_baidu_group_spec.rb} +12 -17
- data/spec/baidu/api_baidu_keyword_spec.rb +61 -0
- data/spec/baidu/api_baidu_phone_spec.rb +22 -0
- data/spec/{api_baidu_plan_spec.rb → baidu/api_baidu_plan_spec.rb} +11 -10
- data/spec/baidu/api_baidu_report_spec.rb +44 -0
- data/spec/{api_baidu_spec.rb → baidu/api_baidu_spec.rb} +10 -15
- data/spec/operation/operation_baidu_report_spec.rb +17 -0
- data/spec/operation/operation_baidu_spec.rb +126 -0
- data/spec/operation/operation_qihu_report_spec.rb +18 -0
- data/spec/operation/operation_qihu_spec.rb +94 -0
- data/spec/operation/operation_sm_report_spec.rb +21 -0
- data/spec/operation/operation_sogou_report_spec.rb +17 -0
- data/spec/operation/operation_sogou_spec.rb +88 -0
- data/spec/{operation_spec_helper.rb → operation/operation_spec_helper.rb} +3 -5
- data/spec/qihu/api_qihu_account_spec.rb +29 -0
- data/spec/qihu/api_qihu_creative_spec.rb +48 -0
- data/spec/qihu/api_qihu_group_spec.rb +40 -0
- data/spec/qihu/api_qihu_keyword_spec.rb +50 -0
- data/spec/qihu/api_qihu_plan_spec.rb +39 -0
- data/spec/qihu/api_qihu_report_spec.rb +54 -0
- data/spec/qihu/api_qihu_sublink_spec.rb +36 -0
- data/spec/sm/api_sm_account_spec.rb +8 -0
- data/spec/sm/api_sm_creative_spec.rb +52 -0
- data/spec/sm/api_sm_group_spec.rb +75 -0
- data/spec/sm/api_sm_keyword_spec.rb +59 -0
- data/spec/sm/api_sm_plan_spec.rb +39 -0
- data/spec/sm/api_sm_report_spec.rb +30 -0
- data/spec/sogou/api_sogou_account_spec.rb +17 -0
- data/spec/sogou/api_sogou_creative_spec.rb +51 -0
- data/spec/sogou/api_sogou_group_spec.rb +50 -0
- data/spec/sogou/api_sogou_keyword_spec.rb +54 -0
- data/spec/sogou/api_sogou_plan_spec.rb +43 -0
- data/spec/sogou/api_sogou_report_spec.rb +51 -0
- data/spec/spec_helper.rb +49 -10
- metadata +140 -46
- data/lib/ppc/baidu.rb +0 -152
- data/lib/ppc/baidu/account.rb +0 -88
- data/lib/ppc/baidu/bulk.rb +0 -52
- data/lib/ppc/baidu/group.rb +0 -99
- data/lib/ppc/baidu/key.rb +0 -38
- data/lib/ppc/baidu/plan.rb +0 -85
- data/lib/ppc/baidu/report.rb +0 -82
- data/spec/api_baidu_account_spec.rb +0 -18
- data/spec/api_baidu_creative_spec.rb +0 -71
- data/spec/api_baidu_keyword_spec.rb +0 -64
- data/spec/api_baidu_report_spec.rb +0 -32
- data/spec/baidu_account_spec.rb +0 -32
- data/spec/baidu_bulk_spec.rb +0 -21
- data/spec/baidu_group_spec.rb +0 -56
- data/spec/baidu_plan_spec.rb +0 -129
- data/spec/baidu_report_spec.rb +0 -24
- data/spec/operation_spec.rb +0 -87
@@ -0,0 +1,40 @@
|
|
1
|
+
describe ::PPC::API::Qihu::Group do
|
2
|
+
auth = $qihu_auth
|
3
|
+
|
4
|
+
test_plan_id = ::PPC::API::Qihu::Plan::ids( auth )[:result][0].to_i
|
5
|
+
test_group_id = 0
|
6
|
+
|
7
|
+
it 'can add a group' do
|
8
|
+
group = { plan_id:test_plan_id, name:'testGroup', price:999}
|
9
|
+
response = ::PPC::API::Qihu::Group::add( auth, group)
|
10
|
+
is_success(response)
|
11
|
+
test_group_id = response[:result][0][:id]
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'can update a group' do
|
15
|
+
group = { id: test_group_id, price:990}
|
16
|
+
response = ::PPC::API::Qihu::Group::update( auth, group )
|
17
|
+
is_success(response)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'can get a group' do
|
21
|
+
response = ::PPC::API::Qihu::Group::get( auth, test_group_id )
|
22
|
+
is_success( response )
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can search id by plan id ' do
|
26
|
+
response = ::PPC::API::Qihu::Group::search_id_by_plan_id( auth, test_plan_id )
|
27
|
+
is_success( response )
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'can search by plan id ' do
|
31
|
+
response = ::PPC::API::Qihu::Group::search_by_plan_id( auth, test_plan_id )
|
32
|
+
is_success( response )
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can delete a group' do
|
36
|
+
response = ::PPC::API::Qihu::Group::delete( auth, test_group_id)
|
37
|
+
is_success( response )
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
describe ::PPC::API::Qihu::Keyword do
|
2
|
+
auth = $qihu_auth
|
3
|
+
|
4
|
+
test_plan_id = ::PPC::API::Qihu::Plan::ids( auth )[:result][0].to_i
|
5
|
+
test_group_id = ::PPC::API::Qihu::Group::search_id_by_plan_id( auth, test_plan_id )[:result][0][:group_ids][0].to_i
|
6
|
+
test_keyword_id = 0
|
7
|
+
|
8
|
+
it 'can search keyword id by group id' do
|
9
|
+
response = ::PPC::API::Qihu::Keyword::search_id_by_group_id( auth, test_group_id )
|
10
|
+
is_success( response)
|
11
|
+
expect( response[:result].class ).to eq Array
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'can search keyword by group id' do
|
15
|
+
response = ::PPC::API::Qihu::Keyword::search_by_group_id( auth, test_group_id )
|
16
|
+
is_success( response)
|
17
|
+
expect( response[:result].class ).to eq Array
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'can add keyword' do
|
21
|
+
keyword1 = { group_id:test_group_id, keyword:"testKeyword1",price:0.3,match_type:"exact"}
|
22
|
+
response = ::PPC::API::Qihu::Keyword::add( auth, keyword1)
|
23
|
+
p response
|
24
|
+
is_success( response )
|
25
|
+
test_keyword_id = response[:result][0][:id]
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'can update keyword' do
|
29
|
+
keyword = { id:test_keyword_id, price:0.4 }
|
30
|
+
response = ::PPC::API::Qihu::Keyword::update( auth, keyword )
|
31
|
+
is_success( response )
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'can get keyword' do
|
35
|
+
response = ::PPC::API::Qihu::Keyword::get( auth, [test_keyword_id] )
|
36
|
+
is_success( response )
|
37
|
+
expect( response[:result][0].keys ).to include( :id, :status )
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'can get status' do
|
41
|
+
response = ::PPC::API::Qihu::Keyword::status( auth, [test_keyword_id] )
|
42
|
+
is_success( response )
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'can delete keyword' do
|
46
|
+
response = ::PPC::API::Qihu::Keyword::delete( auth, [test_keyword_id] )
|
47
|
+
is_success( response )
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
describe ::PPC::API::Qihu::Plan do
|
2
|
+
auth = $qihu_auth
|
3
|
+
#::PPC::API::Qihu.debug_on
|
4
|
+
test_plan_id = 0
|
5
|
+
|
6
|
+
it ' can get all plan ids ' do
|
7
|
+
response = ::PPC::API::Qihu::Plan::ids( auth )
|
8
|
+
is_success( response )
|
9
|
+
expect( response[:result].class ).to eq Array
|
10
|
+
end
|
11
|
+
|
12
|
+
it ' can get all plans ' do
|
13
|
+
response = ::PPC::API::Qihu::Plan::all( auth )
|
14
|
+
is_success( response )
|
15
|
+
expect( response[:result].class ).to eq Array
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'can add a plan' do
|
19
|
+
response = ::PPC::API::Qihu::Plan::add( auth, {name:'planForTest'})
|
20
|
+
is_success( response )
|
21
|
+
test_plan_id = response[:result][0][:id]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'can get a plan' do
|
25
|
+
response = ::PPC::API::Qihu::Plan::get( auth, [test_plan_id] )
|
26
|
+
is_success( response )
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can update a plan' do
|
30
|
+
response = ::PPC::API::Qihu::Plan::update( auth, { id:test_plan_id, name:'planUpdateTest' } )
|
31
|
+
is_success( response )
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'can delete a plan ' do
|
35
|
+
response = ::PPC::API::Qihu::Plan::delete( auth , test_plan_id )
|
36
|
+
is_success( response )
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
describe ::PPC::API::Qihu::Report do
|
2
|
+
auth = $qihu_auth
|
3
|
+
|
4
|
+
# param for test
|
5
|
+
|
6
|
+
# all method of query return 403 forbidden
|
7
|
+
type_list = ['keyword', 'creative', 'sublink']
|
8
|
+
method_list = ['','_now','_now_count','_count']
|
9
|
+
|
10
|
+
startDate = (Time.now - 5*24*3600).to_s[0...10].split('-').join
|
11
|
+
endDate = (Time.now - 2*24*3600).to_s[0...10].split('-').join
|
12
|
+
param = {level:"account", startDate:startDate, endDate:endDate}
|
13
|
+
|
14
|
+
############################
|
15
|
+
# test for Web Service API #
|
16
|
+
############################
|
17
|
+
it "has an workable abstract function" do
|
18
|
+
response = ::PPC::API::Qihu::Report.abstract( auth,'keyword','keywordNowCount','',{})
|
19
|
+
expect(response[:result][0].keys).to eq [:total_num,:total_page]
|
20
|
+
end
|
21
|
+
|
22
|
+
it "have all methods for each report type" do
|
23
|
+
method_list.each do |method|
|
24
|
+
type_list.each do |type|
|
25
|
+
method_name = type+method
|
26
|
+
method_name = method_name.to_sym
|
27
|
+
p ::PPC::API::Qihu::Report.send( method_name, auth, param)
|
28
|
+
# is_success( response )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
################################
|
34
|
+
# test for Operation interface #
|
35
|
+
################################
|
36
|
+
it 'can download report' do
|
37
|
+
report = ::PPC::API::Qihu::Report.download_report( auth, 'keyword', param )
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'can download keyword report' do
|
41
|
+
report = ::PPC::API::Qihu::Report.keyword_report( auth, param )
|
42
|
+
f = open('keyword.txt','w')
|
43
|
+
f.puts report
|
44
|
+
f.close
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'can download creative report' do
|
48
|
+
report = ::PPC::API::Qihu::Report.creative_report( auth, param )
|
49
|
+
f = open('creative.txt','w')
|
50
|
+
f.puts report
|
51
|
+
f.close
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
describe ::PPC::API::Qihu::Sublink do
|
2
|
+
auth = $qihu_auth
|
3
|
+
|
4
|
+
test_plan_id = ::PPC::API::Qihu::Plan::ids( auth )[:result][0].to_i
|
5
|
+
test_group_id = ::PPC::API::Qihu::Group::search_id_by_plan_id( auth, test_plan_id )[:result][0][:group_ids][0].to_i
|
6
|
+
test_sublink_id = 0
|
7
|
+
|
8
|
+
it 'can add a sublink' do
|
9
|
+
sublink1 = {
|
10
|
+
group_id:test_group_id,
|
11
|
+
anchor: "shushide",
|
12
|
+
url: 'http://hotel.elong.com'
|
13
|
+
}
|
14
|
+
response = ::PPC::API::Qihu::Sublink::add( auth, sublink1)
|
15
|
+
is_success( response )
|
16
|
+
test_sublink_id = response[:result][0][:id]
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'can update a sublink' do
|
20
|
+
sublink = { id: test_sublink_id, anchor: 'testaaaaa' }
|
21
|
+
response = ::PPC::API::Qihu::Sublink::update( auth, sublink )
|
22
|
+
is_success( response )
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can get sublinks' do
|
26
|
+
response = ::PPC::API::Qihu::Sublink::get( auth, test_sublink_id )
|
27
|
+
is_success( response )
|
28
|
+
expect( response[:result][0].keys ).to include( :id, :anchor )
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'can delete a sublink' do
|
32
|
+
response = ::PPC::API::Qihu::Sublink::delete( auth, test_sublink_id )
|
33
|
+
is_success( response )
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
describe ::PPC::API::Sm::Creative do
|
2
|
+
auth = $sm_auth
|
3
|
+
creative_service = ::PPC::API::Sm::Creative
|
4
|
+
test_creative_id = 0
|
5
|
+
test_plan_id = ::PPC::API::Sm::Plan.ids(auth)[:result][0]
|
6
|
+
test_group_id = ::PPC::API::Sm::Group.search_id_by_plan_id(auth, test_plan_id)[:result][0][:group_ids][0]
|
7
|
+
|
8
|
+
it "can get ids by group id " do
|
9
|
+
response = creative_service.search_id_by_group_id(auth, test_group_id)
|
10
|
+
p response
|
11
|
+
expect(response[:succ]).to be true
|
12
|
+
expect(response[:result][0][:group_id] == test_group_id).to be true
|
13
|
+
expect(response[:result][0][:creative_ids].is_a? Array).to be true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can get by group id" do
|
17
|
+
response = creative_service.search_by_group_id(auth, test_group_id)
|
18
|
+
p response
|
19
|
+
expect(response[:succ]).to be true
|
20
|
+
expect(response[:result][0][:group_id] == test_group_id).to be true
|
21
|
+
expect(response[:result][0][:creatives].is_a? Array).to be true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can add a new creative" do
|
25
|
+
response = creative_service.add(auth, {group_id: test_group_id, title: 'test title', description1: 'test desc1', mobile_destination: 'http://m.elong.com', mobile_display: 'm.elong.com', pause: true})
|
26
|
+
p response
|
27
|
+
expect(response[:succ]).to be true
|
28
|
+
expect(response[:result][0][:id]).to be > 0
|
29
|
+
test_creative_id = response[:result][0][:id]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can update a creative" do
|
33
|
+
response = creative_service.update(auth, {id: test_creative_id, title: 'test tttt', description1: 'xxxxxxxxxxx', mobile_destination: 'http://m.elong.com'})
|
34
|
+
p response
|
35
|
+
expect(response[:succ]).to be true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can get a creative by id" do
|
39
|
+
response = creative_service.get(auth, test_creative_id)
|
40
|
+
p response
|
41
|
+
expect(response[:succ]).to be true
|
42
|
+
expect(response[:result][0][:title]).to eql 'test tttt'
|
43
|
+
expect(response[:result][0][:pause]).to be true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "can delete a creative by id" do
|
47
|
+
response = creative_service.delete(auth, test_creative_id)
|
48
|
+
p response
|
49
|
+
expect(response[:succ]).to be true
|
50
|
+
expect(response[:result]).to eql 0
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
describe ::PPC::API::Sm::Group do
|
2
|
+
auth = $sm_auth
|
3
|
+
group_service = ::PPC::API::Sm::Group
|
4
|
+
test_group_id = 0
|
5
|
+
test_plan_id = 0
|
6
|
+
|
7
|
+
it "can get all group ids" do
|
8
|
+
response = group_service.ids(auth)
|
9
|
+
p response
|
10
|
+
expect(response[:succ]).to be true
|
11
|
+
plan_group_ids_0 = response[:result][0]
|
12
|
+
plan_id = plan_group_ids_0[:plan_id]
|
13
|
+
expect(plan_id).to be > 0
|
14
|
+
test_plan_id = plan_id
|
15
|
+
group_ids = plan_group_ids_0[:group_ids]
|
16
|
+
expect(group_ids.is_a? Array).to be true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "can get ids by plan id" do
|
20
|
+
response = group_service.search_id_by_plan_id(auth, test_plan_id)
|
21
|
+
p response
|
22
|
+
expect(response[:succ]).to be true
|
23
|
+
plan_group_ids_0 = response[:result][0]
|
24
|
+
plan_id = plan_group_ids_0[:plan_id]
|
25
|
+
expect(plan_id == test_plan_id).to be true
|
26
|
+
group_ids = plan_group_ids_0[:group_ids]
|
27
|
+
expect(group_ids.is_a? Array).to be true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "can get groups by plan id" do
|
31
|
+
response = group_service.search_by_plan_id(auth, test_plan_id)
|
32
|
+
p response
|
33
|
+
expect(response[:succ]).to be true
|
34
|
+
plan_groups_0 = response[:result][0]
|
35
|
+
plan_id = plan_groups_0[:plan_id]
|
36
|
+
expect(plan_id == test_plan_id).to be true
|
37
|
+
groups = plan_groups_0[:groups]
|
38
|
+
expect(groups.is_a? Array).to be true
|
39
|
+
expect(groups[0][:id]).to be > 0
|
40
|
+
end
|
41
|
+
|
42
|
+
it "can add a new group" do
|
43
|
+
# price 不能为空 os 不能为空
|
44
|
+
response = group_service.add(auth, {plan_id: test_plan_id, name: 'test_x', pause: true, price: 1.0, os: 7})
|
45
|
+
p response
|
46
|
+
expect(response[:succ]).to be true
|
47
|
+
group = response[:result][0]
|
48
|
+
expect(group[:id]).to be > 0
|
49
|
+
expect(group[:pause]).to be true
|
50
|
+
test_group_id = group[:id]
|
51
|
+
end
|
52
|
+
|
53
|
+
it "can update a group" do
|
54
|
+
response = group_service.update(auth, {id: test_group_id, pause: false})
|
55
|
+
p response
|
56
|
+
expect(response[:succ]).to be true
|
57
|
+
group = response[:result][0]
|
58
|
+
expect(group[:pause]).to be false
|
59
|
+
end
|
60
|
+
|
61
|
+
it "can get a group by id" do
|
62
|
+
response = group_service.get(auth, test_group_id)
|
63
|
+
p response
|
64
|
+
expect(response[:succ]).to be true
|
65
|
+
group = response[:result][0]
|
66
|
+
expect(group[:name]).to eql 'test_x'
|
67
|
+
end
|
68
|
+
|
69
|
+
it "can delete a group by id" do
|
70
|
+
response = group_service.delete(auth, test_group_id)
|
71
|
+
p response
|
72
|
+
expect(response[:succ]).to be true
|
73
|
+
expect(response[:result]).to eql 0
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
describe ::PPC::API::Sm::Keyword do
|
2
|
+
auth = $sm_auth
|
3
|
+
keyword_service = ::PPC::API::Sm::Keyword
|
4
|
+
test_keyword_id = 0
|
5
|
+
test_plan_id = ::PPC::API::Sm::Plan.ids(auth)[:result][0]
|
6
|
+
test_group_id = ::PPC::API::Sm::Group.search_id_by_plan_id(auth, test_plan_id)[:result][0][:group_ids][0]
|
7
|
+
it "can get ids by group id" do
|
8
|
+
response = keyword_service.search_id_by_group_id(auth, test_group_id)
|
9
|
+
p response
|
10
|
+
expect(response[:succ]).to be true
|
11
|
+
group_id = response[:result][0][:group_id]
|
12
|
+
expect(group_id == test_group_id).to be true
|
13
|
+
expect(response[:result][0][:keyword_ids].is_a? Array).to be true
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can get by group id" do
|
17
|
+
response = keyword_service.search_by_group_id(auth, test_group_id)
|
18
|
+
p response
|
19
|
+
expect(response[:succ]).to be true
|
20
|
+
expect(response[:succ]).to be true
|
21
|
+
group_id = response[:result][0][:group_id]
|
22
|
+
expect(group_id == test_group_id).to be true
|
23
|
+
expect(response[:result][0][:keywords].is_a? Array).to be true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "can add a new keyword" do
|
27
|
+
response = keyword_service.add(auth, {group_id: test_group_id, keyword: 'testtest1', mobile_destination: 'http://m.elong.com', match_type: 'exact', pause: true, price: 1.2})
|
28
|
+
p response
|
29
|
+
expect(response[:succ]).to be true
|
30
|
+
expect(response[:succ]).to be true
|
31
|
+
expect(response[:result][0][:id]).to be > 0
|
32
|
+
test_keyword_id = response[:result][0][:id]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "can update a keyword" do
|
36
|
+
response = keyword_service.update(auth, {id: test_keyword_id, price: 2})
|
37
|
+
p response
|
38
|
+
expect(response[:succ]).to be true
|
39
|
+
expect(response[:succ]).to be true
|
40
|
+
expect(response[:result][0][:price] == 2).to be true
|
41
|
+
end
|
42
|
+
|
43
|
+
it "can get by id" do
|
44
|
+
response = keyword_service.get(auth, test_keyword_id)
|
45
|
+
p response
|
46
|
+
expect(response[:succ]).to be true
|
47
|
+
expect(response[:succ]).to be true
|
48
|
+
expect(response[:result][0][:keyword]).to eql 'testtest1'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "can delete by id" do
|
52
|
+
response = keyword_service.delete(auth, test_keyword_id)
|
53
|
+
p response
|
54
|
+
expect(response[:succ]).to be true
|
55
|
+
expect(response[:succ]).to be true
|
56
|
+
expect(response[:result]).to eql 0
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
describe ::PPC::API::Sm::Plan do
|
2
|
+
|
3
|
+
auth = $sm_auth
|
4
|
+
test_plan_id = 0
|
5
|
+
plan_service = ::PPC::API::Sm::Plan
|
6
|
+
|
7
|
+
it "can get all plans" do
|
8
|
+
response = plan_service.all( auth )
|
9
|
+
p response
|
10
|
+
expect(response[:succ]).to be true
|
11
|
+
end
|
12
|
+
it "can get all plan ids" do
|
13
|
+
response = plan_service.ids( auth )
|
14
|
+
p response
|
15
|
+
expect(response[:succ]).to be true
|
16
|
+
expect(response[:result].is_a? Array).to be true
|
17
|
+
end
|
18
|
+
it "can add a new plan and get its id" do
|
19
|
+
response = plan_service.add(auth, {name: 'test_2', pause: true})
|
20
|
+
p response
|
21
|
+
expect(response[:succ]).to be true
|
22
|
+
new_plan = response[:result][0]
|
23
|
+
expect(new_plan.class).to eql Hash
|
24
|
+
expect(new_plan[:id]).to be > 0
|
25
|
+
test_plan_id = new_plan[:id]
|
26
|
+
end
|
27
|
+
it "can get a plan by id" do
|
28
|
+
response = plan_service.get(auth, test_plan_id)
|
29
|
+
p response
|
30
|
+
plan = response[:result][0]
|
31
|
+
expect(plan.class).to eql Hash
|
32
|
+
expect(plan[:pause]).to be true
|
33
|
+
end
|
34
|
+
it "can delete a plan by id" do
|
35
|
+
response = plan_service.delete(auth, test_plan_id)
|
36
|
+
p response
|
37
|
+
expect(response[:succ]).to be true
|
38
|
+
end
|
39
|
+
end
|