Bug 21336: Fix the API
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 17 Apr 2019 17:31:27 +0000 (14:31 -0300)
committerroot <root@f1ebe1bec408>
Thu, 18 Apr 2019 09:49:57 +0000 (09:49 +0000)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha/REST/V1/Patrons.pm
Koha/Schema/Result/Borrower.pm
api/v1/swagger/definitions/patron.json
t/db_dependent/api/v1/patrons.t

index 5e8e398..e4f7ba1 100644 (file)
@@ -400,6 +400,7 @@ our $to_api_mapping = {
     debarredcomment     => undef, # calculated, API consumers will use /restrictions instead
     emailpro            => 'secondary_email',
     flags               => undef, # permissions manipulation handled in /permissions
+    flgAnonymized       => 'anonymized',
     gonenoaddress       => 'incorrect_address',
     guarantorid         => 'guarantor_id',
     lastseen            => 'last_seen',
@@ -443,6 +444,7 @@ our $to_api_mapping = {
 
 our $to_model_mapping = {
     altaddress_notes         => 'contactnote',
+    anonymized               => 'flgAnonymized',
     category_id              => 'categorycode',
     check_previous_checkout  => 'checkprevcheckout',
     date_enrolled            => 'dateenrolled',
index f2fa3bf..f626ca9 100644 (file)
@@ -1545,7 +1545,8 @@ __PACKAGE__->belongs_to(
 );
 
 __PACKAGE__->add_columns(
-    '+lost' => { is_boolean => 1 },
+    '+flgAnonymized' => { is_boolean => 1 },
+    '+lost'          => { is_boolean => 1 },
     '+gonenoaddress' => { is_boolean => 1 }
 );
 
index 5d6ccd8..1e87ffc 100644 (file)
     "overdrive_auth_token": {
       "type": ["string", "null"],
       "description": "persist OverDrive auth token"
+    },
+    "anonymized": {
+        "type": "boolean",
+        "readOnly": true,
+        "description": "If the patron has been anonymized"
     }
   },
   "additionalProperties": false,
index 6e0b557..4f96a12 100644 (file)
@@ -143,6 +143,7 @@ subtest 'add() tests' => sub {
         # delete RO attributes
         delete $newpatron->{patron_id};
         delete $newpatron->{restricted};
+        delete $newpatron->{anonymized};
 
         # Create a library just to make sure its ID doesn't exist on the DB
         my $library_to_delete = $builder->build_object({ class => 'Koha::Libraries' });
@@ -189,6 +190,7 @@ subtest 'add() tests' => sub {
         # delete RO attributes
         delete $newpatron->{patron_id};
         delete $newpatron->{restricted};
+        delete $newpatron->{anonymized};
         $patron_to_delete->delete;
 
         $tx = $t->ua->build_tx(POST => "/api/v1/patrons" => json => $newpatron);
@@ -235,6 +237,7 @@ subtest 'update() tests' => sub {
         # delete RO attributes
         delete $newpatron->{patron_id};
         delete $newpatron->{restricted};
+        delete $newpatron->{anonymized};
 
         my $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/-1" => json => $newpatron );
         $tx->req->cookies({name => 'CGISESSID', value => $session_id});