Class: PPC::API::Sogou::Group

Inherits:
PPC::API::Sogou show all
Defined in:
lib/ppc/api/sogou/group.rb

Constant Summary collapse

Service =
'CpcGrp'

Class Method Summary collapse

Methods inherited from PPC::API::Sogou

debug_print, process, request, 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



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

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

  body = {cpcGrpTypes:  cpcGrpTypes }
  
  response = request( auth, Service, "addCpcGrp", body  )
  process( response, 'cpcGrpTypes' ){ |x| reverse_type(x) }
end

.delete(auth, ids) ⇒ Object



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

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

.get(auth, ids) ⇒ Object



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

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

.ids(auth) ⇒ Object



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

def self.ids( auth )
  """
  @return : Array of cpcPlanGrpIdTypes
  """
  response = request( auth, Service , "getAllCpcGrpId" )
  #此处返回值与key与开发文档不同
  process( response, 'cpcPlanGrpIds' ){ |x| make_planGroupIds( x ) }
end

.search_by_plan_id(auth, ids) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/ppc/api/sogou/group.rb', line 71

def self.search_by_plan_id( auth, ids )
  ids = [ ids ] unless ids.is_a? Array
  body = { cpcPlanIds: ids }
  response = request( auth, Service ,"getCpcGrpByCpcPlanId",  body )
  # 此处key与开发文档不同
  process( response, 'cpcPlanGrps' ){ |x| make_planGroups( x ) }
end

.search_id_by_plan_id(auth, ids) ⇒ Object



79
80
81
82
83
84
# File 'lib/ppc/api/sogou/group.rb', line 79

def self.search_id_by_plan_id( auth, ids )
  ids = [ ids ] unless ids.is_a? Array
  body = { cpcPlanIds: ids }
  response = request( auth, Service ,"getCpcGrpIdByCpcPlanId",  body )
  process( response, 'cpcPlanGrpIds' ){ |x| make_planGroupIds( x ) }
end

.update(auth, groups) ⇒ Object



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

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