Sha256: 2266bbc116c30d5325529b66d4680b9a92b996c23208940bd6ba63596adaa4f3

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

require "qualtrics/panel_import_file"

module Qualtrics
  class PanelImport < Entity
    attr_accessor :panel, :recipients

    def initialize(options={})
      @panel = options[:panel]
      @recipients = options[:recipients]
    end

    def save
      payload = headers
      payload['LibraryID'] = library_id
      payload['ColumnHeaders'] = 1
      payload['PanelID'] = @panel.id if @panel.persisted?
      file = Qualtrics::PanelImportFile.new(@recipients)
      post 'importPanel', payload, File.read(file.temp_file)
      true
    end

    def headers
      {}.tap do |import_headers|
        Qualtrics::RecipientImportRow.fields.each_with_index.map do |field, index|
          import_headers[field] = index + 1
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qualtrics-0.6.1 lib/qualtrics/panel_import.rb