class PPC::API::Qihu::Report
Constants
- ReportType
- Service
Public Class Methods
abstract( auth, type_name, method_name, key, param = nil, &func )
click to toggle source
API
abstraction #
# File lib/ppc/api/qihu/report.rb, line 32 def self.abstract( auth, type_name, method_name, key, param = nil, &func ) response = request( auth, Service, method_name, make_type( param ) ) process( response, key ){ |x| func[ x ] } end
creative_report( auth, param )
click to toggle source
# File lib/ppc/api/qihu/report.rb, line 63 def self.creative_report( auth, param ) download_report(auth, 'creative', param ) end
download_report(auth, type, param )
click to toggle source
# File lib/ppc/api/qihu/report.rb, line 67 def self.download_report(auth, type, param ) # deal_with time is_now = Date.today == Date.parse(param[:startDate]) # get page num method = (type+ (is_now ? '_now' : '') + '_count').to_sym response = send(method, auth, param) count = response[:result] method = (type+ (is_now ? '_now' : '')).to_sym if count && count[:total_page] count[:total_page].to_i.times.map{ | page_i| p "Start downloading #{page_i+1}th page, totally #{count[:total_page]} pages" param[:page] = page_i +1 send(method, auth, param)[:result] }.flatten else response end end
keyword_report( auth, param )
click to toggle source
Interfaces for operation #
# File lib/ppc/api/qihu/report.rb, line 59 def self.keyword_report( auth, param ) download_report(auth, 'keyword', param ) end
Private Class Methods
make_type( param )
click to toggle source
Helper Function #
incase idlist == nil
# File lib/ppc/api/qihu/report.rb, line 94 def self.make_type( param ) param[:level] ||= 'account' param[:page] ||= 1 param[:IdList] = [param.delete(:ids)].flatten.map(&:to_s) param[:startDate] = Date.parse(param[:startDate]).to_s rescue Date.today.to_s param[:endDate] = Date.parse(param[:endDate]).to_s rescue Date.today.to_s param end