Skip to content

StoreProduct: new pricePerWeek and pricePerYear#1426

Merged
NachoSoto merged 2 commits into
mainfrom
product-price-per-week
Nov 2, 2023
Merged

StoreProduct: new pricePerWeek and pricePerYear#1426
NachoSoto merged 2 commits into
mainfrom
product-price-per-week

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

This brings parity with purchases-ios and will be used for a new paywalls variable.

This brings parity with `purchases-ios` and will be used for a new paywalls variable.
@NachoSoto NachoSoto added the pr:feat A new feature label Nov 1, 2023
@NachoSoto NachoSoto requested a review from a team November 1, 2023 16:48
@Category(AndroidJUnit4::class)
class PriceExtensionsPricePerMonthTest: PriceExtensionsPricePerPeriodTest() {
@Test
@Parameters(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Parameterized tests FTW. It allows us to write repeated tests without duplicating code, and they work great with the IDE:

Screenshot 2023-11-01 at 09 46 20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! yeah, I once tried to update to Juni5 to use them, but they were not compatible with Robolectric, which we use in a bunch of our tests... But adding a library like this for tests makes sense 👍

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great!

final String formattedPricePerMonth = product.formattedPricePerMonth(locale);
final Price pricePerWeek = product.pricePerWeek(locale);
final Price pricePerMonth = product.pricePerMonth(locale);
final Price pricePerYear = product.pricePerYear(locale);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should also add versions without the optional parameter to these (I see we didn't have them for the pricePerMonth and formattedPricePerMonth...), same in the Kotlin API tests.

* For Google subscriptions, this value will use the basePlan to calculate the value.
* @param locale Locale to use for formatting the price. Default is the system default locale.
*/
fun pricePerWeek(locale: Locale = Locale.getDefault()): Price? {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should add a @JvmOverloads here I think, so thee default value works in Java. Same in pricePerYear

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh it's because @JvmOverloads isn't allowed on interface methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can add those explicitly overloaded in a separate PR.

@Category(AndroidJUnit4::class)
class PriceExtensionsPricePerMonthTest: PriceExtensionsPricePerPeriodTest() {
@Test
@Parameters(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! yeah, I once tried to update to Juni5 to use them, but they were not compatible with Robolectric, which we use in a bunch of our tests... But adding a library like this for tests makes sense 👍

@NachoSoto NachoSoto enabled auto-merge (squash) November 2, 2023 16:31
@NachoSoto NachoSoto merged commit 2066a85 into main Nov 2, 2023
@NachoSoto NachoSoto deleted the product-price-per-week branch November 2, 2023 16:48
NachoSoto added a commit that referenced this pull request Nov 2, 2023
NachoSoto added a commit that referenced this pull request Nov 2, 2023
NachoSoto pushed a commit that referenced this pull request Nov 6, 2023
**This is an automatic release.**

### New Features
* `StoreProduct`: new `pricePerWeek` and `pricePerYear` (#1426) via
NachoSoto (@NachoSoto)
### RevenueCatUI
* Fix RevenueCatUI API issues and add API tests (#1433) via Toni Rico
(@tonidero)
* Paywalls: Add initial snapshot testings for RevenueCatUI library
(#1432) via Toni Rico (@tonidero)
* `Paywalls`: new `{{ sub_price_per_week }}` variable (#1427) via
NachoSoto (@NachoSoto)
* `Paywalls`: new `{{ sub_relative_discount }}` variable (#1425) via
NachoSoto (@NachoSoto)
### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `a297205` to `0ddee10`
(#1431) via dependabot[bot] (@dependabot[bot])
### Other Changes
* `Offering`: restore constructor with no `PaywallData` (#1437) via
NachoSoto (@NachoSoto)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants