@Test public void createLink() throws OneDriveException { List<String> items = addThreeFiles().stream().map((item) -> item.id).collect(Collectors.toList()); String itemId = items.get(1); String expectedLink = oneDriveAPI.createLink(itemId, "embed").webUrl; String actualLink = graphClient.me().drive().items(itemId).createLink("embed", null).buildRequest().post().link.webUrl; assertEquals(expectedLink, actualLink); }
public SharingLink createLink(String itemId, String type) throws OneDriveException { if (type.equalsIgnoreCase("embed")) { return graphClient.me().drive().items(itemId).createLink("embed", "anonymous").buildRequest().post().link; } else if (type.equalsIgnoreCase("view")) { return graphClient.me().drive().items(itemId).createLink("view", "anonymous").buildRequest().post().link; } throw new OneDriveException("Link type must be either view or embed"); }
OneDriveAPI { public SharingLink createLink(String itemId, String type) throws OneDriveException { if (type.equalsIgnoreCase("embed")) { return graphClient.me().drive().items(itemId).createLink("embed", "anonymous").buildRequest().post().link; } else if (type.equalsIgnoreCase("view")) { return graphClient.me().drive().items(itemId).createLink("view", "anonymous").buildRequest().post().link; } throw new OneDriveException("Link type must be either view or embed"); } }
OneDriveAPI { public SharingLink createLink(String itemId, String type) throws OneDriveException { if (type.equalsIgnoreCase("embed")) { return graphClient.me().drive().items(itemId).createLink("embed", "anonymous").buildRequest().post().link; } else if (type.equalsIgnoreCase("view")) { return graphClient.me().drive().items(itemId).createLink("view", "anonymous").buildRequest().post().link; } throw new OneDriveException("Link type must be either view or embed"); } OneDriveAPI(String clientId, String clientSecret, String authCode, String redirectUrl);   OneDriveAPI(String clientId,
              String clientSecret,
              String accessToken,
              String refreshToken,
              long expirationTime,
              String redirectUrl); }
OneDriveAPI { public SharingLink createLink(String itemId, String type) throws OneDriveException { if (type.equalsIgnoreCase("embed")) { return graphClient.me().drive().items(itemId).createLink("embed", "anonymous").buildRequest().post().link; } else if (type.equalsIgnoreCase("view")) { return graphClient.me().drive().items(itemId).createLink("view", "anonymous").buildRequest().post().link; } throw new OneDriveException("Link type must be either view or embed"); } OneDriveAPI(String clientId, String clientSecret, String authCode, String redirectUrl);   OneDriveAPI(String clientId,
              String clientSecret,
              String accessToken,
              String refreshToken,
              long expirationTime,
              String redirectUrl); SharingLink createLink(String itemId, String type); void updateToken(OneDriveStoredToken newToken); void removeFolder(String fileId); void removeFile(String fileId); User getUser(); synchronized String getRootId(); synchronized String getUserId(); DriveItem createFolder(String parentId, String name, Calendar created); DriveItem copyFile(String parentId, String fileName, String fileId); DriveItem copyFolder(String parentId, String name, String folderId); OneDriveStoredToken getStoredToken(); @Deprecated String getNotificationUrl(); Subscription getSubscription(); DriveItem copy(String parentId, String fileName, String fileId, boolean isFile); IDriveItemCollectionPage getDriveItemCollectionPage(String folderId); @Deprecated List<DriveItem> getFiles(String folderId); ChangesIterator changes(String deltaToken); String getInsertUploadUrl(String parentId, String name, String conflictBehavior); DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior); DriveItem updateFileContent(String itemId, Calendar created, Calendar modified, InputStream inputStream); DeltaDriveFiles getAllFiles(); DriveItem updateFile(DriveItem driveItem); DriveItem getItem(String itemId); Drive getDrive(); String getBusinessPreviewLink(String itemId); SimpleChildIterator getSimpleChildIterator(Collection<HashSetCompatibleDriveItem> items); ChildIterator getChildIterator(String folderId); }
OneDriveAPI { public SharingLink createLink(String itemId, String type) throws OneDriveException { if (type.equalsIgnoreCase("embed")) { return graphClient.me().drive().items(itemId).createLink("embed", "anonymous").buildRequest().post().link; } else if (type.equalsIgnoreCase("view")) { return graphClient.me().drive().items(itemId).createLink("view", "anonymous").buildRequest().post().link; } throw new OneDriveException("Link type must be either view or embed"); } OneDriveAPI(String clientId, String clientSecret, String authCode, String redirectUrl);   OneDriveAPI(String clientId,
              String clientSecret,
              String accessToken,
              String refreshToken,
              long expirationTime,
              String redirectUrl); SharingLink createLink(String itemId, String type); void updateToken(OneDriveStoredToken newToken); void removeFolder(String fileId); void removeFile(String fileId); User getUser(); synchronized String getRootId(); synchronized String getUserId(); DriveItem createFolder(String parentId, String name, Calendar created); DriveItem copyFile(String parentId, String fileName, String fileId); DriveItem copyFolder(String parentId, String name, String folderId); OneDriveStoredToken getStoredToken(); @Deprecated String getNotificationUrl(); Subscription getSubscription(); DriveItem copy(String parentId, String fileName, String fileId, boolean isFile); IDriveItemCollectionPage getDriveItemCollectionPage(String folderId); @Deprecated List<DriveItem> getFiles(String folderId); ChangesIterator changes(String deltaToken); String getInsertUploadUrl(String parentId, String name, String conflictBehavior); DriveItem insert(String parentId, String fileName, Calendar created, Calendar modified, InputStream inputStream, String conflictBehavior); DriveItem updateFileContent(String itemId, Calendar created, Calendar modified, InputStream inputStream); DeltaDriveFiles getAllFiles(); DriveItem updateFile(DriveItem driveItem); DriveItem getItem(String itemId); Drive getDrive(); String getBusinessPreviewLink(String itemId); SimpleChildIterator getSimpleChildIterator(Collection<HashSetCompatibleDriveItem> items); ChildIterator getChildIterator(String folderId); final static String SCOPES; }