Skip to content
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

Add support for product_mapping in promotional offers #4489

Merged

Conversation

vegaro
Copy link
Contributor

@vegaro vegaro commented Nov 14, 2024

There's a new product_mapping field in the promotional_offer JSON object. This map is more specific on which offer to load. This mapping will be configurable with the new UI, but we should still support the old ios_offer_id in case the developer has not configured a mapping yet.

@vegaro vegaro marked this pull request as ready for review November 15, 2024 12:37
@vegaro vegaro requested review from a team and fire-at-will November 15, 2024 12:37
Copy link
Member

@aboedo aboedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few swifty things but nothing that's actually important, looks good!

Comment on lines +80 to +86
let discount = if !promoOfferDetails.productMapping.isEmpty {
findMappedDiscount(for: product,
productIdentifier: productIdentifier,
promoOfferDetails: promoOfferDetails)
} else {
findLegacyDiscount(for: product, promoOfferDetails: promoOfferDetails)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL let foo = if ... else works. I would have used a ternary but I feel like this might be more readable

Comment on lines +112 to +114
if let exactMatch = product.discounts.first(where: {
$0.offerIdentifier == promoOfferDetails.iosOfferId
}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FFTI, but you can also do it like this

Suggested change
if let exactMatch = product.discounts.first(where: {
$0.offerIdentifier == promoOfferDetails.iosOfferId
}) {
if let exactMatch = product.discounts.first {
$0.offerIdentifier == promoOfferDetails.iosOfferId
} {

Then again maybe the brackets add some clarity since it ends in a { too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually fails because of the ending {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, then nevermind

@vegaro vegaro enabled auto-merge (squash) November 15, 2024 16:53
@vegaro vegaro merged commit 5f98c3b into main Nov 15, 2024
6 of 7 checks passed
@vegaro vegaro deleted the sdk-3631-sdk-ignoring-product_mapping-in-promotional-offers branch November 15, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants