View | Details | Raw Unified | Return to bug 11897
Collapse All | Expand All

(-)a/Koha/REST/V1/Stage.pm (-16 / +17 lines)
Lines 23-47 use Koha::StockRotationRotas; Link Here
23
use Koha::StockRotationStages;
23
use Koha::StockRotationStages;
24
24
25
sub move {
25
sub move {
26
    my ($c, $args, $cb) = @_;
26
    my $c = shift->openapi->valid_input or return;
27
27
    my $input = $c->validation->output;
28
    my $rota = Koha::StockRotationRotas->find($args->{rota_id});
28
29
    my $stage = Koha::StockRotationStages->find($args->{stage_id});
29
    my $rota  = Koha::StockRotationRotas->find( $input->{rota_id} );
30
30
    my $stage = Koha::StockRotationStages->find( $input->{stage_id} );
31
    if ($stage && $rota) {
31
32
        my $result = $stage->move_to($args->{position});
32
    if ( $stage && $rota ) {
33
        return $c->$cb({}, 200) if $result;
33
        my $result = $stage->move_to( $input->{position} );
34
        return $c->$cb(
34
        return $c->render( openapi => {}, status => 200 ) if $result;
35
            { error => "Bad request - new position invalid"},
35
        return $c->render(
36
            400
36
            openapi => { error => "Bad request - new position invalid" },
37
            status  => 400
37
        );
38
        );
38
    } else {
39
    }
39
        return $c->$cb(
40
    else {
40
            { error => "Not found - Invalid rota or stage ID"},
41
        return $c->render(
41
            404
42
            openapi => { error => "Not found - Invalid rota or stage ID" },
43
            status  => 404
42
        );
44
        );
43
    }
45
    }
44
45
}
46
}
46
47
47
1;
48
1;
(-)a/api/v1/swagger/paths/rotas.json (-1 / +1 lines)
Lines 1-6 Link Here
1
{
1
{
2
    "/rotas/{rota_id}/stages/{stage_id}/position": {
2
    "/rotas/{rota_id}/stages/{stage_id}/position": {
3
        "put": {
3
        "put": {
4
            "x-mojo-to": "Stage#move",
4
            "operationId": "moveStage",
5
            "operationId": "moveStage",
5
            "tags": ["rotas"],
6
            "tags": ["rotas"],
6
            "parameters": [{
7
            "parameters": [{
7
- 

Return to bug 11897