diff --git a/lib/IdPAccountManager/ServiceProvider.pm b/lib/IdPAccountManager/ServiceProvider.pm index 748f627ef7e3467465503a30caa249960eda2dc0..d7447464674e753c9612cfb2d40a9b31e17a5327 100644 --- a/lib/IdPAccountManager/ServiceProvider.pm +++ b/lib/IdPAccountManager/ServiceProvider.pm @@ -1,4 +1,5 @@ package IdPAccountManager::ServiceProvider; +use parent 'IdPAccountManager::Data::Serviceprovider'; use strict; @@ -14,63 +15,11 @@ my @EXPORT = qw(); use Carp; -INIT { +INIT { ## Set error mode to non fatal IdPAccountManager::Data::Serviceprovider::Manager->error_mode('return'); } -sub new { - my ($pkg) = shift; - my %args = @_; - - my $self = {}; - - ## Bless ServiceProvider object - bless $self, $pkg; - - ## Object may be created either with a hashref as argument or an IdPAccountManager::Data::Serviceprovider object - ## Second case is usefull when fetching a set of IdPAccountManager::Data::Serviceprovider via IdPAccountManager::Data::Serviceprovider::Manager - if (ref($_[0]) eq 'IdPAccountManager::Data::Serviceprovider') { - $self->{'persistent'} = $_[0]; - }else { - $self->{'persistent'} = IdPAccountManager::Data::Serviceprovider->new(%args); - } - - return $self; -} - -sub load { - my $self = shift; - my %args = @_; - - return $self->{'persistent'}->load(%args); -} - -sub get { - my $self = shift; - my $attribute_name = shift; - - return $self->{'persistent'}->$attribute_name; -} - -sub save { - my $self = shift; - - unless ($self->{'persistent'}->save()) { - IdPAccountManager::Tools::do_log('error', "Failed to save Serviceprovider in DB"); - return undef; - } -} - -## Delete a test account -sub delete { - my $self = shift; - - unless ($self->{'persistent'}->delete()) { - IdPAccountManager::Tools::do_log('error', "Failed to delete a Serviceprovider in DB"); - return undef; - } -} ## Print the content of a test account sub print {