ppc 1.3.0 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/LICENSE +334 -17
  4. data/README.md +75 -3
  5. data/lib/ppc.rb +3 -1
  6. data/lib/ppc/api.rb +137 -2
  7. data/lib/ppc/api/baidu.rb +20 -99
  8. data/lib/ppc/api/baidu/account.rb +21 -21
  9. data/lib/ppc/api/baidu/bulk.rb +39 -3
  10. data/lib/ppc/api/baidu/creative.rb +33 -33
  11. data/lib/ppc/api/baidu/group.rb +14 -14
  12. data/lib/ppc/api/baidu/keyword.rb +57 -46
  13. data/lib/ppc/api/baidu/phone_new_creative.rb +51 -0
  14. data/lib/ppc/api/baidu/plan.rb +34 -31
  15. data/lib/ppc/api/baidu/rank.rb +23 -0
  16. data/lib/ppc/api/baidu/report.rb +100 -81
  17. data/lib/ppc/api/qihu.rb +150 -0
  18. data/lib/ppc/api/qihu/account.rb +86 -0
  19. data/lib/ppc/api/qihu/bulk.rb +35 -0
  20. data/lib/ppc/api/qihu/creative.rb +108 -0
  21. data/lib/ppc/api/qihu/group.rb +96 -0
  22. data/lib/ppc/api/qihu/keyword.rb +113 -0
  23. data/lib/ppc/api/qihu/plan.rb +64 -0
  24. data/lib/ppc/api/qihu/rank.rb +25 -0
  25. data/lib/ppc/api/qihu/report.rb +159 -0
  26. data/lib/ppc/api/qihu/sublink.rb +71 -0
  27. data/lib/ppc/api/shenma.rb +64 -0
  28. data/lib/ppc/api/shenma/report.rb +135 -0
  29. data/lib/ppc/api/sm.rb +50 -0
  30. data/lib/ppc/api/sm/account.rb +44 -0
  31. data/lib/ppc/api/sm/bulk.rb +69 -0
  32. data/lib/ppc/api/sm/creative.rb +86 -0
  33. data/lib/ppc/api/sm/group.rb +94 -0
  34. data/lib/ppc/api/sm/keyword.rb +132 -0
  35. data/lib/ppc/api/sm/phone_new_creative.rb +51 -0
  36. data/lib/ppc/api/sm/plan.rb +63 -0
  37. data/lib/ppc/api/sm/report.rb +136 -0
  38. data/lib/ppc/api/sogou.rb +118 -0
  39. data/lib/ppc/api/sogou/account.rb +42 -0
  40. data/lib/ppc/api/sogou/bulk.rb +69 -0
  41. data/lib/ppc/api/sogou/creative.rb +117 -0
  42. data/lib/ppc/api/sogou/group.rb +123 -0
  43. data/lib/ppc/api/sogou/keyword.rb +188 -0
  44. data/lib/ppc/api/sogou/plan.rb +66 -0
  45. data/lib/ppc/api/sogou/report.rb +129 -0
  46. data/lib/ppc/ext.rb +17 -0
  47. data/lib/ppc/operation.rb +50 -36
  48. data/lib/ppc/operation/account.rb +19 -7
  49. data/lib/ppc/operation/creative.rb +7 -7
  50. data/lib/ppc/operation/group.rb +2 -2
  51. data/lib/ppc/operation/keyword.rb +11 -8
  52. data/lib/ppc/operation/report.rb +23 -0
  53. data/ppc.gemspec +14 -4
  54. data/spec/baidu/api_baidu_account_spec.rb +16 -0
  55. data/spec/baidu/api_baidu_creative_spec.rb +73 -0
  56. data/spec/{api_baidu_group_spec.rb → baidu/api_baidu_group_spec.rb} +12 -17
  57. data/spec/baidu/api_baidu_keyword_spec.rb +61 -0
  58. data/spec/baidu/api_baidu_phone_spec.rb +22 -0
  59. data/spec/{api_baidu_plan_spec.rb → baidu/api_baidu_plan_spec.rb} +11 -10
  60. data/spec/baidu/api_baidu_report_spec.rb +44 -0
  61. data/spec/{api_baidu_spec.rb → baidu/api_baidu_spec.rb} +10 -15
  62. data/spec/operation/operation_baidu_report_spec.rb +17 -0
  63. data/spec/operation/operation_baidu_spec.rb +126 -0
  64. data/spec/operation/operation_qihu_report_spec.rb +18 -0
  65. data/spec/operation/operation_qihu_spec.rb +94 -0
  66. data/spec/operation/operation_sm_report_spec.rb +21 -0
  67. data/spec/operation/operation_sogou_report_spec.rb +17 -0
  68. data/spec/operation/operation_sogou_spec.rb +88 -0
  69. data/spec/{operation_spec_helper.rb → operation/operation_spec_helper.rb} +3 -5
  70. data/spec/qihu/api_qihu_account_spec.rb +29 -0
  71. data/spec/qihu/api_qihu_creative_spec.rb +48 -0
  72. data/spec/qihu/api_qihu_group_spec.rb +40 -0
  73. data/spec/qihu/api_qihu_keyword_spec.rb +50 -0
  74. data/spec/qihu/api_qihu_plan_spec.rb +39 -0
  75. data/spec/qihu/api_qihu_report_spec.rb +54 -0
  76. data/spec/qihu/api_qihu_sublink_spec.rb +36 -0
  77. data/spec/sm/api_sm_account_spec.rb +8 -0
  78. data/spec/sm/api_sm_creative_spec.rb +52 -0
  79. data/spec/sm/api_sm_group_spec.rb +75 -0
  80. data/spec/sm/api_sm_keyword_spec.rb +59 -0
  81. data/spec/sm/api_sm_plan_spec.rb +39 -0
  82. data/spec/sm/api_sm_report_spec.rb +30 -0
  83. data/spec/sogou/api_sogou_account_spec.rb +17 -0
  84. data/spec/sogou/api_sogou_creative_spec.rb +51 -0
  85. data/spec/sogou/api_sogou_group_spec.rb +50 -0
  86. data/spec/sogou/api_sogou_keyword_spec.rb +54 -0
  87. data/spec/sogou/api_sogou_plan_spec.rb +43 -0
  88. data/spec/sogou/api_sogou_report_spec.rb +51 -0
  89. data/spec/spec_helper.rb +49 -10
  90. metadata +140 -46
  91. data/lib/ppc/baidu.rb +0 -152
  92. data/lib/ppc/baidu/account.rb +0 -88
  93. data/lib/ppc/baidu/bulk.rb +0 -52
  94. data/lib/ppc/baidu/group.rb +0 -99
  95. data/lib/ppc/baidu/key.rb +0 -38
  96. data/lib/ppc/baidu/plan.rb +0 -85
  97. data/lib/ppc/baidu/report.rb +0 -82
  98. data/spec/api_baidu_account_spec.rb +0 -18
  99. data/spec/api_baidu_creative_spec.rb +0 -71
  100. data/spec/api_baidu_keyword_spec.rb +0 -64
  101. data/spec/api_baidu_report_spec.rb +0 -32
  102. data/spec/baidu_account_spec.rb +0 -32
  103. data/spec/baidu_bulk_spec.rb +0 -21
  104. data/spec/baidu_group_spec.rb +0 -56
  105. data/spec/baidu_plan_spec.rb +0 -129
  106. data/spec/baidu_report_spec.rb +0 -24
  107. data/spec/operation_spec.rb +0 -87
