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.yaml (+4 lines)
Lines 51-56 patron_extended_attribute: Link Here
51
  $ref: definitions/patron_extended_attribute.yaml
51
  $ref: definitions/patron_extended_attribute.yaml
52
quote:
52
quote:
53
  $ref: definitions/quote.yaml
53
  $ref: definitions/quote.yaml
54
renewal:
55
  $ref: definitions/renewal.yaml
56
renewals:
57
  $ref: definitions/renewals.yaml
54
return_claim:
58
return_claim:
55
  $ref: definitions/return_claim.yaml
59
  $ref: definitions/return_claim.yaml
56
smtp_server:
60
smtp_server:
(-)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.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