Sha256: fe0c05093b54112527ce9ebeb5077ef92b50898763fb6571b5296caf6a229d9d

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

module PPC
  class Baidu
    class Bulk < ::PPC::Baidu
      def initialize(params = {})
        params[:service] = 'BulkJob'
        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 = {
          campaignIds:              plan_ids              || []      ,
          includeQuality:           params[:quality]      || true    ,
          includeTemp:              params[:temp]         || false   ,
          format:                   params[:format]       || 1       ,
          newCreativeFiles:         params[:adcopy]       || 0       ,
          includeTempNewCreatives:  params[:temp_adcopy]  || 0       ,
          includePhraseType:        params[:phrase]       || 0       ,
          extended:                 params[:extended]     || 0
        }
        response = request('getAllObjects',options)

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

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

      def path(id)
        request('getFilePath',{fileId:id})[:envelope][:body][:get_file_path_response][:file_paths]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ppc-1.0.3 lib/ppc/baidu/bulk.rb