-
Notifications
You must be signed in to change notification settings - Fork 0
/
keywordSearch.js
executable file
·34 lines (33 loc) · 1.44 KB
/
keywordSearch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var affiliate = require('flipkart-affiliate-client');
var fk = require('./fkdetails.js');
var client = affiliate.createClient({
FkAffId: fk.id,
FkAffToken: fk.token,
responseType: fk.type
});
module.exports = function keywordSearchData(query,callback)
{
var keywordSearchs = [];
client.keywordSearch({query: query}, function(err, results){
if(err)
return callback(err);
else
{
var jKeywordSearch = JSON.parse(results);
var productInfoListSize = Object.keys(jKeywordSearch.productInfoList);
for(var i=0;i<productInfoListSize.length;i++){
var a = {
title:jKeywordSearch.productInfoList[i].productBaseInfo.productAttributes.title,
image:jKeywordSearch.productInfoList[i].productBaseInfo.productAttributes.imageUrls["200x200"],
productUrl:jKeywordSearch.productInfoList[i].productBaseInfo.productAttributes.productUrl,
flipkartSellingPrice:jKeywordSearch.productInfoList[i].productBaseInfo.productAttributes.sellingPrice.amount,
maximumRetailPrice:jKeywordSearch.productInfoList[i].productBaseInfo.productAttributes.maximumRetailPrice.amount,
productBrand:jKeywordSearch.productInfoList[i].productBaseInfo.productAttributes.productBrand,
inStock:jKeywordSearch.productInfoList[i].productBaseInfo.productAttributes.inStock
};
keywordSearchs.push(a);
}
return callback(keywordSearchs);
}
});
}