Class: PPC::API::Baidu::Group

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

Constant Summary collapse

Service =
'Adgroup'

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

.add(auth, groups) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ppc/api/baidu/group.rb', line 35

def self.add( auth, groups )
  """
  @ input : one or list of AdgroupType
  @ output : list of AdgroupType
  """
  adgrouptypes = make_type( groups )

  body = {adgroupTypes:  adgrouptypes }
  
  response = request( auth, Service, "addAdgroup", body  )
  process( response, 'adgroupTypes' ){ |x| reverse_type(x) }
end

.delete(auth, ids) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/ppc/api/baidu/group.rb', line 60

def self.delete( auth, ids )
  """
  delete group body has no message
  """
  ids = [ ids ] unless ids.is_a? Array
  body = { adgroupIds: ids }
  response = request( auth, Service,"deleteAdgroup", body )
  process( response, 'nil' ){ |x|  x  }
end

.get(auth, ids) ⇒ Object



28
29
30
31
32
33
# File 'lib/ppc/api/baidu/group.rb', line 28

def self.get( auth, ids )
  ids = [ ids ] unless ids.is_a? Array
  body = { adgroupIds: ids }
  response = request(auth, Service, "getAdgroupByAdgroupId",body )
  process( response, 'adgroupTypes' ){ |x| reverse_type(x) }
end

.ids(auth) ⇒ Object



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

def self.ids(auth )
  """
  @return : Array of campaignAdgroupIds
  """
  response = request( auth, Service , "getAllAdgroupId" )
  process( response, 'campaignAdgroupIds' ){ |x| make_planGroupIds( x ) }
end

.search_by_plan_id(auth, ids) ⇒ Object



70
71
72
73
74
75
# File 'lib/ppc/api/baidu/group.rb', line 70

def self.search_by_plan_id( auth, ids )
  ids = [ ids ] unless ids.class == Array
  body = { campaignIds: ids }
  response = request( auth, Service ,"getAdgroupByCampaignId",  body )
  process( response, 'campaignAdgroups' ){ |x| make_planGroups( x ) }
end

.search_id_by_plan_id(auth, ids) ⇒ Object



77
78
79
80
81
82
# File 'lib/ppc/api/baidu/group.rb', line 77

def self.search_id_by_plan_id( auth, ids )
  ids = [ ids ] unless ids.class == Array
  body = { campaignIds: ids }
  response = request( auth, Service ,"getAdgroupIdByCampaignId",  body )
  process( response, 'campaignAdgroupIds' ){ |x| make_planGroupIds( x ) }
end

.update(auth, groups) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ppc/api/baidu/group.rb', line 48

def self.update( auth, groups )
  """
  @ input : one or list of AdgroupType
  @ output : list of AdgroupType
  """
  adgrouptypes = make_type( groups )
  body = {adgroupTypes: adgrouptypes}
  
  response = request( auth, Service, "updateAdgroup",body )
  process( response, 'adgroupTypes' ){ |x| reverse_type(x) }
end