From 355912fc57170dd748fe31bd660c0cb91e2d4ccb Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 25 Apr 2023 08:09:52 +0200 Subject: [PATCH] refs #4823 Changed API_URL to new version --- README.md | 2 +- models/supplier/suppliers.js | 6 ------ utils.js | 13 ++++++------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 38c226a..fc0d38a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ npm i CLIENT_ID = xxxxxxxxxx CLIENT_SECRET = xxxxxxxxxx API_KEY = xxxxxxxxxx -API_URL = https://api.staging.floriday.io/customers-api/2022v2 +API_URL = https://api.staging.floriday.io/customers-api-2023v1 API_ENDPOINT = https://idm.staging.floriday.io/oauth2/ausmw6b47z1BnlHkw0h7/v1/token #SEQUELIZE CONFIG diff --git a/models/supplier/suppliers.js b/models/supplier/suppliers.js index 27add79..e778eba 100644 --- a/models/supplier/suppliers.js +++ b/models/supplier/suppliers.js @@ -43,12 +43,6 @@ const suppliers = { physicalAddress: { type: Sequelize.JSON, }, - pythosanitaryNumber: { - type: Sequelize.STRING, - }, - organizationType: { - type: Sequelize.STRING, - }, isConnected: { type: Sequelize.BOOLEAN, defaultValue: false, diff --git a/utils.js b/utils.js index c2a8fdb..1ae8a75 100644 --- a/utils.js +++ b/utils.js @@ -4,6 +4,7 @@ import { models } from './models/index.js'; import { v4 as uuidv4 } from 'uuid'; import chalk from 'chalk'; import ora from 'ora'; +const env = process.env; /** * Gets the Access Token from the client config table @@ -238,12 +239,12 @@ export async function syncSuppliers(){ let headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${await getCurrentToken()}`, - 'X-Api-Key': process.env.API_KEY + 'X-Api-Key': process.env.API_KEY, }; const response = await fetch(`${env.API_URL}/organizations/current-max-sequence`, { method: 'GET', - headers + headers, }); if (!response.ok) { @@ -255,14 +256,14 @@ export async function syncSuppliers(){ let timeFinish, timeToGoSec, timeToGoMin, timeLeft; for (let curSequenceNumber = 0; curSequenceNumber <= maxSequenceNumber; curSequenceNumber++) { let timeStart = new moment(); - + let query = `${env.API_URL}/organizations/sync/${curSequenceNumber}?organizationType=SUPPLIER`; let response = await fetch(query, { method: 'GET', headers }); let data = await response.json(); - + let suppliers = data.results; for (let supplier of suppliers) { curSequenceNumber = supplier.sequenceNumber; @@ -283,10 +284,8 @@ export async function syncSuppliers(){ endDate: supplier.endDate, mailingAddress: supplier.mailingAddress, physicalAddress: supplier.physicalAddress, - pythosanitaryNumber: supplier.pythosanitaryNumber, - organizationType: supplier.organizationType }); - } + }; await syncSequence(curSequenceNumber, 'suppliers', maxSequenceNumber); timeFinish = new moment(); timeToGoSec = (timeFinish.diff(timeStart, 'seconds') * (maxSequenceNumber - curSequenceNumber) / 1000)