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
|
|
|
|
|
2018-03-15 14:02:29 +01:00
|
|
|
ENTREPRISE_RESOURCE_NAME = "entreprises"
|
|
|
|
ETABLISSEMENT_RESOURCE_NAME = "etablissements"
|
|
|
|
EXERCICES_RESOURCE_NAME = "exercices"
|
|
|
|
RNA_RESOURCE_NAME = "associations"
|
|
|
|
|
2015-08-10 11:05:06 +02:00
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
|
2018-03-15 12:02:45 +01:00
|
|
|
def self.entreprise(siren, procedure_id)
|
2018-03-15 14:02:29 +01:00
|
|
|
call(ENTREPRISE_RESOURCE_NAME, 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)
|
2018-03-15 14:02:29 +01:00
|
|
|
call(ETABLISSEMENT_RESOURCE_NAME, 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)
|
2018-03-15 14:02:29 +01:00
|
|
|
call(EXERCICES_RESOURCE_NAME, 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)
|
2018-03-15 14:02:29 +01:00
|
|
|
call(RNA_RESOURCE_NAME, siret, procedure_id)
|
2015-12-11 10:36:16 +01:00
|
|
|
end
|
|
|
|
|
2018-03-15 14:02:29 +01:00
|
|
|
def self.call(resource_name, siret_or_siren, procedure_id)
|
2018-03-15 14:15:32 +01:00
|
|
|
url = url(resource_name, siret_or_siren)
|
2018-03-15 14:14:50 +01:00
|
|
|
params = params(siret_or_siren, procedure_id)
|
2015-08-10 11:05:06 +02:00
|
|
|
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
|
|
|
|
|
2018-03-15 14:15:32 +01:00
|
|
|
RestClient::Resource.new(url, verify_ssl: verify_ssl_mode).get(params: params)
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|
|
|
|
|
2018-03-15 14:17:57 +01:00
|
|
|
def self.url(resource_name, siret_or_siren)
|
2018-03-15 14:20:26 +01:00
|
|
|
[SIADEURL, resource_name, siret_or_siren].join("/")
|
2018-03-15 14:17:57 +01:00
|
|
|
end
|
|
|
|
|
2018-03-15 14:14:50 +01:00
|
|
|
def self.params(siret_or_siren, procedure_id)
|
2018-03-15 12:02:45 +01:00
|
|
|
{
|
|
|
|
context: "demarches-simplifiees.fr",
|
|
|
|
recipient: siret_or_siren,
|
2018-03-15 14:14:50 +01:00
|
|
|
object: "procedure_id: #{procedure_id}",
|
|
|
|
token: SIADETOKEN
|
2018-03-15 12:02:45 +01:00
|
|
|
}
|
|
|
|
end
|
2015-08-10 11:05:06 +02:00
|
|
|
end
|