@@ -0,0 +1,23 @@
1
+ module PPC
2
+ module Operation
3
+ module Report
4
+
5
+ def download_report( param = nil, debug = false )
6
+ call('report').download_report( @auth, param, debug )
7
+ end
8
+
9
+ def query_report( param = nil, debug = false )
10
+ call('report').query_report( @auth, param, debug )
11
+ end
12
+
13
+ def creative_report( param = nil, debug = false )
14
+ call('report').creative_report( @auth, param, debug )
15
+ end
16
+
17
+ def keyword_report( param = nil, debug = false )
18
+ call('report').keyword_report( @auth, param, debug )
19
+ end
20
+
21
+ end
22
+ end
23
+ end
data/ppc.gemspec CHANGED
@@ -1,7 +1,16 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ # require ppc for version
4
6
  require 'ppc'
7
+
8
+ puts """################ WARNING #################
9
+ # Savon 3.0 is not avaliable on gem source.
10
+ # Please download it from github,
11
+ # checkout savon3 branch and install manually.
12
+ ##########################################"""
13
+
5
14
  Gem::Specification.new do |spec|
6
15
  spec.name = "ppc"
7
16
  spec.version = PPC::VERSION
@@ -9,14 +18,15 @@ Gem::Specification.new do |spec|
9
18
  spec.email = ["maqianlie@gmail.com, liuyu_tc@163.com, seoaqua@qq.com"]
