From 9b1c74b74deaeae4a6e02085ad173c0353d6b5e6 Mon Sep 17 00:00:00 2001
From: Bastien DUMONT <bdumont@grandlyon.com>
Date: Mon, 3 Oct 2022 16:55:08 +0200
Subject: [PATCH] feat: send city to bo

---
 src/core/types/types.js        | 2 ++
 src/core/verifyUserIdentity.js | 1 +
 src/index.js                   | 3 ++-
 src/requests/bo.js             | 5 ++++-
 src/requests/sge.js            | 2 +-
 5 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/core/types/types.js b/src/core/types/types.js
index e69c308..48cd577 100644
--- a/src/core/types/types.js
+++ b/src/core/types/types.js
@@ -36,6 +36,7 @@
  * @property {string} firstname
  * @property {string} address
  * @property {string} postalCode
+ * @property {string} city
  * @property {string} inseeCode
  * @property {string} endDate
  * @property {number} [serviceID]
@@ -51,6 +52,7 @@
  * @property {string} postalCode
  * @property {string} address
  * @property {string} inseeCode
+ * @property {string} city
  */
 
 /**
diff --git a/src/core/verifyUserIdentity.js b/src/core/verifyUserIdentity.js
index 086303e..47e4a8f 100644
--- a/src/core/verifyUserIdentity.js
+++ b/src/core/verifyUserIdentity.js
@@ -52,6 +52,7 @@ async function verifyUserIdentity(
     inseeCode,
     postalCode: fields.postalCode,
     address: fields.address,
+    city: fields.city,
   }
 }
 
diff --git a/src/index.js b/src/index.js
index a1bd2c4..484bebd 100644
--- a/src/index.js
+++ b/src/index.js
@@ -119,7 +119,8 @@ async function start(fields, cozyParameters) {
       user.firstname,
       user.address,
       user.postalCode,
-      user.inseeCode
+      user.inseeCode,
+      user.city
     )
 
     // handle user contract start date in order to preperly request data
diff --git a/src/requests/bo.js b/src/requests/bo.js
index 69ebcad..236b2c8 100644
--- a/src/requests/bo.js
+++ b/src/requests/bo.js
@@ -9,6 +9,7 @@ const { default: axios } = require('axios')
  * @param {string} address
  * @param {string} postalCode
  * @param {string} inseeCode
+ * @param {string} city
  * @returns {Promise<Consent>}
  */
 async function createBoConsent(
@@ -19,7 +20,8 @@ async function createBoConsent(
   firstname,
   address,
   postalCode,
-  inseeCode
+  inseeCode,
+  city
 ) {
   log('info', `Query createBoConsent`)
   const headers = {
@@ -38,6 +40,7 @@ async function createBoConsent(
         address,
         postalCode,
         inseeCode,
+        city,
       },
       headers
     )
diff --git a/src/requests/sge.js b/src/requests/sge.js
index 518c624..22e2d09 100644
--- a/src/requests/sge.js
+++ b/src/requests/sge.js
@@ -131,7 +131,7 @@ function consulterDonneesTechniquesContractuelles(pointId, appLogin) {
 function rechercherPoint(appLogin, name, postalCode, inseeCode, address) {
   log(
     'info',
-    `Query rechercherPoint - postal code / insee code: ${postalCode} / ${inseeCode}`
+    `Query rechercherPoint - postal code : ${postalCode} / insee code: ${inseeCode}`
   )
   return `<?xml version='1.0' encoding='utf-8'?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
-- 
GitLab