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/definitions/renewal.yaml (+33 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  renewal_id:
5
    type: integer
6
    description: internally assigned renewal identifier
7
  checkout_id:
8
    type: integer
9
    description: internally assigned checkout identifier
10
  interface:
11
    type:
12
      - string
13
      - "null"
14
    description: "Interface from which the renewal took place (values can be: api, cron, commandline, intranet, opac and sip)"
15
  renewer_id:
16
    $ref: ../x-primitives.yaml#/patron_id
17
  renewal_date:
18
    type: string
19
    format: date-time
20
    description: Date the renewal took place
21
  seen:
22
    type:
23
      - boolean
24
    description: Seen/Unseen renewal
25
  timestamp:
26
    type: string
27
    description: Last update time
28
  renewer:
29
    type:
30
      - object
31
      - "null"
32
    description: The object representing the renewal issuer
33
additionalProperties: false
(-)a/api/v1/swagger/definitions/renewals.yaml (+5 lines)
Line 0 Link Here
1
---
2
type: array
3
items:
4
  $ref: renewal.yaml
5
additionalProperties: false
(-)a/api/v1/swagger/paths/checkouts.yaml (-1 / +41 lines)
Lines 112-117 Link Here
112
        circulate: circulate_remaining_permissions
112
        circulate: circulate_remaining_permissions
113
    x-koha-embed:
113
    x-koha-embed:
114
      - issuer
114
      - issuer
115
      - renewals
115
"/checkouts/{checkout_id}/renewal":
116
"/checkouts/{checkout_id}/renewal":
116
  post:
117
  post:
117
    x-mojo-to: Checkouts#renew
118
    x-mojo-to: Checkouts#renew
Lines 151-156 Link Here
151
    x-koha-authorization:
152
    x-koha-authorization:
152
      permissions:
153
      permissions:
153
        circulate: circulate_remaining_permissions
154
        circulate: circulate_remaining_permissions
155
"/checkouts/{checkout_id}/renewals":
156
  get:
157
    x-mojo-to: Checkouts#get_renewals
158
    operationId: getRenewals
159
    tags:
160
      - checkouts
161
    summary: List renewals for a checkout
162
    parameters:
163
      - $ref: ../parameters.yaml#/checkout_id_pp
164
    produces:
165
      - application/json
166
    responses:
167
      "200":
168
        description: List of checkouts renewals
169
        schema:
170
          $ref: ../definitions.yaml#/renewal
171
      "403":
172
        description: Access forbidden
173
        schema:
174
          $ref: ../definitions.yaml#/error
175
      "404":
176
        description: Checkout not found
177
        schema:
178
          $ref: ../definitions.yaml#/error
179
      "500":
180
        description: |
181
          Internal server error. Possible `error_code` attribute values:
182
183
          * `internal_server_error`
184
        schema:
185
          $ref: ../definitions.yaml#/error
186
      "503":
187
        description: Under maintenance
188
        schema:
189
          $ref: ../definitions.yaml#/error
190
    x-koha-authorization:
191
      permissions:
192
        circulate: circulate_remaining_permissions
193
    x-koha-embed:
194
        - renewer
154
"/checkouts/{checkout_id}/allows_renewal":
195
"/checkouts/{checkout_id}/allows_renewal":
155
  get:
196
  get:
156
    x-mojo-to: Checkouts#allows_renewal
197
    x-mojo-to: Checkouts#allows_renewal
157
- 

Return to bug 30275