10
19
  spec.summary = %q{ppc api for baidu qihu sogou}
11
20
  spec.description = %q{ppc api for baidu qihu sogou}
12
- spec.homepage = "http://github.com/seoaqua/ppc"
13
- spec.license = "MIT"
21
+ spec.homepage = "https://github.com/warriors-of-the-night/ppc"
22
+ spec.license = "GNU"
14
23
 
15
24
  spec.files = `git ls-files -z`.split("\x0")
16
25
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
26
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
27
  spec.require_paths = ["lib"]
19
28
 
20
- spec.add_development_dependency "bundler", "~> 1.6"
21
- spec.add_development_dependency "rake"
29
+ spec.add_dependency 'httparty', '~> 0.13', '>= 0.13.0'
30
+ spec.add_dependency 'savon', '~> 3.0', '>= 3.0.0'
31
+ spec.add_dependency 'awesome_print'
22
32
  end
@@ -0,0 +1,16 @@
1
+ describe ::PPC::API::Baidu::Account do
2
+ auth = $baidu_auth
3
+ #::PPC::API::Baidu.debug_on
4
+
5
+ it 'can get account info' do
6
+ result = ::PPC::API::Baidu::Account::info auth
7
+ is_success result
8
+ end
9
+
10
+ it 'can update account' do
11
+ update = {budget_type: 1, budget: 1000}
12
+ result = ::PPC::API::Baidu::Account::update(auth, update)
13
+ is_success result
14
+ end
15
+
16
+ end
@@ -0,0 +1,73 @@
1
+ # -*- coding:utf-8 -*-
2
+ describe ::PPC::API::Baidu::Creative do
3
+ auth = $baidu_auth
4
+
5
+ ::PPC::API::Baidu::debug_off
6
+ test_group_id = ::PPC::API::Baidu::Group::ids( auth )[:result][0][:group_ids][0]
7
+ test_plan_id = ::PPC::API::Baidu::Plan::all( auth )[:result][0][:plan_id]
8
+ test_creative_id = []
9
+ ::PPC::API::Baidu::debug_on
10
+
11
+ it 'can add creative' do
12
+ creative = {
13
+ group_id: test_group_id,
14
+ title: 'TestCreative', preference:1,
15
+ description1:'this is rest',
16
+ description2:'also is a test',
17
+ pc_destination:$domain,
18
+ pc_display:$domain
19
+ }
20
+ response = ::PPC::API::Baidu::Creative::add( auth, creative )
21
+ is_success( response )
22
+ test_creative_id << response[:result][0][:id]
23
+ end
24
+
25
+ it 'can update creative' do
26
+ update = {
27
+ id:test_creative_id[0],
28
+ title:'ElongUpdateTest',
29
+ description1:'test for update',
30
+ mobile_destination:$domain,
31
+ pc_destination:$domain,
32
+ pause:true
33
+ }
34
+ response = ::PPC::API::Baidu::Creative::update( auth, update )
35
+ is_success( response )
36
+ end
37
+
38
+ it 'can activate creative' do
39
+ response = ::PPC::API::Baidu::Creative::activate( auth, test_creative_id )
40
+ is_success( response )
41
+ end
42
+
43
+ # 连续测试的系统返回system_failured
44
+ # it 'can get status' do
45
+ # response1 = ::PPC::API::Baidu::Creative::status( auth, test_group_id, 'group' )
46
+ # response2 = ::PPC::API::Baidu::Creative::status( auth, test_creative_id, 'creative' )
47
+ # response3 = ::PPC::API::Baidu::Creative::status( auth, test_plan_id, 'plan' )
48
+ # is_success( response1 )
49
+ # is_success( response2 )
50
+ # is_success( response3 )
51
+ # end
52
+
53
+ it 'can search id by group id' do
54
+ response = ::PPC::API::Baidu::Creative::search_id_by_group_id( auth, test_group_id, 0 )
55
+ is_success( response )
56
+ end
57
+
58
+ it 'can search creative by group id' do
59
+ response = ::PPC::API::Baidu::Creative::search_by_group_id( auth, test_group_id, 0 )
60
+ is_success( response )
61
+ end
62
+
63
+ it 'can search creative by creative id' do
64
+ response = ::PPC::API::Baidu::Creative::get( auth, test_creative_id, 0 )
65
+ is_success( response )
66
+ end
67
+
68
+ it 'can delete creative' do
69
+ response = ::PPC::API::Baidu::Creative::delete( auth, test_creative_id )
70
+ is_success( response )
71
+ end
72
+
73
+ end
@@ -1,49 +1,44 @@
1
1
  describe ::PPC::API::Baidu::Group do
