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
@@ -1,15 +0,0 @@
1
- describe ::PPC::API::Sogou::Account do
2
- auth = $sogou_auth
3
-
4
- it 'can get account info' do
5
- result = ::PPC::API::Sogou::Account::info( auth )
6
- is_success( result )
7
- end
8
-
9
- it 'can update account' do
10
- update = {budget:500}
11
- result = ::PPC::API::Sogou::Account::update( auth, update )
12
- is_success( result )
13
- end
14
-
15
- end
@@ -1,48 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
- describe ::PPC::API::Sogou::Creative do
3
- '''
4
- sogou的创意服务在add的时候需要审核因此自动测试不能一次通过,
5
- 会出现Creative is pending的error.不过手动测试方法没问题了。
6
- '''
7
- auth = $sogou_auth
8
-
9
- # prepare for test param
10
- ::PPC::API::Sogou.debug_off
11
- test_group_id = ::PPC::API::Sogou::Group::ids( auth )[:result][0][:group_ids][0]
12
- test_creative_id = []
13
- ::PPC::API::Sogou.debug_on
14
-
15
- it 'can search Creative by group id' do
16
- response = ::PPC::API::Sogou::Creative::search_by_group_id( auth, test_group_id )
17
- is_success( response )
18
- end
19
-
20
- it 'can add Creative' do
21
- Creative = { group_id: test_group_id, title: 'testCreative',
22
- description1:"this is a test", description2: "this is another test",
23
- pc_destination:$sogou_domain, pc_display:$sogou_domain }
24
- response = ::PPC::API::Sogou::Creative::add( auth, Creative )
25
- is_success( response )
26
- p response
27
- test_creative_id << response[:result][0][:id]
28
- end
29
-
30
- it 'can get status' do
31
- response = ::PPC::API::Sogou::Creative::status( auth, test_creative_id)
32
- is_success(response)
33
- expect(response[:result][0].keys).to eq [:id,:status]
34
- end
35
-
36
- it 'can update Creative' do
37
- update = { id:test_creative_id, description1: 'sogou_expiediction', pause:true}
38
- response = ::PPC::API::Sogou::Creative::update( auth, update )
39
- p response
40
- is_success( response )
41
- end
42
-
43
- it 'can delete Creative' do
44
- response = ::PPC::API::Sogou::Creative::delete( auth, test_creative_id )
45
- is_success( response )
46
- end
47
-
48
- end
@@ -1,45 +0,0 @@
1
- describe ::PPC::API::Sogou::Group do
2
- auth = $sogou_auth
3
-
4
- test_plan_id = ::PPC::API::Sogou::Plan.ids(auth)[:result][0]
5
- test_group_id = []
6
-
7
- it 'can get all group' do
8
- response = ::PPC::API::Sogou::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::Sogou::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::Sogou::Group::update( auth, group )
22
- is_success( response )
23
- end
24
-
25
- it 'can search group by group id' do
26
- response = ::PPC::API::Sogou::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::Sogou::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::Sogou::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::Sogou::Group::delete( auth, test_group_id )
42
- is_success( response )
43
- end
44
-
45
- end
@@ -1,50 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
- describe ::PPC::API::Sogou::Keyword do
3
- '''
4
- sogou的关键词服务在add的时候需要审核因此不能一次通过,
5
- 会出现keyword is pending的error.不过手动测试方法没问题了。
6
- '''
7
- auth = $sogou_auth
8
-
9
- ::PPC::API::Sogou.debug_off
10
- test_group_id = ::PPC::API::Sogou::Group::ids( auth )[:result][0][:group_ids][0]
11
- test_keyword_id = []
12
- ::PPC::API::Sogou.debug_on
13
-
14
- it 'can search keyword by group id' do
15
- response = ::PPC::API::Sogou::Keyword::search_by_group_id( auth, test_group_id )
16
- p response
17
- is_success( response )
18
- end
19
-
20
- it 'can add keyword' do
21
- keyword = { group_id: test_group_id, keyword: 'testkeyword', match_type:'exact' }
22
- response = ::PPC::API::Sogou::Keyword::add( auth, keyword )
23
- is_success( response )
24
- test_keyword_id << response[:result][0][:id]
25
- end
26
-
27
- it 'can get status' do
28
- response = ::PPC::API::Sogou::Keyword::status( auth, test_keyword_id)
29
- is_success(response)
30
- expect(response[:result][0].keys).to eq [:id,:status]
31
- end
32
-
33
- it 'can get quality' do
34
- response = ::PPC::API::Sogou::Keyword::quality( auth, test_keyword_id)
35
- is_success(response)
36
- expect(response[:result][0].keys).to eq [:id,:quality]
37
- end
38
-
39
- it 'can update keyword' do
40
- update = { id:test_keyword_id, pc_destination: $sogou_domain, pause:true}
41
- response = ::PPC::API::Sogou::Keyword::update( auth, update )
42
- is_success( response )
43
- end
44
-
45
- it 'can delete keyword' do
46
- response = ::PPC::API::Sogou::Keyword::delete( auth, test_keyword_id )
47
- is_success( response )
48
- end
49
-
50
- end
@@ -1,39 +0,0 @@
1
- describe ::PPC::API::Sogou::Plan do
2
- auth = $sogou_auth
3
-
4
- test_plan_id = []
5
-
6
- it "can get all plans" do
7
- response = ::PPC::API::Sogou::Plan::all( auth )
8
- is_success( response )
9
- end
10
-
11
- it "can get all plan id" do
12
- response = ::PPC::API::Sogou::Plan::ids( auth )
13
- is_success( response )
14
- end
15
-
16
- it "can add plan" do
17
- test_plan = { name: "test_elong", negative: ["test"] }
18
- response = ::PPC::API::Sogou::Plan::add( auth, test_plan )
19
- is_success( response )
20
- test_plan_id << response[:result][0][:id]
21
- end
22
-
23
- it "can get plan by id" do
24
- response = ::PPC::API::Sogou::Plan::get( auth, test_plan_id )
25
- is_success( response )
26
- end
27
-
28
- it 'can update plan' do
29
- update = { id: test_plan_id[0], name:"test_plan_update"}
30
- response = ::PPC::API::Sogou::Plan::update( auth, update )
31
- is_success( response )
32
- end
33
-
34
- it "can delete plan" do
35
- response = ::PPC::API::Sogou::Plan::delete( auth, test_plan_id )
36
- is_success( response )
37
- end
38
-
39
- end
@@ -1,51 +0,0 @@
1
- describe ::PPC::API::Sogou::Report do
2
- auth = $sogou_auth
3
-
4
- param = {}
5
- param[:type] = 'keyword'
6
- param[:fields] = %w(impression click cpc cost ctr)
7
- param[:endDate] = ( Time.now-2*3600*24).to_s[0..9].split('-').join
8
- param[:startDate] =( Time.now-7*3600*24).to_s[0..9].split('-').join
9
-
10
-
11
- test_report_id = []
12
- it "can get report id" do
13
- response = ::PPC::API::Sogou::Report.get_id( auth, param )
14
- is_success( response )
15
- test_report_id << response[:result]
16
- end
17
-
18
- it "can get report state" do
19
- response = ::PPC::API::Sogou::Report.get_state( auth, test_report_id[0] )
20
- is_success( response )
21
- end
22
-
23
- it "can get report url" do
24
- response = ::PPC::API::Sogou::Report.get_url( auth, test_report_id[0] )
25
- is_success( response )
26
- end
27
-
28
- it "can download one report" do
29
- report = ::PPC::API::Sogou::Report.download_report( auth, param )
30
- end
31
-
32
- end
33
-
34
- describe "::PPC::API::Sogou::Report Operation interface " do
35
- auth = $sogou_auth
36
-
37
- subject{
38
- ::PPC::API::Sogou::Report
39
- }
40
- # opetation report test
41
- it 'can get report' do
42
- endDate = ( Time.now-2*3600*24).to_s[0..9].split('-').join
43
- startDate =( Time.now-27*3600*24).to_s[0..9].split('-').join
44
-
45
- param = {startDate:startDate, endDate:endDate}
46
- subject.query_report( auth, param )
47
- subject.keyword_report( auth, param )
48
- subject.creative_report( auth,param )
49
- end
50
-
51
- end
data/spec/spec_helper.rb DELETED
@@ -1,134 +0,0 @@
1
- # -*- coding:utf-8 -*-
2
- # This file was generated by the `rspec --init` command. Conventionally, all
3
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
4
- # The generated `.rspec` file contains `--require spec_helper` which will cause this
5
- # file to always be loaded, without a need to explicitly require it in any files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, make a
11
- # separate helper file that requires this one and then use it only in the specs
12
- # that actually need it.
13
- #
14
- # The `.rspec` file also contains a few flags that are not defaults but that
15
- # users commonly want.
16
- #
17
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
- RSpec.configure do |config|
19
- # The settings below are suggested to provide a good initial experience
20
- # with RSpec, but feel free to customize to your heart's content.
21
- =begin
22
- # These two settings work together to allow you to limit a spec run
23
- # to individual examples or groups you care about by tagging them with
24
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
25
- # get run.
26
- config.filter_run :focus
27
- config.run_all_when_everything_filtered = true
28
-
29
- # Many RSpec users commonly either run the entire suite or an individual
30
- # file, and it's useful to allow more verbose output when running an
31
- # individual spec file.
32
- if config.files_to_run.one?
33
- # Use the documentation formatter for detailed output,
34
- # unless a formatter has already been configured
35
- # (e.g. via a command-line flag).
36
- config.default_formatter = 'doc'
37
- end
38
-
39
- # Print the 10 slowest examples and example groups at the
40
- # end of the spec run, to help surface which specs are running
41
- # particularly slow.
42
- config.profile_examples = 10
43
-
44
- # Run specs in random order to surface order dependencies. If you find an
45
- # order dependency and want to debug it, you can fix the order by providing
46
- # the seed, which is printed after each run.
47
- # --seed 1234
48
- config.order = :random
49
-
50
- # Seed global randomization in this process using the `--seed` CLI option.
51
- # Setting this allows you to use `--seed` to deterministically reproduce
52
- # test failures related to randomization by passing the same `--seed` value
53
- # as the one that triggered the failure.
54
- Kernel.srand config.seed
55
-
56
- # rspec-expectations config goes here. You can use an alternate
57
- # assertion/expectation library such as wrong or the stdlib/minitest
58
- # assertions if you prefer.
59
- config.expect_with :rspec do |expectations|
60
- # Enable only the newer, non-monkey-patching expect syntax.
61
- # For more details, see:
62
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
63
- expectations.syntax = :expect
64
- end
65
-
66
- # rspec-mocks config goes here. You can use an alternate test double
67
- # library (such as bogus or mocha) by changing the `mock_with` option here.
68
- config.mock_with :rspec do |mocks|
69
- # Enable only the newer, non-monkey-patching expect syntax.
70
- # For more details, see:
71
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
72
- mocks.syntax = :expect
73
-
74
- # Prevents you from mocking or stubbing a method that does not exist on
75
- # a real object. This is generally recommended.
76
- mocks.verify_partial_doubles = true
77
- end
78
- =end
79
- end
80
-
81
-
82
- require 'ppc'
83
-
84
- baidu_username = ''
85
- baidu_password = ''
86
- baidu_token = ''
87
-
88
- qihu_username = ''
89
- qihu_password = ''
90
- qihu_token = ''
91
- qihu_cipherkey = ''
92
- qihu_cipheriv = ''
93
- qihu_accessToken = ''
94
-
95
-
96
- sogou_username = ''
97
- sogou_password = ''
98
- sogou_token = ''
99
-
100
-
101
-
102
- $domain = ''
103
- $baidu_auth = {
104
- username: baidu_username,
105
- password: baidu_password,
106
- token: baidu_token,
107
- se: 'baidu'
108
- }
109
-
110
- $qihu_auth = {
111
- username: qihu_username,
112
- password: qihu_password,
113
- cipherkey: qihu_cipherkey,
114
- cipheriv: qihu_cipheriv,
115
- token: qihu_token,
116
- se: 'qihu'
117
- }
118
-
119
- $sogou_auth = {
120
- username: sogou_username,
121
- password: sogou_password,
122
- token: sogou_token,
123
- se: 'sogou'
124
- }
125
-
126
-
127
-
128
-
129
-
130
-
131
- def is_success( result )
132
- expect( result[:succ] ).to eq true
133
- end
134
-