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 diff --git a/app/views/manager/demandes/index.html.erb b/app/views/manager/demandes/index.html.erb index 9703d5fdb..173185b86 100644 --- a/app/views/manager/demandes/index.html.erb +++ b/app/views/manager/demandes/index.html.erb @@ -34,13 +34,7 @@ <%= form_tag(manager_demandes_create_administrateur_path) do -%> <%= select_tag "stage_id", options_for_select({ - "suspect" => Pipedrive::DealAdapter::PIPEDRIVE_SUSPECTS_COMPTE_CREE_STAGE_ID, - "administration centrale" => Pipedrive::DealAdapter::PIPEDRIVE_ADMIN_CENTRAL_STOCK_STAGE_ID, - "service déco. régional" => Pipedrive::DealAdapter::PIPEDRIVE_SERVICE_DECO_REGIONAL_STOCK_STAGE_ID, - "service déco. départemental" => Pipedrive::DealAdapter::PIPEDRIVE_SERVICE_DECO_DEPARTEMENTAL_STOCK_STAGE_ID, - "collectivité dép. ou rég." =>Pipedrive::DealAdapter::PIPEDRIVE_COLLECTIVITE_DEP_OU_REG_STOCK_STAGE_ID, - "collectivité locale" => Pipedrive::DealAdapter::PIPEDRIVE_COLLECTIVITE_LOCALE_STOCK_STAGE_ID, - "organisme" => Pipedrive::DealAdapter::PIPEDRIVE_ORGANISMES_STOCK_STAGE_ID + "suspect" => Pipedrive::DealAdapter::PIPEDRIVE_SUSPECTS_COMPTE_CREE_STAGE_ID }), style: 'margin-bottom: 20px; width: inherit;' %>