summaryrefslogtreecommitdiff
path: root/lib/Travel
diff options
context:
space:
mode:
authorBirte Kristina Friesel <derf@finalrewind.org>2025-02-02 22:09:49 +0100
committerBirte Kristina Friesel <derf@finalrewind.org>2025-02-02 22:09:49 +0100
commit1f525e4deebe20782f849f86cfb4e7c347bd33e3 (patch)
treea2af93bd4c422fb3360704dcffa264d904ad2b35 /lib/Travel
parent9012931fcffbac4a54ad8f93bee261c91c63943c (diff)
Skip multi-component offers; hide upsell by default
Diffstat (limited to 'lib/Travel')
-rw-r--r--lib/Travel/Routing/DE/DBRIS/Offer.pm22
1 files changed, 16 insertions, 6 deletions
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;