2
- auth = {}
3
- auth[:username] = $baidu_username
4
- auth[:password] = $baidu_password
5
- auth[:token] = $baidu_token
2
+ auth = $baidu_auth
6
3
 
7
- Test_plan_id = []
8
- Test_group_id = []
4
+ test_plan_id = ::PPC::API::Baidu::Plan.ids(auth)[:result][0]
5
+ test_group_id = []
9
6
 
10
7
  it 'can get all group' do
11
8
  response = ::PPC::API::Baidu::Group::ids( auth )
12
- is_successed( response )
13
- pair = response['body']['campaignAdgroupIds'][0]
14
- Test_plan_id << pair['campaignId']
9
+ is_success( response )
15
10
  end
16
11
 
17
12
  it 'can add group' do
18
- group = { name: 'test_group', plan_id:Test_plan_id[0], price:500 }
13
+ group = { name: 'test_group', plan_id:test_plan_id, price:500 }
19
14
  response = ::PPC::API::Baidu::Group::add( auth, group )
20
15
  is_success( response )
21
- Test_group_id << response[:result][0][:id]
16
+ test_group_id << response[:result][0][:id]
22
17
  end
23
18
 
24
19
  it 'can update group' do
25
- group = { id: Test_group_id[0], price:600 }
20
+ group = { id: test_group_id[0], price:600 }
26
21
  response = ::PPC::API::Baidu::Group::update( auth, group )
27
22
  is_success( response )
28
23
  end
29
24
 
30
25
  it 'can search group by group id' do
31
- response = ::PPC::API::Baidu::Group::get( auth, Test_group_id )
26
+ response = ::PPC::API::Baidu::Group::get( auth, test_group_id )
32
27
  is_success( response )
33
28
  end
34
29
 
35
- it 'can search group id by group id' do
36
- response = ::PPC::API::Baidu::Group::search_id_by_plan_id( auth, Test_plan_id )
30
+ it 'can search group id by plan id' do
31
+ response = ::PPC::API::Baidu::Group::search_id_by_plan_id( auth, test_plan_id )
37
32
  is_success( response )
