Skip to content

Commit

Permalink
feat: Deprecate and replace clearDeviceData (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
igstewart3 authored Apr 8, 2024
1 parent e16d2f8 commit cbdcffb
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 5 deletions.
7 changes: 4 additions & 3 deletions .swiftpm/xcode/xcshareddata/xcschemes/MarigoldSwift.xcscheme
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
version = "1.3">
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down Expand Up @@ -40,7 +40,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/sailthru/sailthru-mobile-ios-sdk",
"state": {
"branch": null,
"revision": "4d6c5dfaff08220ba544007d34768ed68220ef4c",
"version": "15.0.0"
"revision": "2e71269a5ce5c75009f2002873af5fa31bd10ce4",
"version": "15.1.0"
}
}
]
Expand Down
11 changes: 11 additions & 0 deletions Sources/MarigoldSwift/EngageBySailthru+Concurrency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ extension EngageBySailthru {
})
}

// MARK: Events

/**
* Clear the custom events from the device data.
*/
public func clearEvents() async throws {
try await withCheckedThrowingContinuation({ continuation in
clearEvents(response: ClosureBuilder.voidErrorClosure(continuation))
})
}

/**
* Registers that the given pageview with Sailthru SPM.
*
Expand Down
9 changes: 9 additions & 0 deletions Sources/MarigoldSwift/MARMessageStream+Concurrency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,13 @@ extension MARMessageStream {
remove(message, withResponse: ClosureBuilder.voidErrorClosure(continuation))
})
}

/**
* Clear the Message Stream for the device.
*/
public func clearMessages() async throws {
try await withCheckedThrowingContinuation({ continuation in
clearMessages(response: ClosureBuilder.voidErrorClosure(continuation))
})
}
}
1 change: 1 addition & 0 deletions Sources/MarigoldSwift/Marigold+Concurrency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extension Marigold {
* - Parameter types: A bitwise OR collection of STMDeviceDataType dictating which sets of data to clear.
* - Throws: Error when call fails.
**/
@available(*, deprecated, message: "Use EngageBySailthru.clearEvents or MARMessageStream.clearMessages instead.")
public func clearDeviceData(for types: MARDeviceDataType) async throws {
try await withCheckedThrowingContinuation({ continuation in
clear(types, withResponse: ClosureBuilder.voidErrorClosure(continuation))
Expand Down
4 changes: 4 additions & 0 deletions Tests/MarigoldSwiftTests/DummyMARMessageStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ class DummyMARMessageStream : MARMessageStream {
handler?(responseError)
}

public override func clearMessages(response handler: ((Error?) -> Void)? = nil) {
calledFunctions.append(#function)
handler?(responseError)
}
}
17 changes: 17 additions & 0 deletions Tests/MarigoldSwiftTests/MARMessageStream+ConcurrencySpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,23 @@ final class MARMessageStreamConcurrencySpec: XCTestCase {
}
}

func test_clearMessages_callsCorrectMethod() async throws {
try await subject.clearMessages()

checkMethodCalled(with: "clearMessages")
}

func test_clearMessages_throwsOnError() async throws {
subject.responseError = TestErrors.testError
do {
try await subject.clearMessages()
XCTFail("Should throw provided error")
} catch TestErrors.testError {
} catch {
XCTFail("Incorrect error thrown: \(error)")
}
}


// MARK: Helpers

Expand Down

0 comments on commit cbdcffb

Please sign in to comment.