mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +03:00
ff0b1a61b3
refs https://github.com/TryGhost/Team/issues/1083 This is a WIP for the Offers API so that Admin development can begin to use it.
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
const offersService = require('../../services/offers');
|
|
|
|
module.exports = {
|
|
docName: 'offers',
|
|
|
|
browse: {
|
|
permissions: true,
|
|
async query(frame) {
|
|
const offers = await offersService.api.listOffers();
|
|
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,
|
|
async query(frame) {
|
|
const offer = await offersService.api.updateOffer({
|
|
...frame.data.offers[0],
|
|
id: frame.options.id
|
|
});
|
|
frame.response = {
|
|
offers: [offer]
|
|
};
|
|
}
|
|
},
|
|
|
|
add: {
|
|
permissions: true,
|
|
async query(frame) {
|
|
const offer = await offersService.api.createOffer(frame.data.offers[0]);
|
|
frame.response = {
|
|
offers: [offer]
|
|
};
|
|
}
|
|
}
|
|
};
|