get all the suppliers from floriday api
This commit is contained in:
parent
1cb0d06282
commit
be0c20307b
|
@ -6,6 +6,4 @@ let floraholland = [
|
||||||
8718288004970,
|
8718288004970,
|
||||||
];
|
];
|
||||||
|
|
||||||
let others = [];
|
|
||||||
|
|
||||||
export default {floraholland};
|
export default {floraholland};
|
45
utils.js
45
utils.js
|
@ -223,19 +223,48 @@ async function syncSuppliers(){
|
||||||
'X-Api-Key': process.env.API_KEY
|
'X-Api-Key': process.env.API_KEY
|
||||||
};
|
};
|
||||||
|
|
||||||
let rFloraHolland = suppliersGln.floraholland;
|
let maximumSequenceNumber = 500;
|
||||||
|
|
||||||
let queryMaxSeqNumber = `${BASE_CUSTOMER_URL}organizations/current-max-sequence`;
|
for (let i = 0; i < maximumSequenceNumber; i++) {
|
||||||
|
|
||||||
let responseMaxSequence = await fetch(queryMaxSeqNumber, {
|
let query = `${BASE_CUSTOMER_URL}organizations/sync/${i}?organizationType=SUPPLIER&limit=500`;
|
||||||
method: 'GET',
|
let response = await fetch(query, {
|
||||||
headers: headers
|
method: 'GET',
|
||||||
});
|
headers: headers
|
||||||
|
});
|
||||||
|
|
||||||
let dataMaxSequence = await responseMaxSequence.json();
|
let data = await response.json();
|
||||||
|
|
||||||
console.log('Maximum sequence number: ', dataMaxSequence);
|
maximumSequenceNumber = data.maximumSequenceNumber;
|
||||||
|
let suppliers = data.results;
|
||||||
|
|
||||||
|
for (let supplier of suppliers) {
|
||||||
|
i = supplier.sequenceNumber;
|
||||||
|
await models.suppliers.upsert({
|
||||||
|
isConnected: false,
|
||||||
|
commercialName: supplier.commercialName,
|
||||||
|
email: supplier.email,
|
||||||
|
phone: supplier.phone,
|
||||||
|
website: supplier.website,
|
||||||
|
mailingAddress: supplier.mailingAddress,
|
||||||
|
physicalAddress: supplier.physicalAddress,
|
||||||
|
pythosanitaryNumber: supplier.pythosanitaryNumber,
|
||||||
|
sequenceNumber: supplier.sequenceNumber,
|
||||||
|
organizationId: supplier.organizationId,
|
||||||
|
companyGln: supplier.companyGln,
|
||||||
|
name: supplier.name,
|
||||||
|
endDate: supplier.endDate,
|
||||||
|
rfhRelationId: supplier.rfhRelationId,
|
||||||
|
organizationType: supplier.organizationType,
|
||||||
|
paymentProviders: `${supplier.paymentProviders}`,
|
||||||
|
});
|
||||||
|
console.log('INSERTED:\t', supplier.commercialName, '\nsequenceNumber:\t', supplier.sequenceNumber);
|
||||||
|
}
|
||||||
|
await syncSequence(i, 'suppliers', maximumSequenceNumber);
|
||||||
|
console.log(data.maximumSequenceNumber);
|
||||||
|
console.log(data.results.length);
|
||||||
|
console.log(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncTradeItems(){
|
async function syncTradeItems(){
|
||||||
|
|
Loading…
Reference in New Issue