Class: PPC::API::Sogou::Keyword

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

Constant Summary collapse

Service =
'Cpc'
Match_type =

Match_type = { ‘exact’ => 0, ‘wide’ => 1,0 => ‘exact’, 1 => ‘wide’ }

{ 'exact' => 0, 'phrase' => 2, 'wide' => 1,'0' => 'exact', '2' => 'phrase', '1' => 'wide' }

Class Method Summary collapse

Methods inherited from PPC::API::Sogou

debug_print, process, request

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, keywords) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/ppc/api/sogou/keyword.rb', line 47

def self.add( auth, keywords )
  '''
  '''
  cpcTypes = make_type( keywords ) 
  body = { cpcTypes: cpcTypes }
  response = request( auth, Service, "addCpc", body )
  process(response, 'cpcTypes'){|x| reverse_type(x)  }
end

.delete(auth, ids) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/ppc/api/sogou/keyword.rb', line 65

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

.get(auth, ids) ⇒ Object

后面改成info方法



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

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

.quality(auth, ids) ⇒ Object



104
105
106
107
108
109
110
111
112
# File 'lib/ppc/api/sogou/keyword.rb', line 104

def self.quality( auth ,ids )
  '''
  Return [ { id: id, quality: quality} ... ]
  '''
  ids = [ ids ] unless ids.is_a? Array
  body = { cpcIds: ids}
  response = request( auth, Service, 'getCpcByCpcId', { cpcIds: ids} )
  process(response, 'cpcTypes'){  |x| reverse_type(x, @quality_map) }
end

.search_by_group_id(auth, group_ids) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ppc/api/sogou/keyword.rb', line 74

def self.search_by_group_id( auth, group_ids )
  """
  getKeywordByGroupIds
  @input: list of group id
  @output:  list of groupKeyword
  """
  group_ids = [ group_ids ] unless group_ids.is_a? Array
  body = { cpcGrpIds: group_ids }
  response = request( auth, Service, "getCpcByCpcGrpId", body )
  process(response, 'cpcGrpCpcs'){|x| make_groupKeywords( x ) }
end

.search_id_by_group_id(auth, group_ids) ⇒ Object



86
87
88
89
90
91
# File 'lib/ppc/api/sogou/keyword.rb', line 86

def self.search_id_by_group_id( auth, group_ids )
  group_ids = [ group_ids ] unless group_ids.is_a? Array
  body = { cpcGrpIds: group_ids }
  response = request( auth, Service, "getCpcIdByCpcGrpId", body )
  process(response, 'cpcGrpCpcIds'){|x| make_groupKeywordIds( x ) }
end

.status(auth, ids) ⇒ Object

sogou的keyword服务不提供质量度和状态,从getInfo方法中查询



94
95
96
97
98
99
100
101
102
# File 'lib/ppc/api/sogou/keyword.rb', line 94

def self.status( auth, ids )
  '''
  Return [ { id: id, status: status} ... ]
  '''
  ids = [ ids ] unless ids.is_a? Array
  body = { cpcIds: ids}
  response = request( auth, Service, 'getCpcByCpcId', body )
  process(response, 'cpcTypes'){  |x|  reverse_type(x, @status_map) }
end

.update(auth, keywords) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/ppc/api/sogou/keyword.rb', line 56

def self.update( auth, keywords )
  '''
  '''
  cpcTypes = make_type( keywords ) 
  body = { cpcTypes: cpcTypes }
  response = request( auth, Service, "updateCpc", body )
  process(response, 'cpcTypes'){|x| reverse_type(x)  }
end