Skip to content

Commit 3ea6eb2

Browse files
authored
feat(SharedLink): add support for vanity_name (#799)
1 parent 4a4ab8e commit 3ea6eb2

12 files changed

+328
-107
lines changed

BoxSDK.xcodeproj/project.pbxproj

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
05031BFA274EA93D00BB9A19 /* GetWebLinkSharedLink_VanityNameEnabled.json in Resources */ = {isa = PBXBuildFile; fileRef = 05031BF8274EA93D00BB9A19 /* GetWebLinkSharedLink_VanityNameEnabled.json */; };
1011
052BC90426F8AD09001E64D2 /* CommentsModuleSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8069D1DF22A84090006B5611 /* CommentsModuleSpecs.swift */; };
1112
052D63C227182FA500C76281 /* CreateSignRequest.json in Resources */ = {isa = PBXBuildFile; fileRef = 052D63C127182FA500C76281 /* CreateSignRequest.json */; };
1213
052D63C4271843FA00C76281 /* GetSignRequests.json in Resources */ = {isa = PBXBuildFile; fileRef = 052D63C3271843FA00C76281 /* GetSignRequests.json */; };
@@ -30,6 +31,8 @@
3031
05A58A4426FB415700AB309C /* QueryParameterConvertibleSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A58A4326FB415700AB309C /* QueryParameterConvertibleSpecs.swift */; };
3132
05A58A4726FB487500AB309C /* EventTypeSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A58A4626FB487500AB309C /* EventTypeSpecs.swift */; };
3233
05A58A5826FB6F0700AB309C /* WatermarkSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A58A5726FB6F0700AB309C /* WatermarkSpecs.swift */; };
34+
05BFA08F274EEA5A00BC2448 /* GetFileSharedLink_VanityNameEnabled.json in Resources */ = {isa = PBXBuildFile; fileRef = 05BFA08D274EEA5A00BC2448 /* GetFileSharedLink_VanityNameEnabled.json */; };
35+
05BFA091274EED9B00BC2448 /* GetFolderSharedLink_VanityNameEnabled.json in Resources */ = {isa = PBXBuildFile; fileRef = 05BFA090274EED9A00BC2448 /* GetFolderSharedLink_VanityNameEnabled.json */; };
3336
05EE814027184A4B006A2329 /* GetSignRequest.json in Resources */ = {isa = PBXBuildFile; fileRef = 05EE813F27184A4B006A2329 /* GetSignRequest.json */; };
3437
05EE814227184EB3006A2329 /* CancelSignRequest.json in Resources */ = {isa = PBXBuildFile; fileRef = 05EE814127184EB3006A2329 /* CancelSignRequest.json */; };
3538
05EE814427185047006A2329 /* FullSignRequest.json in Resources */ = {isa = PBXBuildFile; fileRef = 05EE814327185047006A2329 /* FullSignRequest.json */; };
@@ -539,6 +542,7 @@
539542
/* End PBXCopyFilesBuildPhase section */
540543

