class PPC::API::Qihu::Plan
Constants
- PlanType
- Service
Public Class Methods
add( auth, plan )
click to toggle source
奇虎计划API不提供批量服务
# File lib/ppc/api/qihu/plan.rb, line 53 def self.add( auth, plan ) plan[0][:negative] = {exact: plan[0].delete(:exact_negative), phrase: plan[0].delete(:negative)}.to_json if plan[0][:exact_negative] || plan[0][:negative] params = make_type(plan)[0] response = request( auth, Service, 'add', params ) process( response, 'id' ){ |x| [ { id:x.to_i, name: plan[0][:name]} ] } end
all( auth )
click to toggle source
combine two original method to provice new method
# File lib/ppc/api/qihu/plan.rb, line 37 def self.all( auth ) self.get( auth, self.ids( auth )[:result] ) end
delete( auth, id )
click to toggle source
# File lib/ppc/api/qihu/plan.rb, line 67 def self.delete( auth, id ) response = request( auth, Service, 'deleteById', { id: id[0] } ) process( response, 'affectedRecords' ){ |x| x == '1'? 'success' : 'fail' } end
enable( auth, id )
click to toggle source
# File lib/ppc/api/qihu/plan.rb, line 72 def self.enable( auth, id ) self.update(auth, [{id: id[0], pause: "enable"}]) end
get(auth, ids)
click to toggle source
# File lib/ppc/api/qihu/plan.rb, line 47 def self.get(auth, ids) response = request( auth, Service, 'getInfoByIdList', {idList: ids} ) process( response, 'campaignList' ){ |x| reverse_type(x) } end
ids( auth )
click to toggle source
move getCampaignId to plan module for operation call
# File lib/ppc/api/qihu/plan.rb, line 42 def self.ids( auth ) response = request( auth, 'account', 'getCampaignIdList' ) process( response, 'campaignIdList' ){ |x| x.map(&:to_i) } end
info(auth, ids)
click to toggle source
# File lib/ppc/api/qihu/plan.rb, line 31 def self.info(auth, ids) response = request( auth, Service, 'getInfoByIdList', {idList: ids} ) process( response, 'campaignList' ){ |x| reverse_type(x)[0] } end
pause( auth, id )
click to toggle source
# File lib/ppc/api/qihu/plan.rb, line 76 def self.pause( auth, id ) self.update(auth, [{id: id[0], pause: "pause"}]) end
update( auth, plan )
click to toggle source
# File lib/ppc/api/qihu/plan.rb, line 60 def self.update( auth, plan ) plan[0][:negative] = {exact: plan[0].delete(:exact_negative), phrase: plan[0].delete(:negative)}.to_json if plan[0][:exact_negative] || plan[0][:negative] params = make_type(plan)[0] response = request( auth, Service, 'update', params ) process( response, 'id' ){ |x| [ { id:x.to_i } ] } end