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'
- ReportType =
{ queryword: :queryword, plan_id: :campaignId, creative_id: :creativeId, creative_name: :creativeName, keyword: :keyword, views: :views, clicks: :clicks, startDate: :startDate, endDate: :endDate, date: :date, keyword_id: :keywordId, group_id: :groupId, cost: :totalCost, position: :avgPosition, total_num: :totalNumber, total_page: :totalPage, }
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
Methods included from PPC::API
#debug_off, #debug_on, #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 #
33 34 35 36 |
# File 'lib/ppc/api/qihu/report.rb', line 33 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, debug = false) ⇒ Object
64 65 66 |
# File 'lib/ppc/api/qihu/report.rb', line 64 def self.creative_report( auth, param, debug = false ) download_report(auth, 'creative', param, debug) end |
.download_report(auth, type, param, debug = false) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ppc/api/qihu/report.rb', line 68 def self.download_report(auth, type, param, debug = false) # 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, debug = false) ⇒ Object
Interfaces for operation #
60 61 62 |
# File 'lib/ppc/api/qihu/report.rb', line 60 def self.keyword_report( auth, param, debug = false ) download_report(auth, 'keyword', param, debug ) end |