ppc 0.3.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.autotest +25 -0
  3. data/.gemtest +0 -0
  4. data/History.txt +6 -0
  5. data/Manifest.txt +8 -0
  6. data/README.txt +80 -0
  7. data/Rakefile +19 -0
  8. data/bin/ppc +3 -0
  9. data/lib/ppc.rb +6 -15
  10. data/test/test_ppc.rb +0 -0
  11. metadata +41 -130
  12. data/.gitignore +0 -37
  13. data/.rspec +0 -2
  14. data/LICENSE +0 -339
  15. data/README.md +0 -78
  16. data/lib/ppc/api.rb +0 -10
  17. data/lib/ppc/api/baidu.rb +0 -138
  18. data/lib/ppc/api/baidu/account.rb +0 -47
  19. data/lib/ppc/api/baidu/bulk.rb +0 -41
  20. data/lib/ppc/api/baidu/creative.rb +0 -125
  21. data/lib/ppc/api/baidu/group.rb +0 -111
  22. data/lib/ppc/api/baidu/keyword.rb +0 -204
  23. data/lib/ppc/api/baidu/plan.rb +0 -68
  24. data/lib/ppc/api/baidu/report.rb +0 -143
  25. data/lib/ppc/api/qihu.rb +0 -107
  26. data/lib/ppc/api/qihu/account.rb +0 -86
  27. data/lib/ppc/api/qihu/creative.rb +0 -106
  28. data/lib/ppc/api/qihu/group.rb +0 -113
  29. data/lib/ppc/api/qihu/keyword.rb +0 -111
  30. data/lib/ppc/api/qihu/plan.rb +0 -64
  31. data/lib/ppc/api/qihu/report.rb +0 -159
  32. data/lib/ppc/api/shenma.rb +0 -64
  33. data/lib/ppc/api/shenma/report.rb +0 -135
  34. data/lib/ppc/api/sogou.rb +0 -122
  35. data/lib/ppc/api/sogou/account.rb +0 -42
  36. data/lib/ppc/api/sogou/creative.rb +0 -117
  37. data/lib/ppc/api/sogou/group.rb +0 -116
  38. data/lib/ppc/api/sogou/keyword.rb +0 -182
  39. data/lib/ppc/api/sogou/plan.rb +0 -66
  40. data/lib/ppc/api/sogou/report.rb +0 -129
  41. data/lib/ppc/ext.rb +0 -9
  42. data/lib/ppc/operation.rb +0 -196
  43. data/lib/ppc/operation/account.rb +0 -53
  44. data/lib/ppc/operation/creative.rb +0 -28
  45. data/lib/ppc/operation/group.rb +0 -59
  46. data/lib/ppc/operation/keyword.rb +0 -32
  47. data/lib/ppc/operation/plan.rb +0 -47
  48. data/lib/ppc/operation/report.rb +0 -19
  49. data/ppc.gemspec +0 -26
  50. data/spec/baidu/api_baidu_account_spec.rb +0 -15
  51. data/spec/baidu/api_baidu_creative_spec.rb +0 -67
  52. data/spec/baidu/api_baidu_group_spec.rb +0 -45
  53. data/spec/baidu/api_baidu_keyword_spec.rb +0 -61
  54. data/spec/baidu/api_baidu_plan_spec.rb +0 -43
  55. data/spec/baidu/api_baidu_report_spec.rb +0 -44
  56. data/spec/baidu/api_baidu_spec.rb +0 -55
  57. data/spec/operation/operation_baidu_report_spec.rb +0 -17
  58. data/spec/operation/operation_baidu_spec.rb +0 -78
  59. data/spec/operation/operation_qihu_report_spec.rb +0 -18
  60. data/spec/operation/operation_qihu_spec.rb +0 -51
  61. data/spec/operation/operation_sogou_report_spec.rb +0 -17
  62. data/spec/operation/operation_sogou_spec.rb +0 -51
  63. data/spec/operation/operation_spec_helper.rb +0 -51
  64. data/spec/qihu/api_qihu_account_spec.rb +0 -25
  65. data/spec/qihu/api_qihu_creative_spec.rb +0 -48
  66. data/spec/qihu/api_qihu_group_spec.rb +0 -40
  67. data/spec/qihu/api_qihu_keyword_spec.rb +0 -50
  68. data/spec/qihu/api_qihu_plan_spec.rb +0 -39
  69. data/spec/qihu/api_qihu_report_spec.rb +0 -54
  70. data/spec/sogou/api_sogou_account_spec.rb +0 -15
  71. data/spec/sogou/api_sogou_creative_spec.rb +0 -48
  72. data/spec/sogou/api_sogou_group_spec.rb +0 -45
  73. data/spec/sogou/api_sogou_keyword_spec.rb +0 -50
  74. data/spec/sogou/api_sogou_plan_spec.rb +0 -39
  75. data/spec/sogou/api_sogou_report_spec.rb +0 -51
  76. data/spec/spec_helper.rb +0 -134
