-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from superwall-me/develop
v3.1.0
- Loading branch information
Showing
44 changed files
with
931 additions
and
279 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ddata/xcbaselines/SuperwallKitTests.xcbaseline/A601F2E3-F1FD-45AD-AB16-B47C8B7F81DD.plist
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>classNames</key> | ||
<dict> | ||
<key>CoreDataManagerTests</key> | ||
<dict> | ||
<key>test_countTriggerRuleOccurrences_minutes()</key> | ||
<dict> | ||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key> | ||
<dict> | ||
<key>baselineAverage</key> | ||
<real>0.000849</real> | ||
<key>baselineIntegrationDisplayName</key> | ||
<string>Local Baseline</string> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
40 changes: 40 additions & 0 deletions
40
.swiftpm/xcode/xcshareddata/xcbaselines/SuperwallKitTests.xcbaseline/Info.plist
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,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>runDestinationsByUUID</key> | ||
<dict> | ||
<key>A601F2E3-F1FD-45AD-AB16-B47C8B7F81DD</key> | ||
<dict> | ||
<key>localComputer</key> | ||
<dict> | ||
<key>busSpeedInMHz</key> | ||
<integer>0</integer> | ||
<key>cpuCount</key> | ||
<integer>1</integer> | ||
<key>cpuKind</key> | ||
<string>Apple M1 Max</string> | ||
<key>cpuSpeedInMHz</key> | ||
<integer>0</integer> | ||
<key>logicalCPUCoresPerPackage</key> | ||
<integer>10</integer> | ||
<key>modelCode</key> | ||
<string>MacBookPro18,2</string> | ||
<key>physicalCPUCoresPerPackage</key> | ||
<integer>10</integer> | ||
<key>platformIdentifier</key> | ||
<string>com.apple.platform.macosx</string> | ||
</dict> | ||
<key>targetArchitecture</key> | ||
<string>arm64</string> | ||
<key>targetDevice</key> | ||
<dict> | ||
<key>modelCode</key> | ||
<string>iPhone15,2</string> | ||
<key>platformIdentifier</key> | ||
<string>com.apple.platform.iphonesimulator</string> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
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
117 changes: 117 additions & 0 deletions
117
Sources/SuperwallKit/Config/Models/ComputedPropertyRequest.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,117 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Yusuf Tör on 03/07/2023. | ||
// | ||
|
||
import Foundation | ||
|
||
/// A request to compute a device property associated with an event at runtime. | ||
@objc(SWKComputedPropertyRequest) | ||
@objcMembers | ||
public final class ComputedPropertyRequest: NSObject, Decodable { | ||
/// The type of device property to compute. | ||
@objc(SWKComputedPropertyRequestType) | ||
public enum ComputedPropertyRequestType: Int, Decodable { | ||
/// The number of minutes since the event occurred. | ||
case minutesSince | ||
|
||
/// The number of hours since the event occurred. | ||
case hoursSince | ||
|
||
/// The number of days since the event occurred. | ||
case daysSince | ||
|
||
/// The number of months since the event occurred. | ||
case monthsSince | ||
|
||
/// The number of years since the event occurred. | ||
case yearsSince | ||
|
||
var prefix: String { | ||
switch self { | ||
case .minutesSince: | ||
return "minutesSince_" | ||
case .hoursSince: | ||
return "hoursSince_" | ||
case .daysSince: | ||
return "daysSince_" | ||
case .monthsSince: | ||
return "monthsSince_" | ||
case .yearsSince: | ||
return "yearsSince_" | ||
} | ||
} | ||
|
||
var calendarComponent: Calendar.Component { | ||
switch self { | ||
case .minutesSince: | ||
return .minute | ||
case .hoursSince: | ||
return .hour | ||
case .daysSince: | ||
return .day | ||
case .monthsSince: | ||
return .month | ||
case .yearsSince: | ||
return .year | ||
} | ||
} | ||
|
||
func dateComponent(from components: DateComponents) -> Int? { | ||
switch self { | ||
case .minutesSince: | ||
return components.minute | ||
case .hoursSince: | ||
return components.hour | ||
case .daysSince: | ||
return components.day | ||
case .monthsSince: | ||
return components.month | ||
case .yearsSince: | ||
return components.year | ||
} | ||
} | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case minutesSince = "MINUTES_SINCE" | ||
case hoursSince = "HOURS_SINCE" | ||
case daysSince = "DAYS_SINCE" | ||
case monthsSince = "MONTHS_SINCE" | ||
case yearsSince = "YEARS_SINCE" | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.singleValueContainer() | ||
let rawValue = try container.decode(String.self) | ||
let gatingType = CodingKeys(rawValue: rawValue) | ||
switch gatingType { | ||
case .minutesSince: | ||
self = .minutesSince | ||
case .hoursSince: | ||
self = .hoursSince | ||
case .daysSince: | ||
self = .daysSince | ||
case .monthsSince: | ||
self = .monthsSince | ||
case .yearsSince: | ||
self = .yearsSince | ||
case .none: | ||
throw DecodingError.valueNotFound( | ||
String.self, | ||
.init( | ||
codingPath: [], | ||
debugDescription: "Unsupported computed property type." | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
||
/// The type of device property to compute. | ||
public let type: ComputedPropertyRequestType | ||
|
||
/// The name of the event used to compute the device property. | ||
public let eventName: String | ||
} |
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.