Skip to content

Commit 8ef2533

Browse files
feat: Support Box Doc Gen API (box/box-codegen#644) (#343)
1 parent 9df1df2 commit 8ef2533

File tree

59 files changed

+2836
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2836
-1
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "5ab9c2b", "specHash": "cf0a265", "version": "0.5.0" }
1+
{ "engineHash": "ead925a", "specHash": "091b558", "version": "0.5.0" }

BoxSdkGen.xcodeproj/project.pbxproj

Lines changed: 820 additions & 0 deletions
Large diffs are not rendered by default.

Sources/Client/BoxClient.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ public class BoxClient {
145145

146146
public let ai: AiManager
147147

148+
public let docgenTemplate: DocgenTemplateManager
149+
150+
public let docgen: DocgenManager
151+
148152
public init(auth: Authentication, networkSession: NetworkSession = NetworkSession(baseUrls: BaseUrls())) {
149153
self.auth = auth
150154
self.networkSession = networkSession
@@ -218,6 +222,8 @@ public class BoxClient {
218222
self.signTemplates = SignTemplatesManager(auth: self.auth, networkSession: self.networkSession)
219223
self.integrationMappings = IntegrationMappingsManager(auth: self.auth, networkSession: self.networkSession)
220224
self.ai = AiManager(auth: self.auth, networkSession: self.networkSession)
225+
self.docgenTemplate = DocgenTemplateManager(auth: self.auth, networkSession: self.networkSession)
226+
self.docgen = DocgenManager(auth: self.auth, networkSession: self.networkSession)
221227
}
222228

223229
/// Create a new client to impersonate user with the provided ID. All calls made with the new client will be made in context of the impersonated user, leaving the original client unmodified.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class CreateDocgenBatchV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a CreateDocgenBatchV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import Foundation
2+
3+
public class DocgenManager {
4+
public let auth: Authentication?
5+
6+
public let networkSession: NetworkSession
7+
8+
public init(auth: Authentication? = nil, networkSession: NetworkSession = NetworkSession()) {
9+
self.auth = auth
10+
self.networkSession = networkSession
11+
}
12+
13+
/// Get details of the Box Doc Gen job.
14+
///
15+
/// - Parameters:
16+
/// - jobId: Box Doc Gen job ID.
17+
/// Example: 123
18+
/// - headers: Headers of getDocgenJobByIdV2025R0 method
19+
/// - Returns: The `DocGenJobV2025R0`.
20+
/// - Throws: The `GeneralError`.
21+
public func getDocgenJobByIdV2025R0(jobId: String, headers: GetDocgenJobByIdV2025R0Headers = GetDocgenJobByIdV2025R0Headers()) async throws -> DocGenJobV2025R0 {
22+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
23+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/docgen_jobs/")\(jobId)", method: "GET", headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
24+
return try DocGenJobV2025R0.deserialize(from: response.data)
25+
}
26+
27+
/// Lists all Box Doc Gen jobs for a user.
28+
///
29+
/// - Parameters:
30+
/// - queryParams: Query parameters of getDocgenJobsV2025R0 method
31+
/// - headers: Headers of getDocgenJobsV2025R0 method
32+
/// - Returns: The `DocGenJobsFullV2025R0`.
33+
/// - Throws: The `GeneralError`.
34+
public func getDocgenJobsV2025R0(queryParams: GetDocgenJobsV2025R0QueryParams = GetDocgenJobsV2025R0QueryParams(), headers: GetDocgenJobsV2025R0Headers = GetDocgenJobsV2025R0Headers()) async throws -> DocGenJobsFullV2025R0 {
35+
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["marker": Utils.Strings.toString(value: queryParams.marker), "limit": Utils.Strings.toString(value: queryParams.limit)])
36+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
37+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/docgen_jobs")", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
38+
return try DocGenJobsFullV2025R0.deserialize(from: response.data)
39+
}
40+
41+
/// Lists Box Doc Gen jobs in a batch
42+
///
43+
/// - Parameters:
44+
/// - batchId: Box Doc Gen batch ID.
45+
/// Example: 123
46+
/// - queryParams: Query parameters of getDocgenBatchJobByIdV2025R0 method
47+
/// - headers: Headers of getDocgenBatchJobByIdV2025R0 method
48+
/// - Returns: The `DocGenJobsV2025R0`.
49+
/// - Throws: The `GeneralError`.
50+
public func getDocgenBatchJobByIdV2025R0(batchId: String, queryParams: GetDocgenBatchJobByIdV2025R0QueryParams = GetDocgenBatchJobByIdV2025R0QueryParams(), headers: GetDocgenBatchJobByIdV2025R0Headers = GetDocgenBatchJobByIdV2025R0Headers()) async throws -> DocGenJobsV2025R0 {
51+
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["marker": Utils.Strings.toString(value: queryParams.marker), "limit": Utils.Strings.toString(value: queryParams.limit)])
52+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
53+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/docgen_batch_jobs/")\(batchId)", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
54+
return try DocGenJobsV2025R0.deserialize(from: response.data)
55+
}
56+
57+
/// Generates a document using a Box Doc Gen template.
58+
///
59+
/// - Parameters:
60+
/// - requestBody: Request body of createDocgenBatchV2025R0 method
61+
/// - headers: Headers of createDocgenBatchV2025R0 method
62+
/// - Returns: The `DocGenBatchBaseV2025R0`.
63+
/// - Throws: The `GeneralError`.
64+
public func createDocgenBatchV2025R0(requestBody: DocGenBatchCreateRequestV2025R0, headers: CreateDocgenBatchV2025R0Headers = CreateDocgenBatchV2025R0Headers()) async throws -> DocGenBatchBaseV2025R0 {
65+
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge(["box-version": Utils.Strings.toString(value: headers.boxVersion)], headers.extraHeaders))
66+
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/docgen_batches")", method: "POST", headers: headersMap, data: try requestBody.serialize(), contentType: "application/json", responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
67+
return try DocGenBatchBaseV2025R0.deserialize(from: response.data)
68+
}
69+
70+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class GetDocgenBatchJobByIdV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a GetDocgenBatchJobByIdV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Foundation
2+
3+
public class GetDocgenBatchJobByIdV2025R0QueryParams {
4+
/// Defines the position marker at which to begin returning results. This is
5+
/// used when paginating using marker-based pagination.
6+
///
7+
/// This requires `usemarker` to be set to `true`.
8+
public let marker: String?
9+
10+
/// The maximum number of items to return per page.
11+
public let limit: Int64?
12+
13+
/// Initializer for a GetDocgenBatchJobByIdV2025R0QueryParams.
14+
///
15+
/// - Parameters:
16+
/// - marker: Defines the position marker at which to begin returning results. This is
17+
/// used when paginating using marker-based pagination.
18+
///
19+
/// This requires `usemarker` to be set to `true`.
20+
/// - limit: The maximum number of items to return per page.
21+
public init(marker: String? = nil, limit: Int64? = nil) {
22+
self.marker = marker
23+
self.limit = limit
24+
}
25+
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class GetDocgenJobByIdV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a GetDocgenJobByIdV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
public class GetDocgenJobsV2025R0Headers {
4+
/// Version header
5+
public let boxVersion: BoxVersionHeaderV2025R0
6+
7+
/// Extra headers that will be included in the HTTP request.
8+
public let extraHeaders: [String: String?]?
9+
10+
/// Initializer for a GetDocgenJobsV2025R0Headers.
11+
///
12+
/// - Parameters:
13+
/// - boxVersion: Version header
14+
/// - extraHeaders: Extra headers that will be included in the HTTP request.
15+
public init(boxVersion: BoxVersionHeaderV2025R0 = BoxVersionHeaderV2025R0._20250, extraHeaders: [String: String?]? = [:]) {
16+
self.boxVersion = boxVersion
17+
self.extraHeaders = extraHeaders
18+
}
19+
20+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Foundation
2+
3+
public class GetDocgenJobsV2025R0QueryParams {
4+
/// Defines the position marker at which to begin returning results. This is
5+
/// used when paginating using marker-based pagination.
6+
///
7+
/// This requires `usemarker` to be set to `true`.
8+
public let marker: String?
9+
10+
/// The maximum number of items to return per page.
11+
public let limit: Int64?
12+
13+
/// Initializer for a GetDocgenJobsV2025R0QueryParams.
14+
///
15+
/// - Parameters:
16+
/// - marker: Defines the position marker at which to begin returning results. This is
17+
/// used when paginating using marker-based pagination.
18+
///
19+
/// This requires `usemarker` to be set to `true`.
20+
/// - limit: The maximum number of items to return per page.
21+
public init(marker: String? = nil, limit: Int64? = nil) {
22+
self.marker = marker
23+
self.limit = limit
24+
}
25+
26+
}

0 commit comments

Comments
 (0)