data/ppc.gemspec DELETED
@@ -1,26 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- # require ppc for version
6
- require 'ppc'
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = "ppc"
10
- spec.version = PPC::VERSION
11
- spec.authors = ["Chienli Ma, 刘梦晨, 刘明"]
12
- spec.email = ["maqianlie@gmail.com, liuyu_tc@163.com, seoaqua@qq.com"]
13
- spec.summary = %q{ppc api for baidu qihu sogou}
14
- spec.description = %q{ppc api for baidu qihu sogou}
15
- spec.homepage = "http://github.com/elong/ppc"
16
- spec.license = "GNU"
17
-
18
- spec.files = `git ls-files -z`.split("\x0")
19
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
- spec.require_paths = ["lib"]
22
-
23
- spec.add_dependency 'httparty', '~> 0.13', '>= 0.13.0'
24
- spec.add_dependency 'savon', '~> 3.0', '>= 3.0.0'
25
-
26
- end
@@ -1,15 +0,0 @@
1
- describe ::PPC::API::Baidu::Account do
2
- auth = $baidu_auth
3
-
4
- it 'can get account info' do
5
- result = ::PPC::API::Baidu::Account::info( auth )
6
- is_success( result )
7
- end
8
-
9
- it 'can update account' do
10
- update = {budget:2990}
11
- result = ::PPC::API::Baidu::Account::update( auth, update )
12
- is_success( result )
13
- end
14
-
15
- end
@@ -1,67 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
- describe ::PPC::API::Baidu::Creative 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_creative_id = []
8
-
9
- it 'can add creative' do
10
- creative = { group_id: test_group_id,
11
- title: 'TestCreative', preference:1,
12
- description1:'this is rest',
13
- description2:'also is a test',
14
- pc_destination:$baidu_domain,
15
- pc_display:$baidu_domain }
16
- response = ::PPC::API::Baidu::Creative::add( auth, creative )
17
- is_success( response )
18
- test_creative_id << response[:result][0][:id]
19
- end
20
-
21
- it 'can update creative' do
22
- update = { id:test_creative_id[0],
23
- title:'ElongUpdateTest',
24
- description1:'test for update',
25
- mobile_destination:$baidu_domain,
26
- pc_destination:$baidu_domain,
27
- pause:true}
28
- response = ::PPC::API::Baidu::Creative::update( auth, update )
29
- is_success( response )
30
- end
31
-
32
- it 'can activate creative' do
33
- response = ::PPC::API::Baidu::Creative::activate( auth, test_creative_id )
34
- is_success( response )
35
- end
36
-
37
- # 连续测试的系统返回system_failured
38
- # it 'can get status' do
39
- # response1 = ::PPC::API::Baidu::Creative::status( auth, test_group_id, 'group' )
40
- # response2 = ::PPC::API::Baidu::Creative::status( auth, test_creative_id, 'creative' )
41
- # response3 = ::PPC::API::Baidu::Creative::status( auth, test_plan_id, 'plan' )
42
- # is_success( response1 )
43
- # is_success( response2 )
44
- # is_success( response3 )
45
- # end
46
-
47
- it 'can search id by group id' do
48
- response = ::PPC::API::Baidu::Creative::search_id_by_group_id( auth, test_group_id, 0 )
49
- is_success( response )
50
- end
51
-
52
- it 'can search creative by group id' do
53
- response = ::PPC::API::Baidu::Creative::search_by_group_id( auth, test_group_id, 0 )
54
- is_success( response )
55
- end
56
-
57
- it 'can search creative by creative id' do
58
- response = ::PPC::API::Baidu::Creative::get( auth, test_creative_id, 0 )
59
- is_success( response )
60
- end
61
-
62
- it 'can delete creative' do
63
- response = ::PPC::API::Baidu::Creative::delete( auth, test_creative_id )
64
- is_success( response )
65
- end
66
-
67
- end
@@ -1,45 +0,0 @@
1
- describe ::PPC::API::Baidu::Group do
2
- auth = $baidu_auth
3
-
4
- test_plan_id = ::PPC::API::Baidu::Plan.ids(auth)[:result][0]
5
- test_group_id = []
6
-
7
- it 'can get all group' do
8
- response = ::PPC::API::Baidu::Group::ids( auth )
9
- is_success( response )
10
- end
11
-
12
- it 'can add group' do
13
- group = { name: 'test_group', plan_id:test_plan_id, price:500 }
14
- response = ::PPC::API::Baidu::Group::add( auth, group )
15
- is_success( response )
16
- test_group_id << response[:result][0][:id]
17
- end
18
-
19
- it 'can update group' do
20
- group = { id: test_group_id[0], price:600 }
21
- response = ::PPC::API::Baidu::Group::update( auth, group )
22
- is_success( response )
23
- end
24
-
25
- it 'can search group by group id' do
26
- response = ::PPC::API::Baidu::Group::get( auth, test_group_id )
27
- is_success( response )
28
- end
29
-
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 )
32
- is_success( response )
33
- end
34
-
35
- it 'search by plan id' do
36
- response = ::PPC::API::Baidu::Group::search_by_plan_id( auth, test_plan_id )
37
- is_success( response )
38
- end
39
-
40
- it 'can delete group' do
41
- response = ::PPC::API::Baidu::Group::delete( auth, test_group_id )
42
- is_success( response )
43
- end
44
-
45
- end
@@ -1,61 +0,0 @@
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
@@ -1,43 +0,0 @@
1
- describe ::PPC::API::Baidu::Plan do
2
- auth = $baidu_auth
3
-
4
- test_plan_id = []
5
-
6
- ::PPC::API::Baidu.debug_on
7
-
8
- it "can get all plans" do
9
- response = ::PPC::API::Baidu::Plan::all( auth )
10
- is_success( response )
11
- end
12
-
13
- it "can get all plan id" do
14
- response = ::PPC::API::Baidu::Plan::ids( auth )
15
- is_success( response )
16
- end
17
-
18
- it "can add plan" do
19
- test_plan = { name: "test_elong_e", negative: ["test"] }
20
- response = ::PPC::API::Baidu::Plan::add( auth, test_plan )
21
- is_success( response )
22
- test_plan_id << response[:result][0][:id]
23
- end
24
-
25
- it "can get plan by id" do
26
- response = ::PPC::API::Baidu::Plan::get( auth, test_plan_id )
27
- is_success( response )
28
- end
29
-
30
- it 'can update plan' do
31
- update = { id: test_plan_id[0], name:"test_plan_update", is_dynamic:false }
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
35
- is_success( response )
36
- end
37
-
38
- it "can delete plan" do
39
- response = ::PPC::API::Baidu::Plan::delete( auth, test_plan_id )
40
- is_success( response )
41
- end
42
-
43
- end
@@ -1,44 +0,0 @@
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_status( 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
- subject.query_report( auth, param, true )
40
- subject.keyword_report( auth, param, true )
41
- subject.creative_report( auth,param, true )
42
- end
43
-
44
- end
@@ -1,55 +0,0 @@
1
- require 'json'
2
- require 'ppc/api/baidu/account'
3
- describe ::PPC::API::Baidu do
4
-
5
- fake_response = "{\"header\":{\"desc\":\"success\",\"failures\":[],\"oprs\":1,\"oprtime\":0,
6
- \"quota\":2,\"rquota\":34047,\"status\":0},\"body\":{
7
- \"accountInfoType\":{\"userid\":5707012,\"balance\":0.0,\"cost\":0.0,
8
- \"payment\":0.0,\"budgetType\":1,\"budget\":3000.0,\"regionTarget\":[9999999],
9
- \"excludeIp\":[],\"openDomains\":[\"elong.com\"],\"regDomain\":\"elong.com\",
10
- \"budgetOfflineTime\":[],\"weeklyBudget\":[],\"userStat\":null,\"isDynamicCreative\":null,
11
- \"dynamicCreativeParam\":null,\"opt\":null}}}"
12
-
13
- response = JSON.parse fake_response
14
-
15
- expected_success_result = [:id, :balance, :cost, :payment,
16
- :budget_type, :budget, :region, :exclude_ip,
17
- :open_domains, :reg_domain, :offline_time,
18
- :weekly_budget ]
19
-
20
- expected_failure_result = ["code", "message", "position", "content"]
21
-
22
- it 'can process response' do
23
- response = ::PPC::API::Baidu::process( response, 'accountInfoType' ){|x| ::PPC::API::Baidu::Account::reverse_type(x)}
24
- expect( response[:result][0].keys ).to eq expected_success_result
25
- end
26
-
27
- # params for make_type and reverse_type test
28
- test_map = [
29
- [ :id , :campaignId],
30
- [ :name , :campaignName],
31
- [ :exclude_ip, :excludeIp],
32
- [ :exact_negative , :exactNegativeWords],
33
- ]
34
-
35
- test_type = { }
36
- test_type['campaignId'] = 123
37
- test_type['campaignName'] = 'test_plan'
38
- test_type['excludeIp'] = [321,5432,52,1]
39
- test_type['exactNegativeWords'] = ['wu','liaode']
40
-
41
- test_param = { }
42
- test_param[ :id] = 123
43
- test_param[ :name] = 'testplan'
44
- test_param[ :exclude_ip] = [321,5432,52,1]
45
- test_param[ :exact_negative] = ['wu','liaode']
46
-
47
- expected_type = [{:campaignId=>123, :campaignName=>"testplan", :excludeIp=>[321, 5432, 52, 1], :exactNegativeWords=>["wu", "liaode"]}]
48
- expexted_params = [{:id=>123, :name=>"test_plan", :exclude_ip=>[321, 5432, 52, 1], :exact_negative=>["wu", "liaode"]}]
49
-
50
- it 'can make and reverse type' do
51
- expect( ::PPC::API::Baidu::make_type( test_param , test_map) ).to eq expected_type
52
- expect( ::PPC::API::Baidu::reverse_type(test_type, test_map) ).to eq expexted_params
53
- end
54
-
55
- end
@@ -1,17 +0,0 @@
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
@@ -1,78 +0,0 @@
1
- require 'time'
2
- require './operation_spec_helper'
3
- auth = {}
4
- auth[:username] = $baidu_username
5
- auth[:password] = $baidu_password
6
- auth[:token] = $baidu_token
7
- auth[:se] = 'baidu'
8
- preparation = ::PPC::API::Baidu::Group::ids( auth )
9
- test_plan_id = preparation[:result][0][:plan_id]
10
- test_group_id = preparation[:result][0][:group_ids][0]
11
-
12
- describe ::PPC::Operation::Account do
13
- subject{
14
- ::PPC::Operation::Account.new( auth )
15
- }
16
-
17
- it_should_behave_like( "object", {budget:2990})
18
- it_should_behave_like( "object parent", 'plan')
19
-
20
- it_should_behave_like( "object operator", 'plan', {name:'operation_test_plan'},
21
- {name:'updated_operation_test_plan'})
22
-
23
- it_should_behave_like( "object operator", 'group',
24
- {name:'test_operation_group',plan_id:test_plan_id, price:500},
25
- {name:'updated_operation_test_group'} )
26
-
27
- it_should_behave_like( "object operator", 'keyword',
28
- { keyword:'testKeyword', group_id:test_group_id, match_type:'exact'},
29
- { match_type:'wide'})
30
-
31
- it_should_behave_like( "object operator", 'creative',
32
- { group_id: test_group_id,
33
- title: 'OperationTestCreative', preference:1,
34
- description1:'this is rest',
35
- description2:'also is a test',
36
- pc_destination:$baidu_domain,
37
- pc_display:$baidu_domain },
38
- {title:'OperationTestCreative',
39
- description1:'this is a updated test',
40
- pc_destination:$baidu_domain,
41
- mobil_destination:$baidu_domain})
42
-
43
- # opetation report test
44
- it 'can get report' do
45
- endDate = Time.now.utc.iso8601
46
- startDate =( Time.now-30*3600*24).utc.iso8601
47
- pa = {startDate:startDate, endDate:endDate}
48
- subject.query_report(pa)
49
- subject.keyword_report(pa)
50
- subject.creative_report(pa)
51
- end
52
- end
53
-
54
- describe ::PPC::Operation::Plan do
55
- # get test subject
56
- subject{
57
- ::PPC::Operation::Plan.new( auth.merge({id:test_plan_id}) )
58
- }
59
- it_should_behave_like( "object", {budget:2000})
60
- it_should_behave_like( "object operator", 'group',
61
- {name:'test_operation_group', price:500},
62
- {name:'updated_operation_test_group'} )
63
- it_should_behave_like( "object parent", 'group')
64
- end
65
-
66
- describe ::PPC::Operation::Group do
67
- # get test subject
68
- subject{
69
- ::PPC::Operation::Group.new( auth.merge({id:test_group_id}) )
70
- }
71
-
72
- it_should_behave_like( "object", {price:200})
73
- it_should_behave_like( "object operator", 'keyword',
74
- { keyword:'testKeyword', group_id:test_group_id, match_type:'exact'},
75
- { match_type:'wide'})
76
- it_should_behave_like( "object parent", 'keyword')
77
- end
78
-