2015-08-17 15:53:35 +02:00
|
|
|
class SIADE::API
|
2015-08-10 11:05:06 +02:00
|
|
|
class << self
|
|
|
|
attr_accessor :token
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.entreprise(siren)
|
2016-06-13 10:13:37 +02:00
|
|
|
endpoint = "/v2/entreprises/#{siren}"
|
2015-08-10 11:05:06 +02:00
|
|
|
call(base_url + endpoint)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.etablissement(siret)
|
2016-06-13 10:13:37 +02:00
|
|
|
endpoint = "/v2/etablissements/#{siret}"
|
2015-08-10 11:05:06 +02:00
|
|
|
call(base_url + endpoint)
|
|
|
|
end
|
|
|
|
|
2015-11-16 11:23:29 +01:00
|
|
|
def self.exercices(siret)
|
2016-06-13 10:13:37 +02:00
|
|
|
endpoint = "/v1/etablissements/exercices/#{siret}"
|
2015-11-16 11:23:29 +01:00
|
|
|
call(base_url + endpoint)
|
|
|
|
end
|
|
|
|
|
2015-12-11 10:36:16 +01:00
|
|
|
def self.rna(siret)
|
2016-06-13 10:13:37 +02:00
|
|
|
endpoint = "/v1/associations/#{siret}"
|
2015-12-11 10:36:16 +01:00
|
|
|
call(base_url + endpoint)
|
|
|
|
end
|
|
|
|
|
2015-11-16 11:23:29 +01:00
|
|
|
def self.call(url, params = {})
|
|
|
|
params.merge!(token: SIADETOKEN)
|
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
|
|
|
|
|
|
|
|
RestClient::Resource.new(
|
|
|
|
url,
|
|
|
|
verify_ssl: verify_ssl_mode
|
2015-11-16 11:23:29 +01:00
|
|
|
).get(params: params)
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.base_url
|
2015-09-01 15:33:00 +02:00
|
|
|
if Rails.env.production?
|
2016-06-13 10:13:37 +02:00
|
|
|
'https://api.apientreprise.fr'
|
2015-09-01 15:33:00 +02:00
|
|
|
else
|
|
|
|
'https://api-dev.apientreprise.fr'
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
end
|