Skip to content

Commit

Permalink
Refs #32789: Update /stores/ratings to Magento 2
Browse files Browse the repository at this point in the history
  • Loading branch information
gorbunovav committed Aug 20, 2024
1 parent acff76f commit cfc6803
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/api/extensions/budsies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ module.exports = ({ config, db }) => {
});

budsiesApi.get('/stores/ratings', (req, res) => {
const client = Magento1Client(multiStoreConfig(config.magento1.api, req));
const client = Magento2Client(multiStoreConfig(config.magento2.api, req));

client.addMethods('budsies', (restClient) => {
let module = {};
Expand All @@ -222,23 +222,22 @@ module.exports = ({ config, db }) => {

const customerToken = getToken(req);

let url = `stores/ratings?token=${customerToken}`;
let url = `/stores/ratings`;

if (storeId !== undefined) {
url += `&storeId=${storeId}`;
url += `?storeId=${storeId}`;
}

const data = await restClient.get(url);

const responseData = getResponse(data);
let data = await restClient.get(url, customerToken);

if (responseData) {
await bridgeRequestsCache.setWithTtl(cacheKey, responseData, 300);
if (data) {
data = {'storeRating': data[0]};
await bridgeRequestsCache.setWithTtl(cacheKey, data, 300);
} else {
await bridgeRequestsCache.del(cacheKey);
}

return responseData;
return data;
}

return module;
Expand Down

0 comments on commit cfc6803

Please sign in to comment.