$logger->info("EbookAPI: overlaying new values on existing cache object");
foreach my $k (%$cache_obj) {
# Add/overwrite existing cached value if a new value is defined.
- $orig_cache->{$k} = $cache_obj->{$k} if (defined $cache_obj->{$k});
+ $orig_cache->{$k} = $cache_obj->{$k} if ($k && defined($cache_obj->{$k}));
}
# The cache object we want to save is the (updated) original one.
$cache_obj = $orig_cache;
return;
}
- # cache and return transaction details
- $handler->{$xact_type} = $xacts;
- # Overlay transactions onto existing cached handler.
- if (update_cache($handler, 1)) {
- return $handler->{$xact_type};
- } else {
- $logger->error("EbookAPI: error caching transaction details ($xact_type)");
- return;
+ if (defined($xacts)) {
+ # cache and return transaction details
+ $handler->{$xact_type} = $xacts;
+ # Overlay transactions onto existing cached handler.
+ if (update_cache($handler, 1)) {
+ return $handler->{$xact_type};
+ } else {
+ $logger->error("EbookAPI: error caching transaction details ($xact_type)");
+ return;
+ }
}
}
};
$logger->info("EbookAPI: retrieved " . scalar(@$checkouts) . " RBDigital checkouts for patron $patron_id");
- $self->{checkouts} = $checkouts;
- return $self->{checkouts};
} else {
$logger->error("EbookAPI: failed to retrieve RBDigital checkouts for patron $patron_id");
- return;
+ return ;
}
+ if (scalar(@$checkouts) > 0) {
+ return $checkouts;
+ }
+
return undef;
}
};
};
$logger->info("EbookAPI: retrieved " . scalar(@$holds) . " RBDigital holds for patron $patron_id");
- $self->{holds} = $holds;
- return $self->{holds};
} else {
$logger->error("EbookAPI: failed to retrieve RBDigital holds for patron $patron_id");
- return;
}
+
+ if (scalar(@$holds) > 0) {
+ return $holds;
+ }
+
+ return undef;
}
# Call this method to return 1 - true or 0 - false if the patron is associated with rbdigital library
my %holds_ref;
- if (defined($holds_req->content)) {
+ if (defined($holds_req) && $holds_req->content ne '') {
$logger->info('EbookAPI: RBDigitalSearch Patron Holds API call was successful');
# Loop over the holds contents and build hash array for easier to use in the UI: { isbn => '1', ...}
- $logger->info("Holds response: " . Dumper($holds_req->content));
+ $logger->info("EbookAPI: Holds response: " . Dumper($holds_req->content));
foreach my $value (@{$holds_req->content}) {
$holds_ref{$value->{title_id}} = "1";
}
my %checkouts_ref;
- if (defined($checkouts_req->content)) {
- $logger->info('EbookAPI: RBDigitalSearch Patron Checkouts API call was successful');
+ if (defined($checkouts_req) && $checkouts_req->content ne '') {
+ $logger->info('EbookAPI: EbookAPI: RBDigitalSearch Patron Checkouts API call was successful');
# Loop over the checkout contents and build hash array for easier to use in the UI: { isbn => '1', ...}
- $logger->debug("Checkout response: " . Dumper($checkouts_req->content));
+ $logger->debug("EbookAPI: Checkout response: " . Dumper($checkouts_req->content));
foreach my $value (@{$checkouts_req->content}) {
$checkouts_ref{$value->{title_id}} = $value->{download_url};
}