         clientId = try container.decode(String.self, forKey: .client_id)
         connectionId = try container.decode(String.self, forKey: .connection_id)
         sdp = try container.decode(String.self, forKey: .sdp)
-        if container.contains(.config) {
-            configuration = try container.decode(Configuration.self,
-                                                 forKey: .config)
-        } else {
-            configuration = nil
-        }
-        if container.contains(.metadata) {
-            metadata = try container.decode(Metadata.self, forKey: .metadata)
-        } else {
-            metadata = nil
-        }
+        configuration =
+            try container.decodeIfPresent(Configuration.self,
+                                          forKey: .config)
+        metadata =
+            try container.decodeIfPresent(Metadata.self,
+                                          forKey: .metadata)
     }
     
 }

                if videoCodec != .default {
                    try videoContainer.encode(videoCodec, forKey: .codec_type)
                }
                if let bitRate = videoBitRate {
                    try videoContainer.encode(bitRate, forKey: .bit_rate)
                }
            }
        } else {
            try container.encode(false, forKey: .video)

        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(role, forKey: .role)
        try container.encode(channelId, forKey: .channel_id)
        try container.encodeIfPresent(sdp, forKey: .sdp)
        try container.encodeIfPresent(metadata, forKey: .metadata)
        try container.encodeIfPresent(notifyMetadata,
                                      forKey: .signaling_notify_metadata)
        try container.encodeIfPresent(multistreamEnabled,
                                      forKey: .multistream)
        try container.encodeIfPresent(planBEnabled, forKey: .plan_b)
        
        if videoEnabled {
            if videoCodec != .default || videoBitRate != nil {
