|
Lines 43-56
sub add {
Link Here
|
| 43 |
my $c = shift->openapi->valid_input or return; |
43 |
my $c = shift->openapi->valid_input or return; |
| 44 |
|
44 |
|
| 45 |
return try { |
45 |
return try { |
| 46 |
my $basket = Koha::Acquisition::Basket->new_from_api( $c->validation->param('body') ); |
46 |
my $basket = Koha::Acquisition::Basket->new_from_api( $c->req->json ); |
| 47 |
$basket->store->discard_changes; |
47 |
$basket->store; |
| 48 |
|
48 |
|
| 49 |
$c->res->headers->location( $c->req->url->to_string . '/' . $basket->basketno ); |
49 |
$c->res->headers->location( $c->req->url->to_string . '/' . $basket->basketno ); |
| 50 |
|
50 |
|
| 51 |
return $c->render( |
51 |
return $c->render( |
| 52 |
status => 201, |
52 |
status => 201, |
| 53 |
openapi => $basket->to_api |
53 |
openapi => $c->objects->to_api($basket), |
| 54 |
); |
54 |
); |
| 55 |
} catch { |
55 |
} catch { |
| 56 |
$c->unhandled_exception($_); |
56 |
$c->unhandled_exception($_); |
| 57 |
- |
|
|