Skip to content

Commit 98dc9d7

Browse files
Added endpoint for ringing members (#992)
1 parent 658d38c commit 98dc9d7

File tree

5 files changed

+99
-0
lines changed

5 files changed

+99
-0
lines changed

Sources/StreamVideo/OpenApi/generated/APIs/DefaultAPI.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,26 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {
11701170
try self.jsonDecoder.decode(EmptyResponse.self, from: $0)
11711171
}
11721172
}
1173+
1174+
open func ringCall(type: String, id: String, ringCallRequest: RingCallRequest) async throws -> RingCallResponse {
1175+
var path = "/video/call/{type}/{id}/ring"
1176+
1177+
let typePreEscape = "\(APIHelper.mapValueToPathItem(type))"
1178+
let typePostEscape = typePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
1179+
path = path.replacingOccurrences(of: String(format: "{%@}", "type"), with: typePostEscape, options: .literal, range: nil)
1180+
let idPreEscape = "\(APIHelper.mapValueToPathItem(id))"
1181+
let idPostEscape = idPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
1182+
path = path.replacingOccurrences(of: String(format: "{%@}", "id"), with: idPostEscape, options: .literal, range: nil)
1183+
1184+
let urlRequest = try makeRequest(
1185+
uriPath: path,
1186+
httpMethod: "POST",
1187+
request: ringCallRequest
1188+
)
1189+
return try await send(request: urlRequest) {
1190+
try self.jsonDecoder.decode(RingCallResponse.self, from: $0)
1191+
}
1192+
}
11731193
}
11741194

