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

(-)a/Koha/Acquisition/Bookseller.pm (-1 / +23 lines)
Lines 28-34 Koha::Acquisition::Bookseller Object class Link Here
28
28
29
=head1 API
29
=head1 API
30
30
31
=head2 Class Methods
31
=head2 Class methods
32
32
33
=head3 baskets
33
=head3 baskets
34
34
Lines 73-78 sub subscriptions { Link Here
73
    return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
73
    return Koha::Subscriptions->search( { aqbooksellerid => $self->id } );
74
}
74
}
75
75
76
=head3 to_api_mapping
77
78
This method returns the mapping for representing a Koha::Acquisition::Bookseller object
79
on the API.
80
81
=cut
82
83
sub to_api_mapping {
84
    return {
85
        booksellerfax   => undef,
86
        bookselleremail => undef,
87
        booksellerurl   => undef,
88
        currency        => undef,
89
        othersupplier   => undef,
90
        listprice       => 'list_currency',
91
        invoiceprice    => 'invoice_currency',
92
        gstreg          => 'gst',
93
        listincgst      => 'list_includes_gst',
94
        invoiceincgst   => 'invoice_includes_gst'
95
    };
96
}
97
76
=head2 Internal methods
98
=head2 Internal methods
77
99
78
=head3 _type
100
=head3 _type
(-)a/Koha/REST/V1/Acquisitions/Vendors.pm (-13 / +17 lines)
Lines 48-60 sub list_vendors { Link Here
48
            if $args->{$filter_param};
48
            if $args->{$filter_param};
49
    }
49
    }
50
50
51
    my @vendors;
52
53
    return try {
51
    return try {
54
        @vendors = Koha::Acquisition::Booksellers->search($filter);
52
        my $vendors = Koha::Acquisition::Booksellers->search($filter);
55
        @vendors = map { _to_api($_->TO_JSON) } @vendors;
53
        return $c->render(
56
        return $c->render( status  => 200,
54
            status  => 200,
57
                           openapi => \@vendors );
55
            openapi => $vendors->to_api
56
        );
58
    }
57
    }
59
    catch {
58
    catch {
60
        if ( $_->isa('DBIx::Class::Exception') ) {
59
        if ( $_->isa('DBIx::Class::Exception') ) {
Lines 83-90 sub get_vendor { Link Here
83
                           openapi => { error => "Vendor not found" } );
82
                           openapi => { error => "Vendor not found" } );
84
    }
83
    }
85
84
86
    return $c->render( status  => 200,
85
    return $c->render(
87
                       openapi => _to_api($vendor->TO_JSON) );
86
        status  => 200,
87
        openapi => $vendor->to_api
88
    );
88
}
89
}
89
90
90
=head3 add_vendor
91
=head3 add_vendor
Lines 100-107 sub add_vendor { Link Here
100
101
101
    return try {
102
    return try {
102
        $vendor->store;
103
        $vendor->store;
103
        return $c->render( status  => 200,
104
        return $c->render(
104
                           openapi => _to_api($vendor->TO_JSON) );
105
            status  => 200,
106
            openapi => $vendor->to_api
107
        );
105
    }
108
    }
106
    catch {
109
    catch {
107
        if ( $_->isa('DBIx::Class::Exception') ) {
110
        if ( $_->isa('DBIx::Class::Exception') ) {
Lines 130-137 sub update_vendor { Link Here
130
        $vendor = Koha::Acquisition::Booksellers->find( $c->validation->param('vendor_id') );
133
        $vendor = Koha::Acquisition::Booksellers->find( $c->validation->param('vendor_id') );
131
        $vendor->set( _to_model( $c->validation->param('body') ) );
134
        $vendor->set( _to_model( $c->validation->param('body') ) );
132
        $vendor->store();
135
        $vendor->store();
133
        return $c->render( status  => 200,
136
        return $c->render(
134
                           openapi => _to_api($vendor->TO_JSON) );
137
            status  => 200,
138
            openapi => $vendor->to_api
139
        );
135
    }
140
    }
136
    catch {
141
    catch {
137
        if ( not defined $vendor ) {
142
        if ( not defined $vendor ) {
138
- 

Return to bug 23843