Class: PPC::API::Baidu::Creative

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

Constant Summary collapse

Service =
'Creative'

Class Method Summary collapse

Methods inherited from PPC::API::Baidu

debug_off, debug_on, process, request, request_uri, reverse_type

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

.activate(auth, ids) ⇒ Object



56
57
58
59
60
61
# File 'lib/ppc/api/baidu/creative.rb', line 56

def self.activate( auth, ids )
  ids = [ ids ] unless ids.is_a? Array
  body = { creativeIds: ids }
  response = request( auth, Service, 'activateCreative', body )
  process( response, 'creativeTypes' ){ |x| reverse_type(x) }
end

.add(auth, creatives) ⇒ Object



22
23
24
25
26
# File 'lib/ppc/api/baidu/creative.rb', line 22

def self.add( auth, creatives )
  body = { creativeTypes: make_type( creatives ) }
  response = request( auth, Service, 'addCreative', body )
  process( response, 'creativeTypes' ){ |x| reverse_type(x) }
end

.delete(auth, ids) ⇒ Object



49
50
51
52
53
54
# File 'lib/ppc/api/baidu/creative.rb', line 49

def self.delete( auth, ids )
  ids = [ ids ] unless ids.is_a? Array
  body = { creativeIds: ids }
  response = request( auth, Service, 'deleteCreative', body )
  process( response, 'result' ){ |x| x }
end

.get(auth, ids, getTemp = 0) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ppc/api/baidu/creative.rb', line 28

def self.get( auth, ids, getTemp = 0 )
  '''
  \'getCreativeByCreativeId\'
  @ input : creative ids
  @ output: creative informations
  '''
  ids = [ ids ] unless ids.is_a? Array
  body = { creativeIds: ids, getTemp: getTemp }
  response = request( auth, Service, 'getCreativeByCreativeId', body )
  process( response, 'creativeTypes' ){ |x| reverse_type(x) }
end

.search_by_group_id(auth, ids, getTemp = 0) ⇒ Object



91
92
93
94
95
96
# File 'lib/ppc/api/baidu/creative.rb', line 91

def self.search_by_group_id( auth, ids, getTemp = 0 )
  ids = [ ids ] unless ids.is_a? Array
  body = { adgroupIds: ids, getTemp: getTemp }
  response = request( auth, Service, 'getCreativeByAdgroupId', body )
  process( response, 'groupCreatives' ){ |x| make_groupCreatives( x ) }
end

.search_id_by_group_id(auth, ids, getTemp = 0) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/ppc/api/baidu/creative.rb', line 79

def self.search_id_by_group_id( auth, ids, getTemp = 0 )
  '''
  \'getCreativeIdByAdgroupId\'
  @ input: group ids
  @ output:  groupCreativeIds
  '''
  ids = [ ids ] unless ids.is_a? Array
  body = { adgroupIds: ids, getTemp: getTemp }
  response = request( auth, Service, 'getCreativeIdByAdgroupId', body )
  process( response, 'groupCreativeIds' ){ |x| make_groupCreativeIds( x ) }
end

.status(auth, ids, type) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ppc/api/baidu/creative.rb', line 63

def self.status( auth, ids, type )
  ids = [ ids ] unless ids.is_a? Array
  
  type = case type
    when  'plan'      then    3 
    when  'group'     then    5
    when  'creative'  then    7
    else
      Exception.new( 'type must among: \'plan\',\'group\' and \'key\' ')            
  end

  body = { ids: ids, type: type }
  response = request( auth, Service, 'getCreativeStatus', body )
  process( response, 'CreativeStatus' ){ |x| x }
end

.update(auth, creatives) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/ppc/api/baidu/creative.rb', line 40

def self.update( auth, creatives )
  '''
  根据实际使用情况,更新的时候creative title为必填选
  '''
  body = { creativeTypes: make_type( creatives ) }
  response = request( auth, Service, 'updateCreative', body )
  process( response, 'creativeTypes' ){ |x| reverse_type(x) }
end