-
Notifications
You must be signed in to change notification settings - Fork 192
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
Showing
3 changed files
with
29 additions
and
7 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
22 changes: 21 additions & 1 deletion
22
Sources/WalletConnectHistory/Types/GetMessagesResponse.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,28 @@ | ||
import Foundation | ||
|
||
public struct GetMessagesResponse: Codable { | ||
public struct GetMessagesResponse: Decodable { | ||
public struct Message: Codable { | ||
public let message: String | ||
} | ||
public let topic: String | ||
public let direction: GetMessagesPayload.Direction | ||
public let nextId: Int64? | ||
public let messages: [String] | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case topic | ||
case direction | ||
case nextId | ||
case messages | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
self.topic = try container.decode(String.self, forKey: .topic) | ||
self.direction = try container.decode(GetMessagesPayload.Direction.self, forKey: .direction) | ||
self.nextId = try container.decodeIfPresent(Int64.self, forKey: .nextId) | ||
|
||
let messages = try container.decode([Message].self, forKey: .messages) | ||
self.messages = messages.map { $0.message } | ||
} | ||
} |