From c5953f8aef5c28a300e6c34a8799430e9a7330aa Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 28 Mar 2018 14:42:01 +0200 Subject: [PATCH] Use .join to generate urls (unification) --- app/lib/pipedrive/api.rb | 6 ++++-- config/initializers/urls.rb | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/lib/pipedrive/api.rb b/app/lib/pipedrive/api.rb index 1b08b361d..d0c783dcf 100644 --- a/app/lib/pipedrive/api.rb +++ b/app/lib/pipedrive/api.rb @@ -1,5 +1,7 @@ class Pipedrive::API PIPEDRIVE_ALL_NOT_DELETED_DEALS = 'all_not_deleted' + PIPEDRIVE_DEALS_URL = [PIPEDRIVE_API_URL, 'deals'].join("/") + PIPEDRIVE_PEOPLE_URL = [PIPEDRIVE_API_URL, 'persons'].join("/") def self.get_persons_owned_by_user(user_id) params = { user_id: user_id } @@ -16,13 +18,13 @@ class Pipedrive::API end def self.put_deal(deal_id, params) - url = PIPEDRIVE_DEALS_URL + "/#{deal_id}" + url = [PIPEDRIVE_DEALS_URL, deal_id].join("/") self.put(url, params) end def self.put_person(person_id, params) - url = PIPEDRIVE_PEOPLE_URL + "/#{person_id}" + url = [PIPEDRIVE_PEOPLE_URL, person_id].join("/") self.put(url, params) end diff --git a/config/initializers/urls.rb b/config/initializers/urls.rb index 17bccab1a..510cd60ea 100644 --- a/config/initializers/urls.rb +++ b/config/initializers/urls.rb @@ -4,6 +4,4 @@ else API_ENTREPRISE_URL = 'https://staging.entreprise.api.gouv.fr/v2' end -PIPEDRIVE_API_URL = 'https://api.pipedrive.com/v1/' -PIPEDRIVE_PEOPLE_URL = URI.join(PIPEDRIVE_API_URL, 'persons').to_s -PIPEDRIVE_DEALS_URL = URI.join(PIPEDRIVE_API_URL, 'deals').to_s +PIPEDRIVE_API_URL = 'https://api.pipedrive.com/v1'