-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MOB-22283] Exposing new API for generateDisplayXDM for batching multiple display propositions #3
base: MOB-21475
Are you sure you want to change the base?
Changes from all commits
29fa838
634e69b
f3e04c2
6044c0e
0dc6afb
c1e3e53
bf08a35
1f6ef04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright 2024 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.adobe.marketing.mobile.optimize | ||
|
||
internal object OfferExtension { | ||
@JvmStatic | ||
fun List<Offer>?.toUniquePropositionsList(): List<OptimizeProposition>? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here in conjunction with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please review this again, I've fixed the missing logic here @spoorthipujariadobe |
||
if (this.isNullOrEmpty()) return null | ||
val seenPropsIds = mutableSetOf<String>() | ||
val offerIds = this.mapNotNull { it.id }.toSet() | ||
return this | ||
.mapNotNull { it.propositionReference?.get() } | ||
.filter { proposition -> | ||
with(proposition) { | ||
id !in seenPropsIds && offers.any { it.id in offerIds } | ||
} | ||
}.onEach { proposition -> | ||
seenPropsIds.add(proposition.id) | ||
val filteredOffers = proposition.offers.filter { it.id in offerIds } | ||
OptimizeProposition( | ||
proposition.id, | ||
filteredOffers, | ||
proposition.scope, | ||
proposition.scopeDetails | ||
) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Add
@Nullable
annotation to the API signature