let toInvite = [Sharing.AddMember(member: Sharing.MemberSelector.Email("<EMAIL_ADDRESS_TO_INVITE>"))]
Dropbox.authorizedClient!.sharing.addFolderMember(sharedFolderId: "<SHARED_FOLDER_ID>", members: toInvite).response { response, error in
if (response != nil) {
print("Invited member.")
} else if let callError = error {
switch callError as CallError {
case .BadInputError(let message, let requestId):
print("BadInputError[\(requestId)]: \(message)")
case .HTTPError(let code, let message, let requestId):
print("HTTPError[\(requestId)]: \(code): \(message)")
case .InternalServerError(let code, let message, let requestId):
print("InternalServerError[\(requestId)]: \(code): \(message)")
case .OSError(let err):
print("OSError: \(err)")
case .RateLimitError:
print("RateLimitError")
case .RouteError(let boxed, let requestId):
print("RouteError[\(requestId)]:")
switch boxed.unboxed as Sharing.AddFolderMemberError {
case .AccessError(let sharedFolderAccessError):
print("AccessError")
switch sharedFolderAccessError {
case .EmailUnverified:
print("EmailUnverified")
case .InvalidId:
print("InvalidId")
case .NoPermission:
print("NoPermission")
case .NotAMember:
print("NotAMember")
case .TeamFolder:
print("TeamFolder")
case .Unmounted:
print("Unmounted")
case .Other:
print("Other")
}
case .BadMember(let addMemberSelectorError):
switch addMemberSelectorError {
case .GroupDeleted:
print("GroupDeleted")
case .GroupNotOnTeam:
print("GroupNotOnTeam")
case .InvalidDropboxId(let invalidDropboxId):
print("InvalidDropboxId: \(invalidDropboxId)")
case .InvalidEmail(let invalidEmail):
print("InvalidEmail: \(invalidEmail)")
case .UnverifiedDropboxId(let unverifiedDropboxId):
print("UnverifiedDropboxId: \(unverifiedDropboxId)")
case .Other:
print("Other")
}
case .CantShareOutsideTeam:
print("CantShareOutsideTeam")
case .EmailUnverified:
print("EmailUnverified")
case .InsufficientPlan:
print("InsufficientPlan")
case .NoPermission:
print("NoPermission")
case .RateLimit:
print("RateLimit")
case .TooManyMembers(let limit):
print("TooManyMembers: \(limit)")
case .TooManyPendingInvites(let limit):
print("TooManyPendingInvites: \(limit)")
case .Other:
print("Other")
}
}
}
}
<SHARED_FOLDER_ID>
should be replaced with the shared folder ID, e.g., as returned by sharing.shareFolder
or sharing.listFolders
.
<EMAIL_ADDRESS_TO_INVITE>
should be replaced with the email address of the user to invite. Also, members is an array and can contain multiple users.