Skip to content

Commit a7ca8d6

Browse files
feat: Add Convert Note API (box/box-codegen#955) (#1536)
1 parent f45f926 commit a7ca8d6

38 files changed

Lines changed: 932 additions & 1 deletion

File tree

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "4de40e1", "specHash": "e0ffc4a", "version": "10.13.0" }
1+
{ "engineHash": "5a7add6", "specHash": "d028758", "version": "10.13.0" }

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

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

178178
public IAutomateWorkflowsManager AutomateWorkflows { get; }
179179

180+
public INotesManager Notes { get; }
181+
180182
public BoxClient(IAuthentication auth, NetworkSession? networkSession = default) {
181183
Auth = auth;
182184
NetworkSession = networkSession ?? new NetworkSession(baseUrls: new BaseUrls());
@@ -264,6 +266,7 @@ public BoxClient(IAuthentication auth, NetworkSession? networkSession = default)
264266
Archives = new ArchivesManager(networkSession: this.NetworkSession) { Auth = this.Auth };
265267
ExternalUsers = new ExternalUsersManager(networkSession: this.NetworkSession) { Auth = this.Auth };
266268
AutomateWorkflows = new AutomateWorkflowsManager(networkSession: this.NetworkSession) { Auth = this.Auth };
269+
Notes = new NotesManager(networkSession: this.NetworkSession) { Auth = this.Auth };
267270
}
268271
/// <summary>
269272
/// Make a custom http request using the client authentication and network session.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,7 @@ public interface IBoxClient {
175175

176176
public IAutomateWorkflowsManager AutomateWorkflows { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
177177

178+
public INotesManager Notes { get => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it."); }
179+
178180
}
179181
}
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 CreateNoteConvertV2026R0Headers {
10+
/// <summary>
11+
/// Version header.
12+
/// </summary>
13+
public StringEnum<BoxVersionHeaderV2026R0> 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 CreateNoteConvertV2026R0Headers(BoxVersionHeaderV2026R0 boxVersion = BoxVersionHeaderV2026R0._20260, Dictionary<string, string?>? extraHeaders = default) {
21+
BoxVersion = boxVersion;
22+
ExtraHeaders = extraHeaders ?? new Dictionary<string, string?>() { };
23+
}
24+
}
25+
}
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 interface INotesManager {
10+
/// <summary>
11+
/// Creates a Box Note (`.boxnote` file) from supported source content. See the `content_format` field for supported formats.
12+
/// </summary>
13+
/// <param name="requestBody">
14+
/// Request body of createNoteConvertV2026R0 method
15+
/// </param>
16+
/// <param name="headers">
17+
/// Headers of createNoteConvertV2026R0 method
18+
/// </param>
19+
/// <param name="cancellationToken">
20+
/// Token used for request cancellation.
21+
/// </param>
22+
public System.Threading.Tasks.Task<NotesConvertResponseV2026R0> CreateNoteConvertV2026R0Async(NotesConvertRequestBodyV2026R0 requestBody, CreateNoteConvertV2026R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) => throw new System.NotImplementedException("This method needs to be implemented by the derived class before calling it.");
23+
24+
}
25+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 NotesManager : INotesManager {
10+
public IAuthentication? Auth { get; init; }
11+
12+
public NetworkSession NetworkSession { get; }
13+
14+
public NotesManager(NetworkSession? networkSession = default) {
15+
NetworkSession = networkSession ?? new NetworkSession();
16+
}
17+
/// <summary>
18+
/// Creates a Box Note (`.boxnote` file) from supported source content. See the `content_format` field for supported formats.
19+
/// </summary>
20+
/// <param name="requestBody">
21+
/// Request body of createNoteConvertV2026R0 method
22+
/// </param>
23+
/// <param name="headers">
24+
/// Headers of createNoteConvertV2026R0 method
25+
/// </param>
26+
/// <param name="cancellationToken">
27+
/// Token used for request cancellation.
28+
/// </param>
29+
public async System.Threading.Tasks.Task<NotesConvertResponseV2026R0> CreateNoteConvertV2026R0Async(NotesConvertRequestBodyV2026R0 requestBody, CreateNoteConvertV2026R0Headers? headers = default, System.Threading.CancellationToken? cancellationToken = null) {
30+
headers = headers ?? new CreateNoteConvertV2026R0Headers();
31+
Dictionary<string, string> headersMap = Utils.PrepareParams(map: DictionaryUtils.MergeDictionaries(new Dictionary<string, string?>() { { "box-version", StringUtils.ToStringRepresentation(headers.BoxVersion) } }, headers.ExtraHeaders));
32+
FetchResponse response = await this.NetworkSession.NetworkClient.FetchAsync(options: new FetchOptions(url: string.Concat(this.NetworkSession.BaseUrls.BaseUrl, "/2.0/notes/convert"), method: "POST", contentType: "application/json", responseFormat: Box.Sdk.Gen.ResponseFormat.Json) { Headers = headersMap, Data = SimpleJsonSerializer.Serialize(requestBody), Auth = this.Auth, NetworkSession = this.NetworkSession, CancellationToken = cancellationToken }).ConfigureAwait(false);
33+
return SimpleJsonSerializer.Deserialize<NotesConvertResponseV2026R0>(NullableUtils.Unwrap(response.Data));
34+
}
35+
36+
}
37+
}

