Sha256: 5b37396d7d906fd525443b7b52ec6275f7b171cb8800e58c58fae0d43cce4885

Contents?: true

Size: 724 Bytes

Versions: 12

Compression:

Stored size: 724 Bytes

Contents

module ActsAsIcontact
  class Message < Resource
    # Has a default messageType of "normal" if another isn't passed as an option.
    def initialize(properties={})
      super({:messageType => "normal"}.merge(properties))
    end
    
    # Requires messageType and subject
    def self.required_on_create
      super << "messageType" << "subject"
    end
    
    # messageType must be one of four values: normal, autoresponder, welcome, or confirmation
    def validate_on_save(fields)
      messageType = %w(normal autoresponder welcome confirmation)
      raise ActsAsIcontact::ValidationError, "messageType must be one of: " + messageType.join(', ') unless messageType.include?(fields["messageType"])
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
SFEley-acts_as_icontact-0.1.5 lib/acts_as_icontact/resources/message.rb
SFEley-acts_as_icontact-0.2.0 lib/acts_as_icontact/resources/message.rb
SFEley-acts_as_icontact-0.2.1 lib/acts_as_icontact/resources/message.rb
SFEley-acts_as_icontact-0.2.3 lib/acts_as_icontact/resources/message.rb
SFEley-acts_as_icontact-0.2.4 lib/acts_as_icontact/resources/message.rb
SFEley-acts_as_icontact-0.3.0 lib/acts_as_icontact/resources/message.rb
acts_as_icontact-0.1.5 lib/acts_as_icontact/resources/message.rb
acts_as_icontact-0.2.0 lib/acts_as_icontact/resources/message.rb
acts_as_icontact-0.2.1 lib/acts_as_icontact/resources/message.rb
acts_as_icontact-0.2.3 lib/acts_as_icontact/resources/message.rb
acts_as_icontact-0.2.4 lib/acts_as_icontact/resources/message.rb
acts_as_icontact-0.3.0 lib/acts_as_icontact/resources/message.rb