Skip to content

Commit

Permalink
fix: update collaboration, metadata and collection resources (box/box…
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build authored Nov 20, 2024
1 parent 0aab9f7 commit f5b190a
Show file tree
Hide file tree
Showing 18 changed files with 307 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "6ae899a", "specHash": "c2c76f3", "version": "0.5.0" }
{ "engineHash": "6ae899a", "specHash": "6d5f53e", "version": "0.5.0" }
88 changes: 64 additions & 24 deletions BoxSdkGen.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Sources/Managers/Collections/CollectionsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ public class CollectionsManager {
/// Example: "926489"
/// - queryParams: Query parameters of getCollectionItems method
/// - headers: Headers of getCollectionItems method
/// - Returns: The `Items`.
/// - Returns: The `ItemsOffsetPaginated`.
/// - Throws: The `GeneralError`.
public func getCollectionItems(collectionId: String, queryParams: GetCollectionItemsQueryParams = GetCollectionItemsQueryParams(), headers: GetCollectionItemsHeaders = GetCollectionItemsHeaders()) async throws -> Items {
public func getCollectionItems(collectionId: String, queryParams: GetCollectionItemsQueryParams = GetCollectionItemsQueryParams(), headers: GetCollectionItemsHeaders = GetCollectionItemsHeaders()) async throws -> ItemsOffsetPaginated {
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["fields": Utils.Strings.toString(value: queryParams.fields), "offset": Utils.Strings.toString(value: queryParams.offset), "limit": Utils.Strings.toString(value: queryParams.limit)])
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge([:], headers.extraHeaders))
let response: FetchResponse = try await NetworkClient.shared.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/collections/")\(collectionId)\("/items")", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
return try Items.deserialize(from: response.data)
return try ItemsOffsetPaginated.deserialize(from: response.data)
}

/// Retrieves a collection by its ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ public class GetFolderCollaborationsQueryParams {
/// to the fields requested.
public let fields: [String]?

/// The maximum number of items to return per page.
public let limit: Int64?

/// Defines the position marker at which to begin returning results. This is
/// used when paginating using marker-based pagination.
///
/// This requires `usemarker` to be set to `true`.
public let marker: String?

