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 78-83 Link Here
78
          type: string
78
          type: string
79
          enum:
79
          enum:
80
            - issuer
80
            - issuer
81
            - renewals
81
        collectionFormat: csv
82
        collectionFormat: csv
82
    produces:
83
    produces:
83
      - application/json
84
      - application/json
Lines 147-152 Link Here
147
    x-koha-authorization:
148
    x-koha-authorization:
148
      permissions:
149
      permissions:
149
        circulate: circulate_remaining_permissions
150
        circulate: circulate_remaining_permissions
151
"/checkouts/{checkout_id}/renewals":
152
  get:
153
    x-mojo-to: Checkouts#get_renewals
154
    operationId: getRenewals
155
    tags:
156
      - checkouts
157
    summary: List renewals for a checkout
158
    parameters:
159
      - $ref: ../parameters.yaml#/checkout_id_pp
160
    produces:
161
      - application/json
162
    responses:
163
      "200":
164
        description: List of checkouts renewals
165
        schema:
166
          $ref: ../definitions.yaml#/renewal
167
      "403":
168
        description: Access forbidden
169
        schema:
170
          $ref: ../definitions.yaml#/error
171
      "404":
172
        description: Checkout not found
173
        schema:
174
          $ref: ../definitions.yaml#/error
175
      "500":
176
        description: |
177
          Internal server error. Possible `error_code` attribute values:
178
179
          * `internal_server_error`
180
        schema:
181
          $ref: ../definitions.yaml#/error
182
      "503":
183
        description: Under maintenance
184
        schema:
185
          $ref: ../definitions.yaml#/error
186
    x-koha-authorization:
187
      permissions:
188
        circulate: circulate_remaining_permissions
189
    x-koha-embed:
190
        - renewer
150
"/checkouts/{checkout_id}/allows_renewal":
191
"/checkouts/{checkout_id}/allows_renewal":
151
  get:
192
  get:
152
    x-mojo-to: Checkouts#allows_renewal
193
    x-mojo-to: Checkouts#allows_renewal
153
- 

Return to bug 30275