Skip to content

Commit bb84e79

Browse files
committed
feat: add find app item for shared link endpoint (box/box-openapi#514)
1 parent 772a12b commit bb84e79

File tree

7 files changed

+188
-2
lines changed

7 files changed

+188
-2
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "41feeaa", "specHash": "6782a0d", "version": "0.5.0" }
1+
{ "engineHash": "41feeaa", "specHash": "3dc6f70", "version": "0.5.0" }

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ the SDK are available by topic:
4949
* [Retentionpolicyassignments](retentionpolicyassignments.md)
5050
* [Search](search.md)
5151
* [Sessiontermination](sessiontermination.md)
52+
* [Sharedlinksappitems](sharedlinksappitems.md)
5253
* [Sharedlinksfiles](sharedlinksfiles.md)
5354
* [Sharedlinksfolders](sharedlinksfolders.md)
5455
* [Sharedlinksweblinks](sharedlinksweblinks.md)

docs/sharedlinksappitems.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SharedLinksAppItemsManager
2+
3+
4+
- [Find app item for shared link](#find-app-item-for-shared-link)
5+
6+
## Find app item for shared link
7+
8+
Returns the app item represented by a shared link.
9+
10+
The link can originate from the current enterprise or another.
11+
12+
This operation is performed by calling function `getSharedItemAppItems`.
13+
14+
See the endpoint docs at
15+
[API Reference](https://developer.box.com/reference/get-shared-items--app-items/).
16+
17+
*Currently we don't have an example for calling `getSharedItemAppItems` in integration tests*
18+
19+
### Arguments
20+
21+
- headers `GetSharedItemAppItemsHeaders`
22+
- Headers of getSharedItemAppItems method
23+
24+
25+
### Returns
26+
27+
This function returns a value of type `AppItem`.
28+
29+
Returns a full app item resource if the shared link is valid and
30+
the user has access to it.
31+
32+

docs/sharedlinksweblinks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ userClient.getSharedLinksWebLinks().findWebLinkForSharedLink(new FindWebLinkForS
3939

4040
This function returns a value of type `WebLink`.
4141

42-
Returns a full file resource if the shared link is valid and
42+
Returns a full web link resource if the shared link is valid and
4343
the user has access to it.
4444

4545

src/main/java/com/box/sdkgen/client/BoxClient.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.box.sdkgen.managers.retentionpolicyassignments.RetentionPolicyAssignmentsManager;
4848
import com.box.sdkgen.managers.search.SearchManager;
4949
import com.box.sdkgen.managers.sessiontermination.SessionTerminationManager;
50+
import com.box.sdkgen.managers.sharedlinksappitems.SharedLinksAppItemsManager;
5051
import com.box.sdkgen.managers.sharedlinksfiles.SharedLinksFilesManager;
5152
import com.box.sdkgen.managers.sharedlinksfolders.SharedLinksFoldersManager;
5253
import com.box.sdkgen.managers.sharedlinksweblinks.SharedLinksWebLinksManager;
@@ -159,6 +160,8 @@ public class BoxClient {
159160

160161
public final SharedLinksWebLinksManager sharedLinksWebLinks;
161162

163+
public final SharedLinksAppItemsManager sharedLinksAppItems;
164+
162165
public final UsersManager users;
163166

164167
public final SessionTerminationManager sessionTermination;
@@ -412,6 +415,11 @@ public BoxClient(Authentication auth) {
412415
.auth(this.auth)
413416
.networkSession(this.networkSession)
414417
.build();
418+
this.sharedLinksAppItems =
419+
new SharedLinksAppItemsManager.SharedLinksAppItemsManagerBuilder()
420+
.auth(this.auth)
421+
.networkSession(this.networkSession)
422+
.build();
415423
this.users =
416424
new UsersManager.UsersManagerBuilder()
417425
.auth(this.auth)
@@ -785,6 +793,11 @@ protected BoxClient(BoxClientBuilder builder) {
785793
.auth(this.auth)
786794
.networkSession(this.networkSession)
787795
.build();
796+
this.sharedLinksAppItems =
797+
new SharedLinksAppItemsManager.SharedLinksAppItemsManagerBuilder()
798+
.auth(this.auth)
799+
.networkSession(this.networkSession)
800+
.build();
788801
this.users =
789802
new UsersManager.UsersManagerBuilder()
790803
.auth(this.auth)
@@ -1187,6 +1200,10 @@ public SharedLinksWebLinksManager getSharedLinksWebLinks() {
11871200
return sharedLinksWebLinks;
11881201
}
11891202

1203+
public SharedLinksAppItemsManager getSharedLinksAppItems() {
1204+
return sharedLinksAppItems;
1205+
}
1206+
11901207
public UsersManager getUsers() {
11911208
return users;
11921209
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.box.sdkgen.managers.sharedlinksappitems;
2+
3+
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
4+
5+
import java.util.Map;
6+
7+
public class GetSharedItemAppItemsHeaders {
8+
9+
public final String boxapi;
10+
11+
public Map<String, String> extraHeaders;
12+
13+
public GetSharedItemAppItemsHeaders(String boxapi) {
14+
this.boxapi = boxapi;
15+
this.extraHeaders = mapOf();
16+
}
17+
18+
protected GetSharedItemAppItemsHeaders(GetSharedItemAppItemsHeadersBuilder builder) {
19+
this.boxapi = builder.boxapi;
20+
this.extraHeaders = builder.extraHeaders;
21+
}
22+
23+
public String getBoxapi() {
24+
return boxapi;
25+
}
26+
27+
public Map<String, String> getExtraHeaders() {
28+
return extraHeaders;
29+
}
30+
31+
public static class GetSharedItemAppItemsHeadersBuilder {
32+
33+
protected final String boxapi;
34+
35+
protected Map<String, String> extraHeaders;
36+
37+
public GetSharedItemAppItemsHeadersBuilder(String boxapi) {
38+
this.boxapi = boxapi;
39+
this.extraHeaders = mapOf();
40+
}
41+
42+
public GetSharedItemAppItemsHeadersBuilder extraHeaders(Map<String, String> extraHeaders) {
43+
this.extraHeaders = extraHeaders;
44+
return this;
45+
}
46+
47+
public GetSharedItemAppItemsHeaders build() {
48+
return new GetSharedItemAppItemsHeaders(this);
49+
}
50+
}
51+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package com.box.sdkgen.managers.sharedlinksappitems;
2+
3+
import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
4+
import static com.box.sdkgen.internal.utils.UtilsManager.entryOf;
5+
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
6+
import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps;
7+
import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams;
8+
9+
import com.box.sdkgen.networking.auth.Authentication;
10+
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
11+
import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
12+
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
13+
import com.box.sdkgen.networking.network.NetworkSession;
14+
import com.box.sdkgen.schemas.appitem.AppItem;
15+
import com.box.sdkgen.serialization.json.JsonManager;
16+
import java.util.Map;
17+
18+
public class SharedLinksAppItemsManager {
19+
20+
public Authentication auth;
21+
22+
public NetworkSession networkSession;
23+
24+
public SharedLinksAppItemsManager() {
25+
this.networkSession = new NetworkSession();
26+
}
27+
28+
protected SharedLinksAppItemsManager(SharedLinksAppItemsManagerBuilder builder) {
29+
this.auth = builder.auth;
30+
this.networkSession = builder.networkSession;
31+
}
32+
33+
public AppItem getSharedItemAppItems(GetSharedItemAppItemsHeaders headers) {
34+
Map<String, String> headersMap =
35+
prepareParams(
36+
mergeMaps(
37+
mapOf(entryOf("boxapi", convertToString(headers.getBoxapi()))),
38+
headers.getExtraHeaders()));
39+
FetchResponse response =
40+
this.networkSession
41+
.getNetworkClient()
42+
.fetch(
43+
new FetchOptions.FetchOptionsBuilder(
44+
String.join(
45+
"",
46+
this.networkSession.getBaseUrls().getBaseUrl(),
47+
"/2.0/shared_items#app_items"),
48+
"GET")
49+
.headers(headersMap)
50+
.responseFormat(ResponseFormat.JSON)
51+
.auth(this.auth)
52+
.networkSession(this.networkSession)
53+
.build());
54+
return JsonManager.deserialize(response.getData(), AppItem.class);
55+
}
56+
57+
public Authentication getAuth() {
58+
return auth;
59+
}
60+
61+
public NetworkSession getNetworkSession() {
62+
return networkSession;
63+
}
64+
65+
public static class SharedLinksAppItemsManagerBuilder {
66+
67+
protected Authentication auth;
68+
69+
protected NetworkSession networkSession;
70+
71+
public SharedLinksAppItemsManagerBuilder auth(Authentication auth) {
72+
this.auth = auth;
73+
return this;
74+
}
75+
76+
public SharedLinksAppItemsManagerBuilder networkSession(NetworkSession networkSession) {
77+
this.networkSession = networkSession;
78+
return this;
79+
}
80+
81+
public SharedLinksAppItemsManager build() {
82+
return new SharedLinksAppItemsManager(this);
83+
}
84+
}
85+
}

0 commit comments

Comments
 (0)