11751195
protocol DefaultAPIEndpoints {
@@ -1286,4 +1306,6 @@ protocol DefaultAPIEndpoints {
12861306
func createGuest(createGuestRequest: CreateGuestRequest) async throws -> CreateGuestResponse
12871307

12881308
func videoConnect() async throws -> Void
1309+
1310+
func ringCall(type: String, id: String, ringCallRequest: RingCallRequest) async throws -> RingCallResponse
12891311
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Copyright © 2025 Stream.io Inc. All rights reserved.
3+
//
4+
5+
import Foundation
6+
7+
public final class RingCallRequest: @unchecked Sendable, Codable, JSONEncodable, Hashable {
8+
public var membersIds: [String]?
9+
public var video: Bool?
10+
11+
public init(membersIds: [String]? = nil, video: Bool? = nil) {
12+
self.membersIds = membersIds
13+
self.video = video
14+
}
15+
16+
public enum CodingKeys: String, CodingKey, CaseIterable {
17+
case membersIds = "members_ids"
18+
case video
19+
}
20+
21+
public static func == (lhs: RingCallRequest, rhs: RingCallRequest) -> Bool {
22+
lhs.membersIds == rhs.membersIds &&
23+
lhs.video == rhs.video
24+
}
25+
26+
public func hash(into hasher: inout Hasher) {
27+
hasher.combine(membersIds)
28+
hasher.combine(video)
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Copyright © 2025 Stream.io Inc. All rights reserved.
3+
//
4+
5+
import Foundation
6+
7+
public final class RingCallResponse: @unchecked Sendable, Codable, JSONEncodable, Hashable {
8+
public var duration: String
9+
public var membersIds: [String]
10+
11+
public init(duration: String, membersIds: [String]) {
12+
self.duration = duration
13+
self.membersIds = membersIds
14+
}
15+
16+
public enum CodingKeys: String, CodingKey, CaseIterable {
17+
case duration
18+
case membersIds = "members_ids"
19+
}
20+
21+
public static func == (lhs: RingCallResponse, rhs: RingCallResponse) -> Bool {
22+
lhs.duration == rhs.duration &&
23+
lhs.membersIds == rhs.membersIds
24+
}
25+
26+
public func hash(into hasher: inout Hasher) {
27+
hasher.combine(duration)
28+
hasher.combine(membersIds)
29+
}
30+
}

StreamVideo.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,8 @@
11381138
8414081129F284A800FF2D7C /* AssertJSONEqual.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8414081029F284A800FF2D7C /* AssertJSONEqual.swift */; };
11391139
8414081329F28B5700FF2D7C /* RTCConfiguration_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8414081229F28B5600FF2D7C /* RTCConfiguration_Tests.swift */; };
11401140
8414081529F28FFC00FF2D7C /* CallSettings_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8414081429F28FFC00FF2D7C /* CallSettings_Tests.swift */; };
1141+
841457372EBE5BF100D0D034 /* RingCallResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841457362EBE5BF100D0D034 /* RingCallResponse.swift */; };
1142+
841457382EBE5BF100D0D034 /* RingCallRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841457352EBE5BF100D0D034 /* RingCallRequest.swift */; };
11411143
8415D3E1290B2AF2006E53CB /* outgoing.m4a in Resources */ = {isa = PBXBuildFile; fileRef = 8415D3E0290B2AF2006E53CB /* outgoing.m4a */; };
11421144
8415D3E3290BC882006E53CB /* Sounds.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8415D3E2290BC882006E53CB /* Sounds.swift */; };
11431145
841947982886D9CD0007B36E /* BundleExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841947972886D9CD0007B36E /* BundleExtensions.swift */; };
@@ -2720,6 +2722,8 @@
27202722
8414081029F284A800FF2D7C /* AssertJSONEqual.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssertJSONEqual.swift; sourceTree = "<group>"; };
27212723
8414081229F28B5600FF2D7C /* RTCConfiguration_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RTCConfiguration_Tests.swift; sourceTree = "<group>"; };
27222724
8414081429F28FFC00FF2D7C /* CallSettings_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallSettings_Tests.swift; sourceTree = "<group>"; };
2725+
841457352EBE5BF100D0D034 /* RingCallRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RingCallRequest.swift; sourceTree = "<group>"; };
2726+
841457362EBE5BF100D0D034 /* RingCallResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RingCallResponse.swift; sourceTree = "<group>"; };
27232727
8415D3E0290B2AF2006E53CB /* outgoing.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = outgoing.m4a; sourceTree = "<group>"; };
27242728
8415D3E2290BC882006E53CB /* Sounds.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sounds.swift; sourceTree = "<group>"; };
27252729
841947972886D9CD0007B36E /* BundleExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleExtensions.swift; sourceTree = "<group>"; };
@@ -7182,6 +7186,8 @@
71827186
84DC383E29ADFCFC00946713 /* Models */ = {
71837187
isa = PBXGroup;
71847188
children = (
7189+
841457352EBE5BF100D0D034 /* RingCallRequest.swift */,
7190+
841457362EBE5BF100D0D034 /* RingCallResponse.swift */,
71857191
8464FBA72EB3832000933768 /* CallModerationBlurEvent.swift */,
71867192
8464FBA82EB3832000933768 /* CallModerationWarningEvent.swift */,
71877193
8438AB042E5F3A2900BA834F /* AppEventResponse.swift */,
@@ -8628,6 +8634,8 @@
86288634
84DC38DB29ADFCFD00946713 /* JSONDataEncoding.swift in Sources */,
86298635
40FB15112BF77D5800D5E580 /* StreamStateMachineStage.swift in Sources */,
86308636
8496A9A629CC500F00F15FF1 /* StreamVideoCaptureHandler.swift in Sources */,
8637+
841457372EBE5BF100D0D034 /* RingCallResponse.swift in Sources */,
8638+
841457382EBE5BF100D0D034 /* RingCallRequest.swift in Sources */,
86318639
406568872E0426FD00A67EAC /* IdleTimerAdapter.swift in Sources */,
86328640
84CD12162C73831000056640 /* CallRtmpBroadcastStartedEvent.swift in Sources */,
86338641
40944D232E4E3D7D00088AF0 /* StreamCallAudioRecorder+State.swift in Sources */,

StreamVideoTests/Mock/MockDefaultAPIEndpoints.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ final class MockDefaultAPIEndpoints: DefaultAPIEndpoints, Mockable, @unchecked S
7474
case getEdges
7575
case createGuest
7676
case videoConnect
77+
case ringCall
7778
}
7879

7980
enum MockFunctionInputKey: Payloadable {
@@ -124,6 +125,7 @@ final class MockDefaultAPIEndpoints: DefaultAPIEndpoints, Mockable, @unchecked S
124125
case getEdges
125126
case createGuest(request: CreateGuestRequest)
126127
case videoConnect
128+
case ringCall(request: RingCallRequest)
127129

128130
var payload: Any {
129131
switch self {
@@ -221,6 +223,8 @@ final class MockDefaultAPIEndpoints: DefaultAPIEndpoints, Mockable, @unchecked S
221223
return request
222224
case .videoConnect:
223225
return ()
226+
case let .ringCall(request: request):
227+
return request
224228
}
225229
}
226230
}
@@ -577,4 +581,9 @@ final class MockDefaultAPIEndpoints: DefaultAPIEndpoints, Mockable, @unchecked S
577581
guard stubbedFunction[.videoConnect] != nil else { throw ClientError("Not stubbed function.") }
578582
return ()
579583
}
584+
585+
func ringCall(type: String, id: String, ringCallRequest: RingCallRequest) async throws -> RingCallResponse {
586+
stubbedFunctionInput[.ringCall]?.append(.ringCall(request: ringCallRequest))
587+
return try stubbedResult(for: .ringCall)
588+
}
580589
}

0 commit comments

Comments
 (0)