Skip to content

Commit f89ee55

Browse files
authored
Merge pull request #238 from mcprostar205/main
Lexicon public initializers, decode, encode added that were missing
2 parents 618aa33 + 99c8fb8 commit f89ee55

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityRefreshIdentity.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,18 @@ extension ComAtprotoLexicon.Identity {
2626

2727
/// The AT-identifier of the user account.
2828
public let identifier: String
29+
30+
public init(identifier: String) {
31+
self.identifier = identifier
32+
}
33+
34+
public func encode(to encoder: any Encoder) throws {
35+
var container = encoder.container(keyedBy: CodingKeys.self)
36+
try container.encode(self.identifier, forKey: .identifier)
37+
}
38+
39+
public enum CodingKeys: CodingKey {
40+
case identifier
41+
}
2942
}
3043
}

Sources/ATProtoKit/Models/Lexicons/com.atproto/Identity/ComAtprotoIdentityUpdateHandle.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,18 @@ extension ComAtprotoLexicon.Identity {
2727
///
2828
/// - Note: According to the AT Protocol specifications: "The new handle."
2929
public let handle: String
30+
31+
public init(handle: String) {
32+
self.handle = handle
33+
}
34+
35+
public func encode(to encoder: any Encoder) throws {
36+
var container = encoder.container(keyedBy: CodingKeys.self)
37+
try container.encode(self.handle, forKey: .handle)
38+
}
39+
40+
public enum CodingKeys: CodingKey {
41+
case handle
42+
}
3043
}
3144
}

Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerConfirmEmail.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,27 @@ extension ComAtprotoLexicon.Server {
2727

2828
/// The token given to the user via email.
2929
public let token: String
30+
31+
public init(email: String, token: String) {
32+
self.email = email
33+
self.token = token
34+
}
35+
36+
public init(from decoder: any Decoder) throws {
37+
let container = try decoder.container(keyedBy: CodingKeys.self)
38+
self.email = try container.decode(String.self, forKey: .email)
39+
self.token = try container.decode(String.self, forKey: .token)
40+
}
41+
42+
public func encode(to encoder: any Encoder) throws {
43+
var container = encoder.container(keyedBy: CodingKeys.self)
44+
try container.encode(self.email, forKey: .email)
45+
try container.encode(self.token, forKey: .token)
46+
}
47+
48+
enum CodingKeys: CodingKey {
49+
case email
50+
case token
51+
}
3052
}
3153
}

Sources/ATProtoKit/Models/Lexicons/com.atproto/Server/ComAtprotoServerDescribeServer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ extension ComAtprotoLexicon.Server {
8585
///
8686
/// - Note: According to the AT Protocol specifications: "URLs of service
8787
/// policy documents."
88-
public let servicePolicyURLs: DescribeServer.ServicePolicyURLs
88+
public let servicePolicyURLs: DescribeServer.ServicePolicyURLs?
8989

9090
/// The contact information for the server.
9191
///
9292
/// - Note: According to the AT Protocol specifications: "Contact information."
93-
public let contactInformation: DescribeServer.ContactInformation
93+
public let contactInformation: DescribeServer.ContactInformation?
9494

9595
/// The decentralized identifier (DID) of the server.
9696
public let serverDID: String

0 commit comments

Comments
 (0)