ppc 0.3.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,18 +0,0 @@
1
- auth = $qihu_auth
2
-
3
- describe ::PPC::Operation::Account do
4
- subject{
5
- ::PPC::Operation::Account.new( auth )
6
- }
7
- # opetation report test
8
- it 'can get report' do
9
- endDate = ( Time.now-2*3600*24).to_s[0..9].split('-').join
10
- startDate =( Time.now-27*3600*24).to_s[0..9].split('-').join
11
-
12
- p "startDate:#{startDate},endDate:#{endDate}"
13
- param = {startDate:startDate, endDate:endDate}
14
-
15
- subject.keyword_report( param, true )
16
- subject.creative_report( param, true )
17
- end
18
- end
@@ -1,51 +0,0 @@
1
- require './operation_spec_helper'
2
-
3
- auth = $qihu_auth
4
-
5
- test_plan_id = 717479502
6
- test_group_id = 1203987666
7
-
8
- describe ::PPC::Operation::Account do
9
- subject{
10
- ::PPC::Operation::Account.new( auth )
11
- }
12
-
13
- it_should_behave_like( "object", {budget:2990})
14
-
15
- it_should_behave_like( "object operator", 'plan', {name:'operation_test_plan'},
16
- {name:'updated_operation_test_plan'})
17
-
18
- it_should_behave_like( "object operator", 'group',
19
- {name:'test_operation_group',plan_id:test_plan_id, price:500},
20
- {name:'updated_operation_test_group'} )
21
- end
22
-
23
- describe ::PPC::Operation::Plan do
24
- # get test subject
25
- subject{
26
- ::PPC::Operation::Plan.new( auth.merge({id:test_plan_id}) )
27
- }
28
-
29
- it_should_behave_like( "object", {budget:2000})
30
- it_should_behave_like( "object operator", 'group',
31
- {name:'test_operation_group', price:500},
32
- {name:'updated_operation_test_group'} )
33
- it_should_behave_like( "object parent", 'group')
34
- end
35
-
36
- describe ::PPC::Operation::Group do
37
- # get test subject
38
- subject{
39
- ::PPC::Operation::Group.new( auth.merge({id:test_group_id}) )
40
- }
41
-
42
- it_should_behave_like( "object", {price:200})
43
- it_should_behave_like( "object operator", 'keyword',
44
- { keyword:'testKeyword', group_id:test_group_id, match_type:'exact'},
45
- { match_type:'wide'})
46
- it_should_behave_like( "object parent", 'keyword')
47
-
48
- end
49
-
50
-
51
-
@@ -1,17 +0,0 @@
1
- describe ::PPC::Operation::Account do
2
- subject{
3
- ::PPC::Operation::Account.new( $sogou_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 )
14
- subject.keyword_report( param )
15
- subject.creative_report( param )
16
- end
17
- end
@@ -1,51 +0,0 @@
1
- require './operation_spec_helper'
2
-
3
- auth = $sogou_auth
4
- preparation = ::PPC::API::Sogou::Group::ids( auth )
5
- test_plan_id = preparation[:result][0][:plan_id]
6
- test_group_id = preparation[:result][0][:group_ids][0]
7
-
8
- ::PPC::API::Sogou.debug_on
9
-
10
- describe ::PPC::Operation::Account do
11
- subject{
12
- ::PPC::Operation::Account.new( auth )
13
- }
14
-
15
- it_should_behave_like( "object", {budget:2990})
16
- it_should_behave_like( "object parent", 'plan')
17
-
18
- it_should_behave_like( "object operator", 'plan', {name:'operation_test_plan'},
19
- {name:'updated_operation_test_plan'})
20
-
21
- it_should_behave_like( "object operator", 'group',
22
- {name:'test_operation_group',plan_id:test_plan_id, price:500},
23
- {name:'updated_operation_test_group'} )
24
-
25
- end
26
-
27
- describe ::PPC::Operation::Plan do
28
- # get test subject
29
- subject{
30
- ::PPC::Operation::Plan.new( auth.merge({id:test_plan_id}) )
31
- }
32
-
33
- it_should_behave_like( "object", {budget:2000})
34
- it_should_behave_like( "object operator", 'group',
35
- {name:'test_operation_group', price:500},
36
- {name:'updated_operation_test_group'} )
37
- it_should_behave_like( "object parent", 'group')
38
- end
39
-
40
- describe ::PPC::Operation::Group do
41
- # get test subject
42
- subject{
43
- ::PPC::Operation::Group.new( auth.merge({id:test_group_id}) )
44
- }
45
-
46
- it_should_behave_like( "object", {price:200})
47
- it_should_behave_like( "object parent", 'keyword')
48
- end
49
-
50
-
51
-
@@ -1,51 +0,0 @@
1
- shared_examples "object" do
2
- | update |
3
- it 'can get info' do
4
- result = subject.info
5
- is_success( result )
6
- end
7
-
8
- it 'can update it self' do
9
- result = subject.update( update )
10
- is_success( result )
11
- end
12
- end
13
-
14
- # 在这之前要describ object
15
- shared_examples "object operator" do
16
- |object_name, add_info, update_info |
17
- object_id = 0
18
-
19
- it 'can add object' do
20
- method_name = "add_"+object_name
21
- result = subject.send( method_name.to_sym, add_info )
22
- is_success( result )
23
- object_id = result[:result][0][:id]
24
- end
25
-
26
- it 'can update object' do
27
- method_name = "update_"+object_name
28
- result = subject.send( method_name.to_sym, update_info.merge( {id:object_id} ) )
29
- is_success( result )
30
- end
31
-
32
- it 'can delete object' do
33
- method_name = "delete_"+object_name
34
- result = subject.send( method_name.to_sym, object_id )
35
- is_success( result )
36
- end
37
- end
38
-
39
- shared_examples "object parent" do
40
- | object_name|
41
- it 'can get all objects'do
42
- result = subject.send( (object_name + 's').to_sym )
43
- is_success( result )
44
- end
45
-
46
- it 'can get all object ids' do
47
- result = subject.send( (object_name + '_ids').to_sym )
48
- is_success( result )
49
- end
50
- end
51
-
@@ -1,25 +0,0 @@
1
- describe ::PPC::API::Qihu::Account do
2
- auth = $qihu_auth
3
-
4
- it 'can get accnout info' do
5
- response = ::PPC::API::Qihu::Account::info( auth )
6
- is_success( response )
7
- expect( response[:result].keys ).to eq [:id, :name, :email, :company, :industry1, :industry2, :balance, :budget, :open_domains]
8
- end
9
-
10
- it 'can update exclude iplist' do
11
- response = ::PPC::API::Qihu::Account::update_exclude_ip( auth, ['127.0.0.1'] )
12
- is_success( response )
13
- end
14
-
15
- it 'can get exclude ip list' do
16
- response = ::PPC::API::Qihu::Account::get_exclude_ip( auth )
17
- is_success( response )
18
- end
19
-
20
- it 'can update budget' do
21
- response = ::PPC::API::Qihu::Account::update_budget( auth, 3500 )
22
- is_success( response )
23
- end
24
-
25
- end
@@ -1,48 +0,0 @@
1
- describe ::PPC::API::Qihu::Creative do
2
- auth = $qihu_auth
3
-
4
- test_plan_id = ::PPC::API::Qihu::Account::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].to_i
6
- test_Creative_id = 0
7
-
8
- it 'can search creatives by group id' do
9
- response = ::PPC::API::Qihu::Creative::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 add a creative' do
15
- creative1 = {
16
- group_id:test_group_id,
17
- title:"testCreative1",
18
- description1:'testhahaa',
19
- pc_destination:'www.elong.com'
20
- }
21
- response = ::PPC::API::Qihu::Creative::add( auth, creative1)
22
- is_success( response )
23
- test_Creative_id = response[:result][0]
24
- end
25
-
26
- it 'can update a creative' do
27
- creative = { id:test_Creative_id, description2:'testaaaaa' }
28
- response = ::PPC::API::Qihu::Creative::update( auth, creative )
29
- is_success( response )
30
- end
31
-
32
- it 'can get creatives' do
33
- response = ::PPC::API::Qihu::Creative::get( auth, test_Creative_id )
34
- is_success( response )
35
- expect( response[:result][0].keys ).to include( :id, :title )
36
- end
37
-
38
- it 'can get status' do
39
- response = ::PPC::API::Qihu::Creative::status( auth, test_Creative_id )
40
- is_success( response )
41
- end
42
-
43
- it 'can delete a creative' do
44
- response = ::PPC::API::Qihu::Creative::delete( auth, test_Creative_id )
45
- is_success( response )
46
- end
47
-
48
- end
@@ -1,40 +0,0 @@
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].to_i
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, 717479502 )
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, 717479502 )
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
@@ -1,50 +0,0 @@
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
- is_success( response )
24
- test_keyword_id = response[:result][0]
25
- p response
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
@@ -1,39 +0,0 @@
1
- describe ::PPC::API::Qihu::Plan do
2
- auth = $qihu_auth
3
-
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]
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
@@ -1,54 +0,0 @@
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