class Crm::Activity

A JustRelate WebCRM activity is a record of an action or a sequence of actions, for example a support case. It can be associated with an {Account account} or a {Contact contact}.

Comments

Comments can be read be means of {#comments}. In order to add a comment, set the following write-only attributes on {.create} or {#update}:

@api public

Public Class Methods

create(attributes = {}) click to toggle source

Creates a new activity using the given params. See {Core::Mixins::Modifiable::ClassMethods#create Modifiable.create} for details. @return [self] the created activity. @api public

Calls superclass method
# File lib/crm/activity.rb, line 35
def self.create(attributes = {})
  super(filter_attributes(attributes))
end
filter_attributes(attributes) click to toggle source

@!attribute [r] comments Returns the {Comment comments} of this activity. @return [Array<Comment>] @api public

# File lib/crm/activity.rb, line 118
def self.filter_attributes(attributes)
  attachments = attributes.delete('comment_attachments') ||
      attributes.delete(:comment_attachments)
  if attachments
    attributes['comment_attachments'] = attachments.map do |attachment|
      if attachment.respond_to?(:read)
        Core::AttachmentStore.upload(attachment)
      else
        attachment
      end
    end
  end
  attributes
end

Public Instance Methods

update(attributes = {}) click to toggle source

Updates the attributes of this activity. See {Core::Mixins::Modifiable#update Modifiable#update} for details. @return [self] the updated activity. @api public

Calls superclass method Crm::Core::Mixins::Modifiable#update
# File lib/crm/activity.rb, line 43
def update(attributes = {})
  super(self.class.filter_attributes(attributes))
end

Protected Instance Methods

load_attributes(raw_attributes) click to toggle source
Calls superclass method
# File lib/crm/activity.rb, line 135
def load_attributes(raw_attributes)
  attributes = raw_attributes.dup
  attributes['comments'] = (attributes['comments'] || []).map do |comment_attributes|
    Comment.new(comment_attributes)
  end
  super(attributes)
end