Class: PPC::API::Baidu::Keyword
Constant Summary
collapse
- Service =
'Keyword'
- Match_type =
{ 'exact' => 1, 'phrase' => 2, 'wide' => 3,1 => 'exact', 2=> 'phrase' , 3 => 'wide' }
- Device =
{ 'pc' => 0, 'mobile' => 1, 'all' => 2 }
- Type =
{ 'plan' => 3, 'group' => 5, 'keyword' => 11 }
- KeywordType =
{
id: :keywordId,
group_id: :adgroupId,
plan_id: :campaignId,
keyword: :keyword,
price: :price,
pc_destination: :pcDestinationUrl,
mobile_destination: :mobileDestinationUrl,
match_type: :matchType,
phrase_type: :phraseType,
status: :status,
pause: :pause,
wmatchprefer: :wmatchprefer,
}
- KeywordQualityType =
{
id: :id,
group_id: :adgroupId,
plan_id: :campaignId,
pc_quality: :pcQuality,
pc_reliable: :pcReliable,
pc_reason: :pcReason,
pc_scale: :pcScale,
mobile_quality: :mobileQuality,
mobile_reliable: :mobileReliable,
mobile_reason: :mobileReason,
mobile_scale: :mobileScale,
}
Class Method Summary
collapse
-
.add(auth, keywords) ⇒ Object
-
.all(auth, group_ids) ⇒ Object
-
.delete(auth, ids) ⇒ Object
-
.enable(auth, ids) ⇒ Object
-
.get(auth, ids) ⇒ Object
-
.ids(auth, group_ids) ⇒ Object
-
.info(auth, ids) ⇒ Object
-
.pause(auth, ids) ⇒ Object
-
.quality(auth, ids) ⇒ Object
-
.search(auth, params) ⇒ Object
-
.status(auth, ids) ⇒ Object
-
.update(auth, keywords) ⇒ Object
process, 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
68
69
70
71
72
|
# File 'lib/ppc/api/baidu/keyword.rb', line 68
def self.add( auth, keywords )
body = { keywordTypes: make_type( keywords ) }
response = request( auth, Service, "addWord", body )
process(response, 'keywordTypes' ){|x| reverse_type(x) }
end
|
.all(auth, group_ids) ⇒ Object
50
51
52
53
54
|
# File 'lib/ppc/api/baidu/keyword.rb', line 50
def self.all( auth, group_ids )
body = { ids: group_ids, idType: 5, wordFields: KeywordType.values}
response = request( auth, Service, 'getWord', body )
process(response, 'groupKeywords' ){|x| reverse_type( x ) }
end
|
.delete(auth, ids) ⇒ Object
80
81
82
83
84
|
# File 'lib/ppc/api/baidu/keyword.rb', line 80
def self.delete( auth, ids )
body = { keywordIds: ids}
response = request( auth, Service, 'deleteWord', body )
process(response, 'result' ){|x| x }
end
|
.enable(auth, ids) ⇒ Object
86
87
88
89
|
# File 'lib/ppc/api/baidu/keyword.rb', line 86
def self.enable( auth, ids )
keywords = ids.map{|id| {id: id, pause: false} }
self.update( auth, keywords )
end
|
.get(auth, ids) ⇒ Object
62
63
64
65
66
|
# File 'lib/ppc/api/baidu/keyword.rb', line 62
def self.get( auth, ids )
body = { ids: ids, idType: 11, wordFields: KeywordType.values}
response = request( auth, Service, 'getWord', body )
process(response, 'keywordTypes' ){|x| reverse_type( x ) }
end
|
.ids(auth, group_ids) ⇒ Object
56
57
58
59
60
|
# File 'lib/ppc/api/baidu/keyword.rb', line 56
def self.ids( auth, group_ids )
body = { ids: group_ids, idType: 5, wordFields: [:keywordId]}
response = request( auth, Service, 'getWord', body )
process(response, 'groupKeywordIds' ){|x| reverse_type( x ) }
end
|
.info(auth, ids) ⇒ Object
44
45
46
47
48
|
# File 'lib/ppc/api/baidu/keyword.rb', line 44
def self.info( auth, ids )
body = { ids: ids, idType: 11, wordFields: KeywordType.values}
response = request( auth, Service, 'getWord', body )
process(response, 'keywordType' ){|x| reverse_type( x )[0] }
end
|
.pause(auth, ids) ⇒ Object
91
92
93
94
|
# File 'lib/ppc/api/baidu/keyword.rb', line 91
def self.pause( auth, ids )
keywords = ids.map{|id| {id: id, pause: true} }
self.update( auth, keywords )
end
|
.quality(auth, ids) ⇒ Object
102
103
104
105
106
|
# File 'lib/ppc/api/baidu/keyword.rb', line 102
def self.quality( auth, ids )
body = { ids: ids, idType: 11, keywordTypes: KeywordQualityType.values}
response = request( auth, Service, 'getWord', body )
process(response, 'groupKeywords' ){|x| reverse_type( x , KeywordQualityType) }
end
|
.search(auth, params) ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/ppc/api/baidu/keyword.rb', line 108
def self.search( auth, params )
body = {
searchWord: params[:keyword],
startNum: 1,
endNum: 1000,
searchLevel: 2,
searchType: 1,
}
body.merge!(campaignId: params[:plan_id]) if params[:plan_id]
body.merge!(adgroupId: params[:group_id]) if params[:group_id]
response = request( auth, "Search", 'getMaterialInfoBySearch', body )
process(response, 'materialSearchInfos' ){|x| x[0]["materialSearchInfos"].map{|tmp| tmp["materialInfos"]} }
end
|
.status(auth, ids) ⇒ Object
96
97
98
99
100
|
# File 'lib/ppc/api/baidu/keyword.rb', line 96
def self.status( auth, ids )
body = { ids: ids, idType: 11, keywordTypes: [:keywordId, :status]}
response = request( auth, Service, 'getWord', body )
process(response, 'groupKeywords' ){|x| reverse_type( x ) }
end
|
.update(auth, keywords) ⇒ Object
74
75
76
77
78
|
# File 'lib/ppc/api/baidu/keyword.rb', line 74
def self.update( auth, keywords )
body = { keywordTypes: make_type( keywords ) }
response = request( auth, Service, "updateWord", body )
process(response, 'keywordTypes' ){|x| reverse_type(x) }
end
|