Sha256: 9605af2fbff2946c58011c7f0791ca070deb794aa191169871c605365daab1d4

Contents?: true

Size: 821 Bytes

Versions: 29

Compression:

Stored size: 821 Bytes

Contents

module SparkApi
  module Models
    class Message < Base
      extend Finders
      self.element_name="messages"
      
      def save(arguments={})
        begin
          return save!(arguments)
        rescue BadResourceRequest => e
          SparkApi.logger.warn("Failed to save resource #{self}: #{e.message}")
        rescue NotFound => e
          SparkApi.logger.error("Failed to save resource #{self}: #{e.message}")
        end
        false
      end

      def save!(arguments={})
        results = connection.post self.class.path, {"Messages" => [ attributes ]}, arguments
        true
      end

      def replies(args = {})
        arguments = {:_expand => "Body, Sender"}.merge(args)
        Message.collect(connection.get("#{self.class.path}/#{self.Id}/replies", arguments))
      end

    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
spark_api-1.4.25 lib/spark_api/models/message.rb
spark_api-1.4.24 lib/spark_api/models/message.rb
spark_api-1.4.23 lib/spark_api/models/message.rb
spark_api-1.4.22 lib/spark_api/models/message.rb
spark_api-1.4.21 lib/spark_api/models/message.rb
spark_api-1.4.20 lib/spark_api/models/message.rb
spark_api-1.4.19 lib/spark_api/models/message.rb
spark_api-1.4.18 lib/spark_api/models/message.rb
spark_api-1.4.17 lib/spark_api/models/message.rb
spark_api-1.4.16 lib/spark_api/models/message.rb
spark_api-1.4.15 lib/spark_api/models/message.rb
spark_api-1.4.14 lib/spark_api/models/message.rb
spark_api-1.4.13 lib/spark_api/models/message.rb
spark_api-1.4.12 lib/spark_api/models/message.rb
spark_api-1.4.11 lib/spark_api/models/message.rb
spark_api-1.4.10 lib/spark_api/models/message.rb
spark_api-1.4.9 lib/spark_api/models/message.rb
spark_api-1.4.8 lib/spark_api/models/message.rb
spark_api-1.4.6 lib/spark_api/models/message.rb
spark_api-1.4.5 lib/spark_api/models/message.rb