Skip to content

Commit a67cced

Browse files
committed
chore: update example code
1 parent 9fd3321 commit a67cced

1 file changed

Lines changed: 24 additions & 12 deletions

File tree

README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,32 @@ public struct Decryption {
2323
```swift
2424
import ABCSecureChannel
2525

26-
let url = URL(string: "https://dev-api.id.myabcwallet.com")!
27-
let channelManager = SecureChannelManager(host: url)
28-
channelManager.encrypt(plain: password) { encryption in
29-
// TODO: use callback Encrypted Model
26+
let channelManager = SecureChannelManager(host: "https://dev-api.id.myabcwallet.com")
27+
channelManager.encrypt(plain: password) { result in
28+
switch result {
29+
case .success(let encryption):
30+
// TODO: use callback Encrypted Model
31+
case .failure(let error):
32+
// TODO: handle Error
33+
}
3034
}
3135

32-
channelManager.decrypt(encrypted: message) { decryption in
33-
// TODO: use callback Decrypted Model
36+
channelManager.decrypt(encrypted: message) { result in
37+
switch result {
38+
case .success(let encryption):
39+
// TODO: use callback Decrypted Model
40+
case .failure(let error):
41+
// TODO: handle Error
42+
}
3443
}
3544

36-
channelManager.channelId() { channelId in
37-
// ...
45+
channelManager.channelId() { result in
46+
switch result {
47+
case .success(let channelId):
48+
// ...
49+
case .failure(let error):
50+
// TODO: handle Error
51+
}
3852
}
3953
```
4054

@@ -44,8 +58,7 @@ channelManager.channelId() { channelId in
4458
import ABCSecureChannel
4559
import Combine
4660

47-
let url = URL(string: "https://dev-api.id.myabcwallet.com")!
48-
let channelManager = SecureChannelManager(host: url)
61+
let channelManager = SecureChannelManager(host: "https://dev-api.id.myabcwallet.com")
4962

5063
channelManager
5164
.encrypt(plain: password)
@@ -72,8 +85,7 @@ channelManager
7285
```swift
7386
import ABCSecureChannel
7487

75-
let url = URL(string: "https://dev-api.id.myabcwallet.com")!
76-
let channelManager = SecureChannelManager(host: url)
88+
let channelManager = SecureChannelManager(host: "https://dev-api.id.myabcwallet.com")
7789

7890
Task {
7991
let encryption = try await channelManager.encrypt(plain: password)

0 commit comments

Comments
 (0)