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

(-)a/Koha/REST/V1/Acquisitions/Vendors.pm (-15 / +16 lines)
Lines 38-57 Controller function that handles listing Koha::Acquisition::Bookseller objects Link Here
38
=cut
38
=cut
39
39
40
sub list_vendors {
40
sub list_vendors {
41
    my $c = shift->openapi->valid_input or return;
42
43
    my $args = _to_model($c->req->params->to_hash);
44
    my $filter;
45
41
46
    for my $filter_param ( keys %$args ) {
42
    my $c = shift->openapi->valid_input or return;
47
        $filter->{$filter_param} = { LIKE => $args->{$filter_param} . "%" }
48
            if $args->{$filter_param};
49
    }
50
43
51
    my @vendors;
44
    my @vendors;
52
45
53
    return try {
46
    return try {
54
        @vendors = Koha::Acquisition::Booksellers->search($filter);
47
        my $vendors_set = Koha::Acquisition::Booksellers->new;
48
        @vendors = $c->objects->search( $vendors_set, \&_to_model )->as_list;
55
        @vendors = map { _to_api($_->TO_JSON) } @vendors;
49
        @vendors = map { _to_api($_->TO_JSON) } @vendors;
56
        return $c->render( status  => 200,
50
        return $c->render( status  => 200,
57
                           openapi => \@vendors );
51
                           openapi => \@vendors );
Lines 221-232 attribute names. Link Here
221
sub _to_model {
215
sub _to_model {
222
    my $vendor = shift;
216
    my $vendor = shift;
223
217
224
    # Rename back
218
    my $mapping = {
225
    $vendor->{listprice}     = delete $vendor->{list_currency};
219
        list_currency        => 'listprice',
226
    $vendor->{invoiceprice}  = delete $vendor->{invoice_currency};
220
        invoice_currency     => 'invoiceprice',
227
    $vendor->{gstreg}        = delete $vendor->{gst};
221
        gst                  => 'gstreg',
228
    $vendor->{listincgst}    = delete $vendor->{list_includes_gst};
222
        list_includes_gst    => 'listincgst',
229
    $vendor->{invoiceincgst} = delete $vendor->{invoice_includes_gst};
223
        invoice_includes_gst => 'invoiceincgst'
224
    };
225
226
    foreach my $key ( keys %{ $mapping } ) {
227
        if ( exists $vendor->{ $key } ) {
228
            $vendor->{ $mapping->{$key} } = delete $vendor->{ $key };
229
        }
230
    }
230
231
231
    return $vendor;
232
    return $vendor;
232
}
233
}
(-)a/api/v1/swagger/paths/acquisitions_vendors.json (-1 / +8 lines)
Lines 19-24 Link Here
19
        "description": "Case insensitive search on vendor's account number",
19
        "description": "Case insensitive search on vendor's account number",
20
        "required": false,
20
        "required": false,
21
        "type": "string"
21
        "type": "string"
22
      }, {
23
        "$ref": "../parameters.json#/match"
24
      }, {
25
        "$ref": "../parameters.json#/order_by"
26
      }, {
27
        "$ref": "../parameters.json#/page"
28
      }, {
29
        "$ref": "../parameters.json#/per_page"
22
      }],
30
      }],
23
      "responses": {
31
      "responses": {
24
        "200": {
32
        "200": {
25
- 

Return to bug 19250