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

(-)a/Koha/REST/V1/Illbatches.pm (-23 / +14 lines)
Lines 56-89 Get one batch Link Here
56
=cut
56
=cut
57
57
58
sub get {
58
sub get {
59
    my $c = shift->openapi->valid_input;
59
    my $c = shift->openapi->valid_input or return;
60
60
61
    my $batchid = $c->param('ill_batch_id');
61
    return try {
62
        my $ill_batch = $c->objects->find( Koha::Illbatches->search, $c->param('ill_batch_id') );
62
63
63
    my $batch = Koha::Illbatches->find($batchid);
64
        unless ($ill_batch) {
65
            return $c->render(
66
                status  => 404,
67
                openapi => { error => "ILL batch not found" }
68
            );
69
        }
64
70
65
    if ( not defined $batch ) {
66
        return $c->render(
71
        return $c->render(
67
            status  => 404,
72
            status  => 200,
68
            openapi => { error => "ILL batch not found" }
73
            openapi => $ill_batch
69
        );
74
        );
70
    }
75
    } catch {
71
76
        $c->unhandled_exception($_);
72
    return $c->render(
77
    };
73
        status  => 200,
74
        openapi => {
75
            batch_id       => $batch->id,
76
            backend        => $batch->backend,
77
            library_id     => $batch->branchcode,
78
            name           => $batch->name,
79
            statuscode     => $batch->statuscode,
80
            patron_id      => $batch->borrowernumber,
81
            patron         => $batch->patron->unblessed,
82
            branch         => $batch->branch->unblessed,
83
            status         => $batch->status->unblessed,
84
            requests_count => $batch->requests_count
85
        }
86
    );
87
}
78
}
88
79
89
=head3 add
80
=head3 add
(-)a/api/v1/swagger/paths/ill_batches.yaml (+20 lines)
Lines 127-132 Link Here
127
        description: ILL batch id/name/contents
127
        description: ILL batch id/name/contents
128
        required: true
128
        required: true
129
        type: string
129
        type: string
130
      - $ref: "../swagger.yaml#/parameters/page"
131
      - $ref: "../swagger.yaml#/parameters/per_page"
132
      - $ref: "../swagger.yaml#/parameters/match"
133
      - $ref: "../swagger.yaml#/parameters/order_by"
134
      - $ref: "../swagger.yaml#/parameters/q_param"
135
      - $ref: "../swagger.yaml#/parameters/q_body"
136
      - $ref: "../swagger.yaml#/parameters/request_id_header"
137
      - name: x-koha-embed
138
        in: header
139
        required: false
140
        description: Embed list sent as a request header
141
        type: array
142
        items:
143
          type: string
144
          enum:
145
            - +strings
146
            - requests+count
147
            - patron
148
            - branch
149
        collectionFormat: csv
130
    produces:
150
    produces:
131
      - application/json
151
      - application/json
132
    responses:
152
    responses:
(-)a/t/db_dependent/api/v1/ill_batches.t (-2 / +2 lines)
Lines 161-167 subtest 'get() tests' => sub { Link Here
161
    $patron->set_password( { password => $password, skip_validation => 1 } );
161
    $patron->set_password( { password => $password, skip_validation => 1 } );
162
    my $unauth_userid = $patron->userid;
162
    my $unauth_userid = $patron->userid;
163
163
164
    $t->get_ok( "//$userid:$password@/api/v1/ill/batches/" . $batch->id )->status_is(200)
164
    $t->get_ok( "//$userid:$password@/api/v1/ill/batches/"
165
            . $batch->id => { 'x-koha-embed' => '+strings,requests+count,patron,branch' } )->status_is(200)
165
        ->json_has( '/batch_id',   'Batch ID' )->json_has( '/name', 'Batch name' )
166
        ->json_has( '/batch_id',   'Batch ID' )->json_has( '/name', 'Batch name' )
166
        ->json_has( '/backend',    'Backend name' )->json_has( '/patron_id', 'Borrowernumber' )
167
        ->json_has( '/backend',    'Backend name' )->json_has( '/patron_id', 'Borrowernumber' )
167
        ->json_has( '/library_id', 'Branchcode' )->json_has( '/patron', 'patron embedded' )
168
        ->json_has( '/library_id', 'Branchcode' )->json_has( '/patron', 'patron embedded' )
168
- 

Return to bug 30719