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

(-)a/Koha/Edifact/File.pm (+42 lines)
Lines 27-32 Koha::Edifact::File - Koha::Object class for single edifact file Link Here
27
27
28
=head2 Class methods
28
=head2 Class methods
29
29
30
=head3 vendor
31
32
  my $vendor = $edifile->vendor;
33
34
Returns the I<Koha::Acquisition::Bookseller> associated with this edifact file
35
36
=cut
37
38
sub vendor {
39
    my ($self) = @_;
40
    my $vendor_rs = $self->_result->vendor;
41
    return Koha::Acquisition::Bookseller->_new_from_dbic( $vendor_rs );
42
}
43
44
=head3 basket
45
46
  my $basket = $edifile->basket;
47
48
Returns the I<Koha::Acquisition::Basket> associated with this edifact file.
49
50
=cut
51
52
sub basket {
53
    my ( $self )  = @_;
54
    my $basket_rs = $self->_result->basketno;
55
    return Koha::Acquisition::Basket->_new_from_dbic( $basket_rs );
56
}
57
58
=head3 to_api_mapping
59
60
This method returns the mapping for representing a Koha::Edifact::File object
61
on the API.
62
63
=cut
64
65
sub to_api_mapping {
66
    return {
67
        message_type  => 'type',
68
        basketno => 'basket_id',
69
    };
70
}
71
30
=head2 Internal methods
72
=head2 Internal methods
31
73
32
=head3 _type
74
=head3 _type
(-)a/Koha/Edifact/Files.pm (-2 / +1 lines)
Lines 18-23 package Koha::Edifact::Files; Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Database;
20
use Koha::Database;
21
use Koha::Edifact::File;
21
22
22
use base qw(Koha::Objects);
23
use base qw(Koha::Objects);
23
24
Lines 27-34 Koha::Edifact::Files - Koha Edifact File Object set class Link Here
27
28
28
=head1 API
29
=head1 API
29
30
30
=head2 Class Methods
31
32
=head2 Internal methods
31
=head2 Internal methods
33
32
34
=head3 _type
33
=head3 _type
(-)a/Koha/REST/V1/Acquisitions/Vendor/Edifact/Files.pm (+63 lines)
Line 0 Link Here
1
package Koha::REST::V1::Acquisitions::Vendor::Edifact::Files;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::Edifact::Files;
23
24
use Try::Tiny qw( catch try );
25
26
=head1 NAME
27
28
Koha::REST::V1::Acquisitions::Edifact::Files
29
30
=head1 API
31
32
=head2 Class methods
33
34
=head3 list
35
36
Controller function that handles edifact files
37
38
=cut
39
40
=head3 list
41
42
Return the list of edifact files
43
44
=cut
45
46
sub list {
47
    my $c = shift->openapi->valid_input or return;
48
49
    return try {
50
51
        my $files_rs = Koha::Edifact::Files->new;
52
        my $files    = $c->objects->search($files_rs);
53
54
        return $c->render(
55
            status  => 200,
56
            openapi => $files,
57
        );
58
    } catch {
59
        $c->unhandled_exception($_);
60
    };
61
}
62
63
1;
(-)a/api/v1/swagger/definitions/edifact_file.yaml (+63 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  id:
5
    type: integer
6
    description: internally assigned edifect file identifier
7
    readOnly: true
8
  type:
9
    type:
10
      - string
11
    description: Edifact file type
12
  transfer_date:
13
    type:
14
      - string
15
      - "null"
16
    format: date
17
    description: Edifact file transfer date
18
  vendor_id:
19
    type:
20
      - string
21
      - "null"
22
    description: Koha vendor id
23
  vendor:
24
    type:
25
      - object
26
      - "null"
27
    description: Koha vendor
28
  edi_acct:
29
    type:
30
      - string
31
      - "null"
32
    description: Edifact account
33
  status:
34
    type:
35
      - string
36
      - "null"
37
    description: Edifact file status
38
  basket_id:
39
    type:
40
      - string
41
      - "null"
42
    description: Koha basket id
43
  basket:
44
    type:
45
      - object
46
      - "null"
47
    description: Koha basket
48
  raw_msg:
49
    type:
50
      - string
51
      - "null"
52
    description: Edifact message
53
  filename:
54
    type:
55
      - string
56
      - "null"
57
    description: Edifact file name
58
  deleted:
59
    type:
60
      - boolean
61
      - "null"
62
    description: Is this file deleted
63
additionalProperties: false
(-)a/api/v1/swagger/paths/acquisitions_edifiles.yaml (+63 lines)
Line 0 Link Here
1
---
2
/acquisitions/edifiles:
3
  get:
4
    x-mojo-to: Acquisitions::Vendor::Edifact::Files#list
5
    operationId: listEdifactFiles
6
    tags:
7
      - edifiles
8
    summary: List edifact files
9
    produces:
10
      - application/json
11
    parameters:
12
      - $ref: "../swagger.yaml#/parameters/match"
13
      - $ref: "../swagger.yaml#/parameters/order_by"
14
      - $ref: "../swagger.yaml#/parameters/page"
15
      - $ref: "../swagger.yaml#/parameters/per_page"
16
      - $ref: "../swagger.yaml#/parameters/q_param"
17
      - $ref: "../swagger.yaml#/parameters/q_body"
18
      - $ref: "../swagger.yaml#/parameters/request_id_header"
19
      - name: x-koha-embed
20
        in: header
21
        required: false
22
        description: Embed list sent as a request header
23
        type: array
24
        items:
25
          type: string
26
          enum:
27
            - vendor
28
            - basket
29
        collectionFormat: csv
30
31
    responses:
32
      "200":
33
        description: A list of edifact files
34
        schema:
35
          type: array
36
          items:
37
            $ref: "../swagger.yaml#/definitions/edifact_file"
38
      "401":
39
        description: Authentication required
40
        schema:
41
          $ref: "../swagger.yaml#/definitions/error"
42
      "403":
43
        description: Access forbidden
44
        schema:
45
          $ref: "../swagger.yaml#/definitions/error"
46
      "404":
47
        description: Edifile not found
48
        schema:
49
          $ref: "../swagger.yaml#/definitions/error"
50
      "500":
51
        description: |
52
          Internal server error. Possible `error_code` attribute values:
53
54
          * `internal_server_error`
55
        schema:
56
          $ref: "../swagger.yaml#/definitions/error"
57
      "503":
58
        description: Under maintenance
59
        schema:
60
          $ref: "../swagger.yaml#/definitions/error"
61
    x-koha-authorization:
62
      permissions:
63
        acquisition: edi_manage
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 38-43 definitions: Link Here
38
    $ref: ./definitions/credit.yaml
38
    $ref: ./definitions/credit.yaml
39
  debit:
39
  debit:
40
    $ref: ./definitions/debit.yaml
40
    $ref: ./definitions/debit.yaml
41
  edifact_file:
42
    $ref: ./definitions/edifact_file.yaml
41
  erm_config:
43
  erm_config:
42
    $ref: ./definitions/erm_config.yaml
44
    $ref: ./definitions/erm_config.yaml
43
  erm_agreement:
45
  erm_agreement:
Lines 163-168 definitions: Link Here
163
paths:
165
paths:
164
  /acquisitions/baskets/managers:
166
  /acquisitions/baskets/managers:
165
    $ref: ./paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets~1managers
167
    $ref: ./paths/acquisitions_baskets.yaml#/~1acquisitions~1baskets~1managers
168
  /acquisitions/edifiles:
169
    $ref: ./paths/acquisitions_edifiles.yaml#/~1acquisitions~1edifiles
166
  /acquisitions/funds:
170
  /acquisitions/funds:
167
    $ref: ./paths/acquisitions_funds.yaml#/~1acquisitions~1funds
171
    $ref: ./paths/acquisitions_funds.yaml#/~1acquisitions~1funds
168
  /acquisitions/funds/owners:
172
  /acquisitions/funds/owners:
169
- 

Return to bug 30070