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

(-)a/Koha/REST/V1/RecordSources.pm (-22 / +7 lines)
Lines 55-66 sub get { Link Here
55
55
56
    return try {
56
    return try {
57
        my $source = $c->objects->find( Koha::RecordSources->new, $c->param('record_source_id') );
57
        my $source = $c->objects->find( Koha::RecordSources->new, $c->param('record_source_id') );
58
        unless ($source) {
58
        return $c->render_resource_not_found("Record source")
59
            return $c->render(
59
            unless $source;
60
                status  => 404,
61
                openapi => { error => "Object not found" }
62
            );
63
        }
64
60
65
        return $c->render( status => 200, openapi => $source );
61
        return $c->render( status => 200, openapi => $source );
66
    } catch {
62
    } catch {
Lines 97-108 sub update { Link Here
97
93
98
    my $source = $c->objects->find_rs( Koha::RecordSources->new, $c->param('record_source_id') );
94
    my $source = $c->objects->find_rs( Koha::RecordSources->new, $c->param('record_source_id') );
99
95
100
    unless ($source) {
96
    return $c->render_resource_not_found("Record source")
101
        return $c->render(
97
        unless $source;
102
            status  => 404,
103
            openapi => { error => "Object not found" }
104
        );
105
    }
106
98
107
    return try {
99
    return try {
108
        $source->set_from_api( $c->req->json )->store;
100
        $source->set_from_api( $c->req->json )->store;
Lines 122-140 sub delete { Link Here
122
114
123
    my $source = $c->objects->find_rs( Koha::RecordSources->new, $c->param('record_source_id') );
115
    my $source = $c->objects->find_rs( Koha::RecordSources->new, $c->param('record_source_id') );
124
116
125
    unless ($source) {
117
    return $c->render_resource_not_found("Record source")
126
        return $c->render(
118
        unless $source;
127
            status  => 404,
128
            openapi => { error => "Object not found" }
129
        );
130
    }
131
119
132
    return try {
120
    return try {
133
        $source->delete;
121
        $source->delete;
134
        return $c->render(
122
        return $c->render_resource_deleted;
135
            status  => 204,
136
            openapi => q{}
137
        );
138
    } catch {
123
    } catch {
139
        $c->unhandled_exception($_);
124
        $c->unhandled_exception($_);
140
    };
125
    };
(-)a/t/db_dependent/api/v1/record_sources.t (-2 / +1 lines)
Lines 129-135 subtest 'get() tests' => sub { Link Here
129
    $source->delete;
129
    $source->delete;
130
130
131
    $t->get_ok("//$userid:$password@/api/v1/record_sources/$id")->status_is(404)
131
    $t->get_ok("//$userid:$password@/api/v1/record_sources/$id")->status_is(404)
132
        ->json_is( '/error' => 'Object not found' );
132
        ->json_is( '/error' => 'Record source not found' );
133
133
134
    $schema->storage->txn_rollback;
134
    $schema->storage->txn_rollback;
135
};
135
};
136
- 

Return to bug 37672