38
33
  end
39
34
 
40
35
  it 'search by plan id' do
41
- response = ::PPC::API::Baidu::Group::search_by_plan_id( auth, Test_plan_id )
36
+ response = ::PPC::API::Baidu::Group::search_by_plan_id( auth, test_plan_id )
42
37
  is_success( response )
43
38
  end
44
39
 
45
40
  it 'can delete group' do
46
- response = ::PPC::API::Baidu::Group::delete( auth, Test_group_id )
41
+ response = ::PPC::API::Baidu::Group::delete( auth, test_group_id )
47
42
  is_success( response )
48
43
  end
49
44
 
@@ -0,0 +1,61 @@
1
+ # -*- coding:utf-8 -*-
2
+ describe ::PPC::API::Baidu::Keyword do
3
+ auth = $baidu_auth
4
+
5
+ test_group_id = ::PPC::API::Baidu::Group::ids( auth )[:result][0][:group_ids][0]
6
+ test_plan_id = ::PPC::API::Baidu::Plan::all( auth )[:result][0][:plan_id]
7
+ test_keyword_id = []
8
+
9
+ it 'can search keyword by group id' do
10
+ response = ::PPC::API::Baidu::Keyword::search_by_group_id( auth, test_group_id )
11
+ is_success( response )
12
+ end
13
+
14
+ it 'can add keyword' do
15
+ keyword = { group_id: test_group_id, keyword: 'testkeywordid', match_type:'exact' }
16
+ response = ::PPC::API::Baidu::Keyword::add( auth, keyword )
17
+ is_success( response )
18
+ test_keyword_id << response[:result][0][:id]
19
+ end
20
+
21
+ it 'can update keyword' do
22
+ update = { id:test_keyword_id[0], pc_destination: $baidu_domain, pause:true}
23
+ response = ::PPC::API::Baidu::Keyword::update( auth, update )
24
+ is_success( response )
25
+ end
26
+
27
+ it 'can activate keyword' do
28
+ response = ::PPC::API::Baidu::Keyword::activate( auth, test_keyword_id )
29
+ is_success( response )
30
+ end
31
+
32
+ # 连续测试系统返回system failure
33
+ # it 'can get status' do
34
+ # response1 = ::PPC::API::Baidu::Keyword::status( auth, test_group_id, 'group' )
35
+ # response2 = ::PPC::API::Baidu::Keyword::status( auth, test_keyword_id, 'keyword' )
36
+ # response3 = ::PPC::API::Baidu::Keyword::status( auth, test_plan_id, 'plan' )
37
+ # is_success( response1 )
38
+ # is_success( response2 )
39
+ # is_success( response3 )
40
+ # end
41
+
42
+ # it 'can get quality' do
43
+ # response1 = ::PPC::API::Baidu::Keyword::quality( auth, test_group_id, 'group', true )
44
+ # response2 = ::PPC::API::Baidu::Keyword::quality( auth, test_keyword_id, 'keyword', true )
45
+ # response3 = ::PPC::API::Baidu::Keyword::quality( auth, test_plan_id, 'plan', true )
46
+ # is_successed( response1 )
47
+ # is_successed( response2 )
48
+ # is_successed( response3 )
49
+ # end
50
+
51
+ it 'can get 10-quality' do
52
+ response = ::PPC::API::Baidu::Keyword::quality( auth, test_keyword_id, 'keyword', 'pc' )
53
+ is_success( response )
54
+ end
55
+
56
+ it 'can delete keyword' do
57
+ response = ::PPC::API::Baidu::Keyword::delete( auth, test_keyword_id )
58
+ is_success( response )
59
+ end
60
+
61
+ end
@@ -0,0 +1,22 @@
1
+ # -*- coding:utf-8 -*-
2
+ describe ::PPC::API::Baidu::Phone do
3
+ auth = $baidu_auth
4
+
5
+ ::PPC::API::Baidu::debug_off
6
+ test_group_id = ::PPC::API::Baidu::Group::ids( auth )[:result][0][:group_ids][0]
7
+ test_phone_id = 0
8
+ ::PPC::API::Baidu::debug_on
9
+
10
+ it 'can search id by group id' do
11
+ response = ::PPC::API::Baidu::Phone::search_id_by_group_id( auth, test_group_id, 0 )
12
+ test_phone_id = response[:result][0][:phone_ids][0]
13
+ is_success( response )
14
+ end
15
+
16
+ it 'can update' do
17
+ response = ::PPC::API::Baidu::Phone::update( auth, {id: test_phone_id,pause: true})
18
+ p response
19
+ is_success( response )
20
+ end
21
+
22
+ end
@@ -1,10 +1,9 @@
1
1
  describe ::PPC::API::Baidu::Plan do
