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

(-)a/Koha/Edifact/File.pm (+1 lines)
Lines 68-73 sub to_api_mapping { Link Here
68
    return {
68
    return {
69
        message_type => 'type',
69
        message_type => 'type',
70
        basketno     => 'basket_id',
70
        basketno     => 'basket_id',
71
        deleted      => undef,
71
    };
72
    };
72
}
73
}
73
74
(-)a/Koha/REST/V1/Acquisitions/Vendor/Edifact/Files.pm (-2 / +4 lines)
Lines 46-61 Return the list of edifact files Link Here
46
sub list {
46
sub list {
47
    my $c = shift->openapi->valid_input or return;
47
    my $c = shift->openapi->valid_input or return;
48
48
49
    my $filter = { deleted => 0 };
49
    return try {
50
    return try {
50
51
51
        my $files_rs = Koha::Edifact::Files->new;
52
        my $files_rs = Koha::Edifact::Files->search($filter);
52
        my $files    = $c->objects->search($files_rs);
53
        my $files    = $c->objects->search($files_rs);
53
54
54
        return $c->render(
55
        return $c->render(
55
            status  => 200,
56
            status  => 200,
56
            openapi => $files,
57
            openapi => $files,
57
        );
58
        );
58
    } catch {
59
    }
60
    catch {
59
        $c->unhandled_exception($_);
61
        $c->unhandled_exception($_);
60
    };
62
    };
61
}
63
}
(-)a/api/v1/swagger/definitions/edifact_file.yaml (-5 lines)
Lines 55-63 properties: Link Here
55
      - string
55
      - string
56
      - "null"
56
      - "null"
57
    description: Edifact file name
57
    description: Edifact file name
58
  deleted:
59
    type:
60
      - boolean
61
      - "null"
62
    description: Is this file deleted
63
additionalProperties: false
58
additionalProperties: false
(-)a/t/db_dependent/api/v1/edifact_files.t (-5 / +10 lines)
Lines 66-80 subtest 'list() tests' => sub { Link Here
66
    # No acquisitions\/edifiles, so empty array should be returned
66
    # No acquisitions\/edifiles, so empty array should be returned
67
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is( [] );
67
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is( [] );
68
68
69
    my $file = $builder->build_object( { class => 'Koha::Edifact::Files', value => { message_type => 'ORDER' } } );
69
    my $file = $builder->build_object(
70
        { class => 'Koha::Edifact::Files', value => { message_type => 'ORDER', deleted => 0 } } );
70
71
71
    # One file created, should get returned
72
    my $deleted_file = $builder->build_object(
73
        { class => 'Koha::Edifact::Files', value => { message_type => 'ORDER', deleted => 1 } } );
74
75
    # One file undeleted, should get returned
72
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is( [ $file->to_api ] );
76
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is( [ $file->to_api ] );
73
77
74
    my $another_file_ORDER =
78
    my $another_file_ORDER =
75
        $builder->build_object( { class => 'Koha::Edifact::Files', value => { message_type => 'ORDER' } } );
79
        $builder->build_object(
80
        { class => 'Koha::Edifact::Files', value => { message_type => 'ORDER', deleted => 0 } } );
76
    my $another_file_QUOTE =
81
    my $another_file_QUOTE =
77
        $builder->build_object( { class => 'Koha::Edifact::Files', value => { message_type => 'QUOTE' } } );
82
        $builder->build_object(
83
        { class => 'Koha::Edifact::Files', value => { message_type => 'QUOTE', deleted => 0 } } );
78
84
79
    # Two files created, they should both be returned
85
    # Two files created, they should both be returned
80
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is(
86
    $t->get_ok("//$userid:$password@/api/v1/acquisitions/edifiles")->status_is(200)->json_is(
81
- 

Return to bug 30070