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;
|
|
|
|
let product = offers.find(id);
|
|
|
|
|
|
|
|
return product || new Response(404, {}, {
|
|
|
|
errors: [{
|
|
|
|
type: 'NotFoundError',
|
|
|
|
message: 'Offer not found.'
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
server.put('/offers/:id/');
|
|
|
|
}
|