Merge branch 'develop' into staging

This commit is contained in:
Xavier J 2016-06-13 10:13:46 +02:00
commit 84bcc70246
12 changed files with 152 additions and 59 deletions

View file

@ -7,22 +7,22 @@ class SIADE::API
end
def self.entreprise(siren)
endpoint = "/api/v1/entreprises/#{siren}"
endpoint = "/v2/entreprises/#{siren}"
call(base_url + endpoint)
end
def self.etablissement(siret)
endpoint = "/api/v1/etablissements/#{siret}"
endpoint = "/v2/etablissements/#{siret}"
call(base_url + endpoint)
end
def self.exercices(siret)
endpoint = "/api/v1/etablissements/exercices/#{siret}"
endpoint = "/v1/etablissements/exercices/#{siret}"
call(base_url + endpoint)
end
def self.rna(siret)
endpoint = "/api/v1/associations/#{siret}"
endpoint = "/v1/associations/#{siret}"
call(base_url + endpoint)
end
@ -39,11 +39,9 @@ class SIADE::API
def self.base_url
if Rails.env.production?
'https://apientreprise.fr'
'https://api.apientreprise.fr'
else
'https://api-dev.apientreprise.fr'
end
'https://apientreprise.fr'
end
end

View file

@ -30,7 +30,7 @@ class SIADE::EtablissementAdapter
def adresse
adresse = ''
[:l1, :l2, :l3, :l4, :l5].each do |line|
[:l1, :l2, :l3, :l4, :l5, :l6, :l7].each do |line|
adresse = adresse + data_source[:etablissement][:adresse][line] + "\r\n" unless data_source[:etablissement][:adresse][line].nil?
end
adresse

View file

@ -95,19 +95,19 @@ describe Users::DossiersController, type: :controller do
describe 'POST #create' do
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
.to_return(status: 404, body: 'fake body')
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
stub_request(:get, "https://apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
.to_return(status: exercices_status, body: exercices_body)
stub_request(:get, "https://apientreprise.fr/api/v1/associations/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v1/associations/#{siret}?token=#{SIADETOKEN}")
.to_return(status: rna_status, body: rna_body)
end

View file

@ -28,14 +28,14 @@ feature 'user path for dossier creation' do
end
context 'sets siret' do
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
stub_request(:get, "https://apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
stub_request(:get, "https://apientreprise.fr/api/v1/associations/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v1/associations/#{siret}?token=#{SIADETOKEN}")
.to_return(status: 404, body: '')
page.find_by_id('dossier_siret').set siret

View file

@ -26,13 +26,13 @@ feature 'user arrive on siret page' do
end
context 'when enter a siret' do
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
stub_request(:get, "https://apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
stub_request(:get, "https://apientreprise.fr/api/v1/associations/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v1/associations/#{siret}?token=#{SIADETOKEN}")
.to_return(status: 404, body: '')
page.find_by_id('dossier_siret').set siret

View file

@ -4,7 +4,7 @@ describe SIADE::API do
describe '.entreprise' do
subject { described_class.entreprise(siren) }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/#{siren}?token=#{SIADETOKEN}")
.to_return(status: status, body: body)
end
context 'when siren does not exist' do
@ -30,7 +30,7 @@ describe SIADE::API do
describe '.etablissement' do
subject { described_class.etablissement(siret) }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(status: status, body: body)
end
@ -57,7 +57,7 @@ describe SIADE::API do
describe '.exercices' do
before do
stub_request(:get, /https:\/\/apientreprise.fr\/api\/v1\/etablissements\/exercices\/.*token=/)
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/etablissements\/exercices\/.*token=/)
.to_return(status: status, body: body)
end
@ -88,7 +88,7 @@ describe SIADE::API do
describe '.rna' do
before do
stub_request(:get, /https:\/\/apientreprise.fr\/api\/v1\/associations\/.*token=/)
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/associations\/.*token=/)
.to_return(status: status, body: body)
end

View file

@ -4,7 +4,7 @@ describe SIADE::EntrepriseAdapter do
subject { described_class.new('418166096').to_params }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/entreprises/418166096?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/entreprises/418166096?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/entreprise.json', status: 200))
end
@ -18,7 +18,7 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien un capital_social' do
expect(subject[:capital_social]).to eq(372_795)
expect(subject[:capital_social]).to eq(462308)
end
it 'L\'entreprise contient bien un numero_tva_intracommunautaire' do
@ -46,11 +46,11 @@ describe SIADE::EntrepriseAdapter do
end
it 'L\'entreprise contient bien un code_effectif_entreprise' do
expect(subject[:code_effectif_entreprise]).to eq('22')
expect(subject[:code_effectif_entreprise]).to eq('31')
end
it 'L\'entreprise contient bien une date_creation' do
expect(subject[:date_creation]).to eq('Mon, 01 Jan 1900 00:00:00.000000000 +0100')
expect(subject[:date_creation]).to eq('Wed, 01 Apr 1998 00:00:00.000000000 +0200')
end
it 'L\'entreprise contient bien un nom' do

View file

@ -6,7 +6,7 @@ describe SIADE::EtablissementAdapter do
subject { described_class.new(siret).to_params }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{siret}?token=#{SIADETOKEN}")
.to_return(body: File.read('spec/support/files/etablissement.json', status: 200))
end
@ -33,7 +33,7 @@ describe SIADE::EtablissementAdapter do
context 'Concaténation lignes adresse' do
it 'L\'entreprise contient bien une adresse sur plusieurs lignes' do
expect(subject[:adresse]).to eq("OCTO-TECHNOLOGY\r\n50 AV DES CHAMPS ELYSEES\r\n75008 PARIS 8\r\nligne 4\r\nligne 5\r\n")
expect(subject[:adresse]).to eq("OCTO TECHNOLOGY\r\n50 AVENUE DES CHAMPS ELYSEES\r\n75008 PARIS\r\nFRANCE\r\n")
end
end
@ -73,7 +73,7 @@ describe SIADE::EtablissementAdapter do
subject { described_class.new(bad_siret).to_params }
before do
stub_request(:get, "https://apientreprise.fr/api/v1/etablissements/#{bad_siret}?token=#{SIADETOKEN}")
stub_request(:get, "https://api-dev.apientreprise.fr/v2/etablissements/#{bad_siret}?token=#{SIADETOKEN}")
.to_return(body: 'Fake body', status: 404)
end

View file

@ -5,7 +5,7 @@ describe SIADE::ExercicesAdapter do
subject { described_class.new(siret).to_params }
before do
stub_request(:get, /https:\/\/apientreprise.fr\/api\/v1\/etablissements\/exercices\/.*token=/)
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/etablissements\/exercices\/.*token=/)
.to_return(body: File.read('spec/support/files/exercices.json', status: 200))
end

