diff --git a/app/lib/pipedrive/api.rb b/app/lib/pipedrive/api.rb index 8cbf1ca04..c537a4e50 100644 --- a/app/lib/pipedrive/api.rb +++ b/app/lib/pipedrive/api.rb @@ -48,7 +48,7 @@ class Pipedrive::API params.merge!({ start: 0, limit: 500, - api_token: PIPEDRIVE_TOKEN + api_token: token }) response = RestClient.get(url, params: params) @@ -56,14 +56,18 @@ class Pipedrive::API end def self.put(url, params) - url = "#{url}?api_token=#{PIPEDRIVE_TOKEN}" + url = "#{url}?api_token=#{token}" RestClient.put(url, params.to_json, { content_type: :json }) end def self.post(url, params) - url = "#{url}?api_token=#{PIPEDRIVE_TOKEN}" + url = "#{url}?api_token=#{token}" RestClient.post(url, params.to_json, { content_type: :json }) end + + def self.token + Rails.application.secrets.pipedrive[:key] + end end diff --git a/config/secrets.yml b/config/secrets.yml index a91dc21d7..a2067225b 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -32,6 +32,8 @@ defaults: &defaults api_entreprise: key: <%= ENV['API_ENTREPRISE_KEY'] %> base_url: <%= ENV['API_ENTREPRISE_BASE_URL'] %> + pipedrive: + key: <%= ENV['PIPEDRIVE_KEY'] %> fog: openstack_tenant: <%= ENV['FOG_OPENSTACK_TENANT'] %> openstack_api_key: <%= ENV['FOG_OPENSTACK_API_KEY'] %> @@ -59,6 +61,8 @@ test: fog: base_url: https://storage.apientreprise.fr directory: tps_dev + pipedrive: + key: pipedrive_test_key france_connect_particulier: identifier: france_connect_test_identifier secret: france_connect_test_secret diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7ba0fc94a..e9a3be72a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -81,8 +81,6 @@ DatabaseCleaner.strategy = :transaction TPS::Application.load_tasks -PIPEDRIVE_TOKEN = :pipedrive_test_token if !defined? PIPEDRIVE_TOKEN - include Warden::Test::Helpers include SmartListing::Helper