Skip to content

Commit e7d6964

Browse files
committed
feat: Add Hub Document API (box/box-openapi#587)
1 parent 3e4661c commit e7d6964

File tree

80 files changed

+2669
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2669
-1
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "bc04b80", "specHash": "f2523d5", "version": "10.6.0" }
1+
{ "engineHash": "bc04b80", "specHash": "57b3004", "version": "10.6.0" }

Box.Sdk.Gen.Net/Client/BoxClient.cs

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

168168
public IHubItemsManager HubItems { get; }
169169

170+
public IHubDocumentManager HubDocument { get; }
171+
170172
public IShieldListsManager ShieldLists { get; }
171173

172174
public IArchivesManager Archives { get; }
@@ -255,6 +257,7 @@ public BoxClient(IAuthentication auth, NetworkSession? networkSession = default)
255257
Hubs = new HubsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
256258
HubCollaborations = new HubCollaborationsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
257259
HubItems = new HubItemsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
260+
HubDocument = new HubDocumentManager(networkSession: this.NetworkSession) { Auth = this.Auth };
258261
ShieldLists = new ShieldListsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
259262
Archives = new ArchivesManager(networkSession: this.NetworkSession) { Auth = this.Auth };
260263
ExternalUsers = new ExternalUsersManager(networkSession: this.NetworkSession) { Auth = this.Auth };

Box.Sdk.Gen.Net/Client/IBoxClient.cs

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

