Force new git SHA to avoid CI scientific notation bug. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
98 lines
2.9 KiB
TypeScript
98 lines
2.9 KiB
TypeScript
import axios from 'axios';
|
|
|
|
async function main() {
|
|
// Test Elasticsearch API with API key
|
|
console.log('=== ELASTICSEARCH API ===\n');
|
|
|
|
const esUrl = 'https://search-kyrok9udlk.gapcommerceapi.com/product/search';
|
|
const apiKey = 'V3jHL9dFzi3Gj4UISM4lr38Nm0GSxcps5OBz1PbS';
|
|
|
|
const query = {
|
|
from: 0,
|
|
size: 1000,
|
|
query: {
|
|
bool: {
|
|
must: [
|
|
{ bool: { filter: { range: { customMinPrice: { gte: 0.01, lte: 500000 }}}}},
|
|
{ bool: { should: [{ match: { isAboveThreshold: true }}]}},
|
|
{ bool: { should: [{ match: { isHideFromMenu: false }}]}}
|
|
]
|
|
}
|
|
}
|
|
};
|
|
|
|
try {
|
|
const response = await axios.post(esUrl, query, {
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'x-api-key': apiKey,
|
|
'Origin': 'https://shop.bestdispensary.com',
|
|
'Referer': 'https://shop.bestdispensary.com/',
|
|
},
|
|
timeout: 30000,
|
|
});
|
|
|
|
const data = response.data;
|
|
const total = data.hits?.total?.value || data.hits?.total;
|
|
const products = data.hits?.hits || [];
|
|
|
|
console.log('Total products: ' + total);
|
|
console.log('Products returned: ' + products.length);
|
|
|
|
if (products.length > 0) {
|
|
const first = products[0]._source;
|
|
console.log('\n=== PRODUCT FIELDS ===\n');
|
|
console.log(Object.keys(first).sort().join('\n'));
|
|
|
|
console.log('\n=== SAMPLE PRODUCT ===\n');
|
|
console.log(JSON.stringify(first, null, 2));
|
|
}
|
|
|
|
} catch (err: any) {
|
|
console.log('Elasticsearch Error: ' + err.message);
|
|
if (err.response) {
|
|
console.log('Status: ' + err.response.status);
|
|
}
|
|
}
|
|
|
|
// Test Treez Headless API
|
|
console.log('\n\n=== TREEZ HEADLESS API ===\n');
|
|
|
|
const treezUrl = 'https://headless.treez.io/v2.0/dispensary/best/ecommerce/discounts?excludeInactive=true&hideUnset=true&includeProdInfo=true';
|
|
|
|
try {
|
|
const response = await axios.get(treezUrl, {
|
|
headers: {
|
|
'client_id': '29dce682258145c6b1cf71027282d083',
|
|
'client_secret': 'A57bB49AfD7F4233B1750a0B501B4E16',
|
|
'cache-control': 'max-age=0, no-cache, must-revalidate, proxy-revalidate',
|
|
'Origin': 'https://shop.bestdispensary.com',
|
|
'Referer': 'https://shop.bestdispensary.com/',
|
|
},
|
|
timeout: 30000,
|
|
});
|
|
|
|
const data = response.data;
|
|
console.log('Response type: ' + typeof data);
|
|
|
|
if (Array.isArray(data)) {
|
|
console.log('Array length: ' + data.length);
|
|
if (data.length > 0) {
|
|
console.log('First item: ' + JSON.stringify(data[0], null, 2).slice(0, 1000));
|
|
}
|
|
} else {
|
|
console.log('Keys: ' + Object.keys(data).join(', '));
|
|
console.log('Data: ' + JSON.stringify(data, null, 2).slice(0, 2000));
|
|
}
|
|
|
|
} catch (err: any) {
|
|
console.log('Treez Error: ' + err.message);
|
|
if (err.response) {
|
|
console.log('Status: ' + err.response.status);
|
|
console.log('Data: ' + JSON.stringify(err.response.data).slice(0, 500));
|
|
}
|
|
}
|
|
}
|
|
|
|
main();
|