Class: Qualtrics::Recipient
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#embedded_data ⇒ Object
Returns the value of attribute embedded_data.
-
#external_data ⇒ Object
Returns the value of attribute external_data.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#language ⇒ Object
Returns the value of attribute language.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#panel_id ⇒ Object
Returns the value of attribute panel_id.
-
#unsubscribed ⇒ Object
Returns the value of attribute unsubscribed.
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Object
- #delete ⇒ Object
- #info_hash ⇒ Object
-
#initialize(options = {}) ⇒ Recipient
constructor
qualtrics_attribute :library_id, ‘LibraryID’.
- #panel=(panel) ⇒ Object
- #response_history ⇒ Object
- #save ⇒ Object
- #set_attributes(options = {}) ⇒ Object
- #update(options = {}) ⇒ Object
Methods inherited from Entity
#configuration, configuration, #get, get, #library_id, #library_id=, #persisted?, post, #post, #success?, underscore_attributes
Constructor Details
#initialize(options = {}) ⇒ Recipient
qualtrics_attribute :library_id, ‘LibraryID’
7 8 9 10 11 |
# File 'lib/qualtrics/recipient.rb', line 7 def initialize(={}) set_attributes() @panel_id = [:panel_id] @id = [:id] end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def email @email end |
#embedded_data ⇒ Object
Returns the value of attribute embedded_data.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def end |
#external_data ⇒ Object
Returns the value of attribute external_data.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def external_data @external_data end |
#first_name ⇒ Object
Returns the value of attribute first_name.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def first_name @first_name end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def id @id end |
#language ⇒ Object
Returns the value of attribute language.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def language @language end |
#last_name ⇒ Object
Returns the value of attribute last_name.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def last_name @last_name end |
#panel_id ⇒ Object
Returns the value of attribute panel_id.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def panel_id @panel_id end |
#unsubscribed ⇒ Object
Returns the value of attribute unsubscribed.
3 4 5 |
# File 'lib/qualtrics/recipient.rb', line 3 def unsubscribed @unsubscribed end |
Class Method Details
.attribute_map ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# 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 |
Instance Method Details
#attributes ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# 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' => , 'Unsubscribed' => unsubscribed }.delete_if {|key, value| value.nil? } end |
#delete ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# 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 ⇒ Object
53 54 55 56 57 58 59 60 |
# 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) ⇒ Object
37 38 39 |
# File 'lib/qualtrics/recipient.rb', line 37 def panel=(panel) self.panel_id = panel.id end |
#response_history ⇒ Object
101 102 103 104 105 106 |
# 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 ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# 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 = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/qualtrics/recipient.rb', line 13 def set_attributes(={}) @email = [:email] @first_name = [:first_name] @last_name = [:last_name] @language = [:language] @external_data = [:external_data] = [:embedded_data] @unsubscribed = [:unsubscribed] end |
#update(options = {}) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/qualtrics/recipient.rb', line 62 def update(={}) set_attributes() response = post('updateRecipient', update_params) if response.success? true else false end end |