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

(-)a/Koha/Library.pm (+32 lines)
Lines 89-94 sub cash_registers { Link Here
89
    return Koha::Cash::Registers->_new_from_dbic( $rs );
89
    return Koha::Cash::Registers->_new_from_dbic( $rs );
90
}
90
}
91
91
92
=head3 to_api_mapping
93
94
This method returns the mapping for representing a Koha::Library object
95
on the API.
96
97
=cut
98
99
sub to_api_mapping {
100
    return {
101
        branchcode       => 'library_id',
102
        branchname       => 'name',
103
        branchaddress1   => 'address1',
104
        branchaddress2   => 'address2',
105
        branchaddress3   => 'address3',
106
        branchzip        => 'postal_code',
107
        branchcity       => 'city',
108
        branchstate      => 'state',
109
        branchcountry    => 'country',
110
        branchphone      => 'phone',
111
        branchfax        => 'fax',
112
        branchemail      => 'email',
113
        branchreplyto    => 'reply_to_email',
114
        branchreturnpath => 'return_path_email',
115
        branchurl        => 'url',
116
        issuing          => undef,
117
        branchip         => 'ip',
118
        branchprinter    => undef,
119
        branchnotes      => 'notes',
120
        marcorgcode      => 'marc_org_code',
121
    };
122
}
123
92
=head2 Internal methods
124
=head2 Internal methods
93
125
94
=head3 _type
126
=head3 _type
(-)a/Koha/REST/V1/Library.pm (-4 / +13 lines)
Lines 79-85 sub get { Link Here
79
                           openapi => { error => "Library not found" } );
79
                           openapi => { error => "Library not found" } );
80
    }
80
    }
81
81
82
    return $c->render( status => 200, openapi => _to_api( $library->TO_JSON ) );
82
    return $c->render(
83
        status  => 200,
84
        openapi => $library->to_api
85
    );
83
}
86
}
84
87
85
=head3 add
88
=head3 add
Lines 95-101 sub add { Link Here
95
        my $library = Koha::Library->new( _to_model( $c->validation->param('body') ) );
98
        my $library = Koha::Library->new( _to_model( $c->validation->param('body') ) );
96
        $library->store;
99
        $library->store;
97
        $c->res->headers->location( $c->req->url->to_string . '/' . $library->branchcode );
100
        $c->res->headers->location( $c->req->url->to_string . '/' . $library->branchcode );
98
        return $c->render( status => 201, openapi => _to_api( $library->TO_JSON ) );
101
102
        return $c->render(
103
            status  => 201,
104
            openapi => $library->to_api
105
        );
99
    }
106
    }
100
    catch {
107
    catch {
101
        unless ( blessed $_ && $_->can('rethrow') ) {
108
        unless ( blessed $_ && $_->can('rethrow') ) {
Lines 141-147 sub update { Link Here
141
        my $params = $c->req->json;
148
        my $params = $c->req->json;
142
        $library->set( _to_model($params) );
149
        $library->set( _to_model($params) );
143
        $library->store();
150
        $library->store();
144
        return $c->render( status => 200, openapi => _to_api($library->TO_JSON) );
151
        return $c->render(
152
            status  => 200,
153
            openapi => $library->to_api
154
        );
145
    }
155
    }
146
    catch {
156
    catch {
147
        unless ( blessed $_ && $_->can('rethrow') ) {
157
        unless ( blessed $_ && $_->can('rethrow') ) {
148
- 

Return to bug 23843