Class: PPC::API::Qihu::Account

Inherits:
PPC::API::Qihu show all
Defined in:
lib/ppc/api/qihu/account.rb

Constant Summary collapse

Service =
'account'

Class Method Summary collapse

Methods inherited from PPC::API::Qihu

make_type, process, request_http_body, request_http_header, request_uri, reverse_type, to_id_list, to_json_string

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

.get_all_object(auth, ids) ⇒ Object



52
53
54
55
56
57
# File 'lib/ppc/api/qihu/account.rb', line 52

def self.get_all_object( auth, ids )
  #文档上面写的输入类型是String?
  body = { 'idList' =>  ids }
  response = request( auth, Service, 'getAllObjects' )
  process( response, 'account_getAllObjects_response' ){ |x| x }
end

.get_exclude_ip(auth) ⇒ Object



65
66
67
68
# File 'lib/ppc/api/qihu/account.rb', line 65

def self.get_exclude_ip( auth )
  response = request( auth, Service, 'getExcludeIp' )
  process( response, 'excludeIpList' ){ |x| x}
end

.get_file_state(auth, id) ⇒ Object



59
60
61
62
63
# File 'lib/ppc/api/qihu/account.rb', line 59

def self.get_file_state( auth, id )
  body = { 'fileId' => id }
  response = request( auth, Service, 'getAllObjects' , body )
  process( response, 'account_getFileState_response' ){ |x| x }
end

.info(auth) ⇒ Object



22
23
24
25
# File 'lib/ppc/api/qihu/account.rb', line 22

def self.info( auth )
  response = request( auth, Service, 'getInfo' )
  process( response, '' ){ |x| reverse_type( x )[0]}
end

.update(auth, params) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ppc/api/qihu/account.rb', line 27

def self.update( auth, params )
  '''
  对奇虎两个update的在封装。如果所有操作成功,succ为true,否则为false
  failure中以字符串方式返回失败的操作
  '''
  result = {}
  result[:succ] = true
  result[:failure] = []
  result[:result] = []

  if params[:budget] != nil
    budget_result = update_budget( auth, params[:budget] )
    result[:succ] = result[:succ] && budget_result[:succ]
    result[:failure] << 'budget' unless budget_result[:succ]
  end

  if params[:exclude_ip] != nil
    ip_result = update_exclude_ip( auth, params[:exclude_ip] )
    result[:succ] = result[:succ] && ip_result[:succ]
    result[:failure] << 'exclude_ip' unless budget_result[:succ]
  end

  return result
end