Class: Hubspot::EngagementNote

Inherits:
Engagement show all
Defined in:
lib/hubspot/engagement.rb

Constant Summary

Constants inherited from Engagement

Hubspot::Engagement::ALL_ENGAGEMENTS_PATH, Hubspot::Engagement::ASSOCIATE_ENGAGEMENT_PATH, Hubspot::Engagement::CREATE_ENGAGMEMENT_PATH, Hubspot::Engagement::ENGAGEMENT_PATH, Hubspot::Engagement::GET_ASSOCIATED_ENGAGEMENTS, Hubspot::Engagement::RECENT_ENGAGEMENT_PATH

Instance Attribute Summary

Attributes inherited from Engagement

#associations, #attachments, #engagement, #id, #metadata

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Engagement

#[], all, associate!, #destroy!, #destroyed?, find, find_by_association, find_by_company, find_by_contact, #initialize, recent, #update!

Constructor Details

This class inherits a constructor from Hubspot::Engagement

Class Method Details

.create!(contact_id, note_body, owner_id = nil, deal_id = nil) ⇒ Object



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/hubspot/engagement.rb', line 156

def create!(contact_id, note_body, owner_id = nil, deal_id = nil)
  data = {
    engagement: {
      type: 'NOTE'
    },
    associations: {
      contactIds: [contact_id]
    },
    metadata: {
      body: note_body
    }
  }

  # if the owner id has been provided, append it to the engagement
  data[:engagement][:owner_id] = owner_id if owner_id
  # if the deal id has been provided, associate the note with the deal
  data[:associations][:dealIds] = [deal_id] if deal_id

  super(data)
end

Instance Method Details

#bodyObject



147
148
149
# File 'lib/hubspot/engagement.rb', line 147

def body
  ['body']
end

#contact_idsObject



151
152
153
# File 'lib/hubspot/engagement.rb', line 151

def contact_ids
  associations['contactIds']
end