class PPC::API::Qihu::Keyword

Constants

KeywordType
Service

Public Class Methods

add( auth, keywords ) click to toggle source
# File lib/ppc/api/qihu/keyword.rb, line 56
def self.add( auth,  keywords )
  response = request( auth, Service, 'add', { keywords: make_type( keywords )} )
  process( response, 'keywordIdList'){ |x| x.map.with_index{|id, index| {id: id, keyword: keywords[index][:word]}} }
end
all( auth, group_id ) click to toggle source

combine search_id and get to provide another method

# File lib/ppc/api/qihu/keyword.rb, line 40
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/keyword.rb, line 66
def self.delete( auth, ids )
  response = request( auth, Service, 'deleteByIdList', { idList: ids } )
  process( response, 'affectedRecords' ){ |x|  x == keywords.size ? keywords.map{|keyword| {id: keyword[:id]}} : nil  }     
end
enable( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/keyword.rb, line 71
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/keyword.rb, line 51
def self.get( auth, ids )
  response = request( auth, Service, 'getInfoByIdList', { idList: ids } )
  process( response, 'keywordList'){ |x| reverse_type(x) }
end
getChangedIdList() click to toggle source
# File lib/ppc/api/qihu/keyword.rb, line 89
def self.getChangedIdList
  # unimplemented
end
ids( auth, group_id ) click to toggle source
# File lib/ppc/api/qihu/keyword.rb, line 46
def self.ids( auth, group_id )
  response = request( auth, Service, 'getIdListByGroupId', {'groupId' => group_id[0]} )
  process( response, 'keywordIdList' ){ |x| x.map(&:to_i) }
end
info( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/keyword.rb, line 34
def self.info( auth, ids )
  response = request( auth, Service, 'getInfoByIdList', { idList: ids } )
  process( response, 'keywordList'){ |x| reverse_type(x)[0] }
end
pause( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/keyword.rb, line 75
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/keyword.rb, line 85
def self.quality( auth, ids )
  self.status( auth, ids)
end
status( auth, ids ) click to toggle source
# File lib/ppc/api/qihu/keyword.rb, line 79
def self.status( auth, ids )
  response = request( auth, Service, 'getStatusByIdList', { idList: ids } )
  process( response, 'keywordList' ){ |x| reverse_type(x, @status_map) }
end
update( auth, keywords ) click to toggle source
# File lib/ppc/api/qihu/keyword.rb, line 61
def self.update( auth, keywords )
  response = request( auth, Service, 'update', { keywords: make_type( keywords )} )
  process( response, 'affectedRecords', 'failKeywordIds' ){ |x| x == keywords.size ? keywords.map{|keyword| {id: keyword[:id]}} : nil }
end