Skip to content

Commit aea25de

Browse files
authored
Merge pull request #224 from mcprostar205/main
Added more missing public initializers
2 parents 3fed5a1 + fda2032 commit aea25de

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

Sources/ATProtoKit/Models/Lexicons/app.bsky/Actor/AppBskyActorPutPreferences.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ extension AppBskyLexicon.Actor {
3030
/// A list of preferences by the user.
3131
public let preferences: [AppBskyLexicon.Actor.PreferenceUnion]
3232

33+
public init(preferences: [AppBskyLexicon.Actor.PreferenceUnion]) {
34+
self.preferences = preferences
35+
}
36+
3337
enum CodingKeys: String, CodingKey {
3438
case type = "$type"
3539
case preferences

Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoCreateRecord.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ extension ComAtprotoLexicon.Repository {
5959
/// commit by CID."
6060
public let swapCommit: String?
6161

62+
public init(repositoryDID: String, collection: String, recordKey: String? = nil, shouldValidate: Bool? = nil, record: UnknownType, swapCommit: String? = nil) {
63+
self.repositoryDID = repositoryDID
64+
self.collection = collection
65+
self.recordKey = recordKey
66+
self.shouldValidate = shouldValidate
67+
self.record = record
68+
self.swapCommit = swapCommit
69+
}
70+
6271
public func encode(to encoder: any Encoder) throws {
6372
var container = encoder.container(keyedBy: CodingKeys.self)
6473

Sources/ATProtoKit/Models/Lexicons/com.atproto/Repo/ComAtprotoRepoDeleteRecord.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ extension ComAtprotoLexicon.Repository {
5353
/// previous commit by CID."
5454
public let swapCommit: String?
5555

56+
public init(repositoryDID: String, collection: String, recordKey: String, swapRecord: String?, swapCommit: String?) {
57+
self.repositoryDID = repositoryDID
58+
self.collection = collection
59+
self.recordKey = recordKey
60+
self.swapRecord = swapRecord
61+
self.swapCommit = swapCommit
62+
}
63+
64+
public func encode(to encoder: any Encoder) throws {
65+
var container = encoder.container(keyedBy: CodingKeys.self)
66+
try container.encode(self.repositoryDID, forKey: .repositoryDID)
67+
try container.encode(self.collection, forKey: .collection)
68+
try container.encode(self.recordKey, forKey: .recordKey)
69+
try container.encodeIfPresent(self.swapRecord, forKey: .swapRecord)
70+
try container.encodeIfPresent(self.swapCommit, forKey: .swapCommit)
71+
}
72+
5673
enum CodingKeys: String, CodingKey {
5774
case repositoryDID = "repo"
5875
case collection

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ extension ComAtprotoLexicon.Server {
6262
/// A token used for Two-Factor Authentication. Optional.
6363
let authenticationFactorToken: String?
6464

65+
public init(identifier: String, password: String, authenticationFactorToken: String?) {
66+
self.identifier = identifier
67+
self.password = password
68+
self.authenticationFactorToken = authenticationFactorToken
69+
}
70+
71+
public func encode(to encoder: any Encoder) throws {
72+
var container = encoder.container(keyedBy: CodingKeys.self)
73+
try container.encode(self.identifier, forKey: .identifier)
74+
try container.encode(self.password, forKey: .password)
75+
try container.encodeIfPresent(self.authenticationFactorToken, forKey: .authenticationFactorToken)
76+
}
77+
6578
enum CodingKeys: String, CodingKey {
6679
case identifier
6780
case password

0 commit comments

Comments
 (0)