Class: Qualtrics::Message
Constant Summary collapse
- ALLOWED_CATEGORIES =
%w(InviteEmails InactiveSurveyMessages ReminderEmails ThankYouEmails EndOfSurveyMessages GeneralMessages ValidationMessages LookAndFeelMessages)
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#category ⇒ Object
Returns the value of attribute category.
-
#id ⇒ Object
Returns the value of attribute id.
-
#language ⇒ Object
Returns the value of attribute language.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#attributes ⇒ Object
def destroy response = post(‘deleteLibraryMessage’, { ‘LibraryID’ => library_id, ‘MessageID’ => self.id }) response.success? end.
-
#initialize(options = {}) ⇒ Message
constructor
A new instance of Message.
- #save ⇒ Object
Methods inherited from Entity
#configuration, configuration, #get, get, #library_id, #library_id=, #persisted?, post, #post, #success?, underscore_attributes
Constructor Details
#initialize(options = {}) ⇒ Message
Returns a new instance of Message.
24 25 26 27 28 29 30 31 |
# File 'lib/qualtrics/message.rb', line 24 def initialize(={}) @name = [:name] @id = [:id] @category = [:category] @library_id = [:library_id] @body = [:body] @language = [:language] || 'EN' end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
7 8 9 |
# File 'lib/qualtrics/message.rb', line 7 def body @body end |
#category ⇒ Object
Returns the value of attribute category.
7 8 9 |
# File 'lib/qualtrics/message.rb', line 7 def category @category end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/qualtrics/message.rb', line 7 def id @id end |
#language ⇒ Object
Returns the value of attribute language.
7 8 9 |
# File 'lib/qualtrics/message.rb', line 7 def language @language end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/qualtrics/message.rb', line 7 def name @name end |
Class Method Details
.all(library_id = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/qualtrics/message.rb', line 10 def self.all(library_id = nil) lib_id = library_id || configuration.default_library_id response = get('getLibraryMessages', {'LibraryID' => lib_id}) if response.success? response.result.map do |category, | .map do |, name| new(id: , name: name, category: category_map[category]) end end.flatten else [] end end |
.category_map ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/qualtrics/message.rb', line 63 def self.category_map { 'INVITE' => 'InviteEmails', 'REMINDER' => 'ReminderEmails', 'THANKYOU' => 'ThankYouEmails', 'ENDOFSURVEY' => 'EndOfSurveyMessages', 'INACTIVESURVEY' => 'InactiveSurveyMessages', 'GENERAL' => 'GeneralMessages', 'LOOKANDFEEL' => 'LookAndFeelMessages' } end |
Instance Method Details
#attributes ⇒ Object
def destroy
response = post('deleteLibraryMessage', {
'LibraryID' => library_id,
'MessageID' => self.id
})
response.success?
end
53 54 55 56 57 58 59 60 61 |
# File 'lib/qualtrics/message.rb', line 53 def attributes { 'LibraryID' => library_id, 'Category' => category, 'Name' => name, 'Message' => body, 'Language' => language } end |
#save ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/qualtrics/message.rb', line 33 def save return false if !valid? response = post('createLibraryMessage', attributes) if response.success? self.id = response.result['MessageID'] true else false end end |