Class: PPC::API::Qihu::Report
- Inherits:
-
PPC::API::Qihu
- Object
- PPC::API::Qihu
- PPC::API::Qihu::Report
- Defined in:
- lib/ppc/api/qihu/report.rb
Constant Summary collapse
- Service =
'report'
Class Method Summary collapse
-
.abstract(auth, type_name, method_name, key, param = nil, &func) ⇒ Object
API abstraction #.
- .creative_report(auth, param, debug = false) ⇒ Object
- .download_report(auth, type, param, debug = false) ⇒ Object
-
.keyword_report(auth, param, debug = false) ⇒ Object
Interfaces for operation #.
Methods inherited from PPC::API::Qihu
process, request_http_body, request_http_header, request_uri, reverse_type, to_id_list, to_json_string
Methods included from PPC::API
#debug_off, #debug_on, #is_no_quota, #make_type, #process, #request, #request_http_body, #request_http_header, #request_uri, #reverse_type
Class Method Details
.abstract(auth, type_name, method_name, key, param = nil, &func) ⇒ Object
API abstraction #
31 32 33 34 35 |
# File 'lib/ppc/api/qihu/report.rb', line 31 def self.abstract( auth, type_name, method_name, key, param = nil, &func ) body = make_type( param ) response = request( auth, Service, method_name, body ) process( response, key ){ |x| func[ x ] } end |
.creative_report(auth, param, debug = false) ⇒ Object
68 69 70 |
# File 'lib/ppc/api/qihu/report.rb', line 68 def self.creative_report( auth, param, debug = false ) download_report(auth, 'creative', param, debug) end |
.download_report(auth, type, param, debug = false) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ppc/api/qihu/report.rb', line 72 def self.download_report(auth, type, param, debug = false) # deal_with time now = Time.now.to_s[0...10] is_now = now==parse_date(param[:startDate]) # get page num if is_now method = (type+'_now_count').to_sym count = send(method, auth, param)[:result] method = (type+'_now').to_sym else method = (type+'_count').to_sym count = send(method, auth, param)[:result] method = type.to_sym end report = [] count[:total_page].to_i.times do | page_i| p "Start downloading #{page_i+1}th page, totally #{count[:total_page]} pages" param[:page] = page_i +1 report_i = send(method, auth, param)[:result] report += report_i end return report end |
.keyword_report(auth, param, debug = false) ⇒ Object
Interfaces for operation #
64 65 66 |
# File 'lib/ppc/api/qihu/report.rb', line 64 def self.keyword_report( auth, param, debug = false ) download_report(auth, 'keyword', param, debug ) end |