166166
public IHubItemsManager HubItems { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
167167

168+
public IHubDocumentManager HubDocument { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
169+
168170
public IShieldListsManager ShieldLists { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
169171

170172
public IArchivesManager Archives { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
using Box.Sdk.Gen.Parameters;
7+
8+
namespace Box.Sdk.Gen.Managers {
9+
public class GetHubDocumentBlocksV2025R0Headers {
10+
/// <summary>
11+
/// Version header.
12+
/// </summary>
13+
public StringEnum<BoxVersionHeaderV2025R0> BoxVersion { get; }
14+
15+
/// <summary>
16+
/// Extra headers that will be included in the HTTP request.
17+
/// </summary>
18+
public Dictionary<string, string?> ExtraHeaders { get; }
19+
20+
public GetHubDocumentBlocksV2025R0Headers(BoxVersionHeaderV2025R0 boxVersion = BoxVersionHeaderV2025R0._20250, Dictionary<string, string?>? extraHeaders = default) {
21+
BoxVersion = boxVersion;
22+
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
23+
}
24+
}
25+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
using Box.Sdk.Gen.Parameters;
7+
8+
namespace Box.Sdk.Gen.Managers {
9+
public class GetHubDocumentBlocksV2025R0QueryParams {
10+
/// <summary>
11+
/// The unique identifier that represent a hub.
12+
///
13+
/// The ID for any hub can be determined
14+
/// by visiting this hub in the web application
15+
/// and copying the ID from the URL. For example,
16+
/// for the URL `https://*.app.box.com/hubs/123`
17+
/// the `hub_id` is `123`.
18+
/// </summary>
19+
public string HubId { get; }
20+
21+
/// <summary>
22+
/// The unique identifier of a page within the Box Hub.
23+
/// </summary>
24+
public string PageId { get; }
25+
26+
/// <summary>
27+
/// Defines the position marker at which to begin returning results. This is
28+
/// used when paginating using marker-based pagination.
29+
/// </summary>
30+
public string? Marker { get; init; }
31+
32+
/// <summary>
33+
/// The maximum number of items to return per page.
34+
/// </summary>
35+
public long? Limit { get; init; }
36+
37+
public GetHubDocumentBlocksV2025R0QueryParams(string hubId, string pageId) {
38+
HubId = hubId;
39+
PageId = pageId;
40+
}
41+
}
42+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
using Box.Sdk.Gen.Parameters;
7+
8+
namespace Box.Sdk.Gen.Managers {
9+
public class GetHubDocumentPagesV2025R0Headers {
10+
/// <summary>
11+
/// Version header.
12+
/// </summary>
13+
public StringEnum<BoxVersionHeaderV2025R0> BoxVersion { get; }
14+
15+
/// <summary>
16+
/// Extra headers that will be included in the HTTP request.
17+
/// </summary>
18+
public Dictionary<string, string?> ExtraHeaders { get; }
19+
20+
public GetHubDocumentPagesV2025R0Headers(BoxVersionHeaderV2025R0 boxVersion = BoxVersionHeaderV2025R0._20250, Dictionary<string, string?>? extraHeaders = default) {
21+
BoxVersion = boxVersion;
22+
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
23+
}
24+
}
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
using Box.Sdk.Gen.Parameters;
7+
8+
namespace Box.Sdk.Gen.Managers {
9+
public class GetHubDocumentPagesV2025R0QueryParams {
10+
/// <summary>
11+
/// The unique identifier that represent a hub.
12+
///
13+
/// The ID for any hub can be determined
14+
/// by visiting this hub in the web application
15+
/// and copying the ID from the URL. For example,
16+
/// for the URL `https://*.app.box.com/hubs/123`
17+
/// the `hub_id` is `123`.
18+
/// </summary>
19+
public string HubId { get; }
20+
21+
/// <summary>
22+
/// Defines the position marker at which to begin returning results. This is
23+
/// used when paginating using marker-based pagination.
24+
/// </summary>
25+
public string? Marker { get; init; }
26+
27+
/// <summary>
28+
/// The maximum number of items to return per page.
29+
/// </summary>
30+
public long? Limit { get; init; }
31+
32+
public GetHubDocumentPagesV2025R0QueryParams(string hubId) {
33+
HubId = hubId;
34+
}
35+
}
36+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
using Box.Sdk.Gen.Parameters;
7+
8+
namespace Box.Sdk.Gen.Managers {
9+
public class HubDocumentManager : IHubDocumentManager {
10+
public IAuthentication? Auth { get; init; }
11+
12+
public NetworkSession NetworkSession { get; }
13+
14+
public HubDocumentManager(NetworkSession? networkSession = default) {
15+
NetworkSession = networkSession ?? new NetworkSession();
16+
}
17+
/// <summary>
18+
/// Retrieves a list of Hub Document Pages for the specified hub.
19+
/// Includes both root-level pages and sub pages.
20+
/// </summary>
21+
/// <param name="queryParams">
22+
/// Query parameters of getHubDocumentPagesV2025R0 method
23+
/// </param>
24+
/// <param name="headers">
25+
/// Headers of getHubDocumentPagesV2025R0 method
26+
/// </param>
27+
/// <param name="cancellationToken">
28+
/// Token used for request cancellation.
29+
/// </param>
30+
public async System.Threading.Tasks.Task<HubDocumentPagesV2025R0> GetHubDocumentPagesV2025R0Async(GetHubDocumentPagesV2025R0QueryParams queryParams, GetHubDocumentPagesV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
31+
headers = headers ?? new GetHubDocumentPagesV2025R0Headers();
32+
Dictionary<string, string> queryParamsMap = Utils.PrepareParams(map: new Dictionary<string, string?>() { { "hub_id", StringUtils.ToStringRepresentation(queryParams.HubId) }, { "marker", StringUtils.ToStringRepresentation(queryParams.Marker) }, { "limit", StringUtils.ToStringRepresentation(queryParams.Limit) } });
33+
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { { "box-version", StringUtils.ToStringRepresentation(headers.BoxVersion) } }, headers.ExtraHeaders));
34+
FetchResponse response = await this.NetworkSession.NetworkClient.FetchAsync(options: new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/hub_document_pages"), method: "GET", responseFormat: Box.Sdk.Gen.ResponseFormat.Json) { Parameters = queryParamsMap, Headers = headersMap, Auth = this.Auth, NetworkSession = this.NetworkSession, CancellationToken = cancellationToken }).ConfigureAwait(false);
35+
return SimpleJsonSerializer.Deserialize<HubDocumentPagesV2025R0>(NullableUtils.Unwrap(response.Data));
36+
}
37+
38+
/// <summary>
39+
/// Retrieves a sorted list of all Hub Document Blocks on a specified page in the hub document, excluding items.
40+
/// Blocks are hierarchically organized by their `parent_id`.
41+
/// Blocks are sorted in order based on user specification in the user interface.
42+
/// The response will only include content blocks that belong to the specified page. This will not include sub pages or sub page content blocks.
43+
/// </summary>
44+
/// <param name="queryParams">
45+
/// Query parameters of getHubDocumentBlocksV2025R0 method
46+
/// </param>
47+
/// <param name="headers">
48+
/// Headers of getHubDocumentBlocksV2025R0 method
49+
/// </param>
50+
/// <param name="cancellationToken">
51+
/// Token used for request cancellation.
52+
/// </param>
53+
public async System.Threading.Tasks.Task<HubDocumentBlocksV2025R0> GetHubDocumentBlocksV2025R0Async(GetHubDocumentBlocksV2025R0QueryParams queryParams, GetHubDocumentBlocksV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
54+
headers = headers ?? new GetHubDocumentBlocksV2025R0Headers();
55+
Dictionary<string, string> queryParamsMap = Utils.PrepareParams(map: new Dictionary<string, string?>() { { "hub_id", StringUtils.ToStringRepresentation(queryParams.HubId) }, { "page_id", StringUtils.ToStringRepresentation(queryParams.PageId) }, { "marker", StringUtils.ToStringRepresentation(queryParams.Marker) }, { "limit", StringUtils.ToStringRepresentation(queryParams.Limit) } });
56+
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { { "box-version", StringUtils.ToStringRepresentation(headers.BoxVersion) } }, headers.ExtraHeaders));
57+
FetchResponse response = await this.NetworkSession.NetworkClient.FetchAsync(options: new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/hub_document_blocks"), method: "GET", responseFormat: Box.Sdk.Gen.ResponseFormat.Json) { Parameters = queryParamsMap, Headers = headersMap, Auth = this.Auth, NetworkSession = this.NetworkSession, CancellationToken = cancellationToken }).ConfigureAwait(false);
58+
return SimpleJsonSerializer.Deserialize<HubDocumentBlocksV2025R0>(NullableUtils.Unwrap(response.Data));
59+
}
60+
61+
}
62+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
using Box.Sdk.Gen.Parameters;
7+
8+
namespace Box.Sdk.Gen.Managers {
9+
public interface IHubDocumentManager {
10+
/// <summary>
11+
/// Retrieves a list of Hub Document Pages for the specified hub.
12+
/// Includes both root-level pages and sub pages.
13+
/// </summary>
14+
/// <param name="queryParams">
15+
/// Query parameters of getHubDocumentPagesV2025R0 method
16+
/// </param>
17+
/// <param name="headers">
18+
/// Headers of getHubDocumentPagesV2025R0 method
19+
/// </param>
20+
/// <param name="cancellationToken">
21+
/// Token used for request cancellation.
22+
/// </param>
23+
public System.Threading.Tasks.Task<HubDocumentPagesV2025R0> GetHubDocumentPagesV2025R0Async(GetHubDocumentPagesV2025R0QueryParams queryParams, GetHubDocumentPagesV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");
24+
25+
/// <summary>
26+
/// Retrieves a sorted list of all Hub Document Blocks on a specified page in the hub document, excluding items.
27+
/// Blocks are hierarchically organized by their `parent_id`.
28+
/// Blocks are sorted in order based on user specification in the user interface.
29+
/// The response will only include content blocks that belong to the specified page. This will not include sub pages or sub page content blocks.
30+
/// </summary>
31+
/// <param name="queryParams">
32+
/// Query parameters of getHubDocumentBlocksV2025R0 method
33+
/// </param>
34+
/// <param name="headers">
35+
/// Headers of getHubDocumentBlocksV2025R0 method
36+
/// </param>
37+
/// <param name="cancellationToken">
38+
/// Token used for request cancellation.
39+
/// </param>
40+
public System.Threading.Tasks.Task<HubDocumentBlocksV2025R0> GetHubDocumentBlocksV2025R0Async(GetHubDocumentBlocksV2025R0QueryParams queryParams, GetHubDocumentBlocksV2025R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");
41+
42+
}
43+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using Box.Sdk.Gen;
2+
using System.Text.Json.Serialization;
3+
using Box.Sdk.Gen.Internal;
4+
using System.Collections.Generic;
5+
using Box.Sdk.Gen.Schemas;
6+
7+
namespace Box.Sdk.Gen.Schemas {
8+
public class HubCalloutBoxTextBlockV2025R0 : HubDocumentBlockV2025R0, ISerializable {
9+
/// <summary>
10+
/// The type of this block. The value is always `callout_box`.
11+
/// </summary>
12+
[JsonPropertyName("type")]
13+
[JsonConverter(typeof(StringEnumConverter<HubCalloutBoxTextBlockV2025R0TypeField>))]
14+
public StringEnum<HubCalloutBoxTextBlockV2025R0TypeField> Type { get; }
15+
16+
/// <summary>
17+
/// Text content of the block. Includes rich text formatting.
18+
/// </summary>
19+
[JsonPropertyName("fragment")]
20+
public string Fragment { get; }
21+
22+
public HubCalloutBoxTextBlockV2025R0(string id, string fragment, HubCalloutBoxTextBlockV2025R0TypeField type = HubCalloutBoxTextBlockV2025R0TypeField.CalloutBox) : base(id) {
23+
Type = type;
24+
Fragment = fragment;
25+
}
26+
27+
[JsonConstructorAttribute]
28+
internal HubCalloutBoxTextBlockV2025R0(string id, string fragment, StringEnum<HubCalloutBoxTextBlockV2025R0TypeField> type) : base(id) {
29+
Type = HubCalloutBoxTextBlockV2025R0TypeField.CalloutBox;
30+
Fragment = fragment;
31+
}
32+
internal new string? RawJson { get; set; } = default;
33+
34+
void ISerializable.SetJson(string json) {
35+
RawJson = json;
36+
}
37+
38+
string? ISerializable.GetJson() {
39+
return RawJson;
40+
}
41+
42+
/// <summary>
43+
/// Returns raw json response returned from the API.
44+
/// </summary>
45+
public new Dictionary<string, object?>? GetRawData() {
46+
return SimpleJsonSerializer.GetAllFields(this);
47+
}
48+
49+
}
50+
}

0 commit comments

Comments
 (0)