Sha256: 4ebd39e1ef19b9d77447b8873a658ef54c82f86936453584f963367166569251

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

module PPC
  class Sogou
    class BulkException < Exception
      attr_reader :file_id,:bulk,:exception
      def initialize(file_id,bulk,exception)
        @file_id    = file_id
        @bulk       = bulk
        @exception  = exception
      end
    end

    class Bulk < ::PPC::Sogou
      def initialize(params = {})
        params[:service] = 'AccountDownload'
        super(params)
      end

      def file_id_of_all(params = {})
        plan_ids = params[:plan_ids]

        unless plan_ids.nil?
          plan_ids = plan_ids.class == Array ? plan_ids : [plan_ids]
        end

        options = {
          cpcPlanIds:               plan_ids              || []      ,
          includeQuality:           params[:quality]      || true    ,
          includeTemp:              params[:temp]         || false   ,
          format:                   params[:format]       || 1
        }
        response = request('getAccountFile',options)

        body = response[:envelope][:body]
        raise "no result" if body.nil?
        body[:get_account_file_response][:accountFileId]
      end

      def state(id)
        raise "empty id" if id.nil? or id.empty?
        request('getAccountFileStatus',{accountFileId:id})[:envelope][:body][:get_account_file_status_response][:is_generated]
      end

      def path(id)
        request('getAccountFilePath',{accountFileId:id})[:envelope][:body][:get_account_file_path_response][:account_file_path]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ppc-1.0.6 lib/ppc/sogou/bulk.rb