Class: PPC::API::Qihu
- Inherits:
-
Object
show all
- Extended by:
- PPC::API
- Defined in:
- lib/ppc/api/qihu.rb,
lib/ppc/api/qihu/bulk.rb,
lib/ppc/api/qihu/plan.rb,
lib/ppc/api/qihu/rank.rb,
lib/ppc/api/qihu/group.rb,
lib/ppc/api/qihu/report.rb,
lib/ppc/api/qihu/account.rb,
lib/ppc/api/qihu/keyword.rb,
lib/ppc/api/qihu/sublink.rb,
lib/ppc/api/qihu/creative.rb
Defined Under Namespace
Classes: Account, Bulk, Creative, Group, Keyword, Plan, Rank, Report, Sublink
Class Method Summary
collapse
Methods included from PPC::API
make_type, process, request, request_http_body, request_http_header, request_uri, reverse_type
Class Method Details
.process(response, key, failure_key = '', &func) ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/ppc/api/qihu.rb', line 35
def self.process( response, key, failure_key = '', &func )
result = {}
result[:succ] = response['failures'].nil? || response['failures'].size.zero?
result[:failure] = response['failures'] || response["failure_key"]
result[:result] = (key.empty? ? func[response] : func[response[key]]) rescue nil
result[:no_quota] = (response['failures']['code'] == '90401') rescue false
result[:rquota] = response[:qihu_quota] rescue 0
result
end
|
.request_http_body(auth, params = {}) ⇒ Object
31
32
33
|
# File 'lib/ppc/api/qihu.rb', line 31
def self.request_http_body(auth, params = {})
"format=json&" + params.map{|k,v| "#{k.to_s}=#{v.is_a?(Array) ? v.to_json : v}"}.join('&')
end
|
22
23
24
25
26
27
28
29
|
# File 'lib/ppc/api/qihu.rb', line 22
def self.(auth)
{
'Content-Type' => 'application/x-www-form-urlencoded',
'apiKey' => auth[:api_key],
'accessToken' => auth[:token],
'serveToken' => Time.now.to_i.to_s
}
end
|
.request_uri(param = {}) ⇒ Object
18
19
20
|
# File 'lib/ppc/api/qihu.rb', line 18
def self.request_uri(param = {})
URI("https://api.e.360.cn/2.0/#{param[:service]}/#{param[:method]}")
end
|