From 3b513af32a4ccff63513f437ddd2dcc372eca317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chai=CC=88b=20Martinez?= Date: Thu, 30 May 2019 19:20:45 +0200 Subject: [PATCH] Add nb_of_dossiers by years and deadline to PipeDrive Person MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chaìˆb Martinez --- app/lib/pipedrive/person_adapter.rb | 12 +++++++++--- app/services/pipedrive_service.rb | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/lib/pipedrive/person_adapter.rb b/app/lib/pipedrive/person_adapter.rb index a6289bb90..fe225fd33 100644 --- a/app/lib/pipedrive/person_adapter.rb +++ b/app/lib/pipedrive/person_adapter.rb @@ -1,6 +1,8 @@ class Pipedrive::PersonAdapter PIPEDRIVE_POSTE_ATTRIBUTE_ID = '33a790746f1713d712fe97bcce9ac1ca6374a4d6' PIPEDRIVE_SOURCE_ATTRIBUTE_ID = '2fa7864f467ffa97721cbcd08df5a3d591b15f50' + PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID = '2734a3ff19f4b88bd0d7b4cf02c47c7545617207' + PIPEDRIVE_DEADLINE_ATTRIBUTE_ID = 'ef766dd14de7da246fb5fc1704f45d1f1830f6c9' PIPEDRIVE_ROBOT_ID = '2748449' def self.get_demandes_from_persons_owned_by_robot @@ -11,7 +13,9 @@ class Pipedrive::PersonAdapter poste: datum[PIPEDRIVE_POSTE_ATTRIBUTE_ID], email: datum.dig('email', 0, 'value'), tel: datum.dig('phone', 0, 'value'), - organisation: datum['org_name'] + organisation: datum['org_name'], + nb_dossiers: datum[PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID], + deadline: datum[PIPEDRIVE_DEADLINE_ATTRIBUTE_ID] } end end @@ -22,7 +26,7 @@ class Pipedrive::PersonAdapter Pipedrive::API.put_person(person_id, params) end - def self.add_person(email, phone, name, organization_id, poste, source) + def self.add_person(email, phone, name, organization_id, poste, source, nb_of_dossiers, deadline) params = { email: email, phone: phone, @@ -30,7 +34,9 @@ class Pipedrive::PersonAdapter org_id: organization_id, owner_id: PIPEDRIVE_ROBOT_ID, "#{PIPEDRIVE_POSTE_ATTRIBUTE_ID}": poste, - "#{PIPEDRIVE_SOURCE_ATTRIBUTE_ID}": source + "#{PIPEDRIVE_SOURCE_ATTRIBUTE_ID}": source, + "#{PIPEDRIVE_NB_DOSSIERS_ATTRIBUTE_ID}": nb_of_dossiers, + "#{PIPEDRIVE_DEADLINE_ATTRIBUTE_ID}": deadline } response = Pipedrive::API.post_person(params) diff --git a/app/services/pipedrive_service.rb b/app/services/pipedrive_service.rb index ecd9b8a17..33b80f68e 100644 --- a/app/services/pipedrive_service.rb +++ b/app/services/pipedrive_service.rb @@ -19,7 +19,7 @@ class PipedriveService def self.add_demande(email, phone, name, poste, source, organization_name, address, nb_of_procedures, nb_of_dossiers, deadline) organization_id = Pipedrive::OrganizationAdapter.add_organization(organization_name, address) - person_id = Pipedrive::PersonAdapter.add_person(email, phone, name, organization_id, poste, source) + person_id = Pipedrive::PersonAdapter.add_person(email, phone, name, organization_id, poste, source, nb_of_dossiers, deadline) Pipedrive::DealAdapter.add_deal(organization_id, person_id, organization_name, nb_of_procedures, nb_of_dossiers, deadline) end end