ppc 1.3.0 → 1.3.2
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.
- 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
data/lib/ppc/baidu.rb
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
require 'ppc/baidu/account'
|
|
2
|
-
require 'ppc/baidu/plan'
|
|
3
|
-
require 'ppc/baidu/bulk'
|
|
4
|
-
require 'ppc/baidu/group'
|
|
5
|
-
require 'ppc/baidu/key'
|
|
6
|
-
require 'ppc/baidu/report'
|
|
7
|
-
require 'awesome_print'
|
|
8
|
-
require 'net/http'
|
|
9
|
-
require 'net/https'
|
|
10
|
-
require 'json'
|
|
11
|
-
# require 'savon'
|
|
12
|
-
module PPC
|
|
13
|
-
class Baidu
|
|
14
|
-
include ::PPC
|
|
15
|
-
|
|
16
|
-
def initialize(params = {})
|
|
17
|
-
@service = params[:service] + 'Service'
|
|
18
|
-
@username = params[:username]
|
|
19
|
-
@password = params[:password]
|
|
20
|
-
@token = params[:token]
|
|
21
|
-
@debug = params[:debug] || false
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def request(method,params = {}, with_header = false)
|
|
26
|
-
uri = URI("https://api.baidu.com/json/sms/v3/#{@service}/#{method}")
|
|
27
|
-
http_body = {
|
|
28
|
-
header: request_header,
|
|
29
|
-
body: params
|
|
30
|
-
}.to_json
|
|
31
|
-
|
|
32
|
-
http_header = {
|
|
33
|
-
'Content-Type' => 'application/json; charset=UTF-8'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
http = Net::HTTP.new(uri.host, 443)
|
|
37
|
-
http.set_debug_output $stderr
|
|
38
|
-
http.use_ssl = true
|
|
39
|
-
|
|
40
|
-
response = http.post(uri.path, http_body, http_header)
|
|
41
|
-
response = (JSON.parse response.body)
|
|
42
|
-
# if not needed, only return body
|
|
43
|
-
return response['body'] unless with_header else response
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def operations
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
protected
|
|
50
|
-
def download(params = {})
|
|
51
|
-
bulk = ::PPC::Baidu::Bulk.new({
|
|
52
|
-
username: @username,
|
|
53
|
-
password: @password,
|
|
54
|
-
token: @token,
|
|
55
|
-
debug: @debug
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
params[:extended] = params[:extended] || 2
|
|
59
|
-
|
|
60
|
-
begin
|
|
61
|
-
file_id = bulk.file_id_of_all(params)
|
|
62
|
-
puts "file_id: #{file_id}" if @debug
|
|
63
|
-
|
|
64
|
-
loop do
|
|
65
|
-
state = bulk.state(file_id)
|
|
66
|
-
raise "invalid file state: #{state}" unless %w(1 2 3 null).include? state
|
|
67
|
-
break if state == '3'
|
|
68
|
-
puts "waiting for #{file_id} to be ready. current state:#{state}" if @debug
|
|
69
|
-
sleep 3
|
|
70
|
-
end
|
|
71
|
-
puts "#{file_id} is ready" if @debug
|
|
72
|
-
return bulk.path(file_id)
|
|
73
|
-
rescue
|
|
74
|
-
# @header = bulk.header
|
|
75
|
-
# @oprs = bulk.oprs
|
|
76
|
-
# @oprtime = bulk.oprtime
|
|
77
|
-
# @quota = bulk.quota
|
|
78
|
-
# @rquota = bulk.rquota
|
|
79
|
-
# @status = bulk.status
|
|
80
|
-
|
|
81
|
-
# @desc = bulk.desc
|
|
82
|
-
|
|
83
|
-
# case @desc
|
|
84
|
-
# when 'success'
|
|
85
|
-
# when 'failure'
|
|
86
|
-
# @code = bulk.code
|
|
87
|
-
# @message = bulk.message
|
|
88
|
-
# when 'system failure'
|
|
89
|
-
# @code = bulk.code
|
|
90
|
-
# @message = bulk.message
|
|
91
|
-
# else
|
|
92
|
-
# raise "unknown desc from baidu: #{@desc}"
|
|
93
|
-
# end
|
|
94
|
-
raise BulkException.new(file_id,bulk)
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
return false
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
private
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def request_header
|
|
104
|
-
{
|
|
105
|
-
username: @username,
|
|
106
|
-
password: @password,
|
|
107
|
-
token: @token
|
|
108
|
-
}
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def example(operation,with_header=false)
|
|
112
|
-
operation = make_operation(operation)
|
|
113
|
-
if with_header
|
|
114
|
-
{
|
|
115
|
-
example_header: operation.example_header,
|
|
116
|
-
example_body: operation.example_body
|
|
117
|
-
}
|
|
118
|
-
else
|
|
119
|
-
operation.example_body
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def process_response(response)
|
|
124
|
-
body = response[:envelope]
|
|
125
|
-
print_debug(body,'response.envelope') if @debug
|
|
126
|
-
@header = body[:header]
|
|
127
|
-
res_header = header[:res_header]
|
|
128
|
-
|
|
129
|
-
@oprs = res_header[:oprs]
|
|
130
|
-
@oprtime = res_header[:oprtime]
|
|
131
|
-
@quota = res_header[:quota]
|
|
132
|
-
@rquota = res_header[:rquota]
|
|
133
|
-
@status = res_header[:status]
|
|
134
|
-
|
|
135
|
-
@desc = res_header[:desc]
|
|
136
|
-
case @desc
|
|
137
|
-
when 'success'
|
|
138
|
-
when 'failure'
|
|
139
|
-
failures = res_header[:failures]
|
|
140
|
-
@code = failures[:code]
|
|
141
|
-
@message = failures[:message]
|
|
142
|
-
when 'system failure'
|
|
143
|
-
failures = res_header[:failures]
|
|
144
|
-
@code = failures[:code]
|
|
145
|
-
@message = failures[:message]
|
|
146
|
-
else
|
|
147
|
-
raise "unknown desc from baidu: #{@desc}"
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
end
|
|
152
|
-
end
|
data/lib/ppc/baidu/account.rb
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
module PPC
|
|
2
|
-
class Baidu
|
|
3
|
-
class Account < ::PPC::Baidu
|
|
4
|
-
def initialize(params = {})
|
|
5
|
-
params[:service] = 'Account'
|
|
6
|
-
super(params)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def info
|
|
10
|
-
response = request('getAccountInfo')["accountInfoType"]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def all(params = {})
|
|
14
|
-
download(params)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def update( params = {} )
|
|
18
|
-
"""
|
|
19
|
-
update account info
|
|
20
|
-
@ params : account_info_type
|
|
21
|
-
@return : account info_type
|
|
22
|
-
"""
|
|
23
|
-
info = {
|
|
24
|
-
accountInfoType: {
|
|
25
|
-
budgetType: params[:budget_type] ,
|
|
26
|
-
budget: params[:budget],
|
|
27
|
-
regionTarget: params[:region],
|
|
28
|
-
excludeIp: params[:excludeip] ,
|
|
29
|
-
isDynamicCreative: params[:isdynamic],
|
|
30
|
-
dynamicCreativeParam: params[:creativeparam]
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
# delete null symbol
|
|
34
|
-
info[:accountInfoType].each{
|
|
35
|
-
|pair|
|
|
36
|
-
key, value = pair
|
|
37
|
-
info[:accountInfoType].delete(key) if value == nil
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
request('updateAccountInfo', info)["accountInfoType"]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def query_report(params = {})
|
|
44
|
-
report = ::PPC::Baidu::Report.new({username: @username, password: @password, token: @token, debug: @debug})
|
|
45
|
-
|
|
46
|
-
begin
|
|
47
|
-
@file_id = report.file_id_of_query(params)
|
|
48
|
-
print_debug(@file_id,'file_id') if @debug
|
|
49
|
-
|
|
50
|
-
loop do
|
|
51
|
-
state = report.state(@file_id)
|
|
52
|
-
raise "invalid file state: #{state}" unless %w(1 2 3 null).include? state
|
|
53
|
-
break if state == '3'
|
|
54
|
-
print_debug(state,'file_id.state') if @debug
|
|
55
|
-
sleep 3
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
url = report.path(@file_id)
|
|
59
|
-
open(url).read.force_encoding('gb18030').encode('utf-8')
|
|
60
|
-
rescue Exception => e
|
|
61
|
-
raise ReportException.new(@file_id,report,e)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def cost_report(params = {})
|
|
66
|
-
report = ::PPC::Baidu::Report.new({username: @username, password: @password, token: @token, debug: @debug})
|
|
67
|
-
begin
|
|
68
|
-
@file_id = report.file_id_of_cost(params)
|
|
69
|
-
print_debug(@file_id,'file_id') if @debug
|
|
70
|
-
|
|
71
|
-
loop do
|
|
72
|
-
state = report.state(@file_id)
|
|
73
|
-
raise "invalid file state: #{state}" unless %w(1 2 3 null).include? state
|
|
74
|
-
break if state == '3'
|
|
75
|
-
print_debug(state,'file_id.state') if @debug
|
|
76
|
-
sleep 3
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
url = report.path(@file_id)
|
|
80
|
-
open(url).read.force_encoding('gb18030').encode('utf-8')
|
|
81
|
-
rescue Exception => e
|
|
82
|
-
raise ReportException.new(@file_id,report,e)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
data/lib/ppc/baidu/bulk.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
module PPC
|
|
2
|
-
class Baidu
|
|
3
|
-
class BulkException < Exception
|
|
4
|
-
attr_reader :file_id,:bulk,:exception
|
|
5
|
-
def initialize(file_id,bulk,exception)
|
|
6
|
-
@file_id = file_id
|
|
7
|
-
@bulk = bulk
|
|
8
|
-
@exception = exception
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
class Bulk < ::PPC::Baidu
|
|
13
|
-
def initialize(params = {})
|
|
14
|
-
params[:service] = 'BulkJob'
|
|
15
|
-
super(params)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def file_id_of_all(params = {})
|
|
19
|
-
plan_ids = params[:plan_ids]
|
|
20
|
-
|
|
21
|
-
unless plan_ids.nil?
|
|
22
|
-
plan_ids = plan_ids.class == Array ? plan_ids : [plan_ids]
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
options = {
|
|
26
|
-
campaignIds: plan_ids || [] ,
|
|
27
|
-
includeQuality: params[:quality] || true ,
|
|
28
|
-
includeTemp: params[:temp] || false ,
|
|
29
|
-
format: params[:format] || 1 ,
|
|
30
|
-
newCreativeFiles: params[:adcopy] || 0 ,
|
|
31
|
-
includeTempNewCreatives: params[:temp_adcopy] || 0 ,
|
|
32
|
-
includePhraseType: params[:phrase] || 0 ,
|
|
33
|
-
extended: params[:extended] || 0
|
|
34
|
-
}
|
|
35
|
-
response = request('getAllObjects',options)
|
|
36
|
-
|
|
37
|
-
body = response[:envelope][:body]
|
|
38
|
-
raise "no result" if body.nil?
|
|
39
|
-
body[:get_all_objects_response][:file_id]
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def state(id)
|
|
43
|
-
raise "empty id" if id.nil? or id.empty?
|
|
44
|
-
request('getFileState',{fileId:id})[:envelope][:body][:get_file_state_response][:is_generated]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def path(id)
|
|
48
|
-
request('getFilePath',{fileId:id})[:envelope][:body][:get_file_path_response][:file_paths]
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
data/lib/ppc/baidu/group.rb
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
module PPC
|
|
2
|
-
class Baidu
|
|
3
|
-
class Group < ::PPC::Baidu
|
|
4
|
-
def initialize(params = {})
|
|
5
|
-
params[:service] = 'Adgroup'
|
|
6
|
-
super(params)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def all()
|
|
10
|
-
"""
|
|
11
|
-
@return : Array of campaignAdgroupIds
|
|
12
|
-
"""
|
|
13
|
-
request( "getAllAdgroupId" )["campaignAdgroupIds"]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def add( params={}, test = false)
|
|
17
|
-
"""
|
|
18
|
-
@ input : one or list of AdgroupType
|
|
19
|
-
@ output : list of AdgroupType
|
|
20
|
-
"""
|
|
21
|
-
params = [ params ] unless params.class == Array
|
|
22
|
-
adgroupType = []
|
|
23
|
-
|
|
24
|
-
params.each{ | group_i |
|
|
25
|
-
adgroupType << make_adgrouptype( group_i )
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
body = {adgroupTypes: adgroupType}
|
|
29
|
-
response = request( "addAdgroup", body, test )
|
|
30
|
-
return response['adgroupTypes'] unless test else response
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def update( params={}, test = false )
|
|
34
|
-
"""
|
|
35
|
-
@ input : one or list of AdgroupType
|
|
36
|
-
@ output : list of AdgroupType
|
|
37
|
-
"""
|
|
38
|
-
params = [ params ] unless params.class == Array
|
|
39
|
-
adgroupType = []
|
|
40
|
-
|
|
41
|
-
params.each{ | group_i |
|
|
42
|
-
adgroupType << make_adgrouptype( group_i )
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
body = {adgroupTypes: adgroupType}
|
|
46
|
-
responses = request( "updateAdgroup", body, test )
|
|
47
|
-
return responses['adgroupTypes'] unless test else responses
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def delete( ids )
|
|
51
|
-
# delete responses have no content therefore we
|
|
52
|
-
#return header.desc to judge whether operation success
|
|
53
|
-
ids = [ ids ] unless ids.class == Array
|
|
54
|
-
|
|
55
|
-
body = { adgroupIds: ids }
|
|
56
|
-
request( "deleteAdgroup", body, true )[ 'header' ][ 'desc' ]
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def search_by_planid( ids, test = false )
|
|
60
|
-
ids = [ ids ] unless ids.class == Array
|
|
61
|
-
body = { campaignIds: ids }
|
|
62
|
-
responses = request("getAdgroupByCampaignId", body, test )
|
|
63
|
-
return responses["campaignAdgroups"] unless test else responses
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def search_by_groupid( ids, test = false )
|
|
67
|
-
ids = [ ids ] unless ids.class == Array
|
|
68
|
-
body = { adgroupIds: ids }
|
|
69
|
-
responses = request("getAdgroupByAdgroupId",body, test )
|
|
70
|
-
return responses["adgroupTypes"] unless test else responses
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
private
|
|
74
|
-
def make_adgrouptype( params={} )
|
|
75
|
-
adgrouptype = {
|
|
76
|
-
campaignId: params[:plan_id],
|
|
77
|
-
adgroupId: params[:group_id],
|
|
78
|
-
adgroupName: params[:name],
|
|
79
|
-
maxPrice: params[:maxprice],
|
|
80
|
-
negativeWords: params[:negative],
|
|
81
|
-
exactNegativeWords: params[:exact_negative],
|
|
82
|
-
pause: params[:pause],
|
|
83
|
-
status: params[:status],
|
|
84
|
-
reserved: params[:reserved]
|
|
85
|
-
}
|
|
86
|
-
# delete empty node
|
|
87
|
-
adgrouptype.each{
|
|
88
|
-
|pair|
|
|
89
|
-
key, value = pair
|
|
90
|
-
adgrouptype.delete(key) if value == nil
|
|
91
|
-
}
|
|
92
|
-
# delete invalid note according to request type
|
|
93
|
-
# unimplemented
|
|
94
|
-
return adgrouptype
|
|
95
|
-
end #make_adgrouptype
|
|
96
|
-
|
|
97
|
-
end # class group
|
|
98
|
-
end # class baidu
|
|
99
|
-
end # module
|
data/lib/ppc/baidu/key.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
module PPC
|
|
2
|
-
class Baidu
|
|
3
|
-
class Key < ::PPC::Baidu
|
|
4
|
-
def initialize(params = {})
|
|
5
|
-
params[:service] = 'Keyword'
|
|
6
|
-
@se_id = params[:se_id]
|
|
7
|
-
super(params)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def add()
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def update()
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def delete()
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def active()
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def search_by_groupid( ids, return_id = false )
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def search_by_keywordid( ids )
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def get_status()
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def get_quality()
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def get_10quality()
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
data/lib/ppc/baidu/plan.rb
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
module PPC
|
|
2
|
-
class Baidu
|
|
3
|
-
class Plan < ::PPC::Baidu
|
|
4
|
-
def initialize(params = {})
|
|
5
|
-
params[:service] = 'Campaign'
|
|
6
|
-
@se_id = params[:se_id]
|
|
7
|
-
super(params)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def all(params = {})
|
|
11
|
-
params[:plan_ids] = [@se_id]
|
|
12
|
-
download(params)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def ids
|
|
16
|
-
request('getAllCampaignId')['campaignIds']
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
#add one or more plans
|
|
20
|
-
def add(plans)
|
|
21
|
-
if plans.class == Hash
|
|
22
|
-
plans = [plans]
|
|
23
|
-
single = true
|
|
24
|
-
end
|
|
25
|
-
campaignTypes = []
|
|
26
|
-
|
|
27
|
-
plans.each do |plan|
|
|
28
|
-
campaignTypes << {
|
|
29
|
-
campaignName: plan[:name],
|
|
30
|
-
negativeWords: plan[:negative],
|
|
31
|
-
exactNegativeWords: plan[:exact_negative]
|
|
32
|
-
}
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
options = {campaignTypes: campaignTypes}
|
|
36
|
-
response = request('addCampaign',options)['campaignTypes']
|
|
37
|
-
if single
|
|
38
|
-
response.first
|
|
39
|
-
else
|
|
40
|
-
response
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def get(ids)
|
|
45
|
-
if ids.class != Array
|
|
46
|
-
ids = [ids]
|
|
47
|
-
single = true
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
options = {campaignIds: ids}
|
|
51
|
-
response = request('getCampaignByCampaignId',options)['campaignTypes']
|
|
52
|
-
|
|
53
|
-
if single
|
|
54
|
-
response.first
|
|
55
|
-
else
|
|
56
|
-
response
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# @todo needs testing
|
|
61
|
-
def updates(params)
|
|
62
|
-
params['campaignId'] = @se_id
|
|
63
|
-
options = {campaignTypes: [params]}
|
|
64
|
-
request('updateCampaign',options)['campaignTypes']
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def update_by_id(id,params = {})
|
|
68
|
-
params['campaignId'] = id
|
|
69
|
-
options = {campaignTypes: [params]}
|
|
70
|
-
request('updateCampaign',options)['campaignTypes']
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def update(plans)
|
|
74
|
-
options = {campaignTypes: plans}
|
|
75
|
-
request('updateCampaign',options)['campaignTypes']
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def delete(ids)
|
|
79
|
-
ids = [ids] unless ids.class == Array
|
|
80
|
-
options = {campaignIds: ids}
|
|
81
|
-
request('deleteCampaign',options)['result'] == 1
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|