-
Notifications
You must be signed in to change notification settings - Fork 338
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
Add support for product_mapping
in promotional offers
#4489
Conversation
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.
left a few swifty things but nothing that's actually important, looks good!
RevenueCatUI/CustomerCenter/Data/LoadPromotionalOfferUseCase.swift
Outdated
Show resolved
Hide resolved
RevenueCatUI/CustomerCenter/Data/LoadPromotionalOfferUseCase.swift
Outdated
Show resolved
Hide resolved
let discount = if !promoOfferDetails.productMapping.isEmpty { | ||
findMappedDiscount(for: product, | ||
productIdentifier: productIdentifier, | ||
promoOfferDetails: promoOfferDetails) | ||
} else { | ||
findLegacyDiscount(for: product, promoOfferDetails: promoOfferDetails) | ||
} |
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.
TIL let foo = if ... else works. I would have used a ternary but I feel like this might be more readable
RevenueCatUI/CustomerCenter/Data/LoadPromotionalOfferUseCase.swift
Outdated
Show resolved
Hide resolved
if let exactMatch = product.discounts.first(where: { | ||
$0.offerIdentifier == promoOfferDetails.iosOfferId | ||
}) { |
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.
FFTI, but you can also do it like this
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
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.
It actually fails because of the ending {
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.
oh, then nevermind
There's a new
product_mapping
field in thepromotional_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 oldios_offer_id
in case the developer has not configured a mapping yet.