Ghost/ghost/admin/mirage/config/tiers.js
Rishabh Garg 8b5b3aa734 Updated usage of the Tiers API (#2388)
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>
2022-05-16 19:51:49 +01:00

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/');
}