mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
8b5b3aa734
refs https://github.com/TryGhost/Team/issues/1575 - Update usage of Tier to read monthly & yearly price & currency from top level - Updated usage of Tier to read benefit name from benefits[n], not from benefits[n].name Co-authored-by: Fabien "egg" O'Carroll <fabien@allou.is>
31 lines
744 B
JavaScript
31 lines
744 B
JavaScript
import {paginatedResponse} from '../utils';
|
|
|
|
export default function mockTiers(server) {
|
|
server.post('/tiers/');
|
|
|
|
server.get('/tiers/', paginatedResponse('tiers'));
|
|
|
|
server.get('/tiers/:id/', function ({tiers}, {params}) {
|
|
let {id} = params;
|
|
let tier = tiers.find(id);
|
|
|
|
return tier || new Response(404, {}, {
|
|
errors: [{
|
|
type: 'NotFoundError',
|
|
message: 'Tier not found.'
|
|
}]
|
|
});
|
|
});
|
|
|
|
server.put('/tiers/:id/', function ({tiers}, {params}) {
|
|
const attrs = this.normalizedRequestAttrs();
|
|
const tier = tiers.find(params.id);
|
|
|
|
tier.update(attrs);
|
|
|
|
return tier.save();
|
|
});
|
|
|
|
server.del('/tiers/:id/');
|
|
}
|