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
        return $c->render(
126
        return $c->render(
125
            status  => 201,
127
            status  => 201,
Lines 140-186 sub add { Link Here
140
    };
142
    };
141
}
143
}
142
144
143
=head3 _to_api
144
145
Helper function that maps unblessed Koha::Club::Hold objects into REST api
146
attribute names.
147
148
=cut
149
150
sub _to_api {
151
    my $club_hold    = shift;
152
153
    # Rename attributes
154
    foreach my $column ( keys %{ $Koha::REST::V1::Clubs::Holds::to_api_mapping } ) {
155
        my $mapped_column = $Koha::REST::V1::Clubs::Holds::to_api_mapping->{$column};
156
        if (    exists $club_hold->{ $column }
157
             && defined $mapped_column )
158
        {
159
            # key != undef
160
            $club_hold->{ $mapped_column } = delete $club_hold->{ $column };
161
        }
162
        elsif (    exists $club_hold->{ $column }
163
                && !defined $mapped_column )
164
        {
165
            # key == undef
166
            delete $club_hold->{ $column };
167
        }
168
    }
169
170
    # Calculate the 'restricted' field
171
    return $club_hold;
172
}
173
174
=head3 $to_api_mapping
175
176
=cut
177
178
our $to_api_mapping = {
179
    id => 'club_hold_id',
180
    club_id => 'club_id',
181
    biblio_id => 'biblio_id',
182
    item_id => 'item_id'
183
};
184
185
186
1;
145
1;
187
- 

Return to bug 27330