Class: Hubspot::EngagementNote

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

Constant Summary

Constants inherited from Engagement

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

Instance Attribute Summary

Attributes inherited from Engagement

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Engagement

#[], associate!, #destroy!, #destroyed?, find, find_by_association, find_by_company, find_by_contact, #initialize, #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



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/hubspot/engagement.rb', line 131

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



122
123
124
# File 'lib/hubspot/engagement.rb', line 122

def body
  ['body']
end

#contact_idsObject



126
127
128
# File 'lib/hubspot/engagement.rb', line 126

def contact_ids
  associations['contactIds']
end