#
# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use JSON;
=head1 NAME
-Koha::SharedContent - Set of methods ofr querying Mana KB server
+Koha::SharedContent - Set of methods for querying Mana KB server
=head1 DESCRIPTION
$mana_request->content( to_json($content) );
}
- my $response = $userAgent->request($mana_request);
-
- if ( $response->code != 200 ) {
- return {
- code => $response->code,
- msg => $response->message,
- };
- }
-
+ my $response = $userAgent->simple_request($mana_request);
eval { $result = from_json( $response->decoded_content, { utf8 => 1} ); };
$result->{code} = $response->code;
if ( $@ ){
=cut
sub send_entity {
- my ($lang, $loggedinuser, $resourceid, $resourcetype, $content) = @_;
+ my ($lang, $loggedinuser, $resourceid, $resourcetype) = @_;
- unless ( $content ) {
- $content = prepare_entity_data($lang, $loggedinuser, $resourceid, $resourcetype);
- }
+ my $content = prepare_entity_data($lang, $loggedinuser, $resourceid, $resourcetype);
my $result = process_request(build_request('post', $resourcetype, $content));
return $result;
}
+=head3 comment_entity
+
+my $result = Koha::SharedContent::comment_entity($resource_id, $resource_type, $comment);
+
+Send a comment about a Mana entity.
+
+=cut
+
+sub comment_entity {
+ my ($resourceid, $resourcetype, $comment) = @_;
+
+ my $result = process_request(build_request('post', 'resource_comment',
+ { resource_id => $resourceid, resource_type => $resourcetype, message => $comment }));
+
+ return $result;
+}
+
=head2 prepare_entity_data
$data = prepare_entity_data($language, $borrowernumber, $mana_entity_id, $entity_type);