Skip to content

Commit e07dff3

Browse files
feat(boxsdkgen): Convert Note Public API (box/box-openapi#599) (#1853)
1 parent 6735f5e commit e07dff3

12 files changed

Lines changed: 788 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": "5.11.0" }
1+
{ "engineHash": "4de40e1", "specHash": "8b85e74", "version": "5.11.0" }

docs/sdkgen/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ the SDK are available by topic:
2626
* [Collaborationallowlistexempttargets](collaborationallowlistexempttargets.md)
2727
* [Collections](collections.md)
2828
* [Comments](comments.md)
29+
* [Convertmarkdowntoboxnote](convertmarkdowntoboxnote.md)
2930
* [Devicepinners](devicepinners.md)
3031
* [Docgen](docgen.md)
3132
* [Docgentemplate](docgentemplate.md)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# ConvertMarkdownToBoxNoteManager
2+
3+
4+
- [Convert content to Box Note](#convert-content-to-box-note)
5+
6+
## Convert content to Box Note
7+
8+
Creates a Box Note (`.boxnote` file) from supported source content. See the `content_format` field for supported formats.
9+
10+
This operation is performed by calling function `createNoteConvertV2026R0`.
11+
12+
See the endpoint docs at
13+
[API Reference](https://developer.box.com/reference/v2026.0/post-notes-convert/).
14+
15+
*Currently we don't have an example for calling `createNoteConvertV2026R0` in integration tests*
16+
17+
### Arguments
18+
19+
- requestBody `NotesConvertRequestBodyV2026R0`
20+
- Request body of createNoteConvertV2026R0 method
21+
- headers `CreateNoteConvertV2026R0Headers`
22+
- Headers of createNoteConvertV2026R0 method
23+
24+
25+
### Returns
26+
27+
This function returns a value of type `NotesConvertResponseV2026R0`.
28+
29+
The note was created successfully.
30+
31+

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.box.sdkgen.managers.collaborationallowlistexempttargets.CollaborationAllowlistExemptTargetsManager;
1717
import com.box.sdkgen.managers.collections.CollectionsManager;
1818
import com.box.sdkgen.managers.comments.CommentsManager;
19+
import com.box.sdkgen.managers.convertmarkdowntoboxnote.ConvertMarkdownToBoxNoteManager;
1920
import com.box.sdkgen.managers.devicepinners.DevicePinnersManager;
2021
import com.box.sdkgen.managers.docgen.DocgenManager;
2122
import com.box.sdkgen.managers.docgentemplate.DocgenTemplateManager;
@@ -273,6 +274,8 @@ public class BoxClient {
273274

274275
public final AutomateWorkflowsManager automateWorkflows;
275276

277+
public final ConvertMarkdownToBoxNoteManager convertMarkdownToBoxNote;
278+
276279
public BoxClient(Authentication auth) {
277280
this.auth = auth;
278281
this.networkSession = new NetworkSession.Builder().baseUrls(new BaseUrls()).build();
@@ -626,6 +629,11 @@ public BoxClient(Authentication auth) {
626629
.auth(this.auth)
627630
.networkSession(this.networkSession)
628631
.build();
632+
this.convertMarkdownToBoxNote =
633+
new ConvertMarkdownToBoxNoteManager.Builder()
634+
.auth(this.auth)
635+
.networkSession(this.networkSession)
636+
.build();
629637
}
630638

631639
protected BoxClient(Builder builder) {
@@ -981,6 +989,11 @@ protected BoxClient(Builder builder) {
981989
.auth(this.auth)
982990
.networkSession(this.networkSession)
983991
.build();
992+
this.convertMarkdownToBoxNote =
993+
new ConvertMarkdownToBoxNoteManager.Builder()
994+
.auth(this.auth)
995+
.networkSession(this.networkSession)
996+
.build();
984997
}
985998

986999
/**
@@ -1440,6 +1453,10 @@ public AutomateWorkflowsManager getAutomateWorkflows() {
14401453
return automateWorkflows;
14411454
}
14421455

1456+
public ConvertMarkdownToBoxNoteManager getConvertMarkdownToBoxNote() {
1457+
return convertMarkdownToBoxNote;
1458+
}
1459+
14431460
public static class Builder {
14441461

14451462
protected final Authentication auth;
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package com.box.sdkgen.managers.convertmarkdowntoboxnote;
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.v2026r0.notesconvertrequestbodyv2026r0.NotesConvertRequestBodyV2026R0;
15+
import com.box.sdkgen.schemas.v2026r0.notesconvertresponsev2026r0.NotesConvertResponseV2026R0;
16+
import com.box.sdkgen.serialization.json.JsonManager;
17+
import java.util.Map;
18+
19+
public class ConvertMarkdownToBoxNoteManager {
20+
21+
public Authentication auth;
22+
23+
public NetworkSession networkSession;
24+
25+
public ConvertMarkdownToBoxNoteManager() {
26+
this.networkSession = new NetworkSession();
27+
}
28+
29+
protected ConvertMarkdownToBoxNoteManager(Builder builder) {
30+
this.auth = builder.auth;
31+
this.networkSession = builder.networkSession;
32+
}
33+
34+
/**
35+
* Creates a Box Note (`.boxnote` file) from supported source content. See the `content_format`
36+
* field for supported formats.
37+
*
38+
* @param requestBody Request body of createNoteConvertV2026R0 method
39+
*/
40+
public NotesConvertResponseV2026R0 createNoteConvertV2026R0(
41+
NotesConvertRequestBodyV2026R0 requestBody) {
42+
return createNoteConvertV2026R0(requestBody, new CreateNoteConvertV2026R0Headers());
43+
}
44+
45+
/**
46+
* Creates a Box Note (`.boxnote` file) from supported source content. See the `content_format`
47+
* field for supported formats.
48+
*
49+
* @param requestBody Request body of createNoteConvertV2026R0 method
50+
* @param headers Headers of createNoteConvertV2026R0 method
51+
*/
52+
public NotesConvertResponseV2026R0 createNoteConvertV2026R0(
53+
NotesConvertRequestBodyV2026R0 requestBody, CreateNoteConvertV2026R0Headers headers) {
54+
Map<String, String> headersMap =
55+
prepareParams(
56+
mergeMaps(
57+
mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
58+
headers.getExtraHeaders()));
59+
FetchResponse response =
60+
this.networkSession
61+
.getNetworkClient()
62+
.fetch(
63+
new FetchOptions.Builder(
64+
String.join(
65+
"",
66+
this.networkSession.getBaseUrls().getBaseUrl(),
67+
"/2.0/notes/convert"),
68+
"POST")
69+
.headers(headersMap)
70+
.data(JsonManager.serialize(requestBody))
71+
.contentType("application/json")
72+
.responseFormat(ResponseFormat.JSON)
73+
.auth(this.auth)
74+
.networkSession(this.networkSession)
75+
.build());
76+
return JsonManager.deserialize(response.getData(), NotesConvertResponseV2026R0.class);
77+
}
78+
79+
public Authentication getAuth() {
80+
return auth;
81+
}
82+
83+
public NetworkSession getNetworkSession() {
84+
return networkSession;
85+
}
86+
87+
public static class Builder {
88+
89+
protected Authentication auth;
90+
91+
protected NetworkSession networkSession;
92+
93+
public Builder() {}
94+
95+
public Builder auth(Authentication auth) {
96+
this.auth = auth;
97+
return this;
98+
}
99+
100+
public Builder networkSession(NetworkSession networkSession) {
101+
this.networkSession = networkSession;
102+
return this;
103+
}
104+
105+
public ConvertMarkdownToBoxNoteManager build() {
106+
if (this.networkSession == null) {
107+
this.networkSession = new NetworkSession();
108+
}
109+
return new ConvertMarkdownToBoxNoteManager(this);
110+
}
111+
}
112+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.box.sdkgen.managers.convertmarkdowntoboxnote;
2+
3+
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
4+
5+
import com.box.sdkgen.parameters.v2026r0.boxversionheaderv2026r0.BoxVersionHeaderV2026R0;
6+
import com.box.sdkgen.serialization.json.EnumWrapper;
7+
import java.util.Map;
8+
9+
public class CreateNoteConvertV2026R0Headers {
10+
11+
/** Version header. */
12+
public EnumWrapper<BoxVersionHeaderV2026R0> boxVersion;
13+
14+
/** Extra headers that will be included in the HTTP request. */
15+
public Map<String, String> extraHeaders;
16+
17+
public CreateNoteConvertV2026R0Headers() {
18+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(BoxVersionHeaderV2026R0._2026_0);
19+
this.extraHeaders = mapOf();
20+
}
21+
22+
protected CreateNoteConvertV2026R0Headers(Builder builder) {
23+
this.boxVersion = builder.boxVersion;
24+
this.extraHeaders = builder.extraHeaders;
25+
}
26+
27+
public EnumWrapper<BoxVersionHeaderV2026R0> getBoxVersion() {
28+
return boxVersion;
29+
}
30+
31+
public Map<String, String> getExtraHeaders() {
32+
return extraHeaders;
33+
}
34+
35+
public static class Builder {
36+
37+
protected EnumWrapper<BoxVersionHeaderV2026R0> boxVersion;
38+
39+
protected Map<String, String> extraHeaders;
40+
41+
public Builder() {}
42+
43+
public Builder boxVersion(BoxVersionHeaderV2026R0 boxVersion) {
44+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(boxVersion);
45+
return this;
46+
}
47+
48+
public Builder boxVersion(EnumWrapper<BoxVersionHeaderV2026R0> boxVersion) {
49+
this.boxVersion = boxVersion;
50+
return this;
51+
}
52+
53+
public Builder extraHeaders(Map<String, String> extraHeaders) {
54+
this.extraHeaders = extraHeaders;
55+
return this;
56+
}
57+
58+
public CreateNoteConvertV2026R0Headers build() {
59+
if (this.boxVersion == null) {
60+
this.boxVersion = new EnumWrapper<BoxVersionHeaderV2026R0>(BoxVersionHeaderV2026R0._2026_0);
61+
}
62+
if (this.extraHeaders == null) {
63+
this.extraHeaders = mapOf();
64+
}
65+
return new CreateNoteConvertV2026R0Headers(this);
66+
}
67+
}
68+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.box.sdkgen.schemas.v2026r0.folderreferencev2026r0;
2+
3+
import com.box.sdkgen.internal.NullableFieldTracker;
4+
import com.box.sdkgen.internal.SerializableObject;
5+
import com.box.sdkgen.serialization.json.EnumWrapper;
6+
import com.fasterxml.jackson.annotation.JsonFilter;
7+
import com.fasterxml.jackson.annotation.JsonProperty;
8+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
9+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
10+
import java.util.Objects;
11+
12+
/** Folder reference. */
13+
@JsonFilter("nullablePropertyFilter")
14+
public class FolderReferenceV2026R0 extends SerializableObject {
15+
16+
/** The value will always be `folder`. */
17+
@JsonDeserialize(
18+
using = FolderReferenceV2026R0TypeField.FolderReferenceV2026R0TypeFieldDeserializer.class)
19+
@JsonSerialize(
20+
using = FolderReferenceV2026R0TypeField.FolderReferenceV2026R0TypeFieldSerializer.class)
21+
protected EnumWrapper<FolderReferenceV2026R0TypeField> type;
22+
23+
/** ID of the folder. */
24+
protected final String id;
25+
26+
public FolderReferenceV2026R0(@JsonProperty("id") String id) {
27+
super();
28+
this.id = id;
29+
this.type =
30+
new EnumWrapper<FolderReferenceV2026R0TypeField>(FolderReferenceV2026R0TypeField.FOLDER);
31+
}
32+
33+
protected FolderReferenceV2026R0(Builder builder) {
34+
super();
35+
this.type = builder.type;
36+
this.id = builder.id;
37+
markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
38+
}
39+
40+
public EnumWrapper<FolderReferenceV2026R0TypeField> getType() {
41+
return type;
42+
}
43+
44+
public String getId() {
45+
return id;
46+
}
47+
48+
@Override
49+
public boolean equals(Object o) {
50+
if (this == o) {
51+
return true;
52+
}
53+
if (o == null || getClass() != o.getClass()) {
54+
return false;
55+
}
56+
FolderReferenceV2026R0 casted = (FolderReferenceV2026R0) o;
57+
return Objects.equals(type, casted.type) && Objects.equals(id, casted.id);
58+
}
59+
60+
@Override
61+
public int hashCode() {
62+
return Objects.hash(type, id);
63+
}
64+
65+
@Override
66+
public String toString() {
67+
return "FolderReferenceV2026R0{" + "type='" + type + '\'' + ", " + "id='" + id + '\'' + "}";
68+
}
69+
70+
public static class Builder extends NullableFieldTracker {
71+
72+
protected EnumWrapper<FolderReferenceV2026R0TypeField> type;
73+
74+
protected final String id;
75+
76+
public Builder(String id) {
77+
super();
78+
this.id = id;
79+
}
80+
81+
public Builder type(FolderReferenceV2026R0TypeField type) {
82+
this.type = new EnumWrapper<FolderReferenceV2026R0TypeField>(type);
83+
return this;
84+
}
85+
86+
public Builder type(EnumWrapper<FolderReferenceV2026R0TypeField> type) {
87+
this.type = type;
88+
return this;
89+
}
90+
91+
public FolderReferenceV2026R0 build() {
92+
if (this.type == null) {
93+
this.type =
94+
new EnumWrapper<FolderReferenceV2026R0TypeField>(
95+
FolderReferenceV2026R0TypeField.FOLDER);
96+
}
97+
return new FolderReferenceV2026R0(this);
98+
}
99+
}
100+
}

0 commit comments

Comments
 (0)