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

(-)a/Koha/REST/V1/Checkouts.pm (+36 lines)
Lines 99-104 sub get { Link Here
99
    };
99
    };
100
}
100
}
101
101
102
=head3 get_renewals
103
104
List Koha::Checkout::Renewals
105
106
=cut
107
108
sub get_renewals {
109
    my $c = shift->openapi->valid_input or return;
110
111
    try {
112
        my $checkout_id = $c->validation->param('checkout_id');
113
        my $checkout    = Koha::Checkouts->find($checkout_id);
114
        $checkout = Koha::Old::Checkouts->find($checkout_id)
115
          unless ($checkout);
116
117
        unless ($checkout) {
118
            return $c->render(
119
                status  => 404,
120
                openapi => { error => "Checkout doesn't exist" }
121
            );
122
        }
123
124
        my $renewals_rs = $checkout->renewals;
125
        my $renewals = $c->objects->search( $renewals_rs );
126
127
        return $c->render(
128
            status  => 200,
129
            openapi => $renewals
130
        );
131
    }
132
    catch {
133
        $c->unhandled_exception($_);
134
    };
135
}
136
137
102
=head3 renew
138
=head3 renew
103
139
104
Renew a checkout
140
Renew a checkout
(-)a/api/v1/swagger/paths.yaml (+2 lines)
Lines 29-34 Link Here
29
  $ref: paths/checkouts.yaml#/~1checkouts
29
  $ref: paths/checkouts.yaml#/~1checkouts
30
"/checkouts/{checkout_id}":
30
"/checkouts/{checkout_id}":
31
  $ref: paths/checkouts.yaml#/~1checkouts~1{checkout_id}
31
  $ref: paths/checkouts.yaml#/~1checkouts~1{checkout_id}
32
"/checkouts/{checkout_id}/renewals":
33
  $ref: paths/checkouts.yaml#/~1checkouts~1{checkout_id}~1renewals
32
"/checkouts/{checkout_id}/renewal":
34
"/checkouts/{checkout_id}/renewal":
33
  $ref: paths/checkouts.yaml#/~1checkouts~1{checkout_id}~1renewal
35
  $ref: paths/checkouts.yaml#/~1checkouts~1{checkout_id}~1renewal
34
/circulation-rules/kinds:
36
/circulation-rules/kinds:
(-)a/api/v1/swagger/paths/checkouts.yaml (-1 / +41 lines)
Lines 91-96 Link Here
91
        circulate: circulate_remaining_permissions
91
        circulate: circulate_remaining_permissions
92
    x-koha-embed:
92
    x-koha-embed:
93
      - issuer
93
      - issuer
94
      - renewals
94
"/checkouts/{checkout_id}/renewal":
95
"/checkouts/{checkout_id}/renewal":
95
  post:
96
  post:
96
    x-mojo-to: Checkouts#renew
97
    x-mojo-to: Checkouts#renew
Lines 130-135 Link Here
130
    x-koha-authorization:
131
    x-koha-authorization:
131
      permissions:
132
      permissions:
132
        circulate: circulate_remaining_permissions
133
        circulate: circulate_remaining_permissions
134
"/checkouts/{checkout_id}/renewals":
135
  get:
136
    x-mojo-to: Checkouts#get_renewals
137
    operationId: getRenewals
138
    tags:
139
      - checkouts
140
    summary: List renewals for a checkout
141
    parameters:
142
      - $ref: ../parameters.yaml#/checkout_id_pp
143
    produces:
144
      - application/json
145
    responses:
146
      "200":
147
        description: List of checkouts renewals
148
        schema:
149
          $ref: ../definitions.yaml#/renewal
150
      "403":
151
        description: Access forbidden
152
        schema:
153
          $ref: ../definitions.yaml#/error
154
      "404":
155
        description: Checkout not found
156
        schema:
157
          $ref: ../definitions.yaml#/error
158
      "500":
159
        description: |
160
          Internal server error. Possible `error_code` attribute values:
161
162
          * `internal_server_error`
163
        schema:
164
          $ref: ../definitions.yaml#/error
165
      "503":
166
        description: Under maintenance
167
        schema:
168
          $ref: ../definitions.yaml#/error
169
    x-koha-authorization:
170
      permissions:
171
        circulate: circulate_remaining_permissions
172
    x-koha-embed:
173
        - renewer
133
"/checkouts/{checkout_id}/allows_renewal":
174
"/checkouts/{checkout_id}/allows_renewal":
134
  get:
175
  get:
135
    x-mojo-to: Checkouts#allows_renewal
176
    x-mojo-to: Checkouts#allows_renewal
136
- 

Return to bug 30275