From f9e09eda4381a13550cb9cb79b397347ebc26b43 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 19 Dec 2024 17:00:30 +0000 Subject: [PATCH] Bug 38010: Change how interface details are displayed Signed-off-by: Michaela Sieber Signed-off-by: Jonathan Druart --- Koha/Acquisition/Bookseller.pm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Koha/Acquisition/Bookseller.pm b/Koha/Acquisition/Bookseller.pm index b845aba7370..3745e506739 100644 --- a/Koha/Acquisition/Bookseller.pm +++ b/Koha/Acquisition/Bookseller.pm @@ -219,6 +219,34 @@ sub to_api_mapping { }; } +=head3 to_api + + my $json = $av->to_api; + +Overloaded method that returns a JSON representation of the Koha::Acquisition::Bookseller object, +suitable for API output. + +=cut + +sub to_api { + my ( $self, $params ) = @_; + + my $response = $self->SUPER::to_api($params); + my $overrides = {}; + + if ( $self->interfaces ) { + my $interfaces = $self->interfaces->as_list; + my @updated_interfaces; + foreach my $interface ( @{$interfaces} ) { + $interface->password( $interface->plain_text_password ); + push @updated_interfaces, $interface->unblessed; + } + $overrides->{interfaces} = ( \@updated_interfaces ); + } + + return { %$response, %$overrides }; +} + =head2 Internal methods =head3 _type -- 2.34.1