Class: Qualtrics::Mailer
- Includes:
- ActiveModel::Validations, ActiveSupport
- Defined in:
- lib/qualtrics/mailer.rb
Constant Summary collapse
- QUALTRICS_POST_TIMEZONE =
'Mountain Time (US & Canada)'
Instance Attribute Summary collapse
-
#from_email ⇒ Object
Returns the value of attribute from_email.
-
#from_name ⇒ Object
Returns the value of attribute from_name.
-
#send_date ⇒ Object
Returns the value of attribute send_date.
-
#sent_from_address ⇒ Object
Returns the value of attribute sent_from_address.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(options = {}) ⇒ Mailer
constructor
A new instance of Mailer.
- #send_reminder(distribution, message) ⇒ Object
- #send_survey_to_individual(recipient, message, survey) ⇒ Object
- #send_survey_to_panel(panel, message, survey) ⇒ Object
Methods inherited from Entity
#configuration, configuration, #get, get, #library_id, #library_id=, #persisted?, post, #post, #success?, underscore_attributes
Constructor Details
#initialize(options = {}) ⇒ Mailer
Returns a new instance of Mailer.
17 18 19 20 21 22 23 |
# File 'lib/qualtrics/mailer.rb', line 17 def initialize(={}) @send_date = [:send_date] || post_time @from_email = [:from_email] @from_name = [:from_name] @subject = [:subject] @sent_from_address = [:sent_from_address] || '[email protected]' end |
Instance Attribute Details
#from_email ⇒ Object
Returns the value of attribute from_email.
9 10 11 |
# File 'lib/qualtrics/mailer.rb', line 9 def from_email @from_email end |
#from_name ⇒ Object
Returns the value of attribute from_name.
9 10 11 |
# File 'lib/qualtrics/mailer.rb', line 9 def from_name @from_name end |
#send_date ⇒ Object
Returns the value of attribute send_date.
9 10 11 |
# File 'lib/qualtrics/mailer.rb', line 9 def send_date @send_date end |
#sent_from_address ⇒ Object
Returns the value of attribute sent_from_address.
9 10 11 |
# File 'lib/qualtrics/mailer.rb', line 9 def sent_from_address @sent_from_address end |
#subject ⇒ Object
Returns the value of attribute subject.
9 10 11 |
# File 'lib/qualtrics/mailer.rb', line 9 def subject @subject end |
Instance Method Details
#attributes ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/qualtrics/mailer.rb', line 84 def attributes { 'SendDate' => send_date, 'FromEmail' => from_email, 'FromName' => from_name, 'Subject' => subject, 'SentFromAddress' => sent_from_address } end |
#send_reminder(distribution, message) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/qualtrics/mailer.rb', line 66 def send_reminder(distribution, ) return false if !valid? response = post('sendReminder', attributes.merge( { 'ParentEmailDistributionID' => distribution.id, 'MessageID' => .id, 'LibraryID' => library_id, }) ) if response.success? create_distribution(response, distribution.survey_id, .id) else false end end |
#send_survey_to_individual(recipient, message, survey) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/qualtrics/mailer.rb', line 25 def send_survey_to_individual(recipient, , survey) return false if !valid? response = post('sendSurveyToIndividual', attributes.merge( { 'RecipientID' => recipient.id, 'MessageID' => .id, 'SurveyID' => survey.id, 'MessageLibraryID' => library_id, 'PanelID' => recipient.panel_id, 'PanelLibraryID' => library_id }) ) if response.success? create_distribution(response, survey.id, .id) else false end end |
#send_survey_to_panel(panel, message, survey) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/qualtrics/mailer.rb', line 46 def send_survey_to_panel(panel, , survey) return false if !valid? response = post('sendSurveyToPanel', attributes.merge( { 'PanelID' => panel.id, 'MessageID' => .id, 'SurveyID' => survey.id, 'MessageLibraryID' => library_id, 'PanelLibraryID' => library_id }) ) if response.success? create_distribution(response, survey.id, .id) else false end end |