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}:
-
comment_notes
(String) - the comment text. -
comment_contact_id
(String) - the contact ID of the comment author (optional). -
comment_published
(Boolean) - whether the comment should be visible to the associated contact of this activity (item.contact_id
). Default:false
. -
comment_attachments
(Array<String, read>) - the comment attachments (optional). Every array element may either be an attachment ID or an object that implements#read
(e.g. an open file). In the latter case, the content will be uploaded automatically. See {Crm::Core::AttachmentStore} for manually uploading attachments.
@api public
Public Class Methods
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
# File lib/crm/activity.rb, line 35 def self.create(attributes = {}) super(filter_attributes(attributes)) end
@!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
Updates the attributes of this activity. See {Core::Mixins::Modifiable#update Modifiable#update} for details. @return [self] the updated activity. @api public
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
# 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