2
- auth = {}
3
- auth[:username] = $baidu_username
4
- auth[:password] = $baidu_password
5
- auth[:token] = $baidu_token
2
+ auth = $baidu_auth
6
3
 
7
- Test_plan_id = []
4
+ test_plan_id = []
5
+
6
+ #::PPC::API::Baidu.debug_on
8
7
 
9
8
  it "can get all plans" do
10
9
  response = ::PPC::API::Baidu::Plan::all( auth )
@@ -17,25 +16,27 @@ describe ::PPC::API::Baidu::Plan do
17
16
  end
18
17
 
19
18
  it "can add plan" do
20
- test_plan = { name: "test_plan1", negative: ["test"] }
19
+ test_plan = { name: "test_elong_e", negative: ["test"] }
21
20
  response = ::PPC::API::Baidu::Plan::add( auth, test_plan )
22
21
  is_success( response )
23
- Test_plan_id << response['body']['campaignTypes'][0]['campaignId']
22
+ test_plan_id << response[:result][0][:id]
24
23
  end
25
24
 
26
25
  it "can get plan by id" do
27
- response = ::PPC::API::Baidu::Plan::get( auth, Test_plan_id )
26
+ response = ::PPC::API::Baidu::Plan::get( auth, test_plan_id )
28
27
  is_success( response )
29
28
  end
30
29
 
31
30
  it 'can update plan' do
32
- update = { id: Test_plan_id[0], name:"test_plan_update"}
31
+ update = { id: test_plan_id[0], name:"test_plan_update", is_dynamic:false }
33
32
  response = ::PPC::API::Baidu::Plan::update( auth, update )
33
+ # param isDynamicCreative should not be default value
34
+ expect( response[:result][0][:is_dynamic] ).to eq false
34
35
  is_success( response )
35
36
  end
36
37
 
37
38
  it "can delete plan" do
38
- response = ::PPC::API::Baidu::Plan::delete( auth, Test_plan_id )
39
+ response = ::PPC::API::Baidu::Plan::delete( auth, test_plan_id )
39
40
  is_success( response )
40
41
  end
41
42
 
@@ -0,0 +1,44 @@
1
+ describe ::PPC::API::Baidu::Report do
2
+ auth = $baidu_auth
3
+
4
+ test_report_id = []
5
+
6
+ it 'can get professional report id' do
7
+ param = { type: 'plan', level:'plan',range:'plan',unit:'week',device:'all' }
8
+ response = ::PPC::API::Baidu::Report::get_id( auth, param )
9
+ is_success( response )
10
+ test_report_id << response[:result]
11
+ end
12
+
13
+ it 'can get professional report status' do
14
+ response = ::PPC::API::Baidu::Report::get_state( auth, test_report_id[0] )
15
+ is_success( response )
16
+ end
17
+
18
+ # it 'can get professional report download URL' do
19
+ # response = ::PPC::API::Baidu::Report::get_file_url( auth, test_report_id[0] )
20
+ # is_success( response )
21
+ # end
22
+ end
23
+
24
+ describe "::PPC::API::Baidu::Report Operation interface" do
25
+ auth = $baidu_auth
26
+
27
+ subject{
28
+ ::PPC::API::Baidu::Report
29
+ }
30
+ # opetation report test
31
+ it 'can get report' do
32
+ endDate = ( Time.now-2*3600*24).to_s[0..9].split('-').join
33
+ startDate =( Time.now-27*3600*24).to_s[0..9].split('-').join
34
+
35
+ p "startDate:#{startDate}"
36
+ p "endDate:#{endDate}"
37
+
38
+ param = {startDate:startDate, endDate:endDate}
39
+ p subject.query_report( auth, param, true )
40
+ p subject.keyword_report( auth, param, true )
41
+ p subject.creative_report( auth,param, true )
42
+ end
43
+
44
+ end
@@ -12,30 +12,25 @@ describe ::PPC::API::Baidu do
12
12
 
