class Qualtrics::Recipient
Attributes
email[RW]
embedded_data[RW]
external_data[RW]
first_name[RW]
id[RW]
language[RW]
last_name[RW]
panel_id[RW]
unsubscribed[RW]
Public Class Methods
attribute_map()
click to toggle source
# File lib/qualtrics/recipient.rb, line 87 def self.attribute_map { 'LibraryID' => :library_id, 'PanelID' => :panel_id, 'Email' => :email, 'FirstName' => :first_name, 'LastName' => :last_name, 'ExternalDataRef' => :external_data, 'Language' => :language, 'ED' => :embedded_data, 'Unsubscribed' => :unsubscribed } end
new(options={})
click to toggle source
qualtrics_attribute :library_id, 'LibraryID'
# File lib/qualtrics/recipient.rb, line 7 def initialize(options={}) set_attributes(options) @panel_id = options[:panel_id] @id = options[:id] end
Public Instance Methods
attributes()
click to toggle source
# File lib/qualtrics/recipient.rb, line 23 def attributes { 'LibraryID' => library_id, 'PanelID' => panel_id, 'Email' => email, 'FirstName' => first_name, 'LastName' => last_name, 'ExternalDataRef' => external_data, 'Language' => language, 'ED' => embedded_data, 'Unsubscribed' => unsubscribed }.delete_if {|key, value| value.nil? } end
delete()
click to toggle source
# File lib/qualtrics/recipient.rb, line 73 def delete response = post('removeRecipient', { 'LibraryID' => library_id, 'RecipientID' => id, 'PanelID' => panel_id }) if response.success? true else false end end
info_hash()
click to toggle source
# File lib/qualtrics/recipient.rb, line 53 def info_hash response = get('getRecipient', {'LibraryID' => library_id, 'RecipientID' => id}) if response.success? && !response.result['Recipient'].nil? response.result['Recipient'] else false end end
panel=(panel)
click to toggle source
# File lib/qualtrics/recipient.rb, line 37 def panel=(panel) self.panel_id = panel.id end
response_history()
click to toggle source
# File lib/qualtrics/recipient.rb, line 101 def response_history info_hash["RecipientResponseHistory"].map do |r| response = Hash[r.map{|k,v| [Qualtrics::Submission.attribute_map[k], v]}] Qualtrics::Submission.new(response) end end
save()
click to toggle source
# File lib/qualtrics/recipient.rb, line 41 def save return false if !valid? response = post('addRecipient', attributes) if response.success? self.id = response.result['RecipientID'] true else false end end
set_attributes(options={})
click to toggle source
# File lib/qualtrics/recipient.rb, line 13 def set_attributes(options={}) @email = options[:email] @first_name = options[:first_name] @last_name = options[:last_name] @language = options[:language] @external_data = options[:external_data] @embedded_data = options[:embedded_data] @unsubscribed = options[:unsubscribed] end
update(options={})
click to toggle source
# File lib/qualtrics/recipient.rb, line 62 def update(options={}) set_attributes(options) response = post('updateRecipient', update_params) if response.success? true else false end end
Protected Instance Methods
update_params()
click to toggle source
# File lib/qualtrics/recipient.rb, line 109 def update_params { 'LibraryID' => library_id, 'RecipientID' => id }.merge(attributes) end