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

(-)a/Koha/REST/V1/Patrons/Account.pm (+48 lines)
Lines 174-179 sub add_credit { Link Here
174
    };
174
    };
175
}
175
}
176
176
177
=head3 get_credit
178
179
=cut
180
181
sub get_credit {
182
    my $c = shift->openapi->valid_input or return;
183
184
    my $patron = Koha::Patrons->find( $c->param('patron_id') );
185
186
    return $c->render_resource_not_found("Patron")
187
        unless $patron;
188
189
    return try {
190
        my $credit = $c->objects->find( $patron->account->credits, $c->param('credit_id') );
191
192
        return $c->render_resource_not_found("Credit")
193
            unless $credit;
194
195
        return $c->render( status => 200, openapi => $credit );
196
    } catch {
197
        $c->unhandled_exception($_);
198
    };
199
}
200
177
=head3 list_debits
201
=head3 list_debits
178
202
179
=cut
203
=cut
Lines 194-199 sub list_debits { Link Here
194
    };
218
    };
195
}
219
}
196
220
221
=head3 get_debit
222
223
=cut
224
225
sub get_debit {
226
    my $c = shift->openapi->valid_input or return;
227
228
    my $patron = Koha::Patrons->find( $c->param('patron_id') );
229
230
    return $c->render_resource_not_found("Patron")
231
        unless $patron;
232
233
    return try {
234
        my $debit = $c->objects->find( $patron->account->debits, $c->param('debit_id') );
235
236
        return $c->render_resource_not_found("Debit")
237
            unless $debit;
238
239
        return $c->render( status => 200, openapi => $debit );
240
    } catch {
241
        $c->unhandled_exception($_);
242
    };
243
}
244
197
=head3 add_debit
245
=head3 add_debit
198
246
199
=cut
247
=cut
(-)a/api/v1/swagger/paths/patrons_account.yaml (+82 lines)
Lines 144-149 Link Here
144
    x-koha-authorization:
144
    x-koha-authorization:
145
      permissions:
145
      permissions:
146
        updatecharges: remaining_permissions
146
        updatecharges: remaining_permissions
147
"/patrons/{patron_id}/account/credits/{credit_id}":
148
  get:
149
    x-mojo-to: Patrons::Account#get_credit
150
    operationId: getPatronCredit
151
    tags:
152
      - patrons
153
    summary: Get a patron credit
154
    produces:
155
      - application/json
156
    parameters:
157
      - $ref: "../swagger.yaml#/parameters/patron_id_pp"
158
      - $ref: "../swagger.yaml#/parameters/credit_id_pp"
159
    responses:
160
      "200":
161
        description: A patron credit
162
        schema:
163
          $ref: "../swagger.yaml#/definitions/credit"
164
      "400":
165
        description: Bad request
166
        schema:
167
          $ref: "../swagger.yaml#/definitions/error"
168
      "403":
169
        description: Access forbidden
170
        schema:
171
          $ref: "../swagger.yaml#/definitions/error"
172
      "404":
173
        description: Patron not found
174
        schema:
175
          $ref: "../swagger.yaml#/definitions/error"
176
      "500":
177
        description: Internal error
178
        schema:
179
          $ref: "../swagger.yaml#/definitions/error"
180
      "503":
181
        description: Under maintenance
182
        schema:
183
          $ref: "../swagger.yaml#/definitions/error"
184
    x-koha-authorization:
185
      permissions:
186
        borrowers: edit_borrowers
187
        updatecharges: remaining_permissions
147
"/patrons/{patron_id}/account/debits":
188
"/patrons/{patron_id}/account/debits":
148
  get:
189
  get:
149
    x-mojo-to: Patrons::Account#list_debits
190
    x-mojo-to: Patrons::Account#list_debits
Lines 246-248 Link Here
246
    x-koha-authorization:
287
    x-koha-authorization:
247
      permissions:
288
      permissions:
248
        updatecharges: remaining_permissions
289
        updatecharges: remaining_permissions
290
"/patrons/{patron_id}/account/debits/{debit_id}":
291
  get:
292
    x-mojo-to: Patrons::Account#get_debit
293
    operationId: getPatronDebit
294
    tags:
295
      - patrons
296
    summary: Get a patron debit
297
    produces:
298
      - application/json
299
    parameters:
300
      - $ref: "../swagger.yaml#/parameters/patron_id_pp"
301
      - $ref: "../swagger.yaml#/parameters/debit_id_pp"
302
    responses:
303
      "200":
304
        description: A patron debit
305
        schema:
306
          $ref: "../swagger.yaml#/definitions/debit"
307
      "400":
308
        description: Bad request
309
        schema:
310
          $ref: "../swagger.yaml#/definitions/error"
311
      "403":
312
        description: Access forbidden
313
        schema:
314
          $ref: "../swagger.yaml#/definitions/error"
315
      "404":
316
        description: Patron not found
317
        schema:
318
          $ref: "../swagger.yaml#/definitions/error"
319
      "500":
320
        description: Internal error
321
        schema:
322
          $ref: "../swagger.yaml#/definitions/error"
323
      "503":
324
        description: Under maintenance
325
        schema:
326
          $ref: "../swagger.yaml#/definitions/error"
327
    x-koha-authorization:
328
      permissions:
329
        borrowers: edit_borrowers
330
        updatecharges: remaining_permissions
(-)a/api/v1/swagger/swagger.yaml (-1 / +16 lines)
Lines 471-476 paths: Link Here
471
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account"
471
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account"
472
  "/patrons/{patron_id}/account/credits":
472
  "/patrons/{patron_id}/account/credits":
473
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1credits"
473
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1credits"
474
  "/patrons/{patron_id}/account/credits/{credit_id}":
475
      $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1credits~1{credit_id}"
476
  "/patrons/{patron_id}/account/debits/{debit_id}":
477
      $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1debits~1{debit_id}"
474
  "/patrons/{patron_id}/account/debits":
478
  "/patrons/{patron_id}/account/debits":
475
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1debits"
479
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1debits"
476
  "/patrons/{patron_id}/extended_attributes":
480
  "/patrons/{patron_id}/extended_attributes":
Lines 705-710 parameters: Link Here
705
    name: club_id
709
    name: club_id
706
    required: true
710
    required: true
707
    type: integer
711
    type: integer
712
  credit_id_pp:
713
    description: Internal credit identifier
714
    in: path
715
    name: credit_id
716
    required: true
717
    type: integer
718
  debit_id_pp:
719
    description: Internal debit identifier
720
    in: path
721
    name: debit_id
722
    required: true
723
    type: integer
708
  eholdings_title_id_pp:
724
  eholdings_title_id_pp:
709
    description: Title internal identifier
725
    description: Title internal identifier
710
    in: path
726
    in: path
711
- 

Return to bug 38931