Skip to content

Commit

Permalink
feat(RenewalInfo): enhance IRenewalInfo with renewalPrice and currenc… (
Browse files Browse the repository at this point in the history
#85)

* feat(RenewalInfo): enhance IRenewalInfo with renewalPrice and currency fields

* apply formatting changes

---------

Co-authored-by: M7md <[email protected]>
  • Loading branch information
M7md-Ebrahim and M7md-Ebrahim authored Oct 17, 2024
1 parent b6dabf3 commit af8d8ac
Show file tree
Hide file tree
Showing 83 changed files with 806 additions and 534 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ All notable changes to this project will be documented in this file.
- Updated in Pull Request [#74](https://github.com/space-code/flare/pull/74).
- Update `README.md`
- Updated in Pull Request [#70](https://github.com/space-code/flare/pull/70).
- Update Transaction Model with price and currency
- Updated in Pull Request [#84](https://github.com/space-code/flare/pull/84)
- Update RenewalInfo Model with renewalPrice and currency
- Updated in Pull Request [#85](https://github.com/space-code/flare/pull/85)

#### 3.x Releases
- `3.0.x` Releases - [`3.0.0`](#300) | [`3.0.1`](#301) | [`3.0.2`](#302)
Expand Down Expand Up @@ -66,8 +70,6 @@ Released on 2024-05-10.
## Updated
- Update the `dependabot.yml` configuration
- Updated in Pull Request [#34](https://github.com/space-code/flare/pull/34)
- Update Transaction Model with price and currency
- Updated in Pull Request [#84](https://github.com/space-code/flare/pull/84)

## Fixed
- Fix handling of cancelling operations
Expand Down
2 changes: 1 addition & 1 deletion Sources/Flare/Classes/Common/Types.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Sources/Flare/Classes/Extensions/SKProduct+.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
2 changes: 1 addition & 1 deletion Sources/Flare/Classes/Flare.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import struct Log.LogLevel
Expand Down
517 changes: 336 additions & 181 deletions Sources/Flare/Classes/Generated/Strings.swift

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

#if canImport(UIKit)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Flare/Classes/IFlare.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Sources/Flare/Classes/Models/IAPError.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
15 changes: 15 additions & 0 deletions Sources/Flare/Classes/Models/Internal/Protocols/IRenewalInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import Foundation
import StoreKit

// MARK: - IRenewalInfo

public protocol IRenewalInfo {
/// The JSON representation of the renewal information.
var jsonRepresentation: Data { get }
Expand All @@ -31,6 +33,12 @@ public protocol IRenewalInfo {
/// The status of a price increase for the user.
var priceIncreaseStatus: PriceIncreaseStatus { get }

/// The renewal price of the auto-renewable subscription that renews at the next billing period.
var renewalPrice: Decimal? { get }

/// The currency of the subscription's renewal price.
var currency: String? { get }

/// Whether the subscription is in a billing retry period.
var isInBillingRetry: Bool { get }

Expand All @@ -44,3 +52,10 @@ public protocol IRenewalInfo {
/// offers and if there will be no offer applied for the next billing period.
var offerID: String? { get }
}

/// Default implementation of the currency property for backward compatibility.
extension IRenewalInfo {
var currency: String? {
Locale.current.currencyCodeID
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import Foundation

// MARK: - IStoreTransaction

/// A type that represents a store transaction.
protocol IStoreTransaction {
/// The unique identifier for the product.
Expand All @@ -23,7 +25,7 @@ protocol IStoreTransaction {
var price: Decimal? { get }
/// The currency of the price of the product.
var currency: String? { get }

/// The raw JWS representation of the transaction.
///
/// - Note: This is only available for StoreKit 2 transactions.
Expand All @@ -38,10 +40,6 @@ protocol IStoreTransaction {
/// Default implementation of the currency property for backward compatibility.
extension IStoreTransaction {
var currency: String? {
if #available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *) {
return Locale.current.currency?.identifier
} else {
return Locale.current.currencyCode
}
Locale.current.currencyCodeID
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension SK1StoreProduct: ISKProduct {
var currencySymbol: String? {
numberFormatter.currencySymbol
}

var locale: Locale {
product.priceLocale
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ extension SK1StoreTransaction: IStoreTransaction {
var environment: StoreEnvironment? {
nil
}

var price: Decimal? {
nil
}

var currency: String? {
nil
}
Expand Down
12 changes: 12 additions & 0 deletions Sources/Flare/Classes/Models/Internal/SK2RenewalInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@ extension SK2RenewalInfo: IRenewalInfo {
var priceIncreaseStatus: PriceIncreaseStatus {
PriceIncreaseStatus(underlyingRenewalInfo.priceIncreaseStatus)
}

var renewalPrice: Decimal? {
underlyingRenewalInfo.renewalPrice
}

var currency: String? {
if #available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *) {
underlyingRenewalInfo.currency?.identifier
} else {
underlyingRenewalInfo.currencyCode
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension SK2StoreProduct: ISKProduct {
var currencySymbol: String? {
numberFormatter.currencySymbol
}

var locale: Locale {
currencyFormat.locale
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ extension SK2StoreTransaction: IStoreTransaction {
var environment: StoreEnvironment? {
StoreEnvironment(transaction: transaction)
}

var price: Decimal? {
transaction.price
}

var currency: String? {
if #available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *) {
transaction.currency?.identifier
Expand Down
2 changes: 1 addition & 1 deletion Sources/Flare/Classes/Models/RefundError.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
2 changes: 1 addition & 1 deletion Sources/Flare/Classes/Models/RefundRequestStatus.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
8 changes: 8 additions & 0 deletions Sources/Flare/Classes/Models/RenewalInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ extension RenewalInfo: IRenewalInfo {
public var priceIncreaseStatus: PriceIncreaseStatus {
underlyingRenewalInfo.priceIncreaseStatus
}

public var renewalPrice: Decimal? {
underlyingRenewalInfo.renewalPrice
}

public var currency: String? {
underlyingRenewalInfo.currency
}
}
2 changes: 1 addition & 1 deletion Sources/Flare/Classes/Models/StoreProduct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extension StoreProduct: ISKProduct {
public var currencySymbol: String? {
product.currencySymbol
}

public var locale: Locale {
product.locale
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/Flare/Classes/Models/StoreTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ extension StoreTransaction: IStoreTransaction {
var environment: StoreEnvironment? {
storeTransaction.environment
}

var price: Decimal? {
storeTransaction.price
}

var currency: String? {
storeTransaction.currency
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Concurrency
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import StoreKit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Atomic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// Flare
// Copyright © 2023 Space Code. All rights reserved.
// Copyright © 2024 Space Code. All rights reserved.
//

import Foundation
Expand Down
Loading

0 comments on commit af8d8ac

Please sign in to comment.