541544
/* Begin PBXFileReference section */
545+
05031BF8274EA93D00BB9A19 /* GetWebLinkSharedLink_VanityNameEnabled.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = GetWebLinkSharedLink_VanityNameEnabled.json; sourceTree = "<group>"; };
542546
052D63C127182FA500C76281 /* CreateSignRequest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = CreateSignRequest.json; sourceTree = "<group>"; };
543547
052D63C3271843FA00C76281 /* GetSignRequests.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = GetSignRequests.json; sourceTree = "<group>"; };
544548
052D85CA271734FC00648C70 /* SignRequestsModuleSpecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignRequestsModuleSpecs.swift; sourceTree = "<group>"; };
@@ -564,6 +568,8 @@
564568
05A58A4326FB415700AB309C /* QueryParameterConvertibleSpecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueryParameterConvertibleSpecs.swift; sourceTree = "<group>"; };
565569
05A58A4626FB487500AB309C /* EventTypeSpecs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventTypeSpecs.swift; sourceTree = "<group>"; };
566570
05A58A5726FB6F0700AB309C /* WatermarkSpecs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WatermarkSpecs.swift; sourceTree = "<group>"; };
571+
05BFA08D274EEA5A00BC2448 /* GetFileSharedLink_VanityNameEnabled.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = GetFileSharedLink_VanityNameEnabled.json; sourceTree = "<group>"; };
572+
05BFA090274EED9A00BC2448 /* GetFolderSharedLink_VanityNameEnabled.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = GetFolderSharedLink_VanityNameEnabled.json; sourceTree = "<group>"; };
567573
05EE813F27184A4B006A2329 /* GetSignRequest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = GetSignRequest.json; sourceTree = "<group>"; };
568574
05EE814127184EB3006A2329 /* CancelSignRequest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = CancelSignRequest.json; sourceTree = "<group>"; };
569575
05EE814327185047006A2329 /* FullSignRequest.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = FullSignRequest.json; sourceTree = "<group>"; };
@@ -1550,39 +1556,40 @@
15501556
225639C7225389B100D951B5 /* Files */ = {
15511557
isa = PBXGroup;
15521558
children = (
1553-
05A58A2F26FB216A00AB309C /* FullFile_MissingRequiredField.json */,
1554-
05A58A3026FB216A00AB309C /* FullFile_ValueFormatMismatch.json */,
1555-
22B77832230C440B00FF6614 /* ChunkedUploadSessionGetSession.json */,
1559+
22643AC722B952D1009497CA /* AddFileToFavorites.json */,
15561560
22B7782B230C367C00FF6614 /* ChunkedUploadSessionCommit.json */,
1561+
22B77832230C440B00FF6614 /* ChunkedUploadSessionGetSession.json */,
15571562
22C95BE2230AF90F004F5C18 /* ChunkedUploadSessionListParts.json */,
1558-
22C95BD6230AD97E004F5C18 /* ChunkedUploadSessionUploadPart.json */,
1559-
22C95BD4230AD64F004F5C18 /* ChunkedUploadSessionNewFileVersion.json */,
15601563
22C95BD2230AC54E004F5C18 /* ChunkedUploadSessionNewFile.json */,
1561-
22E60D6A2303207300E86A4A /* FileRepresentationState.json */,
1562-
22E60D6823031E6100E86A4A /* GetRepresentationsPendingState.json */,
1563-
22E60D66230317C100E86A4A /* GetRepresentationsUnknownState.json */,
1564-
22E60D642303074C00E86A4A /* GetRepresentationsErrorState.json */,
1565-
22D8D12F22E605B60022FA44 /* SharedLinkPermissions.json */,
1566-
22643AC722B952D1009497CA /* AddFileToFavorites.json */,
1567-
22643AC622B952D1009497CA /* RemoveFileFromFavorites.json */,
1568-
0CA0651D22980EE900A751B1 /* image.png */,
1564+
22C95BD4230AD64F004F5C18 /* ChunkedUploadSessionNewFileVersion.json */,
1565+
22C95BD6230AD97E004F5C18 /* ChunkedUploadSessionUploadPart.json */,
15691566
225639CA225389B100D951B5 /* CopyFile.json */,
1570-
225639C8225389B100D951B5 /* GetFileInfo.json */,
1571-
225639C9225389B100D951B5 /* UpdateFileInfo.json */,
1572-
22A6576A225B805B00FB13F4 /* UploadFile.json */,
1573-
9D8AF93B22D63137009D3D01 /* UploadFileVersion.json */,
1574-
9771D4E622B058E800B76DF8 /* FullFile.json */,
1575-
0CD484292295A22C00E61C35 /* LockFile.json */,
1576-
0CD4843C2295F8CA00E61C35 /* UnlockFile.json */,
1577-
0CA06521229810C700A751B1 /* GetEmbedLink.json */,
15781567
0CA065252298121E00A751B1 /* FileCollaborations.json */,
15791568
0CA0652D22981B4C00A751B1 /* FileComments.json */,
1569+
22E60D6A2303207300E86A4A /* FileRepresentationState.json */,
1570+
05A58A2F26FB216A00AB309C /* FullFile_MissingRequiredField.json */,
1571+
05A58A3026FB216A00AB309C /* FullFile_ValueFormatMismatch.json */,
1572+
9771D4E622B058E800B76DF8 /* FullFile.json */,
1573+
0CA06521229810C700A751B1 /* GetEmbedLink.json */,
1574+
225639C8225389B100D951B5 /* GetFileInfo.json */,
1575+
9DD0AA4422DDBFDD0028702B /* GetFileSharedLink_PasswordNotEnabled.json */,
1576+
05BFA08D274EEA5A00BC2448 /* GetFileSharedLink_VanityNameEnabled.json */,
1577+
9DEA474322D380A50035C959 /* GetFileSharedLink.json */,
15801578
0CA0653122982E0F00A751B1 /* GetFileTasks.json */,
15811579
80F652CB22BAFF4200F38485 /* GetRepresentations.json */,
1580+
22E60D642303074C00E86A4A /* GetRepresentationsErrorState.json */,
15821581
80F652CE22BC431800F38485 /* GetRepresentationsNoHeader.json */,
1583-
9DEA474322D380A50035C959 /* GetFileSharedLink.json */,
1584-
9DD0AA4422DDBFDD0028702B /* GetFileSharedLink_PasswordNotEnabled.json */,
1582+
22E60D6823031E6100E86A4A /* GetRepresentationsPendingState.json */,
1583+
22E60D66230317C100E86A4A /* GetRepresentationsUnknownState.json */,
1584+
0CA0651D22980EE900A751B1 /* image.png */,
1585+
0CD484292295A22C00E61C35 /* LockFile.json */,
1586+
22643AC622B952D1009497CA /* RemoveFileFromFavorites.json */,
15851587
9717866E22F0C9ED004A5F6D /* RemoveFileSharedLink.json */,
1588+
22D8D12F22E605B60022FA44 /* SharedLinkPermissions.json */,
1589+
0CD4843C2295F8CA00E61C35 /* UnlockFile.json */,
1590+
225639C9225389B100D951B5 /* UpdateFileInfo.json */,
1591+
22A6576A225B805B00FB13F4 /* UploadFile.json */,
1592+
9D8AF93B22D63137009D3D01 /* UploadFileVersion.json */,
15861593
B40558AF25AD2ABF0068784E /* ZipDownload.json */,
15871594
B40558BA25AE57C10068784E /* ZipDownloadStatus.json */,
15881595
);
@@ -1594,26 +1601,27 @@
15941601
children = (
15951602
22D0043522AFBC6A00478F1E /* AddFolderToFavorites.json */,
15961603
22D0043622AFBC6A00478F1E /* CopyFolder.json */,
1604+
225639CC225389B100D951B5 /* CreateFolder.json */,
15971605
22D0043422AFBC6A00478F1E /* FolderCollaborations.json */,
1606+
B4882E6F25EEE12F00EB57BA /* FolderLock.json */,
1607+
B4882E7225EEFBC600EB57BA /* FolderLocks.json */,
1608+
97D3FFB922B1D4A4008C1CE6 /* FullFolder.json */,
15981609
22D0043122AFBC6A00478F1E /* GetFolderInfo.json */,
1599-
22D0043222AFBC6A00478F1E /* RemoveFolderFromFavorites.json */,
1600-
22D0043322AFBC6A00478F1E /* UpdateFolder.json */,
16011610
2259225022722F1A000568FC /* GetFolderItems.json */,
16021611
2262403B227214810048E638 /* GetFolderItemsMarkerIterator1.json */,
16031612
22624039227214810048E638 /* GetFolderItemsMarkerIterator2.json */,
16041613
22624038227214810048E638 /* GetFolderItemsOffsetIterator1.json */,
16051614
2262403A227214810048E638 /* GetFolderItemsOffsetIterator2.json */,
1606-
225639CC225389B100D951B5 /* CreateFolder.json */,
1607-
97D3FFB922B1D4A4008C1CE6 /* FullFolder.json */,
1615+
9DD6F53F22DDB89300F9D2D5 /* GetFolderSharedLink_PasswordNotEnabled.json */,
1616+
05BFA090274EED9A00BC2448 /* GetFolderSharedLink_VanityNameEnabled.json */,
1617+
9DEA474822D391220035C959 /* GetFolderSharedLink.json */,
1618+
22D0043222AFBC6A00478F1E /* RemoveFolderFromFavorites.json */,
1619+
9717866C22F0C694004A5F6D /* RemoveFolderSharedLink.json */,
1620+
22D0043322AFBC6A00478F1E /* UpdateFolder.json */,
16081621
0C00835B229C06FE0067C1AF /* GetFolderInfo.json */,
16091622
0C008369229C39F00067C1AF /* CopyFolder.json */,
16101623
0C00836D229C41CA0067C1AF /* FolderCollaborations.json */,
16111624
0C008371229C45480067C1AF /* UpdateFolder.json */,
1612-
9DEA474822D391220035C959 /* GetFolderSharedLink.json */,
1613-
9DD6F53F22DDB89300F9D2D5 /* GetFolderSharedLink_PasswordNotEnabled.json */,
1614-
9717866C22F0C694004A5F6D /* RemoveFolderSharedLink.json */,
1615-
B4882E6F25EEE12F00EB57BA /* FolderLock.json */,
1616-
B4882E7225EEFBC600EB57BA /* FolderLocks.json */,
16171625
);
16181626
path = Folders;
16191627
sourceTree = "<group>";
@@ -1983,10 +1991,11 @@
19831991
children = (
19841992
97F04DA322B867910034B9A3 /* FullWebLink.json */,
19851993
8093D29722FA398500DB628E /* GetWebLink.json */,
1986-
8093D29922FA399D00DB628E /* UpdateWebLink.json */,
1987-
806ACE4C22FB8E0000257353 /* GetWebLinkSharedLink.json */,
19881994
80E5679E2303683100798E3A /* GetWebLinkSharedLink_PasswordNotEnabled.json */,
1995+
05031BF8274EA93D00BB9A19 /* GetWebLinkSharedLink_VanityNameEnabled.json */,
1996+
806ACE4C22FB8E0000257353 /* GetWebLinkSharedLink.json */,
19891997
80E567B0230619AB00798E3A /* RemoveWebLinkSharedLink.json */,
1998+
8093D29922FA399D00DB628E /* UpdateWebLink.json */,
19901999
);
19912000
path = "Web Links";
19922001
sourceTree = "<group>";
@@ -2353,6 +2362,7 @@
23532362
97F04D9F22B84D260034B9A3 /* FullUser.json in Resources */,
23542363
0C00835C229C06FE0067C1AF /* GetFolderInfo.json in Resources */,
23552364
80E5679C22FB932000798E3A /* GetWebLinkSharedLink.json in Resources */,
2365+
05031BFA274EA93D00BB9A19 /* GetWebLinkSharedLink_VanityNameEnabled.json in Resources */,
23562366
0CD4843D2295F8CA00E61C35 /* UnlockFile.json in Resources */,
23572367
2262403F227214820048E638 /* GetFolderItemsMarkerIterator1.json in Resources */,
23582368
80FEB7D32321BDE10037331C /* GetMembershipsForUser.json in Resources */,
@@ -2431,6 +2441,7 @@
24312441
0CD34259228AF07800BAFF4B /* InviteUserToEnterprise.json in Resources */,
24322442
F969D3AC233A73A4001301FC /* GetStoragePolicies.json in Resources */,
24332443
0CD3425D228AF94700BAFF4B /* MoveUserItemsToAnotherUser.json in Resources */,
2444+
05BFA091274EED9B00BC2448 /* GetFolderSharedLink_VanityNameEnabled.json in Resources */,
24342445
176CAE09231D72BC004269F5 /* GetFileVersionRetention.json in Resources */,
24352446
22E60D67230317C100E86A4A /* GetRepresentationsUnknownState.json in Resources */,
24362447
22B01E3422AAC8D400E434ED /* DownscopeToken.json in Resources */,
@@ -2472,6 +2483,7 @@
24722483
9731D2C6227D29D40092BCCE /* Search200.json in Resources */,
24732484
8061988F22AB18B100B09896 /* CreateComment.json in Resources */,
24742485
0CD34251228AE60C00BAFF4B /* CreateAppUser.json in Resources */,
2486+
05BFA08F274EEA5A00BC2448 /* GetFileSharedLink_VanityNameEnabled.json in Resources */,
24752487
80BC8435232C56B700010E08 /* GetTermsOfServiceUserStatuses.json in Resources */,
24762488
22CE53A122DD0C3E00F3D59F /* CreateMetadataOnFolder.json in Resources */,
24772489
80BC843E232C56C700010E08 /* FullTermsOfService.json in Resources */,

Sources/Modules/FilesModule.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,17 @@ public class FilesModule {
122122
///
123123
/// - Parameters:
124124
/// - fileId: The ID of the file on which to perform the update.
125-
/// - updateFileInfo: The new values with which to update the file.
125+
/// - name: An optional new name for the file. Box supports file names of 255 characters or
126+
/// less. Names containing non-printable ASCII characters, "/" or "\", names with trailing
127+
/// spaces, and the special names “.” and “..” are also not allowed.
128+
/// - description: The description of the file.
129+
/// - parentId: The ID of the parent folder.
130+
/// - sharedLink: Shared links provide direct, read-only access to file on Box using a URL.
131+
/// - tags: Array of tags to be added or replaced to the file
132+
/// - collections: List of collection identifiers to which the file membership will be set.
133+
/// - lock: Defines a lock on an item.
134+
/// This prevents the item from being moved, renamed, or otherwise changed by anyone other than the user who created the lock.
135+
/// Set this to null to remove the lock.
126136
/// - ifMatch: This is in the ‘etag’ field of the file object, which can be included to prevent race conditions.
127137
/// - fields: String array of [fields](https://developer.box.com/reference#fields) to
128138
/// include in the response. Any attribute in the full
@@ -1235,14 +1245,17 @@ public class FilesModule {
12351245
///
12361246
/// - Parameters:
12371247
/// - fileId: The ID of the file
1238-
/// - stopSharingAt: The date-time that this link will become disabled. This field can only be set by users with paid accounts
1248+
/// - unsharedAt: The date-time that this link will become disabled. This field can only be set by users with paid accounts
1249+
/// - vanityName: The custom name of a shared link, as used in the vanityUrl field.
1250+
/// It should be between 12 and 30 characters. This field can contains only letters, numbers, and hyphens.
12391251
/// - access: The level of access. If you omit this field then the access level will be set to the default access level specified by the enterprise admin
12401252
/// - password: The password required to access the shared link. Set to .empty to delete the password
12411253
/// - canDownload: Whether the shared link allows downloads
12421254
/// - completion: Returns a standard SharedLink object or an error
12431255
public func setSharedLink(
12441256
forFile fileId: String,
12451257
unsharedAt: NullableParameter<Date>? = nil,
1258+
vanityName: NullableParameter<String>? = nil,
12461259
access: SharedLinkAccess? = nil,
12471260
password: NullableParameter<String>? = nil,
12481261
canDownload: Bool? = nil,
@@ -1254,6 +1267,7 @@ public class FilesModule {
12541267
access: access,
12551268
password: password,
12561269
unsharedAt: unsharedAt,
1270+
vanityName: vanityName,
12571271
canDownload: canDownload
12581272
)),
12591273
fields: ["shared_link"]

Sources/Modules/FoldersModule.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,7 @@ public class FoldersModule {
220220
/// - name: The name of the folder.
221221
/// - description: The description of the folder.
222222
/// - parentId: The ID of the parent folder
223-
/// - access: The level of access. Can be open ("People with the link"), company ("People in your company"), or collaborators ("People in this folder").
224-
/// If you omit this field then the access level will be set to the default access level specified by the enterprise admin.
225-
/// - password: The password required to access the shared link. Set to .empty value to delete password
226-
/// - unsharedAt: The date-time that this link will become disabled. This field can only be set by users with paid accounts.
227-
/// - canDownload: Whether the shared link allows downloads. For shared links on folders, this also applies to any items in the folder.
228-
/// Can only be set with access levels open and company (not collaborators).
223+
/// - sharedLink: Shared links provide direct, read-only access to folder on Box using a URL.
229224
/// - folderUploadEmailAccess: Can be open or collaborators
230225
/// - tags: Array of tags to be added or replaced to the folder
231226
/// - canNonOwnersInvite: If this parameter is set to false, only folder owners and co-owners can send collaborator invites
@@ -482,13 +477,16 @@ public class FoldersModule {
482477
/// - folderId: The ID of the folder
483478
/// - access: The level of access. If you omit this field then the access level will be set to the default access level specified by the enterprise admin
484479
/// - unsharedAt: The date-time that this link will become disabled. This field can only be set by users with paid accounts
480+
/// - vanityName: The custom name of a shared link, as used in the vanityUrl field.
481+
/// It should be between 12 and 30 characters. This field can contains only letters, numbers, and hyphens.
485482
/// - password: The password required to access the shared link. Set to .null to remove the password
486483
/// - canDownload: Whether the shared link allows downloads. Applies to any items in the folder
487484
/// - completion: Returns a standard SharedLink object or an error
488485
public func setSharedLink(
489486
forFolder folderId: String,
490487
access: SharedLinkAccess? = nil,
491488
unsharedAt: NullableParameter<Date>? = nil,
489+
vanityName: NullableParameter<String>? = nil,
492490
password: NullableParameter<String>? = nil,
493491
canDownload: Bool? = nil,
494492
completion: @escaping Callback<SharedLink>
@@ -499,6 +497,7 @@ public class FoldersModule {
499497
access: access,
500498
password: password,
501499
unsharedAt: unsharedAt,
500+
vanityName: vanityName,
502501
canDownload: canDownload
503502
)),
504503
fields: ["shared_link"]

0 commit comments

Comments
 (0)