View file

@ -8,7 +8,7 @@ describe SIADE::RNAAdapter do
subject { described_class.new(siret).to_params }
before do
stub_request(:get, /https:\/\/apientreprise.fr\/api\/v1\/associations\/.*token=/)
stub_request(:get, /https:\/\/api-dev.apientreprise.fr\/v1\/associations\/.*token=/)
.to_return(body: body, status: status)
end

View file

@ -1,24 +1,27 @@
{
"entreprise": {
"siren": "418166096",
"capital_social": 372795,
"capital_social": 462308,
"numero_tva_intracommunautaire": "FR16418166096",
"forme_juridique": "SA à directoire (s.a.i.)",
"forme_juridique_code": "5699",
"nombre_etablissements_actifs": 1,
"nom_commercial": "OCTO-TECHNOLOGY",
"procedure_collective": false,
"raison_sociale": "OCTO-TECHNOLOGY",
"siret_siege_social": "41816609600051",
"code_effectif_entreprise": "22",
"date_creation": -2208992400,
"code_effectif_entreprise": "31",
"date_creation": 891381600,
"nom": "test_nom",
"prenom": "test_prenom",
"etat_administratif": {
"value": "Actif",
"date_mise_a_jour": 891381600
},
"date_radiation": null,
"categorie_entreprise": "PME",
"tranche_effectif_salarie_entreprise": {
"de": 200,
"a": 249,
"code": "31",
"date_reference": "2014",
"intitule": "200 à 249 salariés"
},
"exercices": [
{
"chiffre_affaires": null,
@ -46,7 +49,10 @@
"fonction": "PRESIDENT DU DIRECTOIRE",
"dirigeant": true,
"date_naissance": "1965-01-27",
"date_naissance_timestamp": -155523600
"date_naissance_timestamp": -155523600,
"raison_sociale": "",
"identifiant": "",
"type": "PP"
},
{
"nom": "BONTE",
@ -54,7 +60,10 @@
"fonction": "PRESIDENT DU CONSEIL DE SURVEILLANCE",
"dirigeant": true,
"date_naissance": "1965-01-21",
"date_naissance_timestamp": -156042000
"date_naissance_timestamp": -156042000,
"raison_sociale": "",
"identifiant": "",
"type": "PP"
},
{
"nom": "BOSQUE",
@ -62,7 +71,10 @@
"fonction": "VICE PRESIDENT ET MEMBRE DU CONSEIL DE SURVEILLANCE",
"dirigeant": true,
"date_naissance": "1970-12-31",
"date_naissance_timestamp": 31446000
"date_naissance_timestamp": 31446000,
"raison_sociale": "",
"identifiant": "",
"type": "PP"
},
{
"nom": "CINQUIN",
@ -70,7 +82,10 @@
"fonction": "MEMBRE DU DIRECTOIRE",
"dirigeant": true,
"date_naissance": "1972-01-25",
"date_naissance_timestamp": 65142000
"date_naissance_timestamp": 65142000,
"raison_sociale": "",
"identifiant": "",
"type": "PP"
},
{
"nom": "LUCAS",
@ -78,7 +93,10 @@
"fonction": "MEMBRE DU CONSEIL DE SURVEILLANCE",
"dirigeant": true,
"date_naissance": "1964-12-02",
"date_naissance_timestamp": -160362000
"date_naissance_timestamp": -160362000,
"raison_sociale": "",
"identifiant": "",
"type": "PP"
},
{
"nom": "DEGONSE",
@ -86,7 +104,10 @@
"fonction": "MEMBRE DU CONSEIL DE SURVEILLANCE",
"dirigeant": true,
"date_naissance": "1947-07-03",
"date_naissance_timestamp": -710038800
"date_naissance_timestamp": -710038800,
"raison_sociale": "",
"identifiant": "",
"type": "PP"
},
{
"nom": "PLANTIN",
@ -94,7 +115,10 @@
"fonction": "COMMISSAIRE AUX COMPTES TITULAIRE",
"dirigeant": true,
"date_naissance": "1959-01-27",
"date_naissance_timestamp": -344912400
"date_naissance_timestamp": -344912400,
"raison_sociale": "",
"identifiant": "",
"type": "PP"
},
{
"nom": "",
@ -102,9 +126,58 @@
"fonction": "COMMISSAIRE AUX COMPTES SUPPLEANT",
"dirigeant": true,
"date_naissance": "",
"date_naissance_timestamp": 0
"date_naissance_timestamp": 0,
"raison_sociale": "BCRH \u0026 ASSOCIES - SOCIETE A RESPONSABILITE LIMITEE A ASSOCIE UNIQUE",
"identifiant": "490092574",
"type": "PM"
}
]
},
"etablissement_siege": {
"siege_social": true,
"siret": "41816609600051",
"naf": "6202A",
"libelle_naf": "Conseil en systèmes et logiciels informatiques",
"date_mise_a_jour": 1449183600,
"tranche_effectif_salarie_etablissement": {
"de": 200,
"a": 249,
"code": "31",
"date_reference": "2014",
"intitule": "200 à 249 salariés"
},
"date_creation_etablissement": 1108594800,
"enseigne": null,
"region_implantation": {
"code": "11",
"value": "Île-de-France"
},
"commune_implantation": {
"code": "75108",
"value": "PARIS 8"
},
"pays_implantation": {
"code": null,
"value": null
},
"diffusable_commercialement": null,
"adresse": {
"l1": "OCTO TECHNOLOGY",
"l2": null,
"l3": null,
"l4": "50 AVENUE DES CHAMPS ELYSEES",
"l5": null,
"l6": "75008 PARIS",
"l7": "FRANCE",
"numero_voie": "50",
"type_voie": "AV",
"nom_voie": "DES CHAMPS ELYSEES",
"complement_adresse": null,
"code_postal": "75008",
"localite": "PARIS 8",
"code_insee_localite": "75108",
"cedex": null
}
},
"gateway_error": false
}

