Skip to content

Commit 30db401

Browse files
committed
fix: Make parameter of update collaboration optional (box/box-openapi#557)
1 parent af28805 commit 30db401

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "9334953", "specHash": "62fdfd1", "version": "10.0.0" }
1+
{ "engineHash": "9334953", "specHash": "c7acada", "version": "10.0.0" }

BoxSdkGen/Sources/Managers/UserCollaborations/UpdateCollaborationByIdRequestBody.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class UpdateCollaborationByIdRequestBody: Codable, RawJSONReadable {
1818

1919

2020
/// The level of access granted.
21-
public let role: UpdateCollaborationByIdRequestBodyRoleField
21+
public let role: UpdateCollaborationByIdRequestBodyRoleField?
2222

2323
/// Set the status of a `pending` collaboration invitation,
2424
/// effectively accepting, or rejecting the invite.
@@ -86,7 +86,7 @@ public class UpdateCollaborationByIdRequestBody: Codable, RawJSONReadable {
8686
/// `true`.
8787
///
8888
/// `can_view_path` can only be used for folder collaborations.
89-
public init(role: UpdateCollaborationByIdRequestBodyRoleField, status: UpdateCollaborationByIdRequestBodyStatusField? = nil, expiresAt: Date? = nil, canViewPath: Bool? = nil) {
89+
public init(role: UpdateCollaborationByIdRequestBodyRoleField? = nil, status: UpdateCollaborationByIdRequestBodyStatusField? = nil, expiresAt: Date? = nil, canViewPath: Bool? = nil) {
9090
self.role = role
9191
self.status = status
9292
self.expiresAt = expiresAt
@@ -95,15 +95,15 @@ public class UpdateCollaborationByIdRequestBody: Codable, RawJSONReadable {
9595

9696
required public init(from decoder: Decoder) throws {
9797
let container = try decoder.container(keyedBy: CodingKeys.self)
98-
role = try container.decode(UpdateCollaborationByIdRequestBodyRoleField.self, forKey: .role)
98+
role = try container.decodeIfPresent(UpdateCollaborationByIdRequestBodyRoleField.self, forKey: .role)
9999
status = try container.decodeIfPresent(UpdateCollaborationByIdRequestBodyStatusField.self, forKey: .status)
100100
expiresAt = try container.decodeDateTimeIfPresent(forKey: .expiresAt)
101101
canViewPath = try container.decodeIfPresent(Bool.self, forKey: .canViewPath)
102102
}
103103

104104
public func encode(to encoder: Encoder) throws {
105105
var container = encoder.container(keyedBy: CodingKeys.self)
106-
try container.encode(role, forKey: .role)
106+
try container.encodeIfPresent(role, forKey: .role)
107107
try container.encodeIfPresent(status, forKey: .status)
108108
try container.encodeDateTimeIfPresent(field: expiresAt, forKey: .expiresAt)
109109
try container.encodeIfPresent(canViewPath, forKey: .canViewPath)

BoxSdkGen/Sources/Managers/UserCollaborations/UserCollaborationsManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class UserCollaborationsManager {
2828

2929
/// Updates a collaboration.
3030
/// Can be used to change the owner of an item, or to
31-
/// accept collaboration invites.
31+
/// accept collaboration invites. In case of accepting collaboration invite, role is not required.
3232
///
3333
/// - Parameters:
3434
/// - collaborationId: The ID of the collaboration.
@@ -37,7 +37,7 @@ public class UserCollaborationsManager {
3737
/// - headers: Headers of updateCollaborationById method
3838
/// - Returns: The `Collaboration?`.
3939
/// - Throws: The `GeneralError`.
40-
public func updateCollaborationById(collaborationId: String, requestBody: UpdateCollaborationByIdRequestBody, headers: UpdateCollaborationByIdHeaders = UpdateCollaborationByIdHeaders()) async throws -> Collaboration? {
40+
public func updateCollaborationById(collaborationId: String, requestBody: UpdateCollaborationByIdRequestBody = UpdateCollaborationByIdRequestBody(), headers: UpdateCollaborationByIdHeaders = UpdateCollaborationByIdHeaders()) async throws -> Collaboration? {
4141
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge([:], headers.extraHeaders))
4242
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/collaborations/")\(collaborationId)", method: "PUT", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: ResponseFormat.json, auth: self.auth, networkSession: self.networkSession))
4343
if Utils.Strings.toString(value: response.status) == "204" {

docs/UserCollaborations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Returns a collaboration object.
4141

4242
Updates a collaboration.
4343
Can be used to change the owner of an item, or to
44-
accept collaboration invites.
44+
accept collaboration invites. In case of accepting collaboration invite, role is not required.
4545

4646
This operation is performed by calling function `updateCollaborationById`.
4747

0 commit comments

Comments
 (0)