Bug 20287: Replace occurrences of AddMember in REST API
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 29 Mar 2018 15:53:01 +0000 (12:53 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 18 Jul 2018 15:49:55 +0000 (15:49 +0000)
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Koha/REST/V1/Patrons.pm

index 2c1934a..a24a7d5 100644 (file)
@@ -19,7 +19,7 @@ use Modern::Perl;
 
 use Mojo::Base 'Mojolicious::Controller';
 
-use C4::Members qw( AddMember ModMember );
+use C4::Members qw( ModMember );
 use Koha::Patrons;
 
 use Scalar::Util qw(blessed);
@@ -126,9 +126,8 @@ sub add {
 
         my $body = _to_model( $c->validation->param('body') );
 
-        # TODO: Use AddMember until it has been moved to Koha-namespace
-        my $patron_id = AddMember( %{ _to_model($body) } );
-        my $patron    = _to_api( Koha::Patrons->find($patron_id)->TO_JSON );
+        my $patron = Koha::Patron->new( _to_model($body) )->store;
+        $patron    = _to_api( $patron->TO_JSON );
 
         return $c->render( status => 201, openapi => $patron );
     }