@@ -25,7 +25,7 @@ extension AppBskyLexicon.Actor {
2525 ///
2626 /// - Note: According to the AT Protocol specifications: "An optional embed associated with
2727 /// the status."
28- public let embed : String ?
28+ public let embed : EmbedUnion ?
2929
3030 /// The amount of time the status has lasted in minutes.
3131 ///
@@ -36,7 +36,7 @@ extension AppBskyLexicon.Actor {
3636 /// The date and time the record was created.
3737 public let createdAt : Date
3838
39- public init ( status: Status , embed: String ? , durationMinutes: Int ? , createdAt: Date ) {
39+ public init ( status: Status , embed: EmbedUnion ? , durationMinutes: Int ? , createdAt: Date ) {
4040 self . status = status
4141 self . embed = embed
4242 self . durationMinutes = durationMinutes
@@ -47,7 +47,7 @@ extension AppBskyLexicon.Actor {
4747 let container = try decoder. container ( keyedBy: CodingKeys . self)
4848
4949 self . status = try container. decode ( AppBskyLexicon . Actor. StatusRecord. Status. self, forKey: . status)
50- self . embed = try container. decodeIfPresent ( String . self, forKey: . embed)
50+ self . embed = try container. decodeIfPresent ( EmbedUnion . self, forKey: . embed)
5151 self . durationMinutes = try container. decodeIfPresent ( Int . self, forKey: . durationMinutes)
5252 self . createdAt = try container. decodeDate ( forKey: . createdAt)
5353 }
@@ -85,6 +85,27 @@ extension AppBskyLexicon.Actor {
8585
8686 /// An external embed view.
8787 case externalView( AppBskyLexicon . Embed . ExternalDefinition . View )
88+
89+ public init ( from decoder: any Decoder ) throws {
90+ let container = try decoder. singleValueContainer ( )
91+
92+ if let value = try ? container. decode ( AppBskyLexicon . Embed. ExternalDefinition. View. self) {
93+ self = . externalView( value)
94+ } else {
95+ throw DecodingError . typeMismatch (
96+ EmbedUnion . self, DecodingError . Context (
97+ codingPath: decoder. codingPath, debugDescription: " Unknown EmbedUnion type " ) )
98+ }
99+ }
100+
101+ public func encode( to encoder: any Encoder ) throws {
102+ var container = encoder. singleValueContainer ( )
103+
104+ switch self {
105+ case . externalView( let value) :
106+ try container. encode ( value)
107+ }
108+ }
88109 }
89110 }
90111}
0 commit comments