// TradeTracker feed discovery - list available campaigns and product feeds
const https = require('https');

const TT_CUSTOMER_ID = '35058';

// Try product feed with different parameters
const urls = [
  // List feeds with category filter for shoes
  `https://pf.tradetracker.net/?aid=${TT_CUSTOMER_ID}&encoding=utf-8&type=json&categoryType=2&additionalType=2&limit=5&q=sneakers`,
  // Try with campaign filter
  `https://pf.tradetracker.net/?aid=${TT_CUSTOMER_ID}&encoding=utf-8&type=json&limit=5&q=nike+sneaker`,
];

async function fetchUrl(url) {
  return new Promise((resolve, reject) => {
    https.get(url, (res) => {
      let data = '';
      res.on('data', chunk => data += chunk);
      res.on('end', () => resolve({ status: res.statusCode, data: data.substring(0, 2000) }));
    }).on('error', reject);
  });
}

(async () => {
  for (const url of urls) {
    console.log('\n--- URL:', url.substring(0, 100));
    try {
      const result = await fetchUrl(url);
      console.log('Status:', result.status);
      console.log('Response:', result.data);
    } catch (e) {
      console.log('Error:', e.message);
    }
  }
})();
