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
|
|
|
|
|
2018-03-15 12:02:45 +01:00
|
|
|
def self.entreprise(siren, procedure_id)
|
2016-06-13 10:13:37 +02:00
|
|
|
endpoint = "/v2/entreprises/#{siren}"
|
2018-03-15 12:02:45 +01:00
|
|
|
call(base_url + endpoint, mandatory_params(siren, procedure_id))
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
2018-03-15 12:02:45 +01:00
|
|
|
def self.etablissement(siret, procedure_id)
|
2016-06-13 10:13:37 +02:00
|
|
|
endpoint = "/v2/etablissements/#{siret}"
|
2018-03-15 12:02:45 +01:00
|
|
|
call(base_url + endpoint, mandatory_params(siret, procedure_id))
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
2018-03-15 12:02:45 +01:00
|
|
|
def self.exercices(siret, procedure_id)
|
2017-12-01 10:56:29 +01:00
|
|
|
endpoint = "/v2/exercices/#{siret}"
|
2018-03-15 12:02:45 +01:00
|
|
|
call(base_url + endpoint, mandatory_params(siret, procedure_id))
|
2015-11-16 11:23:29 +01:00
|
|
|
end
|
|
|
|
|
2018-03-15 12:02:45 +01:00
|
|
|
def self.rna(siret, procedure_id)
|
2017-12-01 10:56:29 +01:00
|
|
|
endpoint = "/v2/associations/#{siret}"
|
2018-03-15 12:02:45 +01:00
|
|
|
call(base_url + endpoint, mandatory_params(siret, procedure_id))
|
2015-12-11 10:36:16 +01:00
|
|
|
end
|
|
|
|
|
2015-11-16 11:23:29 +01:00
|
|
|
def self.call(url, params = {})
|
2017-11-20 18:55:59 +01:00
|
|
|
params[:token] = SIADETOKEN
|
2015-11-16 11:23:29 +01:00
|
|
|
|
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
|
|
|
|
|
2018-03-15 12:02:45 +01:00
|
|
|
def self.mandatory_params(siret_or_siren, procedure_id)
|
|
|
|
{
|
|
|
|
context: "demarches-simplifiees.fr",
|
|
|
|
recipient: siret_or_siren,
|
|
|
|
object: "procedure_id: #{procedure_id}"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
def self.base_url
|
2016-09-01 12:09:44 +02:00
|
|
|
SIADEURL
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
end
|