Skip to content
This repository was archived by the owner on Jun 30, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 38 additions & 4 deletions lib/hubspot/engagement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def create!(contact_id, note_body, owner_id = nil)
}

# if the owner id has been provided, append it to the engagement
data[:engagement][:owner_id] = owner_id if owner_id
data[:engagement][:ownerId] = owner_id if owner_id

super(data)
end
Expand Down Expand Up @@ -156,8 +156,7 @@ def create!(contact_vid, body, duration, owner_id = nil, deal_id = nil, status =
},
associations: {
contactIds: [contact_vid],
dealIds: [deal_id],
ownerIds: [owner_id]
dealIds: [deal_id]
},
metadata: {
body: body,
Expand All @@ -167,10 +166,45 @@ def create!(contact_vid, body, duration, owner_id = nil, deal_id = nil, status =
}

data[:engagement][:timestamp] = (time.to_i) * 1000 if time
data[:engagement][:owner_id] = owner_id if owner_id
data[:engagement][:ownerId] = owner_id if owner_id

super(data)
end
end
end

class EngagementTask < Engagement
def body
metadata['body']
end

def contact_ids
associations['contactIds']
end

class << self
def create!(contact_id, task_title, task_body, owner_id = nil, status="NOT_STARTED", object_type="CONTACT")
data = {
engagement: {
type: 'TASK'
},
associations: {
contactIds: [contact_id]
},
metadata: {
body: task_body,
subject: task_title,
status: status,
forObjectType: object_type
}
}

# if the owner id has been provided, append it to the engagement
data[:engagement][:ownerId] = owner_id if owner_id

super(data)
end
end

end
end