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

(-)a/Koha/REST/V1/Patrons/Account.pm (+48 lines)
Lines 178-183 sub add_credit { Link Here
178
    };
178
    };
179
}
179
}
180
180
181
=head3 get_credit
182
183
=cut
184
185
sub get_credit {
186
    my $c = shift->openapi->valid_input or return;
187
188
    my $patron = Koha::Patrons->find( $c->param('patron_id') );
189
190
    return $c->render_resource_not_found("Patron")
191
        unless $patron;
192
193
    return try {
194
        my $credit = $c->objects->find( $patron->account->credits, $c->param('credit_id') );
195
196
        return $c->render_resource_not_found("Credit")
197
            unless $credit;
198
199
        return $c->render( status => 200, openapi => $credit );
200
    } catch {
201
        $c->unhandled_exception($_);
202
    };
203
}
204
181
=head3 list_debits
205
=head3 list_debits
182
206
183
=cut
207
=cut
Lines 199-204 sub list_debits { Link Here
199
    };
223
    };
200
}
224
}
201
225
226
=head3 get_debit
227
228
=cut
229
230
sub get_debit {
231
    my $c = shift->openapi->valid_input or return;
232
233
    my $patron = Koha::Patrons->find( $c->param('patron_id') );
234
235
    return $c->render_resource_not_found("Patron")
236
        unless $patron;
237
238
    return try {
239
        my $debit = $c->objects->find( $patron->account->debits, $c->param('debit_id') );
240
241
        return $c->render_resource_not_found("Debit")
242
            unless $debit;
243
244
        return $c->render( status => 200, openapi => $debit );
245
    } catch {
246
        $c->unhandled_exception($_);
247
    };
248
}
249
202
=head3 add_debit
250
=head3 add_debit
203
251
204
=cut
252
=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 457-462 paths: Link Here
457
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account"
457
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account"
458
  "/patrons/{patron_id}/account/credits":
458
  "/patrons/{patron_id}/account/credits":
459
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1credits"
459
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1credits"
460
  "/patrons/{patron_id}/account/credits/{credit_id}":
461
      $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1credits~1{credit_id}"
462
  "/patrons/{patron_id}/account/debits/{debit_id}":
463
      $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1debits~1{debit_id}"
460
  "/patrons/{patron_id}/account/debits":
464
  "/patrons/{patron_id}/account/debits":
461
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1debits"
465
    $ref: "./paths/patrons_account.yaml#/~1patrons~1{patron_id}~1account~1debits"
462
  "/patrons/{patron_id}/extended_attributes":
466
  "/patrons/{patron_id}/extended_attributes":
Lines 687-692 parameters: Link Here
687
    name: club_id
691
    name: club_id
688
    required: true
692
    required: true
689
    type: integer
693
    type: integer
694
  credit_id_pp:
695
    description: Internal credit identifier
696
    in: path
697
    name: credit_id
698
    required: true
699
    type: integer
700
  debit_id_pp:
701
    description: Internal debit identifier
702
    in: path
703
    name: debit_id
704
    required: true
705
    type: integer
690
  eholdings_title_id_pp:
706
  eholdings_title_id_pp:
691
    description: Title internal identifier
707
    description: Title internal identifier
692
    in: path
708
    in: path
693
- 

Return to bug 38931