Skip to content

Commit 9af2838

Browse files
committed
fixed an issue with usage of recommendation
1 parent bc3d7f5 commit 9af2838

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

dist/breinify-api.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13445,7 +13445,7 @@ dependencyScope.jQuery = $;;
1344513445
return type + unixTimestamp + amount;
1344613446
},
1344713447

13448-
generateRecommendationMessage: function (amount, unixTimestamp) {
13448+
generateRecommendationMessage: function (recommendation, unixTimestamp) {
1344913449
return '' + unixTimestamp;
1345013450
},
1345113451

@@ -13693,6 +13693,11 @@ dependencyScope.jQuery = $;;
1369313693
_privates.ajax(url, data, callback, callback);
1369413694
});
1369513695
},
13696+
'Object,Object,Function': function (user, recommendation, callback) {
13697+
Breinify.recommendationUser(user, recommendation, false, function (data) {
13698+
_privates.ajax(url, data, callback, callback);
13699+
});
13700+
},
1369613701
'Object,Object,Boolean,Function': function (user, recommendation, sign, callback) {
1369713702
Breinify.recommendationUser(user, recommendation, sign, function (data) {
1369813703
_privates.ajax(url, data, callback, callback);
@@ -13731,19 +13736,18 @@ dependencyScope.jQuery = $;;
1373113736
// get the other values needed
1373213737
var unixTimestamp = BreinifyUtil.unixTimestamp();
1373313738
var signature = null;
13739+
1373413740
if (sign) {
1373513741
var secret = _config.get(ATTR_CONFIG.SECRET);
1373613742
if (typeof secret === 'string') {
13737-
var message = _privates.generateRecommendationMessage(nrOfRecommendations, unixTimestamp);
13743+
var message = _privates.generateRecommendationMessage(recommendation, unixTimestamp);
1373813744
signature = _privates.determineSignature(message, _config.get(ATTR_CONFIG.SECRET))
1373913745
} else {
1374013746
_onReady(null);
1374113747
return;
1374213748
}
1374313749
}
1374413750

13745-
category = typeof category === 'undefined' || category === null ? '' : category;
13746-
1374713751
// create the data set
1374813752
var data = {
1374913753
'user': user.all(),
@@ -13755,6 +13759,8 @@ dependencyScope.jQuery = $;;
1375513759
'unixTimestamp': unixTimestamp
1375613760
};
1375713761

13762+
console.log(JSON.stringify(data));
13763+
1375813764
if ($.isFunction(onReady)) {
1375913765
_onReady(data);
1376013766
}

dist/breinify-api.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specs/Breinify-spec.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ describe('Breinify', function () {
100100
Breinify.UTL.unixTimestamp = function () {
101101
return 1451962516;
102102
};
103-
Breinify.recommendationUser({}, 10, "some category", false, function (data) {
103+
Breinify.recommendationUser({}, {
104+
'numRecommendations': 10,
105+
'recommendationCategory': "some category"
106+
}, false, function (data) {
104107

105108
//noinspection JSUnresolvedFunction
106109
expect(data.apiKey).toBe('41B2-F48C-156A-409A-B465-317F-A0B4-E0E8');

src/Breinify.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
return type + unixTimestamp + amount;
163163
},
164164

165-
generateRecommendationMessage: function (amount, unixTimestamp) {
165+
generateRecommendationMessage: function (recommendation, unixTimestamp) {
166166
return '' + unixTimestamp;
167167
},
168168

@@ -410,6 +410,11 @@
410410
_privates.ajax(url, data, callback, callback);
411411
});
412412
},
413+
'Object,Object,Function': function (user, recommendation, callback) {
414+
Breinify.recommendationUser(user, recommendation, false, function (data) {
415+
_privates.ajax(url, data, callback, callback);
416+
});
417+
},
413418
'Object,Object,Boolean,Function': function (user, recommendation, sign, callback) {
414419
Breinify.recommendationUser(user, recommendation, sign, function (data) {
415420
_privates.ajax(url, data, callback, callback);
@@ -448,19 +453,18 @@
448453
// get the other values needed
449454
var unixTimestamp = BreinifyUtil.unixTimestamp();
450455
var signature = null;
456+
451457
if (sign) {
452458
var secret = _config.get(ATTR_CONFIG.SECRET);
453459
if (typeof secret === 'string') {
454-
var message = _privates.generateRecommendationMessage(nrOfRecommendations, unixTimestamp);
460+
var message = _privates.generateRecommendationMessage(recommendation, unixTimestamp);
455461
signature = _privates.determineSignature(message, _config.get(ATTR_CONFIG.SECRET))
456462
} else {
457463
_onReady(null);
458464
return;
459465
}
460466
}
461467

462-
category = typeof category === 'undefined' || category === null ? '' : category;
463-
464468
// create the data set
465469
var data = {
466470
'user': user.all(),
@@ -472,6 +476,8 @@
472476
'unixTimestamp': unixTimestamp
473477
};
474478

479+
console.log(JSON.stringify(data));
480+
475481
if ($.isFunction(onReady)) {
476482
_onReady(data);
477483
}

0 commit comments

Comments
 (0)