13
13
  response = JSON.parse fake_response
14
14
 
15
- Expected_success_result = [:id, :balance, :cost, :payment,
15
+ expected_success_result = [:id, :balance, :cost, :payment,
16
16
  :budget_type, :budget, :region, :exclude_ip,
17
17
  :open_domains, :reg_domain, :offline_time,
18
18
  :weekly_budget ]
19
19
 
20
- Expected_failure_result = ["code", "message", "position", "content"]
20
+ expected_failure_result = ["code", "message", "position", "content"]
21
21
 
22
22
  it 'can process response' do
23
23
  response = ::PPC::API::Baidu::process( response, 'accountInfoType' ){|x| ::PPC::API::Baidu::Account::reverse_type(x)}
24
-
25
- p "HAHA"*12
26
- p response
27
-
28
- expect( response[:result][0].keys ).to eq Expected_success_result
24
+ expect( response[:result][0].keys ).to eq expected_success_result
29
25
  end
30
26
 
31
27
  # params for make_type and reverse_type test
32
- test_map =
33
- [
34
- [ :id , :campaignId],
35
- [ :name , :campaignName],
36
- [ :exclude_ip, :excludeIp],
37
- [ :exact_negative , :exactNegativeWords],
38
- ]
28
+ test_map = [
29
+ [ :id , :campaignId],
30
+ [ :name , :campaignName],
31
+ [ :exclude_ip, :excludeIp],
32
+ [ :exact_negative , :exactNegativeWords],
33
+ ]
39
34
 
40
35
  test_type = { }
41
36
  test_type['campaignId'] = 123
@@ -47,7 +42,7 @@ describe ::PPC::API::Baidu do
47
42
  test_param[ :id] = 123
48
43
  test_param[ :name] = 'testplan'
49
44
  test_param[ :exclude_ip] = [321,5432,52,1]
50
- test_param[ :exact_negative] = ['test','plan']
45
+ test_param[ :exact_negative] = ['wu','liaode']
51
46
 
52
47
  expected_type = [{:campaignId=>123, :campaignName=>"testplan", :excludeIp=>[321, 5432, 52, 1], :exactNegativeWords=>["wu", "liaode"]}]
53
48
  expexted_params = [{:id=>123, :name=>"test_plan", :exclude_ip=>[321, 5432, 52, 1], :exact_negative=>["wu", "liaode"]}]
@@ -0,0 +1,17 @@
1
+ describe ::PPC::Operation::Account do
2
+ subject{
3
+ ::PPC::Operation::Account.new( $baidu_auth )
4
+ }
5
+ # opetation report test
6
+ it 'can get report' do
7
+ endDate = ( Time.now-2*3600*24).to_s[0..9].split('-').join
8
+ startDate =( Time.now-27*3600*24).to_s[0..9].split('-').join
9
+
10
+ p "startDate:#{startDate},endDate:#{endDate}"
11
+ param = {startDate:startDate, endDate:endDate}
12
+
13
+ subject.query_report( param, true )
14
+ subject.keyword_report( param, true )
15
+ subject.creative_report( param, true )
16
+ end
17
+ end