Skip to content

Commit

Permalink
feat: Add is_active parameter to user collaboration (box/box-openap…
Browse files Browse the repository at this point in the history
…i#437) (#163)

Co-authored-by: box-sdk-build <[email protected]>
  • Loading branch information
box-sdk-build and box-sdk-build authored Jul 18, 2024
1 parent 2071b97 commit 5f726bb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "5a07c4a", "specHash": "e95d6fa", "version": "0.3.0" }
{ "engineHash": "25c4224", "specHash": "137da0d", "version": "0.3.0" }
3 changes: 2 additions & 1 deletion Sources/Internal/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ public enum Utils {
/// - Parameters:
/// - stream: InputStream to iterate over
/// - chunkSize: Size of chunk
/// - fileSize: Size of the file
/// - Returns: The asynchronous sequence AsyncStream
public static func iterateChunks(stream: InputStream, chunkSize: Int64) -> AsyncStream<InputStream> {
public static func iterateChunks(stream: InputStream, chunkSize: Int64, fileSize: Int64) -> AsyncStream<InputStream> {
return AsyncStream<InputStream> { continuation in
_Concurrency.Task {
stream.open()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public class ChunkedUploadsManager {
assert(partSize * Int64(totalParts) >= fileSize)
assert(uploadSession.numPartsProcessed == 0)
let fileHash: Hash = Hash(algorithm: HashName.sha1)
let chunksIterator: AsyncStream<InputStream> = Utils.iterateChunks(stream: file, chunkSize: partSize)
let chunksIterator: AsyncStream<InputStream> = Utils.iterateChunks(stream: file, chunkSize: partSize, fileSize: fileSize)
let results: PartAccumulator = try await Utils.reduceIterator(iterator: chunksIterator, reducer: self.reducer, initialValue: PartAccumulator(lastIndex: -1, parts: [], fileSize: fileSize, uploadSessionId: uploadSessionId, fileHash: fileHash))
let parts: [UploadPart] = results.parts
let processedSessionParts: UploadParts = try await self.getFileUploadSessionParts(uploadSessionId: uploadSessionId)
Expand Down
10 changes: 9 additions & 1 deletion Sources/Schemas/UserCollaborations/UserCollaborations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class UserCollaborations: UserBase {
private enum CodingKeys: String, CodingKey {
case name
case login
case isActive = "is_active"
}

/// The display name of this user. If the collaboration status is `pending`, an empty string is returned.
Expand All @@ -14,16 +15,21 @@ public class UserCollaborations: UserBase {
/// The primary email address of this user. If the collaboration status is `pending`, an empty string is returned.
public let login: String?

/// If set to `false`, the user is either deactivated or deleted.
public let isActive: Bool?

/// Initializer for a UserCollaborations.
///
/// - Parameters:
/// - id: The unique identifier for this user
/// - type: `user`
/// - name: The display name of this user. If the collaboration status is `pending`, an empty string is returned.
/// - login: The primary email address of this user. If the collaboration status is `pending`, an empty string is returned.
public init(id: String, type: UserBaseTypeField = UserBaseTypeField.user, name: String? = nil, login: String? = nil) {
/// - isActive: If set to `false`, the user is either deactivated or deleted.
public init(id: String, type: UserBaseTypeField = UserBaseTypeField.user, name: String? = nil, login: String? = nil, isActive: Bool? = nil) {
self.name = name
self.login = login
self.isActive = isActive

super.init(id: id, type: type)
}
Expand All @@ -32,6 +38,7 @@ public class UserCollaborations: UserBase {
let container = try decoder.container(keyedBy: CodingKeys.self)
name = try container.decodeIfPresent(String.self, forKey: .name)
login = try container.decodeIfPresent(String.self, forKey: .login)
isActive = try container.decodeIfPresent(Bool.self, forKey: .isActive)

try super.init(from: decoder)
}
Expand All @@ -40,6 +47,7 @@ public class UserCollaborations: UserBase {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(name, forKey: .name)
try container.encodeIfPresent(login, forKey: .login)
try container.encodeIfPresent(isActive, forKey: .isActive)
try super.encode(to: encoder)
}

Expand Down

0 comments on commit 5f726bb

Please sign in to comment.