class PPC::API::Qihu::Creative

Constants

CreativeType
Service

Public Class Methods

add( auth, creatives ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 54
def self.add( auth,  creatives )
  response = request( auth, Service, 'add', { creatives: make_type( creatives ) } )
  process( response, 'creativeIdList'){ |x| x.map{|tmp| { id: i.to_i } } }
end
all( auth, group_id ) click to toggle source

combine two methods to provide another mether

# File lib/ppc/api/qihu/creative.rb, line 38
def self.all( auth, group_id )
  results = self.ids( auth, group_id )
  return results unless results[:succ]
  self.get( auth , results[:result] )
end
delete( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 64
def self.delete( auth, ids )
  response = request( auth, Service, 'deleteByIdList', { idList: ids } )
  process( response, 'affectedRecords' ){ |x|x }
end
enable( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 69
def self.enable( auth, ids )
  self.update( auth, ids.map{ |id| { id: id, pause: "enable"} } )
end
get( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 49
def self.get( auth, ids )
  response = request( auth, Service, 'getInfoByIdList', { idList: ids } )
  process( response, 'creativeList'){ |x| reverse_type(x) }
end
ids( auth, group_id ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 44
def self.ids( auth, group_id )
  response = request( auth, Service, 'getIdListByGroupId', {"groupId" => group_id[0]} )
  process( response, 'creativeIdList' ){ |x| x.map(&:to_i) }
end
info( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 32
def self.info( auth, ids )
  response = request( auth, Service, 'getInfoByIdList', { idList: ids } )
  process( response, 'creativeList'){ |x| reverse_type(x)[0] }
end
pause( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 73
def self.pause( auth, ids )
  self.update( auth, ids.map{ |id| { id: id, pause: "pause"} } )
end
quality( auth, ids ) click to toggle source

quality 本质上和 status 在一个方法里面

# File lib/ppc/api/qihu/creative.rb, line 83
def self.quality( auth, ids )
  self.status( auth, ids)
end
status( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 77
def self.status( auth, ids )
  response = request( auth, Service, 'getStatusByIdList', { idList: ids } )
  process( response, 'creativeList' ){ |x| reverse_type( x, @status_map ) }
end
update( auth, creatives ) click to toggle source
# File lib/ppc/api/qihu/creative.rb, line 59
def self.update( auth, creatives )
  response = request( auth, Service, 'update', { creatives: make_type( creatives ) } )
  process( response, 'affectedRecords', 'failCreativeIds' ){ |x| x }
end