View file

@ -4,23 +4,45 @@
"siret": "41816609600051",
"naf": "6202A",
"libelle_naf": "Conseil en systèmes et logiciels informatiques",
"etat_administratif_etablissement": {
"value": "Actif",
"date_mise_a_jour": 1108594800
"date_mise_a_jour": 1449183600,
"tranche_effectif_salarie_etablissement": {
"de": 200,
"a": 249,
"code": "31",
"date_reference": "2014",
"intitule": "200 à 249 salariés"
},
"date_creation_etablissement": 1108594800,
"enseigne": null,
"region_implantation": {
"code": "11",
"value": "Île-de-France"
},
"commune_implantation": {
"code": "75108",
"value": "PARIS 8"
},
"pays_implantation": {
"code": null,
"value": null
},
"diffusable_commercialement": null,
"adresse": {
"l1": "OCTO-TECHNOLOGY",
"l2": "50 AV DES CHAMPS ELYSEES",
"l3": "75008 PARIS 8",
"l4": "ligne 4",
"l5": "ligne 5",
"l1": "OCTO TECHNOLOGY",
"l2": null,
"l3": null,
"l4": "50 AVENUE DES CHAMPS ELYSEES",
"l5": null,
"l6": "75008 PARIS",
"l7": "FRANCE",
"numero_voie": "50",
"type_voie": "AV",
"nom_voie": "DES CHAMPS ELYSEES",
"complement_adresse": "complement_adresse",
"code_postal": "75008",
"localite": "PARIS 8",
"code_insee_localite": "75108"
"code_insee_localite": "75108",
"cedex": null
}
},
"gateway_error": false