diff --git a/CHANGELOG.md b/CHANGELOG.md index b7d676482..a50a9f647 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### ✅ Added - Support for session timers. [#425](https://github.com/GetStream/stream-video-swift/pull/425) +- Rejecting call contains a reason parameter. [#428](https://github.com/GetStream/stream-video-swift/issues/428) # [1.0.6](https://github.com/GetStream/stream-video-swift/releases/tag/1.0.6) _May 30, 2024_ diff --git a/Sources/StreamVideo/Call.swift b/Sources/StreamVideo/Call.swift index f14eb5fd8..2e4d242b0 100644 --- a/Sources/StreamVideo/Call.swift +++ b/Sources/StreamVideo/Call.swift @@ -322,9 +322,13 @@ public class Call: @unchecked Sendable, WSEventsSubscriber { .response } - /// Rejects a call. + /// Rejects a call with an optional reason. + /// - Parameters: + /// - reason: An optional `String` providing the reason for the rejection. Default is `nil`. + /// - Returns: A `RejectCallResponse` object indicating the result of the rejection. + /// - Throws: An error if the rejection fails. @discardableResult - public func reject() async throws -> RejectCallResponse { + public func reject(reason: String? = nil) async throws -> RejectCallResponse { let currentStage = stateMachine.currentStage switch currentStage.id { case .rejecting: @@ -334,7 +338,11 @@ public class Call: @unchecked Sendable, WSEventsSubscriber { return stage.response default: try stateMachine.transition(.rejecting(self, actionBlock: { [coordinatorClient, callType, callId, streamVideo, cId] in - let response = try await coordinatorClient.rejectCall(type: callType, id: callId) + let response = try await coordinatorClient.rejectCall( + type: callType, + id: callId, + rejectCallRequest: .init(reason: reason) + ) if streamVideo.state.ringingCall?.cId == cId { Task { @MainActor in streamVideo.state.ringingCall = nil diff --git a/Sources/StreamVideo/OpenApi/generated/APIs/DefaultAPI.swift b/Sources/StreamVideo/OpenApi/generated/APIs/DefaultAPI.swift index 5030a0842..0c2208c27 100644 --- a/Sources/StreamVideo/OpenApi/generated/APIs/DefaultAPI.swift +++ b/Sources/StreamVideo/OpenApi/generated/APIs/DefaultAPI.swift @@ -855,12 +855,13 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable { /** Reject Call - - parameter type: (path) - - parameter id: (path) + - parameter type: (path) + - parameter id: (path) + - parameter rejectCallRequest: (body) - returns: RejectCallResponse */ - open func rejectCall(type: String, id: String) async throws -> RejectCallResponse { + open func rejectCall(type: String, id: String, rejectCallRequest: RejectCallRequest) async throws -> RejectCallResponse { var localVariablePath = "/video/call/{type}/{id}/reject" let typePreEscape = "\(APIHelper.mapValueToPathItem(type))" let typePostEscape = typePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? "" @@ -871,21 +872,13 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable { let urlRequest = try makeRequest( uriPath: localVariablePath, - httpMethod: "POST" + httpMethod: "POST", + request: rejectCallRequest ) return try await send(request: urlRequest) { try self.jsonDecoder.decode(RejectCallResponse.self, from: $0) } } - /** - Reject Call - - POST /video/call/{type}/{id}/reject - - Sends events: - call.rejected Required permissions: - JoinCall - - parameter type: (path) - - parameter id: (path) - - returns: RequestBuilder - */ - /** Request permission @@ -1544,7 +1537,7 @@ protocol DefaultAPIEndpoints { func queryMembers(queryMembersRequest: QueryMembersRequest) async throws -> QueryMembersResponse - func rejectCall(type: String, id: String) async throws -> RejectCallResponse + func rejectCall(type: String, id: String, rejectCallRequest: RejectCallRequest) async throws -> RejectCallResponse func requestPermission(type: String, id: String, requestPermissionRequest: RequestPermissionRequest) async throws -> RequestPermissionResponse diff --git a/Sources/StreamVideo/OpenApi/generated/Models/RejectCallRequest.swift b/Sources/StreamVideo/OpenApi/generated/Models/RejectCallRequest.swift new file mode 100644 index 000000000..2171eadae --- /dev/null +++ b/Sources/StreamVideo/OpenApi/generated/Models/RejectCallRequest.swift @@ -0,0 +1,30 @@ +// +// RejectCallRequest.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + + +public struct RejectCallRequest: Codable, JSONEncodable, Hashable { + /** Reason for rejecting the call */ + public var reason: String? + + public init(reason: String? = nil) { + self.reason = reason + } + + public enum CodingKeys: String, CodingKey, CaseIterable { + case reason + } + + // Encodable protocol methods + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(reason, forKey: .reason) + } +} + diff --git a/StreamVideo.xcodeproj/project.pbxproj b/StreamVideo.xcodeproj/project.pbxproj index ea1fd9918..619bf1cb5 100644 --- a/StreamVideo.xcodeproj/project.pbxproj +++ b/StreamVideo.xcodeproj/project.pbxproj @@ -690,6 +690,7 @@ 845C09932C0E1BF900F725B3 /* DemoSessionTimerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845C09922C0E1BF900F725B3 /* DemoSessionTimerView.swift */; }; 845C09942C0E1BFF00F725B3 /* DemoSessionTimerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845C09922C0E1BF900F725B3 /* DemoSessionTimerView.swift */; }; 845C09952C10A7D700F725B3 /* SessionTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845C09902C0E0B7600F725B3 /* SessionTimer.swift */; }; + 845C09972C11AAA200F725B3 /* RejectCallRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845C09962C11AAA100F725B3 /* RejectCallRequest.swift */; }; 845E31062A7121D6004DC470 /* BroadcastObserver_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845E31052A7121D6004DC470 /* BroadcastObserver_Tests.swift */; }; 845E31082A712389004DC470 /* BroadcastUtils_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845E31072A712389004DC470 /* BroadcastUtils_Tests.swift */; }; 8468821328DFA448003BA9EE /* UnsecureRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8468821228DFA448003BA9EE /* UnsecureRepository.swift */; }; @@ -1668,6 +1669,7 @@ 845C09862C0DF3D100F725B3 /* LimitsSettingsResponse+Dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LimitsSettingsResponse+Dummy.swift"; sourceTree = ""; }; 845C09902C0E0B7600F725B3 /* SessionTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionTimer.swift; sourceTree = ""; }; 845C09922C0E1BF900F725B3 /* DemoSessionTimerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoSessionTimerView.swift; sourceTree = ""; }; + 845C09962C11AAA100F725B3 /* RejectCallRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RejectCallRequest.swift; sourceTree = ""; }; 845E31052A7121D6004DC470 /* BroadcastObserver_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BroadcastObserver_Tests.swift; sourceTree = ""; }; 845E31072A712389004DC470 /* BroadcastUtils_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BroadcastUtils_Tests.swift; sourceTree = ""; }; 8468821228DFA448003BA9EE /* UnsecureRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsecureRepository.swift; sourceTree = ""; }; @@ -3897,6 +3899,7 @@ 84DC383E29ADFCFC00946713 /* Models */ = { isa = PBXGroup; children = ( + 845C09962C11AAA100F725B3 /* RejectCallRequest.swift */, 845C09822C0DEB5C00F725B3 /* LimitsSettingsRequest.swift */, 845C09832C0DEB5C00F725B3 /* LimitsSettingsResponse.swift */, 841BAA1D2BD15CDC000C73E4 /* CallEvent.swift */, @@ -5240,6 +5243,7 @@ 84CC058B2A531B0B00EE9815 /* CallSettingsManager.swift in Sources */, 84DC38B929ADFCFD00946713 /* MemberRequest.swift in Sources */, 84DC38BE29ADFCFD00946713 /* CallSettingsRequest.swift in Sources */, + 845C09972C11AAA200F725B3 /* RejectCallRequest.swift in Sources */, 40FB02032BAC93A800A1C206 /* CallKitAdapter.swift in Sources */, 402F04AB2B70ED8600CA1986 /* StreamCallStatisticsFormatter.swift in Sources */, 8487D8B02A697E9A00536ED4 /* VideoCapturing.swift in Sources */,