lib/ppc/baidu.rb in ppc-1.0.3 vs lib/ppc/baidu.rb in ppc-1.0.6

- old
+ new

@@ -1,8 +1,9 @@ require 'ppc/baidu/account' require 'ppc/baidu/plan' require 'ppc/baidu/bulk' +require 'ppc/baidu/report' require 'awesome_print' require 'savon' module PPC class Baidu include ::PPC @@ -22,19 +23,18 @@ operation = make_operation(method) operation.header = operation_header operation.body = { method+'Request' =>params } - ap operation.body if @debug - puts operation.build if @debug + print_debug(operation.body,'operation.body') if @debug + print_debug(operation.build,'operation.build') if @debug response = operation.call.hash process_response(response) - ap response if @debug + print_debug(response,'response') if @debug response end - def operations @client.operations(@service,@service) end protected @@ -60,36 +60,38 @@ sleep 3 end puts "#{file_id} is ready" if @debug return bulk.path(file_id) rescue - @header = bulk.header - @oprs = bulk.oprs - @oprtime = bulk.oprtime - @quota = bulk.quota - @rquota = bulk.rquota - @status = bulk.status + # @header = bulk.header + # @oprs = bulk.oprs + # @oprtime = bulk.oprtime + # @quota = bulk.quota + # @rquota = bulk.rquota + # @status = bulk.status - @desc = bulk.desc + # @desc = bulk.desc - case @desc - when 'success' - when 'failure' - @code = bulk.code - @message = bulk.message - when 'system failure' - @code = bulk.code - @message = bulk.message - else - raise "unknown desc from baidu: #{@desc}" - end + # case @desc + # when 'success' + # when 'failure' + # @code = bulk.code + # @message = bulk.message + # when 'system failure' + # @code = bulk.code + # @message = bulk.message + # else + # raise "unknown desc from baidu: #{@desc}" + # end + raise BulkException.new(file_id,bulk) end return false end private + def make_operation(operation_name) @client.operation(@service,@service,operation_name) end def operation_header @@ -115,9 +117,10 @@ end end def process_response(response) body = response[:envelope] + print_debug(body,'response.envelope') if @debug @header = body[:header] res_header = header[:res_header] @oprs = res_header[:oprs] @oprtime = res_header[:oprtime]