Box.Sdk.Gen.Net/Schemas/SignRequest/SignRequestStatusField.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public enum SignRequestStatusField {
1818
Cancelled,
1919
[Description("declined")]
2020
Declined,
21+
[Description("error")]
22+
Error,
2123
[Description("error_converting")]
2224
ErrorConverting,
2325
[Description("error_sending")]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using Box.Sdk.Gen;
2+
using System.Text.Json.Serialization;
3+
using Box.Sdk.Gen.Internal;
4+
using System.Collections.Generic;
5+
6+
namespace Box.Sdk.Gen.Schemas {
7+
public class FolderReferenceV2026R0 : ISerializable {
8+
/// <summary>
9+
/// The value will always be `folder`.
10+
/// </summary>
11+
[JsonPropertyName("type")]
12+
[JsonConverter(typeof(StringEnumConverter<FolderReferenceV2026R0TypeField>))]
13+
public StringEnum<FolderReferenceV2026R0TypeField> Type { get; }
14+
15+
/// <summary>
16+
/// ID of the folder.
17+
/// </summary>
18+
[JsonPropertyName("id")]
19+
public string Id { get; }
20+
21+
public FolderReferenceV2026R0(string id, FolderReferenceV2026R0TypeField type = FolderReferenceV2026R0TypeField.Folder) {
22+
Type = type;
23+
Id = id;
24+
}
25+
26+
[JsonConstructorAttribute]
27+
internal FolderReferenceV2026R0(string id, StringEnum<FolderReferenceV2026R0TypeField> type) {
28+
Type = FolderReferenceV2026R0TypeField.Folder;
29+
Id = id;
30+
}
31+
internal string? RawJson { get; set; } = default;
32+
33+
void ISerializable.SetJson(string json) {
34+
RawJson = json;
35+
}
36+
37+
string? ISerializable.GetJson() {
38+
return RawJson;
39+
}
40+
41+
/// <summary>
42+
/// Returns raw json response returned from the API.
43+
/// </summary>
44+
public Dictionary<string, object?>? GetRawData() {
45+
return SimpleJsonSerializer.GetAllFields(this);
46+
}
47+
48+
}
49+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System.ComponentModel;
2+
using Box.Sdk.Gen.Internal;
3+
4+
namespace Box.Sdk.Gen.Schemas {
5+
public enum FolderReferenceV2026R0TypeField {
6+
[Description("folder")]
7+
Folder
8+
}
9+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 NotesConvertRequestBodyV2026R0 : ISerializable {
9+
/// <summary>
10+
/// The content to convert to a note. See the `content_format` field for supported formats.
11+
/// </summary>
12+
[JsonPropertyName("content")]
13+
public string Content { get; }
14+
15+
/// <summary>
16+
/// Format of the content to convert.
17+
/// </summary>
18+
[JsonPropertyName("content_format")]
19+
[JsonConverter(typeof(StringEnumConverter<NotesConvertRequestBodyV2026R0ContentFormatField>))]
20+
public StringEnum<NotesConvertRequestBodyV2026R0ContentFormatField> ContentFormat { get; }
21+
22+
[JsonPropertyName("parent")]
23+
public FolderReferenceV2026R0 Parent { get; }
24+
25+
/// <summary>
26+
/// The name for the created note. The `.boxnote` extension is appended automatically.
27+
/// </summary>
28+
[JsonPropertyName("name")]
29+
public string Name { get; }
30+
31+
public NotesConvertRequestBodyV2026R0(string content, FolderReferenceV2026R0 parent, string name, NotesConvertRequestBodyV2026R0ContentFormatField contentFormat = NotesConvertRequestBodyV2026R0ContentFormatField.Markdown) {
32+
Content = content;
33+
ContentFormat = contentFormat;
34+
Parent = parent;
35+
Name = name;
36+
}
37+
38+
[JsonConstructorAttribute]
39+
internal NotesConvertRequestBodyV2026R0(string content, FolderReferenceV2026R0 parent, string name, StringEnum<NotesConvertRequestBodyV2026R0ContentFormatField> contentFormat) {
40+
Content = content;
41+
ContentFormat = NotesConvertRequestBodyV2026R0ContentFormatField.Markdown;
42+
Parent = parent;
43+
Name = name;
44+
}
45+
internal string? RawJson { get; set; } = default;
46+
47+
void ISerializable.SetJson(string json) {
48+
RawJson = json;
49+
}
50+
51+
string? ISerializable.GetJson() {
52+
return RawJson;
53+
}
54+
55+
/// <summary>
56+
/// Returns raw json response returned from the API.
57+
/// </summary>
58+
public Dictionary<string, object?>? GetRawData() {
59+
return SimpleJsonSerializer.GetAllFields(this);
60+
}
61+
62+
}
63+
}

0 commit comments

Comments
 (0)