-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '14-purchase' into develop
- Loading branch information
Showing
12 changed files
with
337 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ityCoreiOS/SOLARdVPNCommunityCoreiOS/Root/RouteCollections/Purchase/Models/Offering.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Offering.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 11.10.2022. | ||
// | ||
|
||
import Foundation | ||
import RevenueCat | ||
|
||
struct Offering { | ||
let identifier: String | ||
let serverDescription: String | ||
let availablePackages: [Package] | ||
let lifetime: Package? | ||
let annual: Package? | ||
let sixMonth: Package? | ||
let threeMonth: Package? | ||
let twoMonth: Package? | ||
let monthly: Package? | ||
let weekly: Package? | ||
} | ||
|
||
extension Offering { | ||
init(from model: RevenueCat.Offering) { | ||
self.identifier = model.identifier | ||
self.serverDescription = model.serverDescription | ||
self.availablePackages = model.availablePackages.map { Package(from: $0) } | ||
self.lifetime = Package(from: model.lifetime) | ||
self.annual = Package(from: model.annual) | ||
self.sixMonth = Package(from: model.sixMonth) | ||
self.threeMonth = Package(from: model.threeMonth) | ||
self.twoMonth = Package(from: model.twoMonth) | ||
self.monthly = Package(from: model.monthly) | ||
self.weekly = Package(from: model.weekly) | ||
} | ||
} | ||
|
||
extension Offering: Codable {} |
39 changes: 39 additions & 0 deletions
39
...nityCoreiOS/SOLARdVPNCommunityCoreiOS/Root/RouteCollections/Purchase/Models/Package.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Package.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 11.10.2022. | ||
// | ||
|
||
import Foundation | ||
import RevenueCat | ||
|
||
struct Package { | ||
let identifier: String | ||
let packageType: PackageType | ||
let storeProduct: StoreProduct | ||
let offeringIdentifier: String | ||
let localizedPriceString: String | ||
let localizedIntroductoryPriceString: String? | ||
} | ||
|
||
extension Package { | ||
init?(from optionalModel: RevenueCat.Package?) { | ||
guard let model = optionalModel else { | ||
return nil | ||
} | ||
|
||
self.init(from: model) | ||
} | ||
|
||
init(from model: RevenueCat.Package) { | ||
self.identifier = model.identifier | ||
self.packageType = PackageType.init(rawValue: model.packageType.rawValue) ?? .unknown | ||
self.storeProduct = StoreProduct.init(from: model.storeProduct) | ||
self.offeringIdentifier = model.offeringIdentifier | ||
self.localizedPriceString = model.localizedPriceString | ||
self.localizedIntroductoryPriceString = model.localizedIntroductoryPriceString | ||
} | ||
} | ||
|
||
extension Package: Codable {} |
22 changes: 22 additions & 0 deletions
22
...CoreiOS/SOLARdVPNCommunityCoreiOS/Root/RouteCollections/Purchase/Models/PackageType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// PackageType.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 11.10.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
enum PackageType: Int { | ||
case unknown = -2 | ||
case custom | ||
case lifetime | ||
case annual | ||
case sixMonth | ||
case threeMonth | ||
case twoMonth | ||
case monthly | ||
case weekly | ||
} | ||
|
||
extension PackageType: Codable {} |
12 changes: 12 additions & 0 deletions
12
...OS/SOLARdVPNCommunityCoreiOS/Root/RouteCollections/Purchase/Models/PurchasePostBody.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// PurchasePostBody.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 12.10.2022. | ||
// | ||
|
||
import Vapor | ||
|
||
struct PurchasePostBody: Content { | ||
let package_identifier: String | ||
} |
19 changes: 19 additions & 0 deletions
19
...SOLARdVPNCommunityCoreiOS/Root/RouteCollections/Purchase/Models/PurchasesModelError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// PurchasesModelError.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 12.10.2022. | ||
// | ||
|
||
import Foundation | ||
|
||
enum PurchasesModelError: LocalizedError { | ||
case purchaseCancelled | ||
|
||
var errorDescription: String? { | ||
switch self { | ||
case .purchaseCancelled: | ||
return "Purchase was canceled." | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...oreiOS/SOLARdVPNCommunityCoreiOS/Root/RouteCollections/Purchase/Models/StoreProduct.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// StoreProduct.swift | ||
// SOLARdVPNCommunityCoreiOS | ||
// | ||
// Created by Viktoriia Kostyleva on 11.10.2022. | ||
// | ||
|
||
import Foundation | ||
import RevenueCat | ||
|
||
struct StoreProduct { | ||
let price: Decimal | ||
let currency: String | ||
} | ||
|
||
extension StoreProduct { | ||
init(from model: RevenueCat.StoreProduct) { | ||
self.price = model.price | ||
self.currency = model.priceFormatter?.currencySymbol ?? "$" | ||
} | ||
} | ||
|
||
extension StoreProduct: Codable {} |
Oops, something went wrong.