Skip to content

Commit 6684e04

Browse files
author
Drew Parker
committed
fix: rename BoxFile.getPreviewLink to BoxFile.getExpiringEmbedLink
BREAKING CHANGE: Any calls to BoxFile.getPreviewLink will need to be updated to BoxFile.getExpiringEmbedLink. Closes #1
1 parent ab5d09a commit 6684e04

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/classes/BoxFile.cls

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class BoxFile extends BoxItem {
4444
private static String GET_VERSIONS_URL = 'files/{0}/versions';
4545
private static String FILE_TRASH_URL = 'files/{0}/trash';
4646
private static string ADD_COMMENT_URL = 'comments';
47-
private static string PREVIEW_LINK_URL = '/files/{0}?fields=expiring_embed_link';
47+
private static string EXPIRING_EMBED_LINK_URL = '/files/{0}?fields=expiring_embed_link';
4848

4949
/**
5050
* Constructs a BoxFile for a file with a given ID.
@@ -174,10 +174,13 @@ public class BoxFile extends BoxItem {
174174
*
175175
* @return preview link url, this link can be used in an embedded iframe to provide a rendering of the file.
176176
*/
177-
public String getPreviewLink() {
177+
public String getExpiringEmbedLink() {
178178
String url =
179179
this.api.baseUrl +
180-
String.format(PREVIEW_LINK_URL, new List<String>{ this.getId() });
180+
String.format(
181+
EXPIRING_EMBED_LINK_URL,
182+
new List<String>{ this.getId() }
183+
);
181184
BoxApiRequest request = new BoxApiRequest(
182185
this.api,
183186
url,
@@ -190,7 +193,7 @@ public class BoxFile extends BoxItem {
190193
HttpResponse response = request.send();
191194
String responseBody = BoxApiRequest.getBoxResourceResponseBody(
192195
response,
193-
'BoxFile.getPreviewLink'
196+
'BoxFile.getExpiringEmbedLink'
194197
);
195198

196199
BoxGenericJsonObject responseObject = new BoxGenericJsonObject(

src/classes/BoxFileTests.cls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public class BoxFileTests {
246246
System.assertEquals('tigers.jpeg', fileInfo.getValue('name'));
247247
}
248248

249-
public static testMethod void testGetPreviewLink() {
249+
public static testMethod void testGetExpiringEmbedLink() {
250250
String mockResponseBody = '{"type": "file", "id": "34122832467", "etag": "1", "expiring_embed_link": {"url": "https://app.box.com/preview/expiring_embed/gvoct6FE!Qz2rDey"}}';
251251
Test.setMock(
252252
HttpCalloutMock.class,
@@ -257,12 +257,12 @@ public class BoxFileTests {
257257
BoxFile file = new BoxFile(api, '5000948880');
258258

259259
Test.startTest();
260-
String previewLink = file.getPreviewLink();
260+
String expiringEmbedLink = file.getExpiringEmbedLink();
261261
Test.stopTest();
262262

263263
System.assertEquals(
264264
'https://app.box.com/preview/expiring_embed/gvoct6FE!Qz2rDey',
265-
previewLink
265+
expiringEmbedLink
266266
);
267267
}
268268

0 commit comments

Comments
 (0)