Use .join to generate urls (unification)

This commit is contained in:
gregoirenovel 2018-03-28 14:42:01 +02:00
parent 298d7d050c
commit c5953f8aef
2 changed files with 5 additions and 5 deletions

View file

@ -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

View file

@ -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'