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

(-)a/Koha/Club/Hold.pm (-4 / +1 lines)
Lines 161-170 on the API. Link Here
161
161
162
sub to_api_mapping {
162
sub to_api_mapping {
163
    return {
163
    return {
164
        id        => 'club_hold_id',
164
        id => 'club_hold_id'
165
        club_id   => 'club_id',
166
        biblio_id => 'biblio_id',
167
        item_id   => 'item_id'
168
    };
165
    };
169
}
166
}
170
167
(-)a/Koha/REST/V1/Clubs/Holds.pm (-54 / +12 lines)
Lines 110-125 sub add { Link Here
110
            $expiration_date = output_pref( dt_from_string( $expiration_date, 'rfc3339' ) );
110
            $expiration_date = output_pref( dt_from_string( $expiration_date, 'rfc3339' ) );
111
        }
111
        }
112
112
113
        my $club_hold = Koha::Club::Hold::add({
113
        my $club_hold = Koha::Club::Hold::add(
114
            club_id => $club_id,
114
            {
115
            biblio_id => $biblio->biblionumber,
115
                club_id             => $club_id,
116
            item_id => $item_id,
116
                biblio_id           => $biblio->biblionumber,
117
            pickup_library_id => $pickup_library_id,
117
                item_id             => $item_id,
118
            expiration_date => $expiration_date,
118
                pickup_library_id   => $pickup_library_id,
119
            notes => $notes,
119
                expiration_date     => $expiration_date,
120
            item_type => $item_type,
120
                notes               => $notes,
121
            default_patron_home => $default_patron_home
121
                item_type           => $item_type,
122
        });
122
                default_patron_home => $default_patron_home
123
            }
124
        );
123
125
124
        $c->res->headers->location( $c->req->url->to_string . '/' );
126
        $c->res->headers->location( $c->req->url->to_string . '/' );
125
127
Lines 142-188 sub add { Link Here
142
    };
144
    };
143
}
145
}
144
146
145
=head3 _to_api
146
147
Helper function that maps unblessed Koha::Club::Hold objects into REST api
148
attribute names.
149
150
=cut
151
152
sub _to_api {
153
    my $club_hold    = shift;
154
155
    # Rename attributes
156
    foreach my $column ( keys %{ $Koha::REST::V1::Clubs::Holds::to_api_mapping } ) {
157
        my $mapped_column = $Koha::REST::V1::Clubs::Holds::to_api_mapping->{$column};
158
        if (    exists $club_hold->{ $column }
159
             && defined $mapped_column )
160
        {
161
            # key != undef
162
            $club_hold->{ $mapped_column } = delete $club_hold->{ $column };
163
        }
164
        elsif (    exists $club_hold->{ $column }
165
                && !defined $mapped_column )
166
        {
167
            # key == undef
168
            delete $club_hold->{ $column };
169
        }
170
    }
171
172
    # Calculate the 'restricted' field
173
    return $club_hold;
174
}
175
176
=head3 $to_api_mapping
177
178
=cut
179
180
our $to_api_mapping = {
181
    id => 'club_hold_id',
182
    club_id => 'club_id',
183
    biblio_id => 'biblio_id',
184
    item_id => 'item_id'
185
};
186
187
188
1;
147
1;
189
- 

Return to bug 27330