Class: PPC::API::Baidu::Report

Inherits:
PPC::API::Baidu show all
Defined in:
lib/ppc/api/baidu/report.rb

Constant Summary collapse

Service =
'Report'
Type_map =

需要用到的映射集合

{ 'account' => 2, 'plan'=> 10, 'group'=> 11, 
                      'keyword'=> 14, 'creative'=> 12, 'pair'=> 15, 
'region'=> 3, 'wordid'=> 9 , 'query'=>6 }
Level_map =
{  'account' => 2, 'plan' => 3, 'group' => 5, 
                        'creative'=> 7, 'keywordid' => 11, 'pair' => 12, 
'wordid' => 6 }
Device_map =
{ 'all' => 0, 'pc' => 1, 'mobile' => 2 }
Unit_map =
{ 'day' => 5, 'week' => 4, 'month' => 3, 'year' => 1, 'hour' => 7 }

Class Method Summary collapse

Methods inherited from PPC::API::Baidu

process, request_uri

Methods included from PPC::API

#make_type, #process, #request, #request_http_body, #request_http_header, #request_uri, #reverse_type

Class Method Details

.get_id(auth, params) ⇒ Object

API wraping function #



24
25
26
27
28
29
# File 'lib/ppc/api/baidu/report.rb', line 24

def self.get_id( auth, params  )
  request = make_reportrequest( params )
  body =  { reportRequestType:  request }
  response = request( auth, Service, 'getProfessionalReportId' ,body) 
  process( response, 'reportId' ){ |x| x[0]["reportId"] }
end

.get_state(auth, id) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/ppc/api/baidu/report.rb', line 31

def self.get_state( auth, id )
  '''
  input id should be string
  '''
  status = {1=>'Waiting' ,2=>'Opearting' ,3=>'Finished'}
  body = { reportId:  id }
  response = request( auth, Service, 'getReportState' ,body)
  process( response, 'isGenerated' ){ |x| status[x[0]["isGenerated"]] }
end

.get_url(auth, id) ⇒ Object



41
42
43
44
45
# File 'lib/ppc/api/baidu/report.rb', line 41

def self.get_url( auth, id  )
  body = { reportId:  id }
  response = request( auth, Service, 'getReportFileUrl' ,body)
  process( response, 'reportFilePath' ){ |x| x[0]["reportFilePath"] }       
end