-
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
Nov 28, 2023
1 parent
5d78d56
commit e94a87d
Showing
27 changed files
with
185 additions
and
75 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
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
25 changes: 25 additions & 0 deletions
25
AffiseAttributionLib/Classes/parameters/providers/BuildProvider.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,25 @@ | ||
import Foundation | ||
|
||
/** | ||
* Provider for parameter [ProviderType.BUILD] | ||
*/ | ||
class BuildProvider: StringPropertyProvider { | ||
|
||
private let useCase: RemarketingUseCase | ||
|
||
init(_ useCase: RemarketingUseCase) { | ||
self.useCase = useCase | ||
} | ||
|
||
override func provide() -> String? { | ||
useCase.build | ||
} | ||
|
||
public override func getOrder() -> Float { | ||
70.0 | ||
} | ||
|
||
public override func getKey() -> ProviderType? { | ||
ProviderType.BUILD | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
AffiseAttributionLib/Classes/parameters/providers/DeviceProvider.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,25 @@ | ||
import Foundation | ||
|
||
/** | ||
* Provider for parameter [ProviderType.DEVICE] | ||
*/ | ||
class DeviceProvider: StringPropertyProvider { | ||
|
||
private let useCase: RemarketingUseCase | ||
|
||
init(_ useCase: RemarketingUseCase) { | ||
self.useCase = useCase | ||
} | ||
|
||
override func provide() -> String? { | ||
useCase.device | ||
} | ||
|
||
public override func getOrder() -> Float { | ||
69.0 | ||
} | ||
|
||
public override func getKey() -> ProviderType? { | ||
ProviderType.DEVICE | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
AffiseAttributionLib/Classes/parameters/providers/OsAndVersionProvider.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,25 @@ | ||
import Foundation | ||
|
||
/** | ||
* Provider for parameter [ProviderType.OS_AND_VERSION] | ||
*/ | ||
class OsAndVersionProvider: StringPropertyProvider { | ||
|
||
private let useCase: RemarketingUseCase | ||
|
||
init(_ useCase: RemarketingUseCase) { | ||
self.useCase = useCase | ||
} | ||
|
||
override func provide() -> String? { | ||
useCase.osAndVersion | ||
} | ||
|
||
public override func getOrder() -> Float { | ||
68.0 | ||
} | ||
|
||
public override func getKey() -> ProviderType? { | ||
ProviderType.OS_AND_VERSION | ||
} | ||
} |
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
8 changes: 0 additions & 8 deletions
8
AffiseAttributionLib/Classes/usecase/PreferencesUseCase.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
8 changes: 0 additions & 8 deletions
8
AffiseAttributionLib/Classes/usecase/PreferencesUseCaseImpl.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
8 changes: 8 additions & 0 deletions
8
AffiseAttributionLib/Classes/usecase/RemarketingUseCase.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,8 @@ | ||
protocol RemarketingUseCase { | ||
|
||
var osAndVersion: String { get } | ||
var device: String? { get } | ||
var build: String? { get } | ||
|
||
func local() -> String | ||
} |
45 changes: 45 additions & 0 deletions
45
AffiseAttributionLib/Classes/usecase/RemarketingUseCaseImpl.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,45 @@ | ||
import Foundation | ||
import UIKit | ||
|
||
internal class RemarketingUseCaseImpl: RemarketingUseCase { | ||
|
||
lazy var osAndVersion: String = getOsAndVersion() | ||
|
||
lazy var device: String? = getDevice() | ||
|
||
lazy var build: String? = getBuild() | ||
|
||
func local() -> String { | ||
let locale = Locale.current | ||
guard let languageCode = locale.languageCode else { return locale.identifier } | ||
guard let regionCode = locale.regionCode else { return locale.identifier } | ||
return "\(languageCode)_\(regionCode)" | ||
} | ||
|
||
private func getOsAndVersion() -> String { | ||
let uid:UIDevice = UIDevice.current | ||
return "\(uid.systemName) \(uid.systemVersion)" | ||
} | ||
|
||
private func getDevice() -> String? { | ||
return SysctlKey("hw.machine") | ||
} | ||
|
||
private func getBuild() -> String? { | ||
if let build = SysctlKey("kern.osversion") { | ||
return "Build/\(build)" | ||
} | ||
return nil | ||
} | ||
|
||
private func SysctlKey(_ key: String) -> String? { | ||
var bufferSize = 0 | ||
sysctlbyname(key, nil, &bufferSize, nil, 0) | ||
var buffer = [CChar](repeating: 0, count: Int(bufferSize)) | ||
let status = sysctlbyname(key, &buffer, &bufferSize, nil, 0) | ||
if status != 0 { | ||
return nil | ||
} | ||
return String(cString:buffer, encoding: String.Encoding.utf8) | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
AffiseAttributionLib/Classes/usecase/SendDataToServerUseCase.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
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
Oops, something went wrong.