Sha256: 160a861347064b9c64701af0c328bcc942700f302b834116bf199f27002bb04d

Contents?: true

Size: 960 Bytes

Versions: 6

Compression:

Stored size: 960 Bytes

Contents

# -*- coding:utf-8 -*-
require 'json'
module PPC
  module API
    class Qihu
      class Bulk < Qihu
        Service = 'account'

        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

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

        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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ppc-2.0.5 lib/ppc/api/qihu/bulk.rb
ppc-2.0.4 lib/ppc/api/qihu/bulk.rb
ppc-2.0.3 lib/ppc/api/qihu/bulk.rb
ppc-2.0.2 lib/ppc/api/qihu/bulk.rb
ppc-2.0.1 lib/ppc/api/qihu/bulk.rb
ppc-2.0.0 lib/ppc/api/qihu/bulk.rb