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

(-)a/Koha/REST/V1/Holds.pm (-3 / +3 lines)
Lines 284-304 sub suspend { Link Here
284
    my $hold_id  = $c->validation->param('hold_id');
284
    my $hold_id  = $c->validation->param('hold_id');
285
    my $hold     = Koha::Holds->find($hold_id);
285
    my $hold     = Koha::Holds->find($hold_id);
286
    my $body     = $c->req->json;
286
    my $body     = $c->req->json;
287
    my $exp_date = ($body) ? $body->{expiration_date} : undef;
287
    my $end_date = ($body) ? $body->{end_date} : undef;
288
288
289
    unless ($hold) {
289
    unless ($hold) {
290
        return $c->render( status => 404, openapi => { error => 'Hold not found.' } );
290
        return $c->render( status => 404, openapi => { error => 'Hold not found.' } );
291
    }
291
    }
292
292
293
    return try {
293
    return try {
294
        my $date = ($exp_date) ? dt_from_string( $exp_date, 'rfc3339' ) : undef;
294
        my $date = ($end_date) ? dt_from_string( $end_date, 'rfc3339' ) : undef;
295
        $hold->suspend_hold($date);
295
        $hold->suspend_hold($date);
296
        $hold->discard_changes;
296
        $hold->discard_changes;
297
        $c->res->headers->location( $c->req->url->to_string );
297
        $c->res->headers->location( $c->req->url->to_string );
298
        return $c->render(
298
        return $c->render(
299
            status  => 201,
299
            status  => 201,
300
            openapi => {
300
            openapi => {
301
                expiration_date => output_pref(
301
                end_date => output_pref(
302
                    {   dt         => dt_from_string( $hold->suspend_until ),
302
                    {   dt         => dt_from_string( $hold->suspend_until ),
303
                        dateformat => 'rfc3339',
303
                        dateformat => 'rfc3339',
304
                        dateonly   => 1
304
                        dateonly   => 1
(-)a/api/v1/swagger/paths/holds.json (-1 / +1 lines)
Lines 402-408 Link Here
402
          "schema": {
402
          "schema": {
403
            "type": "object",
403
            "type": "object",
404
            "properties": {
404
            "properties": {
405
              "expiration_date": {
405
              "end_date": {
406
                "description": "Date the hold suspension expires",
406
                "description": "Date the hold suspension expires",
407
                "type": "string",
407
                "type": "string",
408
                "format": "date"
408
                "format": "date"
(-)a/t/db_dependent/api/v1/holds.t (-6 / +6 lines)
Lines 330-336 $schema->storage->txn_rollback; Link Here
330
330
331
subtest 'suspend and resume tests' => sub {
331
subtest 'suspend and resume tests' => sub {
332
332
333
    plan tests => 20;
333
    plan tests => 21;
334
334
335
    $schema->storage->txn_begin;
335
    $schema->storage->txn_begin;
336
336
Lines 359-365 subtest 'suspend and resume tests' => sub { Link Here
359
359
360
    ok( $hold->is_suspended, 'Hold is suspended' );
360
    ok( $hold->is_suspended, 'Hold is suspended' );
361
    $t->json_is(
361
    $t->json_is(
362
        '/expiration_date',
362
        '/end_date',
363
        output_pref(
363
        output_pref(
364
            {   dt         => dt_from_string( $hold->suspend_until ),
364
            {   dt         => dt_from_string( $hold->suspend_until ),
365
                dateformat => 'rfc3339',
365
                dateformat => 'rfc3339',
Lines 378-389 subtest 'suspend and resume tests' => sub { Link Here
378
              "//$userid:$password@/api/v1/holds/"
378
              "//$userid:$password@/api/v1/holds/"
379
            . $hold->id
379
            . $hold->id
380
            . "/suspension" => json => {
380
            . "/suspension" => json => {
381
            expiration_date =>
381
            end_date =>
382
                output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } )
382
                output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } )
383
            }
383
            }
384
    )->status_is( 201, 'Hold suspension created' )
384
    )->status_is( 201, 'Hold suspension created' )
385
        ->json_is( '/expiration_date',
385
        ->json_is( '/end_date',
386
        output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } ) );
386
        output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } ) )
387
        ->header_is( Location => "/api/v1/holds/" . $hold->id . "/suspension", 'The Location header is set' );
387
388
388
    $t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" )
389
    $t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" )
389
      ->status_is( 204, "Correct status when deleting a resource" )
390
      ->status_is( 204, "Correct status when deleting a resource" )
390
- 

Return to bug 22206