2018-03-23 17:21:51 +01:00
|
|
|
class PipedriveService
|
2018-03-28 15:19:34 +02:00
|
|
|
def self.accept_demande_from_person(person_id, owner_id, stage_id)
|
2018-04-05 16:50:57 +02:00
|
|
|
person_deals_ids = Pipedrive::DealAdapter.get_deals_ids_for_person(person_id)
|
2018-04-05 16:49:39 +02:00
|
|
|
person_deals_ids.each { |deal_id| Pipedrive::DealAdapter.update_deal_owner_and_stage(deal_id, owner_id, stage_id) }
|
2018-03-28 11:56:19 +02:00
|
|
|
Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id)
|
|
|
|
end
|
2018-03-23 17:21:51 +01:00
|
|
|
|
2018-03-28 15:19:34 +02:00
|
|
|
def self.refuse_demande_from_person(person_id, owner_id)
|
2018-04-05 16:50:57 +02:00
|
|
|
person_deals_ids = Pipedrive::DealAdapter.get_deals_ids_for_person(person_id)
|
2018-04-05 16:49:39 +02:00
|
|
|
person_deals_ids.each { |deal_id| Pipedrive::DealAdapter.refuse_deal(deal_id, owner_id) }
|
2018-03-28 11:56:19 +02:00
|
|
|
Pipedrive::PersonAdapter.update_person_owner(person_id, owner_id)
|
|
|
|
end
|
2018-03-27 13:32:14 +02:00
|
|
|
|
2018-03-28 11:56:19 +02:00
|
|
|
def self.get_demandes
|
|
|
|
Pipedrive::PersonAdapter.get_demandes_from_persons_owned_by_robot
|
2018-03-23 17:21:51 +01:00
|
|
|
end
|
2018-05-24 16:40:39 +02:00
|
|
|
|
|
|
|
def self.add_demande(email, phone, name, poste, source, organization_name, address)
|
|
|
|
organization_id = Pipedrive::OrganizationAdapter.add_organization(organization_name, address)
|
|
|
|
person_id = Pipedrive::PersonAdapter.add_person(email, phone, name, organization_id, poste, source)
|
|
|
|
Pipedrive::DealAdapter.add_deal(organization_id, person_id, organization_name)
|
|
|
|
end
|
2018-03-23 17:21:51 +01:00
|
|
|
end
|