2021-10-06 17:29:15 +03:00
|
|
|
import {paginatedResponse} from '../utils';
|
|
|
|
|
|
|
|
export default function mockOffers(server) {
|
2022-02-23 17:21:28 +03:00
|
|
|
server.post('/offers/');
|
2021-10-06 17:29:15 +03:00
|
|
|
|
|
|
|
server.get('/offers/', paginatedResponse('offers'));
|
|
|
|
|
|
|
|
server.get('/offers/:id/', function ({offers}, {params}) {
|
|
|
|
let {id} = params;
|
2022-05-11 20:11:54 +03:00
|
|
|
let tier = offers.find(id);
|
2021-10-06 17:29:15 +03:00
|
|
|
|
2022-05-11 20:11:54 +03:00
|
|
|
return tier || new Response(404, {}, {
|
2021-10-06 17:29:15 +03:00
|
|
|
errors: [{
|
|
|
|
type: 'NotFoundError',
|
|
|
|
message: 'Offer not found.'
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
server.put('/offers/:id/');
|
|
|
|
}
|