Skip to content

Commit 4dc5dc1

Browse files
feat: add find app item for shared link endpoint (box/box-openapi#514) (#426)
1 parent 53a6b59 commit 4dc5dc1

9 files changed

+126
-2
lines changed

.codegen.json

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

Box.Sdk.Gen/Client/BoxClient.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public class BoxClient : IBoxClient {
7777

7878
public ISharedLinksWebLinksManager SharedLinksWebLinks { get; }
7979

80+
public ISharedLinksAppItemsManager SharedLinksAppItems { get; }
81+
8082
public IUsersManager Users { get; }
8183

8284
public ISessionTerminationManager SessionTermination { get; }
@@ -192,6 +194,7 @@ public BoxClient(IAuthentication auth, NetworkSession? networkSession = default)
192194
WebLinks = new WebLinksManager(networkSession: this.NetworkSession) { Auth = this.Auth };
193195
TrashedWebLinks = new TrashedWebLinksManager(networkSession: this.NetworkSession) { Auth = this.Auth };
194196
SharedLinksWebLinks = new SharedLinksWebLinksManager(networkSession: this.NetworkSession) { Auth = this.Auth };
197+
SharedLinksAppItems = new SharedLinksAppItemsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
195198
Users = new UsersManager(networkSession: this.NetworkSession) { Auth = this.Auth };
196199
SessionTermination = new SessionTerminationManager(networkSession: this.NetworkSession) { Auth = this.Auth };
197200
Avatars = new AvatarsManager(networkSession: this.NetworkSession) { Auth = this.Auth };

Box.Sdk.Gen/Client/IBoxClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public interface IBoxClient {
7575

7676
public ISharedLinksWebLinksManager SharedLinksWebLinks { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
7777

78+
public ISharedLinksAppItemsManager SharedLinksAppItems { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
79+
7880
public IUsersManager Users { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
7981

8082
public ISessionTerminationManager SessionTermination { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using Box.Sdk.Gen.Internal;
5+
using Box.Sdk.Gen.Schemas;
6+
7+
namespace Box.Sdk.Gen.Managers {
8+
public class GetSharedItemAppItemsHeaders {
9+
/// <summary>
10+
/// A header containing the shared link and optional password for the
11+
/// shared link.
12+
///
13+
/// The format for this header is `shared_link=[link]&shared_link_password=[password]`
14+
/// </summary>
15+
public string Boxapi { get; }
16+
17+
/// <summary>
18+
/// Extra headers that will be included in the HTTP request.
19+
/// </summary>
20+
public Dictionary<string, string?> ExtraHeaders { get; }
21+
22+
public GetSharedItemAppItemsHeaders(string boxapi, Dictionary<string, string?>? extraHeaders = default) {
23+
Boxapi = boxapi;
24+
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
25+
}
26+
}
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using Box.Sdk.Gen.Internal;
5+
using Box.Sdk.Gen.Schemas;
6+
7+
namespace Box.Sdk.Gen.Managers {
8+
public interface ISharedLinksAppItemsManager {
9+
/// <summary>
10+
/// Returns the app item represented by a shared link.
11+
///
12+
/// The link can originate from the current enterprise or another.
13+
/// </summary>
14+
/// <param name="headers">
15+
/// Headers of getSharedItemAppItems method
16+
/// </param>
17+
/// <param name="cancellationToken">
18+
/// Token used for request cancellation.
19+
/// </param>
20+
public System.Threading.Tasks.Task<AppItem> GetSharedItemAppItemsAsync(GetSharedItemAppItemsHeaders headers, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");
21+
22+
}
23+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Box.Sdk.Gen;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using Box.Sdk.Gen.Internal;
5+
using Box.Sdk.Gen.Schemas;
6+
7+
namespace Box.Sdk.Gen.Managers {
8+
public class SharedLinksAppItemsManager : ISharedLinksAppItemsManager {
9+
public IAuthentication? Auth { get; init; }
10+
11+
public NetworkSession NetworkSession { get; }
12+
13+
public SharedLinksAppItemsManager(NetworkSession? networkSession = default) {
14+
NetworkSession = networkSession ?? new NetworkSession();
15+
}
16+
/// <summary>
17+
/// Returns the app item represented by a shared link.
18+
///
19+
/// The link can originate from the current enterprise or another.
20+
/// </summary>
21+
/// <param name="headers">
22+
/// Headers of getSharedItemAppItems method
23+
/// </param>
24+
/// <param name="cancellationToken">
25+
/// Token used for request cancellation.
26+
/// </param>
27+
public async System.Threading.Tasks.Task<AppItem> GetSharedItemAppItemsAsync(GetSharedItemAppItemsHeaders headers, System.Threading.CancellationToken? cancellationToken = null) {
28+
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { { "boxapi", StringUtils.ToStringRepresentation(headers.Boxapi) } }, headers.ExtraHeaders));
29+
FetchResponse response = await this.NetworkSession.NetworkClient.FetchAsync(options: new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/shared_items#app_items"), method: "GET", responseFormat: Box.Sdk.Gen.ResponseFormat.Json) { Headers = headersMap, Auth = this.Auth, NetworkSession = this.NetworkSession, CancellationToken = cancellationToken }).ConfigureAwait(false);
30+
return SimpleJsonSerializer.Deserialize<AppItem>(NullableUtils.Unwrap(response.Data));
31+
}
32+
33+
}
34+
}

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
* [Retention policy assignments](RetentionPolicyAssignments.md)
5050
* [Search](Search.md)
5151
* [Session termination](SessionTermination.md)
52+
* [Shared links app items](SharedLinksAppItems.md)
5253
* [Shared links files](SharedLinksFiles.md)
5354
* [Shared links folders](SharedLinksFolders.md)
5455
* [Shared links web links](SharedLinksWebLinks.md)

docs/SharedLinksAppItems.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ISharedLinksAppItemsManager
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+
- cancellationToken `System.Threading.CancellationToken?`
24+
- Token used for request cancellation.
25+
26+
27+
### Returns
28+
29+
This function returns a value of type `AppItem`.
30+
31+
Returns a full app item resource if the shared link is valid and
32+
the user has access to it.
33+
34+

docs/SharedLinksWebLinks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ await userClient.SharedLinksWebLinks.FindWebLinkForSharedLinkAsync(queryParams:
4141

4242
This function returns a value of type `WebLink`.
4343

44-
Returns a full file resource if the shared link is valid and
44+
Returns a full web link resource if the shared link is valid and
4545
the user has access to it.
4646

4747

0 commit comments

Comments
 (0)