class Qualtrics::Panel

Attributes

category[RW]
id[RW]
name[RW]

Public Class Methods

all(library_id = nil) click to toggle source
# File lib/qualtrics/panel.rb, line 9
def self.all(library_id = nil)
  lib_id = library_id || configuration.default_library_id
  response = get('getPanels', {'LibraryID' => lib_id})
  if response.success?
    response.result['Panels'].map do |panel|
      new(underscore_attributes(panel))
    end
  else
    []
  end
end
attribute_map() click to toggle source
# File lib/qualtrics/panel.rb, line 21
def self.attribute_map
  {
    'LibraryID' => :library_id,
    'Category' => :category,
    'Name' => :name,
    'PanelID' => :id
  }
end
new(options={}) click to toggle source
# File lib/qualtrics/panel.rb, line 30
def initialize(options={})
  @name = options[:name]
  @id = options[:id]
  @category = options[:category]
  @library_id = options[:library_id]
end

Public Instance Methods

add_recipients(recipients) click to toggle source
# File lib/qualtrics/panel.rb, line 53
def add_recipients(recipients)
  panel_import = Qualtrics::PanelImport.new({
      panel: self,
      recipients: recipients
  })
  panel_import.save
end
attributes() click to toggle source
# File lib/qualtrics/panel.rb, line 69
def attributes
  {
    'LibraryID' => library_id,
    'Category' => category,
    'Name' => name
  }
end
destroy() click to toggle source
# File lib/qualtrics/panel.rb, line 61
def destroy
  response = post('deletePanel', {
    'LibraryID' => library_id,
    'PanelID' => self.id
    })
  response.success?
end
save() click to toggle source
# File lib/qualtrics/panel.rb, line 37
def save
  response = nil
  if persisted?
    raise Qualtrics::UpdateNotAllowed
  else
    response = post('createPanel', attributes)
  end

  if response.success?
    self.id = response.result['PanelID']
    true
  else
    false
  end
end