Class: Qualtrics::PanelImport

Inherits:
Entity
  • Object
show all
Defined in:
lib/qualtrics/panel_import.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Entity

#configuration, configuration, #get, get, #library_id, #library_id=, #persisted?, post, #post, #success?, underscore_attributes

Constructor Details

#initialize(options = {}) ⇒ PanelImport

Returns a new instance of PanelImport.



7
8
9
10
# File 'lib/qualtrics/panel_import.rb', line 7

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

Instance Attribute Details

#panelObject

Returns the value of attribute panel.



5
6
7
# File 'lib/qualtrics/panel_import.rb', line 5

def panel
  @panel
end

#recipientsObject

Returns the value of attribute recipients.



5
6
7
# File 'lib/qualtrics/panel_import.rb', line 5

def recipients
  @recipients
end

Instance Method Details

#headersObject



21
22
23
24
25
26
27
# File 'lib/qualtrics/panel_import.rb', line 21

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

#saveObject



12
13
14
15
16
17
18
19
# File 'lib/qualtrics/panel_import.rb', line 12

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