Explorar el Código

Add code for storing address when square merchant is created.

Lee Morgan hace 5 años
padre
commit
6e52710d37
Se han modificado 1 ficheros con 12 adiciones y 2 borrados
  1. 12 2
      controllers/squareData.js

+ 12 - 2
controllers/squareData.js

@@ -127,8 +127,18 @@ module.exports = {
                 return Promise.all([items, location]);
             })
             .then((response)=>{
-                if(owner.email === response[1].data.location.business_email) merchant.status = [];
-                merchant.name = response[1].data.location.name;
+                let location = response[1].data.location;
+                if(owner.email === location.business_email) merchant.status = [];
+                merchant.name = location.name;
+
+                merchant.address = {
+                    country: location.address.country,
+                    state: location.address.administrative_district_level_1,
+                    city: location.address.locality,
+                    street: location.address.address_line_1,
+                    postalCode: location.address.postal_code,
+                    timeZone: location.timezone
+                };
                 
                 let recipes = helper.createRecipesFromSquare(response[0].data.objects, merchant._id);
                 merchant.recipes = recipes;