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

Implement locale for StoreProduct #81

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file.

## Added
- Implement locale for StoreProduct
- Added in Pull Request [#66](https://github.com/space-code/flare/pull/75).

## Updated
- Update `CHANGELOG.md`
- Updated in Pull Request [#74](https://github.com/space-code/flare/pull/74).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ protocol ISKProduct {

/// The currency Symbol for the product's price.
var currencySymbol: String? { get }

/// The locale for the product's currency.
var locale: Locale { get }

/// The price of the product in decimal format.
var price: Decimal { get }
Expand Down
4 changes: 4 additions & 0 deletions Sources/Flare/Classes/Models/Internal/SK1StoreProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ extension SK1StoreProduct: ISKProduct {
var currencySymbol: String? {
numberFormatter.currencySymbol
}

var locale: Locale {
self.product.priceLocale
}

var price: Decimal {
product.price as Decimal
Expand Down
4 changes: 4 additions & 0 deletions Sources/Flare/Classes/Models/Internal/SK2StoreProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ extension SK2StoreProduct: ISKProduct {
var currencySymbol: String? {
numberFormatter.currencySymbol
}

var locale: Locale {
self.currencyFormat.locale
}

var price: Decimal {
product.price
Expand Down
4 changes: 4 additions & 0 deletions Sources/Flare/Classes/Models/StoreProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ extension StoreProduct: ISKProduct {
public var currencySymbol: String? {
product.currencySymbol
}

public var locale: Locale {
self.product.locale
}

public var price: Decimal {
product.price
Expand Down
10 changes: 10 additions & 0 deletions Sources/FlareMock/Mocks/ProductMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ public final class ProductMock: ISKProduct {
invokedCurrencyCodeGetterCount += 1
return stubbedCurrencyCode
}

public var invokedLocaleGetter = false
public var invokedLocaleGetterCount = 0
public var stubbedLocale: Locale!

public var locale: Locale {
invokedLocaleGetter = true
invokedLocaleGetterCount += 1
return stubbedLocale
}

public var invokedCurrencySymbolGetter = false
public var invokedCurrencySymbolGetterCount = 0
Expand Down
Loading