/// Initializer for a GetFolderCollaborationsQueryParams.
///
/// - Parameters:
Expand All @@ -24,8 +33,15 @@ public class GetFolderCollaborationsQueryParams {
/// the response unless explicitly specified, instead only
/// fields for the mini representation are returned, additional
/// to the fields requested.
public init(fields: [String]? = nil) {
/// - limit: The maximum number of items to return per page.
/// - marker: Defines the position marker at which to begin returning results. This is
/// used when paginating using marker-based pagination.
///
/// This requires `usemarker` to be set to `true`.
public init(fields: [String]? = nil, limit: Int64? = nil, marker: String? = nil) {
self.fields = fields
self.limit = limit
self.marker = marker
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class ListCollaborationsManager {
/// - Returns: The `Collaborations`.
/// - Throws: The `GeneralError`.
public func getFolderCollaborations(folderId: String, queryParams: GetFolderCollaborationsQueryParams = GetFolderCollaborationsQueryParams(), headers: GetFolderCollaborationsHeaders = GetFolderCollaborationsHeaders()) async throws -> Collaborations {
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["fields": Utils.Strings.toString(value: queryParams.fields)])
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["fields": Utils.Strings.toString(value: queryParams.fields), "limit": Utils.Strings.toString(value: queryParams.limit), "marker": Utils.Strings.toString(value: queryParams.marker)])
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge([:], headers.extraHeaders))
let response: FetchResponse = try await NetworkClient.shared.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/folders/")\(folderId)\("/collaborations")", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
return try Collaborations.deserialize(from: response.data)
Expand All @@ -63,13 +63,13 @@ public class ListCollaborationsManager {
/// - Parameters:
/// - queryParams: Query parameters of getCollaborations method
/// - headers: Headers of getCollaborations method
/// - Returns: The `Collaborations`.
/// - Returns: The `CollaborationsOffsetPaginated`.
/// - Throws: The `GeneralError`.
public func getCollaborations(queryParams: GetCollaborationsQueryParams, headers: GetCollaborationsHeaders = GetCollaborationsHeaders()) async throws -> Collaborations {
public func getCollaborations(queryParams: GetCollaborationsQueryParams, headers: GetCollaborationsHeaders = GetCollaborationsHeaders()) async throws -> CollaborationsOffsetPaginated {
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["status": Utils.Strings.toString(value: queryParams.status), "fields": Utils.Strings.toString(value: queryParams.fields), "offset": Utils.Strings.toString(value: queryParams.offset), "limit": Utils.Strings.toString(value: queryParams.limit)])
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge([:], headers.extraHeaders))
let response: FetchResponse = try await NetworkClient.shared.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/collaborations")", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
return try Collaborations.deserialize(from: response.data)
return try CollaborationsOffsetPaginated.deserialize(from: response.data)
}

/// Retrieves all the collaborations for a group. The user
Expand All @@ -83,13 +83,13 @@ public class ListCollaborationsManager {
/// Example: "57645"
/// - queryParams: Query parameters of getGroupCollaborations method
/// - headers: Headers of getGroupCollaborations method
/// - Returns: The `Collaborations`.
/// - Returns: The `CollaborationsOffsetPaginated`.
/// - Throws: The `GeneralError`.
public func getGroupCollaborations(groupId: String, queryParams: GetGroupCollaborationsQueryParams = GetGroupCollaborationsQueryParams(), headers: GetGroupCollaborationsHeaders = GetGroupCollaborationsHeaders()) async throws -> Collaborations {
public func getGroupCollaborations(groupId: String, queryParams: GetGroupCollaborationsQueryParams = GetGroupCollaborationsQueryParams(), headers: GetGroupCollaborationsHeaders = GetGroupCollaborationsHeaders()) async throws -> CollaborationsOffsetPaginated {
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["limit": Utils.Strings.toString(value: queryParams.limit), "offset": Utils.Strings.toString(value: queryParams.offset)])
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge([:], headers.extraHeaders))
let response: FetchResponse = try await NetworkClient.shared.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/groups/")\(groupId)\("/collaborations")", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
return try Collaborations.deserialize(from: response.data)
return try CollaborationsOffsetPaginated.deserialize(from: response.data)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@ public class GetMetadataTemplatesByInstanceIdQueryParams {
/// The ID of an instance of the metadata template to find.
public let metadataInstanceId: String

/// Defines the position marker at which to begin returning results. This is
/// used when paginating using marker-based pagination.
///
/// This requires `usemarker` to be set to `true`.
public let marker: String?

/// The maximum number of items to return per page.
public let limit: Int64?

/// Initializer for a GetMetadataTemplatesByInstanceIdQueryParams.
///
/// - Parameters:
/// - metadataInstanceId: The ID of an instance of the metadata template to find.
public init(metadataInstanceId: String) {
/// - marker: Defines the position marker at which to begin returning results. This is
/// used when paginating using marker-based pagination.
///
/// This requires `usemarker` to be set to `true`.
/// - limit: The maximum number of items to return per page.
public init(metadataInstanceId: String, marker: String? = nil, limit: Int64? = nil) {
self.metadataInstanceId = metadataInstanceId
self.marker = marker
self.limit = limit
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MetadataTemplatesManager {
/// - Returns: The `MetadataTemplates`.
/// - Throws: The `GeneralError`.
public func getMetadataTemplatesByInstanceId(queryParams: GetMetadataTemplatesByInstanceIdQueryParams, headers: GetMetadataTemplatesByInstanceIdHeaders = GetMetadataTemplatesByInstanceIdHeaders()) async throws -> MetadataTemplates {
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["metadata_instance_id": Utils.Strings.toString(value: queryParams.metadataInstanceId)])
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["metadata_instance_id": Utils.Strings.toString(value: queryParams.metadataInstanceId), "marker": Utils.Strings.toString(value: queryParams.marker), "limit": Utils.Strings.toString(value: queryParams.limit)])
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge([:], headers.extraHeaders))
let response: FetchResponse = try await NetworkClient.shared.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/metadata_templates")", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
return try MetadataTemplates.deserialize(from: response.data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ public class CollaborationAcceptanceRequirementsStatusStrongPasswordRequirementF
}

/// Whether or not the enterprise that owns the content requires
/// a strong password to collaborate on the content.
/// a strong password to collaborate on the content, or enforces
/// an exposed password detection for the external collaborators.
public let enterpriseHasStrongPasswordRequiredForExternalUsers: Bool?

/// Whether or not the user has a strong password set for their
/// account. The field is `null` when a strong password is not
/// required.
/// Whether or not the user has a strong and not exposed password set
/// for their account. The field is `null` when a strong password is
/// not required.
public let userHasStrongPassword: Bool?

/// Initializer for a CollaborationAcceptanceRequirementsStatusStrongPasswordRequirementField.
///
/// - Parameters:
/// - enterpriseHasStrongPasswordRequiredForExternalUsers: Whether or not the enterprise that owns the content requires
/// a strong password to collaborate on the content.
/// - userHasStrongPassword: Whether or not the user has a strong password set for their
/// account. The field is `null` when a strong password is not
/// required.
/// a strong password to collaborate on the content, or enforces
/// an exposed password detection for the external collaborators.
/// - userHasStrongPassword: Whether or not the user has a strong and not exposed password set
/// for their account. The field is `null` when a strong password is
/// not required.
public init(enterpriseHasStrongPasswordRequiredForExternalUsers: Bool? = nil, userHasStrongPassword: Bool? = nil) {
self.enterpriseHasStrongPasswordRequiredForExternalUsers = enterpriseHasStrongPasswordRequiredForExternalUsers
self.userHasStrongPassword = userHasStrongPassword
Expand Down
50 changes: 1 addition & 49 deletions Sources/Schemas/Collaborations/Collaborations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ public class Collaborations: Codable {
case limit
case nextMarker = "next_marker"
case prevMarker = "prev_marker"
case totalCount = "total_count"
case offset
case order
case entries
}

Expand All @@ -23,27 +20,6 @@ public class Collaborations: Codable {
/// The marker for the start of the previous page of results.
public let prevMarker: String?

/// One greater than the offset of the last entry in the entire collection.
/// The total number of entries in the collection may be less than
/// `total_count`.
///
/// This field is only returned for calls that use offset-based pagination.
/// For marker-based paginated APIs, this field will be omitted.
public let totalCount: Int64?

/// The 0-based offset of the first entry in this set. This will be the same
/// as the `offset` query parameter.
///
/// This field is only returned for calls that use offset-based pagination.
/// For marker-based paginated APIs, this field will be omitted.
public let offset: Int64?

/// The order by which items are returned.
///
/// This field is only returned for calls that use offset-based pagination.
/// For marker-based paginated APIs, this field will be omitted.
public let order: [CollaborationsOrderField]?

/// A list of collaborations
public let entries: [Collaboration]?

Expand All @@ -55,29 +31,11 @@ public class Collaborations: Codable {
/// allowed. The maximum value varies by API.
/// - nextMarker: The marker for the start of the next page of results.
/// - prevMarker: The marker for the start of the previous page of results.
/// - totalCount: One greater than the offset of the last entry in the entire collection.
/// The total number of entries in the collection may be less than
/// `total_count`.
///
/// This field is only returned for calls that use offset-based pagination.
/// For marker-based paginated APIs, this field will be omitted.
/// - offset: The 0-based offset of the first entry in this set. This will be the same
/// as the `offset` query parameter.
///
/// This field is only returned for calls that use offset-based pagination.
/// For marker-based paginated APIs, this field will be omitted.
/// - order: The order by which items are returned.
///
/// This field is only returned for calls that use offset-based pagination.
/// For marker-based paginated APIs, this field will be omitted.
/// - entries: A list of collaborations
public init(limit: Int64? = nil, nextMarker: String? = nil, prevMarker: String? = nil, totalCount: Int64? = nil, offset: Int64? = nil, order: [CollaborationsOrderField]? = nil, entries: [Collaboration]? = nil) {
public init(limit: Int64? = nil, nextMarker: String? = nil, prevMarker: String? = nil, entries: [Collaboration]? = nil) {
self.limit = limit
self.nextMarker = nextMarker
self.prevMarker = prevMarker
self.totalCount = totalCount
self.offset = offset
self.order = order
self.entries = entries
}

Expand All @@ -86,9 +44,6 @@ public class Collaborations: Codable {
limit = try container.decodeIfPresent(Int64.self, forKey: .limit)
nextMarker = try container.decodeIfPresent(String.self, forKey: .nextMarker)
prevMarker = try container.decodeIfPresent(String.self, forKey: .prevMarker)
totalCount = try container.decodeIfPresent(Int64.self, forKey: .totalCount)
offset = try container.decodeIfPresent(Int64.self, forKey: .offset)
order = try container.decodeIfPresent([CollaborationsOrderField].self, forKey: .order)
entries = try container.decodeIfPresent([Collaboration].self, forKey: .entries)
}

Expand All @@ -97,9 +52,6 @@ public class Collaborations: Codable {
try container.encodeIfPresent(limit, forKey: .limit)
try container.encodeIfPresent(nextMarker, forKey: .nextMarker)
try container.encodeIfPresent(prevMarker, forKey: .prevMarker)
try container.encodeIfPresent(totalCount, forKey: .totalCount)
try container.encodeIfPresent(offset, forKey: .offset)
try container.encodeIfPresent(order, forKey: .order)
try container.encodeIfPresent(entries, forKey: .entries)
}

Expand Down

This file was deleted.

Loading

0 comments on commit f5b190a

Please sign in to comment.