Class: PPC::API::Qihu::Keyword
Constant Summary
collapse
- Service =
'keyword'
- KeywordType =
{
id: :id,
group_id: :groupId,
keyword: :word,
price: :price,
match_type: :matchType,
pc_destination: :url,
"pc_destination" => :destinationUrl,
mobile_destination: :mobileUrl,
"mobile_destination" => :mobileDestinationUrl,
pause: :status,
mobile_pause: :mobileStatus,
add_time: :addTime,
update_time: :updateTime,
}
Class Method Summary
collapse
-
.add(auth, keywords) ⇒ Object
-
.all(auth, group_id) ⇒ Object
combine search_id and get to provide another method.
-
.delete(auth, ids) ⇒ Object
-
.enable(auth, ids) ⇒ Object
-
.get(auth, ids) ⇒ Object
-
.getChangedIdList ⇒ Object
-
.ids(auth, group_id) ⇒ Object
-
.info(auth, ids) ⇒ Object
-
.pause(auth, ids) ⇒ Object
-
.quality(auth, ids) ⇒ Object
quality 本质上和 status 在一个方法里面.
-
.status(auth, ids) ⇒ Object
-
.update(auth, keywords) ⇒ Object
process, request_http_body, request_http_header, request_uri
Methods included from PPC::API
#make_type, #process, #request, #request_http_body, #request_http_header, #request_uri, #reverse_type
Class Method Details
.add(auth, keywords) ⇒ Object
57
58
59
60
|
# File 'lib/ppc/api/qihu/keyword.rb', line 57
def self.add( auth, keywords )
response = request( auth, Service, 'add', { keywords: make_type( keywords )} )
process( response, 'keywordIdList'){ |x| x.map.with_index{|id, index| {id: id, keyword: keywords[index][:word]}} }
end
|
.all(auth, group_id) ⇒ Object
combine search_id and get to provide another method
41
42
43
44
45
|
# File 'lib/ppc/api/qihu/keyword.rb', line 41
def self.all( auth, group_id )
results = self.ids( auth, group_id )
return results unless results[:succ]
self.get( auth , results[:result] )
end
|
.delete(auth, ids) ⇒ Object
67
68
69
70
|
# File 'lib/ppc/api/qihu/keyword.rb', line 67
def self.delete( auth, ids )
response = request( auth, Service, 'deleteByIdList', { idList: ids } )
process( response, 'affectedRecords' ){ |x| x == keywords.size ? keywords.map{|keyword| {id: keyword[:id]}} : nil }
end
|
.enable(auth, ids) ⇒ Object
72
73
74
|
# File 'lib/ppc/api/qihu/keyword.rb', line 72
def self.enable( auth, ids )
self.update( auth, ids.map{ |id| { id: id, pause:'enable'} } )
end
|
.get(auth, ids) ⇒ Object
52
53
54
55
|
# File 'lib/ppc/api/qihu/keyword.rb', line 52
def self.get( auth, ids )
response = request( auth, Service, 'getInfoByIdList', { idList: ids } )
process( response, 'keywordList'){ |x| reverse_type(x) }
end
|
.getChangedIdList ⇒ Object
90
91
92
|
# File 'lib/ppc/api/qihu/keyword.rb', line 90
def self.getChangedIdList
end
|
.ids(auth, group_id) ⇒ Object
47
48
49
50
|
# File 'lib/ppc/api/qihu/keyword.rb', line 47
def self.ids( auth, group_id )
response = request( auth, Service, 'getIdListByGroupId', {'groupId' => group_id[0]} )
process( response, 'keywordIdList' ){ |x| x.map(&:to_i) }
end
|
.info(auth, ids) ⇒ Object
35
36
37
38
|
# File 'lib/ppc/api/qihu/keyword.rb', line 35
def self.info( auth, ids )
response = request( auth, Service, 'getInfoByIdList', { idList: ids } )
process( response, 'keywordList'){ |x| reverse_type(x)[0] }
end
|
.pause(auth, ids) ⇒ Object
76
77
78
|
# File 'lib/ppc/api/qihu/keyword.rb', line 76
def self.pause( auth, ids )
self.update( auth, ids.map{ |id| { id: id, pause:'pause'} } )
end
|
.quality(auth, ids) ⇒ Object
quality 本质上和 status 在一个方法里面
86
87
88
|
# File 'lib/ppc/api/qihu/keyword.rb', line 86
def self.quality( auth, ids )
self.status( auth, ids)
end
|
.status(auth, ids) ⇒ Object
80
81
82
83
|
# File 'lib/ppc/api/qihu/keyword.rb', line 80
def self.status( auth, ids )
response = request( auth, Service, 'getStatusByIdList', { idList: ids } )
process( response, 'keywordList' ){ |x| reverse_type(x, @status_map) }
end
|
.update(auth, keywords) ⇒ Object
62
63
64
65
|
# File 'lib/ppc/api/qihu/keyword.rb', line 62
def self.update( auth, keywords )
response = request( auth, Service, 'update', { keywords: make_type( keywords )} )
process( response, 'affectedRecords', 'failKeywordIds' ){ |x| x == keywords.size ? keywords.map{|keyword| {id: keyword[:id]}} : nil }
end
|