Class: PPC::API::Qihu::Bulk

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

Constant Summary collapse

Service =
'account'

Class Method Summary collapse

Methods inherited from PPC::API::Qihu

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

.download(auth, ids = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/ppc/api/qihu/bulk.rb', line 22

def self.download( auth, ids = nil)
  result = get_all_object(auth, ids)
  field_id = result[:result]
  loop do 
    status = get_file_state(auth, field_id)
    return status if status[:result]['isGenerated'] == 'success'
    sleep 15
  end
end

.get_all_object(auth, ids) ⇒ Object



9
10
11
12
13
14
# File 'lib/ppc/api/qihu/bulk.rb', line 9

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

.get_file_state(auth, id) ⇒ Object



16
17
18
19
20
# File 'lib/ppc/api/qihu/bulk.rb', line 16

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