Ghost/core/server/api/canary/offers.js
Fabien O'Carroll b1914758b8 Added support for filter Offers by status
refs https://github.com/TryGhost/Team/issues/1131

This will allow Ghost Admin to display separate lists of active and
archived Offers! We must pass the options through so that the
OffersService is able to handle the filter passed in the request.
2021-10-12 18:39:25 +02:00

60 lines
1.3 KiB
JavaScript

const offersService = require('../../services/offers');
module.exports = {
docName: 'offers',
browse: {
options: [
'filter'
],
permissions: true,
async query(frame) {
const offers = await offersService.api.listOffers(frame.options);
frame.response = {
offers
};
}
},
read: {
data: ['id'],
permissions: true,
async query(frame) {
const offer = await offersService.api.getOffer(frame.data);
frame.response = {
offers: [offer]
};
}
},
edit: {
options: ['id'],
permissions: true,
headers: {
cacheInvalidate: true
},
async query(frame) {
const offer = await offersService.api.updateOffer({
...frame.data.offers[0],
id: frame.options.id
});
frame.response = {
offers: [offer]
};
}
},
add: {
permissions: true,
headers: {
cacheInvalidate: true
},
async query(frame) {
const offer = await offersService.api.createOffer(frame.data.offers[0]);
frame.response = {
offers: [offer]
};
}
}
};