Class: PPC::Baidu::Bulk

Inherits:
PPC::Baidu show all
Defined in:
lib/ppc/baidu/bulk.rb

Constant Summary

Constants included from PPC

VERSION

Instance Method Summary collapse

Methods inherited from PPC::Baidu

#operations, #request

Constructor Details

#initialize(params = {}) ⇒ Bulk

Returns a new instance of Bulk.



13
14
15
16
# File 'lib/ppc/baidu/bulk.rb', line 13

def initialize(params = {})
  params[:service] = 'BulkJob'
  super(params)
end

Instance Method Details

#file_id_of_all(params = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ppc/baidu/bulk.rb', line 18

def file_id_of_all(params = {})
  plan_ids = params[:plan_ids]

  unless plan_ids.nil?
    plan_ids = plan_ids.class == Array ? plan_ids : [plan_ids]
  end

  options = {
    campaignIds:              plan_ids              || []      ,
    includeQuality:           params[:quality]      || true    ,
    includeTemp:              params[:temp]         || false   ,
    format:                   params[:format]       || 1       ,
    newCreativeFiles:         params[:adcopy]       || 0       ,
    includeTempNewCreatives:  params[:temp_adcopy]  || 0       ,
    includePhraseType:        params[:phrase]       || 0       ,
    extended:                 params[:extended]     || 0
  }
  response = request('getAllObjects',options)

  body = response[:envelope][:body]
  raise "no result" if body.nil?
  body[:get_all_objects_response][:file_id]
end

#path(id) ⇒ Object



47
48
49
# File 'lib/ppc/baidu/bulk.rb', line 47

def path(id)
  request('getFilePath',{fileId:id})[:envelope][:body][:get_file_path_response][:file_paths]
end

#state(id) ⇒ Object



42
43
44
45
# File 'lib/ppc/baidu/bulk.rb', line 42

def state(id)
  raise "empty id" if id.nil? or id.empty?
  request('getFileState',{fileId:id})[:envelope][:body][:get_file_state_response][:is_generated]
end