From 5eb9afab09f6d6fc4ea563363dd06b64c2dcc9b5 Mon Sep 17 00:00:00 2001 From: santig Date: Fri, 23 Jun 2017 14:28:00 -0500 Subject: [PATCH 1/4] creating engagement task --- lib/hubspot/engagement.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/hubspot/engagement.rb b/lib/hubspot/engagement.rb index 080645cc..724e7289 100644 --- a/lib/hubspot/engagement.rb +++ b/lib/hubspot/engagement.rb @@ -173,4 +173,39 @@ def create!(contact_vid, body, duration, owner_id = nil, deal_id = nil, status = 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][:owner_id] = owner_id if owner_id + + super(data) + end + end + + end end From 1f4e9c170334a2dfc16fd664f98510d0e2aab7d9 Mon Sep 17 00:00:00 2001 From: santig Date: Fri, 23 Jun 2017 16:54:22 -0500 Subject: [PATCH 2/4] adding owner id to owner Ids in engagement stask --- lib/hubspot/engagement.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/hubspot/engagement.rb b/lib/hubspot/engagement.rb index 724e7289..c3a60477 100644 --- a/lib/hubspot/engagement.rb +++ b/lib/hubspot/engagement.rb @@ -190,7 +190,8 @@ def create!(contact_id, task_title, task_body, owner_id = nil, status="NOT_START type: 'TASK' }, associations: { - contactIds: [contact_id] + contactIds: [contact_id], + ownerIds: [owner_id] }, metadata: { body: task_body, From b4971e635954086e9202a18483a844c0a150f750 Mon Sep 17 00:00:00 2001 From: santig Date: Fri, 23 Jun 2017 17:14:58 -0500 Subject: [PATCH 3/4] fix on ownerId keys --- lib/hubspot/engagement.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/hubspot/engagement.rb b/lib/hubspot/engagement.rb index c3a60477..bd27b018 100644 --- a/lib/hubspot/engagement.rb +++ b/lib/hubspot/engagement.rb @@ -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 @@ -167,7 +167,7 @@ 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 @@ -202,7 +202,7 @@ def create!(contact_id, task_title, task_body, owner_id = nil, status="NOT_START } # 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 From c84a8a95b7516e0a30c52eb83cc0243599bc9c81 Mon Sep 17 00:00:00 2001 From: santig Date: Fri, 23 Jun 2017 17:31:27 -0500 Subject: [PATCH 4/4] removin ownerIds from associations. It was deprecated on API --- lib/hubspot/engagement.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/hubspot/engagement.rb b/lib/hubspot/engagement.rb index bd27b018..83b144e1 100644 --- a/lib/hubspot/engagement.rb +++ b/lib/hubspot/engagement.rb @@ -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, @@ -190,8 +189,7 @@ def create!(contact_id, task_title, task_body, owner_id = nil, status="NOT_START type: 'TASK' }, associations: { - contactIds: [contact_id], - ownerIds: [owner_id] + contactIds: [contact_id] }, metadata: { body: task_body,