Skip to content

Commit 2f5e2f1

Browse files
box-sdk-buildbox-sdk-build
andauthored
feat: Add Box Sign shared requests (box/box-openapi#504) (#348)
Co-authored-by: box-sdk-build <[email protected]>
1 parent 58ff930 commit 2f5e2f1

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "b5ed925", "specHash": "99792c6", "version": "0.5.0" }
1+
{ "engineHash": "b5ed925", "specHash": "3dc3f1e", "version": "0.5.0" }

Sources/Managers/SignRequests/GetSignRequestsQueryParams.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ public class GetSignRequestsQueryParams {
1010
/// The maximum number of items to return per page.
1111
public let limit: Int64?
1212

13+
/// A list of sender emails to filter the signature requests by sender.
14+
/// If provided, `shared_requests` must be set to `true`.
15+
public let senders: [String]?
16+
17+
/// If set to `true`, only includes requests that user is not an owner,
18+
/// but user is a collaborator. Collaborator access is determined by the
19+
/// user access level of the sign files of the request.
20+
/// Default is `false`. Must be set to `true` if `senders` are provided.
21+
public let sharedRequests: Bool?
22+
1323
/// Initializer for a GetSignRequestsQueryParams.
1424
///
1525
/// - Parameters:
@@ -18,9 +28,17 @@ public class GetSignRequestsQueryParams {
1828
///
1929
/// This requires `usemarker` to be set to `true`.
2030
/// - limit: The maximum number of items to return per page.
21-
public init(marker: String? = nil, limit: Int64? = nil) {
31+
/// - senders: A list of sender emails to filter the signature requests by sender.
32+
/// If provided, `shared_requests` must be set to `true`.
33+
/// - sharedRequests: If set to `true`, only includes requests that user is not an owner,
34+
/// but user is a collaborator. Collaborator access is determined by the
35+
/// user access level of the sign files of the request.
36+
/// Default is `false`. Must be set to `true` if `senders` are provided.
37+
public init(marker: String? = nil, limit: Int64? = nil, senders: [String]? = nil, sharedRequests: Bool? = nil) {
2238
self.marker = marker
2339
self.limit = limit
40+
self.senders = senders
41+
self.sharedRequests = sharedRequests
2442
}
2543

2644
}

Sources/Managers/SignRequests/SignRequestsManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class SignRequestsManager {
5959
/// - Returns: The `SignRequests`.
6060
/// - Throws: The `GeneralError`.
6161
public func getSignRequests(queryParams: GetSignRequestsQueryParams = GetSignRequestsQueryParams(), headers: GetSignRequestsHeaders = GetSignRequestsHeaders()) async throws -> SignRequests {
62-
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["marker": Utils.Strings.toString(value: queryParams.marker), "limit": Utils.Strings.toString(value: queryParams.limit)])
62+
let queryParamsMap: [String: String] = Utils.Dictionary.prepareParams(map: ["marker": Utils.Strings.toString(value: queryParams.marker), "limit": Utils.Strings.toString(value: queryParams.limit), "senders": Utils.Strings.toString(value: queryParams.senders), "shared_requests": Utils.Strings.toString(value: queryParams.sharedRequests)])
6363
let headersMap: [String: String] = Utils.Dictionary.prepareParams(map: Utils.Dictionary.merge([:], headers.extraHeaders))
6464
let response: FetchResponse = try await self.networkSession.networkClient.fetch(options: FetchOptions(url: "\(self.networkSession.baseUrls.baseUrl)\("/2.0/sign_requests")", method: "GET", params: queryParamsMap, headers: headersMap, responseFormat: "json", auth: self.auth, networkSession: self.networkSession))
6565
return try SignRequests.deserialize(from: response.data)

Sources/Schemas/SignRequest/SignRequest.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public class SignRequest: SignRequestBase {
1414
case signFiles = "sign_files"
1515
case autoExpireAt = "auto_expire_at"
1616
case parentFolder = "parent_folder"
17+
case collaboratorLevel = "collaborator_level"
18+
case senderEmail = "sender_email"
19+
case senderId = "sender_id"
1720
}
1821

1922
/// object type
@@ -54,6 +57,15 @@ public class SignRequest: SignRequestBase {
5457

5558
public let parentFolder: FolderMini?
5659

60+
/// The collaborator level of the user to the sign request. Values can include "owner", "editor", and "viewer"
61+
public let collaboratorLevel: String?
62+
63+
/// The email address of the sender of the sign request.
64+
public let senderEmail: String?
65+
66+
/// The user ID of the sender of the sign request.
67+
public let senderId: Int64?
68+
5769
/// Initializer for a SignRequest.
5870
///
5971
/// - Parameters:
@@ -88,7 +100,10 @@ public class SignRequest: SignRequestBase {
88100
/// and can be downloaded at any point in the signing process.
89101
/// - autoExpireAt: Uses `days_valid` to calculate the date and time, in GMT, the sign request will expire if unsigned.
90102
/// - parentFolder:
91-
public init(isDocumentPreparationNeeded: Bool? = nil, redirectUrl: String? = nil, declinedRedirectUrl: String? = nil, areTextSignaturesEnabled: Bool? = nil, emailSubject: String? = nil, emailMessage: String? = nil, areRemindersEnabled: Bool? = nil, name: String? = nil, prefillTags: [SignRequestPrefillTag]? = nil, daysValid: Int64? = nil, externalId: String? = nil, templateId: String? = nil, externalSystemName: String? = nil, type: SignRequestTypeField? = nil, sourceFiles: [FileBase]? = nil, signers: [SignRequestSigner]? = nil, signatureColor: String? = nil, id: String? = nil, prepareUrl: String? = nil, signingLog: FileMini? = nil, status: SignRequestStatusField? = nil, signFiles: SignRequestSignFilesField? = nil, autoExpireAt: Date? = nil, parentFolder: FolderMini? = nil) {
103+
/// - collaboratorLevel: The collaborator level of the user to the sign request. Values can include "owner", "editor", and "viewer"
104+
/// - senderEmail: The email address of the sender of the sign request.
105+
/// - senderId: The user ID of the sender of the sign request.
106+
public init(isDocumentPreparationNeeded: Bool? = nil, redirectUrl: String? = nil, declinedRedirectUrl: String? = nil, areTextSignaturesEnabled: Bool? = nil, emailSubject: String? = nil, emailMessage: String? = nil, areRemindersEnabled: Bool? = nil, name: String? = nil, prefillTags: [SignRequestPrefillTag]? = nil, daysValid: Int64? = nil, externalId: String? = nil, templateId: String? = nil, externalSystemName: String? = nil, type: SignRequestTypeField? = nil, sourceFiles: [FileBase]? = nil, signers: [SignRequestSigner]? = nil, signatureColor: String? = nil, id: String? = nil, prepareUrl: String? = nil, signingLog: FileMini? = nil, status: SignRequestStatusField? = nil, signFiles: SignRequestSignFilesField? = nil, autoExpireAt: Date? = nil, parentFolder: FolderMini? = nil, collaboratorLevel: String? = nil, senderEmail: String? = nil, senderId: Int64? = nil) {
92107
self.type = type
93108
self.sourceFiles = sourceFiles
94109
self.signers = signers
@@ -100,6 +115,9 @@ public class SignRequest: SignRequestBase {
100115
self.signFiles = signFiles
101116
self.autoExpireAt = autoExpireAt
102117
self.parentFolder = parentFolder
118+
self.collaboratorLevel = collaboratorLevel
119+
self.senderEmail = senderEmail
120+
self.senderId = senderId
103121

104122
super.init(isDocumentPreparationNeeded: isDocumentPreparationNeeded, redirectUrl: redirectUrl, declinedRedirectUrl: declinedRedirectUrl, areTextSignaturesEnabled: areTextSignaturesEnabled, emailSubject: emailSubject, emailMessage: emailMessage, areRemindersEnabled: areRemindersEnabled, name: name, prefillTags: prefillTags, daysValid: daysValid, externalId: externalId, templateId: templateId, externalSystemName: externalSystemName)
105123
}
@@ -122,6 +140,9 @@ public class SignRequest: SignRequestBase {
122140
}
123141

124142
parentFolder = try container.decodeIfPresent(FolderMini.self, forKey: .parentFolder)
143+
collaboratorLevel = try container.decodeIfPresent(String.self, forKey: .collaboratorLevel)
144+
senderEmail = try container.decodeIfPresent(String.self, forKey: .senderEmail)
145+
senderId = try container.decodeIfPresent(Int64.self, forKey: .senderId)
125146

126147
try super.init(from: decoder)
127148
}
@@ -142,6 +163,9 @@ public class SignRequest: SignRequestBase {
142163
}
143164

144165
try container.encodeIfPresent(parentFolder, forKey: .parentFolder)
166+
try container.encodeIfPresent(collaboratorLevel, forKey: .collaboratorLevel)
167+
try container.encodeIfPresent(senderEmail, forKey: .senderEmail)
168+
try container.encodeIfPresent(senderId, forKey: .senderId)
145169
try super.encode(to: encoder)
146170
}
147171

0 commit comments

Comments
 (0)