From 1f525e4deebe20782f849f86cfb4e7c347bd33e3 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 2 Feb 2025 22:09:49 +0100 Subject: Skip multi-component offers; hide upsell by default --- lib/Travel/Routing/DE/DBRIS/Offer.pm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/Travel/Routing/DE/DBRIS/Offer.pm b/lib/Travel/Routing/DE/DBRIS/Offer.pm index 47bf543..a87216b 100644 --- a/lib/Travel/Routing/DE/DBRIS/Offer.pm +++ b/lib/Travel/Routing/DE/DBRIS/Offer.pm @@ -10,7 +10,7 @@ use parent 'Class::Accessor'; our $VERSION = '0.03'; Travel::Routing::DE::DBRIS::Offer->mk_ro_accessors( - qw(class name price price_unit)); + qw(class name price price_unit is_upsell is_cross_sell needs_context)); sub new { my ( $obj, %opt ) = @_; @@ -18,13 +18,23 @@ sub new { my $json = $opt{json}; my $ref = { - class => $json->{klasse} =~ s{KLASSE_}{}r, - name => $json->{name}, - price => $json->{preis}{betrag}, - price_unit => $json->{preis}{waehrung}, - conditions => $json->{konditionsAnzeigen}, + class => $json->{klasse} =~ s{KLASSE_}{}r, + name => $json->{name}, + price => $json->{preis}{betrag}, + price_unit => $json->{preis}{waehrung}, + conditions => $json->{konditionsAnzeigen}, + is_upsell => exists $json->{upsellInfos} ? 1 : 0, + is_cross_sell => exists $json->{crosssellInfos} ? 1 : 0, }; + for my $relation ( @{ $json->{angebotsbeziehungList} // [] } ) { + for my $offer_ref ( @{ $relation->{referenzen} // [] } ) { + if ( $offer_ref->{referenzAngebotsoption} eq 'PFLICHT' ) { + $ref->{needs_context} = 1; + } + } + } + bless( $ref, $obj ); return $ref; -- cgit v1.2.3