Revert "fix: throttle Tiny API usage across backfills"
This reverts commit 10d7048497.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Request, Response } from 'express';
|
||||
import { sendToN8n } from '../services/n8n.service';
|
||||
import { sendTinyOrderToGraphs } from '../services/graphs.service';
|
||||
import { tinyPost } from '../services/tiny-api.service';
|
||||
import axios from 'axios';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
@@ -50,7 +50,9 @@ export const handleTinyOrderUpdate = async (req: Request, res: Response): Promis
|
||||
params.append('id', orderId);
|
||||
params.append('formato', 'JSON');
|
||||
|
||||
const apiResponse = await tinyPost('pedido.obter.php', params);
|
||||
const apiResponse = await axios.post('https://api.tiny.com.br/api2/pedido.obter.php', params, {
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||
});
|
||||
|
||||
if (apiResponse.data?.retorno?.status === 'OK') {
|
||||
fullOrderDetails = apiResponse.data.retorno.pedido;
|
||||
@@ -59,14 +61,16 @@ export const handleTinyOrderUpdate = async (req: Request, res: Response): Promis
|
||||
|
||||
// OPTION B: Fetch Vendor's WhatsApp
|
||||
const idVendedor = fullOrderDetails.id_vendedor;
|
||||
if (process.env.TINY_FETCH_SELLER_DETAILS !== 'false' && idVendedor && idVendedor !== "0") {
|
||||
if (idVendedor && idVendedor !== "0") {
|
||||
console.log(`Fetching seller details for Seller ID: ${idVendedor}...`);
|
||||
const vendorParams = new URLSearchParams();
|
||||
vendorParams.append('token', tinyApiToken);
|
||||
vendorParams.append('id', idVendedor);
|
||||
vendorParams.append('formato', 'JSON');
|
||||
|
||||
const vendorResponse = await tinyPost('contato.obter.php', vendorParams);
|
||||
const vendorResponse = await axios.post('https://api.tiny.com.br/api2/contato.obter.php', vendorParams, {
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||
});
|
||||
|
||||
if (vendorResponse.data?.retorno?.status === 'OK') {
|
||||
const contato = vendorResponse.data.retorno.contato;
|
||||
|
||||
Reference in New Issue
Block a user