Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
14 changes: 11 additions & 3 deletions Sources/StreamVideo/Call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
21 changes: 7 additions & 14 deletions Sources/StreamVideo/OpenApi/generated/APIs/DefaultAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?? ""
Expand All @@ -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<RejectCallResponse>
*/


/**
Request permission
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
}
}

4 changes: 4 additions & 0 deletions StreamVideo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -1668,6 +1669,7 @@
845C09862C0DF3D100F725B3 /* LimitsSettingsResponse+Dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LimitsSettingsResponse+Dummy.swift"; sourceTree = "<group>"; };
845C09902C0E0B7600F725B3 /* SessionTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionTimer.swift; sourceTree = "<group>"; };
845C09922C0E1BF900F725B3 /* DemoSessionTimerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoSessionTimerView.swift; sourceTree = "<group>"; };
845C09962C11AAA100F725B3 /* RejectCallRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RejectCallRequest.swift; sourceTree = "<group>"; };
845E31052A7121D6004DC470 /* BroadcastObserver_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BroadcastObserver_Tests.swift; sourceTree = "<group>"; };
845E31072A712389004DC470 /* BroadcastUtils_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BroadcastUtils_Tests.swift; sourceTree = "<group>"; };
8468821228DFA448003BA9EE /* UnsecureRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsecureRepository.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3897,6 +3899,7 @@
84DC383E29ADFCFC00946713 /* Models */ = {
isa = PBXGroup;
children = (
845C09962C11AAA100F725B3 /* RejectCallRequest.swift */,
845C09822C0DEB5C00F725B3 /* LimitsSettingsRequest.swift */,
845C09832C0DEB5C00F725B3 /* LimitsSettingsResponse.swift */,
841BAA1D2BD15CDC000C73E4 /* CallEvent.swift */,
Expand Down Expand Up @@ -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 */,
Expand Down