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 }
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

make_type, process, request, reverse_type

Class Method Details

.get_file_url(auth, id, debug = false) ⇒ Object



52
53
54
55
56
# File 'lib/ppc/api/baidu/report.rb', line 52

def self.get_file_url( auth, id, debug = false )
  body = { reportId:  id }
  response = request( auth, Service, 'getReportFileUrl' ,body)
  process( response, 'reportFilePath', debug ){ |x| x }       
end

.get_id(auth, params, debug = false) ⇒ Object



35
36
37
38
39
40
# File 'lib/ppc/api/baidu/report.rb', line 35

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

.get_realtime(auth, params, type = 'data', debug = false) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ppc/api/baidu/report.rb', line 18

def self.get_realtime( auth, params, type = 'data', debug = false )
  request = make_realtimerequest( params )[0]
  body = { realTimeRequestTypes:  request }
  response = request( auth, Service, 'getRealTimeData' ,body)
  if debug
    return response
  end

  response = case type
    when 'data'     then    response['body']['realTimeResultTypes']
    when 'query'  then   response['body']['realTimeQueryResultTypes']
    when 'pair'      then    response['body']['realTimePairResultTypes']
  end
  return response                   
end

.get_status(auth, id, debug = false) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/ppc/api/baidu/report.rb', line 42

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