Skip to content
Snippets Groups Projects
Commit fe2d077d authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

Merge branch 'feat/insee-code' of...

Merge branch 'feat/insee-code' of https://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector into feat/insee-code
parents 9358e443 cfc2658d
No related branches found
No related tags found
1 merge request!9Feat/insee code
Pipeline #39580 passed
......@@ -8,6 +8,10 @@ describe('getInseeCode', () => {
expect(await getInseeCode(69069)).toEqual(null)
})
it('should return null for post code 69290 when city is not provided', async () => {
expect(await getInseeCode(69290)).toEqual(null)
})
it('should return Craponne insee code for post code 69290', async () => {
expect(await getInseeCode(69290, 'CRAPONNE')).toEqual('69069')
})
......
......@@ -2,7 +2,7 @@
const { default: axios } = require('axios')
const { log } = require('cozy-konnector-libs')
const API_URL = 'https://apicarto.ign.fr/api'
const API_URL = 'https://apicarto.ign.fr/api/codes-postaux/communes'
/**
* Return inseeCode given a postalCode
......@@ -12,9 +12,7 @@ const API_URL = 'https://apicarto.ign.fr/api'
*/
async function getInseeCode(postalCode, city) {
try {
const response = await axios.get(
`${API_URL}/codes-postaux/communes/${postalCode}`
)
const response = await axios.get(`${API_URL}/${postalCode}`)
log('info', `Query getInseeCode for postalCode ${postalCode} / ${city}`)
if (response.data.length === 1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment