class PPC::API::Qihu::Group
Constants
- GroupType
- Service
Public Class Methods
add( auth, groups )
click to toggle source
# File lib/ppc/api/qihu/group.rb, line 42 def self.add( auth, groups ) groups.each{ |group| group[:negative] = {exact: group.delete(:exact_negative), phrase: group.delete(:negative)} if group[:exact_negative] || group[:negative] } response = request( auth, Service, 'batchAdd', {groups: make_type( groups )} ) process( response, 'groupIdList' ){ |x| x.map.with_index{|id, index| {id: id, name: groups[index][:name]}} } end
all( auth, plan_id )
click to toggle source
# File lib/ppc/api/qihu/group.rb, line 27 def self.all( auth, plan_id ) group_ids = self.ids( auth, plan_id )[:result][:group_ids] self.get( auth, group_ids ) end
delete( auth, id )
click to toggle source
# File lib/ppc/api/qihu/group.rb, line 56 def self.delete( auth, id ) response = request( auth, Service, 'deleteById', {id: id[0]} ) process( response, 'affectedRecords' ){ |x| x == '1' } end
enable( auth, id )
click to toggle source
# File lib/ppc/api/qihu/group.rb, line 61 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/group.rb, line 37 def self.get( auth, ids ) response = request( auth, Service, 'getInfoByIdList', { idList: ids } ) process( response, 'groupList' ){ |x| reverse_type(x) } end
ids( auth, plan_id )
click to toggle source
# File lib/ppc/api/qihu/group.rb, line 32 def self.ids( auth, plan_id ) response = request( auth, Service, 'getIdListByCampaignId', { campaignId: plan_id[0] } ) process( response, 'groupIdList' ){ |x| { plan_id: plan_id[0], group_ids: x.map(&:to_i) } } end
info( auth, ids )
click to toggle source
# File lib/ppc/api/qihu/group.rb, line 22 def self.info( auth, ids ) response = request( auth, Service, 'getInfoByIdList', { idList: ids } ) process( response, 'groupList' ){ |x| reverse_type(x)[0] } end
pause( auth, id )
click to toggle source
# File lib/ppc/api/qihu/group.rb, line 65 def self.pause( auth, id ) self.update(auth, [{id: id[0], pause: "pause"}]) end
update( auth, group )
click to toggle source
奇虎组服务不提供批量delete和update方法
# File lib/ppc/api/qihu/group.rb, line 49 def self.update( auth, group ) group[0][:negative] = {exact: group[0].delete(:exact_negative), phrase: group[0].delete(:negative)}.to_json if group[0][:exact_negative] || group[0][:negative] params = make_type(group)[0] response = request( auth, Service, 'update', params ) process( response, 'id' ){ |x| [{id: x, name: group[0][:name]}] } end