-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Korney
committed
Jun 28, 2024
1 parent
641006d
commit 07b2f47
Showing
39 changed files
with
707 additions
and
174 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import Foundation | ||
|
||
|
||
@objc | ||
public class DeeplinkValue: NSObject { | ||
|
||
public let deeplink: String | ||
public let scheme: String? | ||
public let host: String? | ||
public let path: String? | ||
public let parameters: [String:[String]] | ||
|
||
init( | ||
deeplink: String, | ||
scheme: String?, | ||
host: String?, | ||
path: String?, | ||
parameters: [String:[String]] | ||
) { | ||
self.deeplink = deeplink | ||
self.scheme = scheme | ||
self.host = host | ||
self.path = path | ||
self.parameters = parameters | ||
} | ||
} | ||
|
||
extension DeeplinkValue { | ||
public override var description: String { "DeeplinkValue(scheme=\"\(self.scheme ?? "")\", host=\"\(self.host ?? "")\", path=\"\(self.path ?? "")\", parameters=\(self.parameters))" } | ||
} | ||
|
||
|
||
extension Optional where Wrapped == URL { | ||
|
||
func toDeeplinkValue() -> DeeplinkValue { | ||
guard let self = self else { | ||
return DeeplinkValue( | ||
deeplink: "", | ||
scheme: nil, | ||
host: nil, | ||
path: nil, | ||
parameters: [:] | ||
) | ||
} | ||
|
||
var host: String? | ||
var path: String? | ||
var parameters: [String:[String]] = [:] | ||
|
||
if #available(iOS 16.0, *) { | ||
#if swift(>=5.7.1) | ||
host = self.host(percentEncoded: false) | ||
path = self.path(percentEncoded: false) | ||
#else | ||
host = self.host | ||
path = self.path | ||
#endif | ||
} else { | ||
host = self.host | ||
path = self.path | ||
} | ||
|
||
let component = URLComponents(string: self.absoluteString) | ||
for item in component?.queryItems ?? [] { | ||
let value = item.value?.removingPercentEncoding | ||
if parameters[item.name] != nil { | ||
parameters[item.name]?.append(value ?? "") | ||
} else { | ||
parameters[item.name] = [value ?? ""] | ||
} | ||
} | ||
|
||
return DeeplinkValue( | ||
deeplink: self.absoluteString, | ||
scheme: self.scheme, | ||
host: host, | ||
path: path, | ||
parameters: parameters | ||
) | ||
} | ||
} |
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,3 @@ | ||
public protocol AffiseModuleApi { | ||
|
||
} |
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
33 changes: 33 additions & 0 deletions
33
AffiseAttributionLib/Classes/modules/link/AffiseLink.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,33 @@ | ||
import Foundation | ||
|
||
class AffiseLink { | ||
private static var api: AffiseLinkApi? { | ||
get { | ||
if module != nil { | ||
return module | ||
} else { | ||
module = Affise.Module.getApi(.Link) as? AffiseLinkApi | ||
} | ||
return module | ||
} | ||
} | ||
|
||
private static var module: AffiseLinkApi? = nil | ||
|
||
/** | ||
* Module Link url Resolve | ||
*/ | ||
public static func linkResolve(_ url: String, _ callback: @escaping AffiseLinkCallback) { | ||
api?.linkResolve(url, callback) ?? callback("") | ||
} | ||
} | ||
|
||
extension Affise.Module { | ||
|
||
/** | ||
* Module Link url Resolve | ||
*/ | ||
public static func linkResolve(_ url: String, _ callback: @escaping AffiseLinkCallback) { | ||
AffiseLink.linkResolve(url, callback) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
AffiseAttributionLib/Classes/modules/link/AffiseLinkApi.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,5 @@ | ||
import Foundation | ||
|
||
public protocol AffiseLinkApi: AffiseModuleApi { | ||
func linkResolve(_ url: String, _ callback: @escaping AffiseLinkCallback) | ||
} |
3 changes: 3 additions & 0 deletions
3
AffiseAttributionLib/Classes/modules/link/AffiseLinkCallback.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,3 @@ | ||
import Foundation | ||
|
||
public typealias AffiseLinkCallback = (_ result: String) -> Void |
41 changes: 41 additions & 0 deletions
41
AffiseAttributionLib/Classes/modules/subscription/AffiseSubscription.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,41 @@ | ||
class AffiseSubscription { | ||
private static var api: AffiseSubscriptionApi? { | ||
get { | ||
if module != nil { | ||
return module | ||
} else { | ||
module = Affise.Module.getApi(.Subscription) as? AffiseSubscriptionApi | ||
} | ||
return module | ||
} | ||
} | ||
|
||
private static var module: AffiseSubscriptionApi? = nil | ||
|
||
public static func hasSubscriptionModule() -> Bool { | ||
return api != nil | ||
} | ||
|
||
public static func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>) { | ||
api?.fetchProducts(productsIds, callback) | ||
} | ||
|
||
public static func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>) { | ||
api?.purchase(product, type, callback) | ||
} | ||
} | ||
|
||
|
||
extension Affise.Module { | ||
public static func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>) { | ||
AffiseSubscription.fetchProducts(productsIds, callback) | ||
} | ||
|
||
public static func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>) { | ||
AffiseSubscription.purchase(product, type, callback) | ||
} | ||
|
||
public static func hasSubscriptionModule() -> Bool { | ||
return AffiseSubscription.hasSubscriptionModule() | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
AffiseAttributionLib/Classes/modules/subscription/AffiseSubscriptionApi.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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import Foundation | ||
|
||
|
||
public protocol AffiseSubscriptionApi { | ||
static func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>) | ||
public protocol AffiseSubscriptionApi : AffiseModuleApi { | ||
func fetchProducts(_ productsIds: [String], _ callback: @escaping AffiseResultCallback<AffiseProductsResult>) | ||
|
||
static func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>) | ||
func purchase(_ product: AffiseProduct, _ type: AffiseProductType?, _ callback: @escaping AffiseResultCallback<AffisePurchasedInfo>) | ||
} |
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
Oops, something went wrong.